2 * link_veth.c veth driver module
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
9 * Authors: Pavel Emelianov <xemul@openvz.org>
15 #include <linux/veth.h>
18 #include "ip_common.h"
20 static void usage(void)
22 printf("Usage: ip link <options> type veth "
23 "[peer <options>]\nTo get <options> type "
24 "'ip link add help'\n");
27 static int veth_parse_opt(struct link_util
*lu
, int argc
, char **argv
,
30 char *name
, *type
, *link
, *dev
;
34 if (strcmp(argv
[0], "peer") != 0) {
39 data
= NLMSG_TAIL(hdr
);
40 addattr_l(hdr
, 1024, VETH_INFO_PEER
, NULL
, 0);
42 hdr
->nlmsg_len
+= sizeof(struct ifinfomsg
);
44 err
= iplink_parse(argc
- 1, argv
+ 1, (struct iplink_req
*)hdr
,
45 &name
, &type
, &link
, &dev
);
50 len
= strlen(name
) + 1;
52 invarg("\"name\" too long\n", *argv
);
53 addattr_l(hdr
, 1024, IFLA_IFNAME
, name
, len
);
56 data
->rta_len
= (void *)NLMSG_TAIL(hdr
) - (void *)data
;
57 return argc
- 1 - err
;
60 struct link_util veth_link_util
= {
62 .parse_opt
= veth_parse_opt
,