2 * iplink_vxcan.c vxcan device support (Virtual CAN Tunnel)
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 * Author: Oliver Hartkopp <socketcan@hartkopp.net>
10 * Based on: link_veth.c from Pavel Emelianov <xemul@openvz.org>
17 #include <linux/can/vxcan.h>
20 #include "ip_common.h"
22 static void print_usage(FILE *f
)
24 printf("Usage: ip link <options> type vxcan [peer <options>]\n"
25 "To get <options> type 'ip link add help'\n");
28 static void usage(void)
33 static int vxcan_parse_opt(struct link_util
*lu
, int argc
, char **argv
,
44 struct ifinfomsg
*ifm
, *peer_ifm
;
45 unsigned int ifi_flags
, ifi_change
;
47 if (strcmp(argv
[0], "peer") != 0) {
53 ifi_flags
= ifm
->ifi_flags
;
54 ifi_change
= ifm
->ifi_change
;
59 addattr_l(n
, 1024, VXCAN_INFO_PEER
, NULL
, 0);
61 n
->nlmsg_len
+= sizeof(struct ifinfomsg
);
63 err
= iplink_parse(argc
- 1, argv
+ 1, (struct iplink_req
*)n
,
64 &name
, &type
, &link
, &dev
, &group
, &index
);
69 duparg("type", argv
[err
]);
73 IFLA_IFNAME
, name
, strlen(name
) + 1);
76 peer_ifm
= RTA_DATA(data
);
77 peer_ifm
->ifi_index
= index
;
78 peer_ifm
->ifi_flags
= ifm
->ifi_flags
;
79 peer_ifm
->ifi_change
= ifm
->ifi_change
;
80 ifm
->ifi_flags
= ifi_flags
;
81 ifm
->ifi_change
= ifi_change
;
84 addattr32(n
, 1024, IFLA_GROUP
, group
);
86 data
->rta_len
= (void *)NLMSG_TAIL(n
) - (void *)data
;
87 return argc
- 1 - err
;
90 static void vxcan_print_help(struct link_util
*lu
, int argc
, char **argv
,
96 struct link_util vxcan_link_util
= {
98 .parse_opt
= vxcan_parse_opt
,
99 .print_help
= vxcan_print_help
,