]>
git.proxmox.com Git - mirror_iproute2.git/blob - ip/link_xfrm.c
1 // SPDX-License-Identifier: GPL-2.0
3 * link_xfrm.c Virtual XFRM Interface driver module
5 * Authors: Matt Ellison <matt@arroyo.io>
9 #include <linux/if_link.h>
13 #include "ip_common.h"
16 static void xfrm_print_help(struct link_util
*lu
, int argc
, char **argv
,
20 "Usage: ... %-4s dev PHYS_DEV [ if_id IF-ID ]\n"
22 "Where: IF-ID := { 0x0..0xffffffff }\n",
26 static int xfrm_parse_opt(struct link_util
*lu
, int argc
, char **argv
,
29 unsigned int link
= 0;
33 if (!matches(*argv
, "dev")) {
35 link
= ll_name_to_index(*argv
);
38 } else if (!matches(*argv
, "if_id")) {
40 if (!get_u32(&if_id
, *argv
, 0))
41 addattr32(n
, 1024, IFLA_XFRM_IF_ID
, if_id
);
43 xfrm_print_help(lu
, argc
, argv
, stderr
);
50 addattr32(n
, 1024, IFLA_XFRM_LINK
, link
);
52 fprintf(stderr
, "must specify physical device\n");
59 static void xfrm_print_opt(struct link_util
*lu
, FILE *f
, struct rtattr
*tb
[])
65 if (tb
[IFLA_XFRM_IF_ID
]) {
66 __u32 id
= rta_getattr_u32(tb
[IFLA_XFRM_IF_ID
]);
68 print_0xhex(PRINT_ANY
, "if_id", "if_id %#llx ", id
);
74 struct link_util xfrm_link_util
= {
76 .maxattr
= IFLA_XFRM_MAX
,
77 .parse_opt
= xfrm_parse_opt
,
78 .print_opt
= xfrm_print_opt
,
79 .print_help
= xfrm_print_help
,