]> git.proxmox.com Git - mirror_iproute2.git/blob - ip/ila_common.h
nexthop: fix error reporting in filter dump
[mirror_iproute2.git] / ip / ila_common.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ILA_COMMON_H_
3 #define _ILA_COMMON_H_
4
5 #include <linux/ila.h>
6 #include <string.h>
7
8 static inline char *ila_csum_mode2name(__u8 csum_mode)
9 {
10 switch (csum_mode) {
11 case ILA_CSUM_ADJUST_TRANSPORT:
12 return "adj-transport";
13 case ILA_CSUM_NEUTRAL_MAP:
14 return "neutral-map";
15 case ILA_CSUM_NO_ACTION:
16 return "no-action";
17 case ILA_CSUM_NEUTRAL_MAP_AUTO:
18 return "neutral-map-auto";
19 default:
20 return "unknown";
21 }
22 }
23
24 static inline int ila_csum_name2mode(char *name)
25 {
26 if (strcmp(name, "adj-transport") == 0)
27 return ILA_CSUM_ADJUST_TRANSPORT;
28 else if (strcmp(name, "neutral-map") == 0)
29 return ILA_CSUM_NEUTRAL_MAP;
30 else if (strcmp(name, "neutral-map-auto") == 0)
31 return ILA_CSUM_NEUTRAL_MAP_AUTO;
32 else if (strcmp(name, "no-action") == 0)
33 return ILA_CSUM_NO_ACTION;
34 else if (strcmp(name, "neutral-map-auto") == 0)
35 return ILA_CSUM_NEUTRAL_MAP_AUTO;
36 else
37 return -1;
38 }
39
40 static inline char *ila_ident_type2name(__u8 ident_type)
41 {
42 switch (ident_type) {
43 case ILA_ATYPE_IID:
44 return "iid";
45 case ILA_ATYPE_LUID:
46 return "luid";
47 case ILA_ATYPE_VIRT_V4:
48 return "virt-v4";
49 case ILA_ATYPE_VIRT_UNI_V6:
50 return "virt-uni-v6";
51 case ILA_ATYPE_VIRT_MULTI_V6:
52 return "virt-multi-v6";
53 case ILA_ATYPE_NONLOCAL_ADDR:
54 return "nonlocal-addr";
55 case ILA_ATYPE_USE_FORMAT:
56 return "use-format";
57 default:
58 return "unknown";
59 }
60 }
61
62 static inline int ila_ident_name2type(char *name)
63 {
64 if (!strcmp(name, "luid"))
65 return ILA_ATYPE_LUID;
66 else if (!strcmp(name, "use-format"))
67 return ILA_ATYPE_USE_FORMAT;
68 #if 0 /* No kernel support for configuring these yet */
69 else if (!strcmp(name, "iid"))
70 return ILA_ATYPE_IID;
71 else if (!strcmp(name, "virt-v4"))
72 return ILA_ATYPE_VIRT_V4;
73 else if (!strcmp(name, "virt-uni-v6"))
74 return ILA_ATYPE_VIRT_UNI_V6;
75 else if (!strcmp(name, "virt-multi-v6"))
76 return ILA_ATYPE_VIRT_MULTI_V6;
77 else if (!strcmp(name, "nonlocal-addr"))
78 return ILA_ATYPE_NONLOCAL_ADDR;
79 #endif
80 else
81 return -1;
82 }
83
84 static inline char *ila_hook_type2name(__u8 hook_type)
85 {
86 switch (hook_type) {
87 case ILA_HOOK_ROUTE_OUTPUT:
88 return "output";
89 case ILA_HOOK_ROUTE_INPUT:
90 return "input";
91 default:
92 return "unknown";
93 }
94 }
95
96 static inline int ila_hook_name2type(char *name)
97 {
98 if (!strcmp(name, "output"))
99 return ILA_HOOK_ROUTE_OUTPUT;
100 else if (!strcmp(name, "input"))
101 return ILA_HOOK_ROUTE_INPUT;
102 else
103 return -1;
104 }
105
106 #endif /* _ILA_COMMON_H_ */