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
,
39 struct ifinfomsg
*ifm
, *peer_ifm
;
40 unsigned int ifi_flags
, ifi_change
, ifi_index
;
42 if (strcmp(argv
[0], "peer") != 0) {
48 ifi_flags
= ifm
->ifi_flags
;
49 ifi_change
= ifm
->ifi_change
;
50 ifi_index
= ifm
->ifi_index
;
55 data
= addattr_nest(n
, 1024, VXCAN_INFO_PEER
);
57 n
->nlmsg_len
+= sizeof(struct ifinfomsg
);
59 err
= iplink_parse(argc
- 1, argv
+ 1, (struct iplink_req
*)n
, &type
);
64 duparg("type", argv
[err
]);
66 peer_ifm
= RTA_DATA(data
);
67 peer_ifm
->ifi_index
= ifm
->ifi_index
;
68 peer_ifm
->ifi_flags
= ifm
->ifi_flags
;
69 peer_ifm
->ifi_change
= ifm
->ifi_change
;
70 ifm
->ifi_flags
= ifi_flags
;
71 ifm
->ifi_change
= ifi_change
;
72 ifm
->ifi_index
= ifi_index
;
74 addattr_nest_end(n
, data
);
75 return argc
- 1 - err
;
78 static void vxcan_print_help(struct link_util
*lu
, int argc
, char **argv
,
84 struct link_util vxcan_link_util
= {
86 .parse_opt
= vxcan_parse_opt
,
87 .print_help
= vxcan_print_help
,