]>
Commit | Line | Data |
---|---|---|
6054c1eb | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
0b4b35e1 DB |
2 | #ifndef _IP_COMMON_H_ |
3 | #define _IP_COMMON_H_ | |
4 | ||
5 | #include <stdbool.h> | |
6 | ||
7 | #include "json_print.h" | |
8 | ||
741dd5cd DA |
9 | struct link_filter { |
10 | int ifindex; | |
11 | int family; | |
12 | int oneline; | |
13 | int showqueue; | |
14 | inet_prefix pfx; | |
15 | int scope, scopemask; | |
16 | int flags, flagmask; | |
17 | int up; | |
18 | char *label; | |
19 | int flushed; | |
20 | char *flushb; | |
21 | int flushp; | |
22 | int flushe; | |
23 | int group; | |
24 | int master; | |
25 | char *kind; | |
26 | char *slave_kind; | |
27 | }; | |
28 | ||
f7b49a3f PS |
29 | int get_operstate(const char *name); |
30 | int print_linkinfo(const struct sockaddr_nl *who, | |
31 | struct nlmsghdr *n, void *arg); | |
f7b49a3f PS |
32 | int print_addrinfo(const struct sockaddr_nl *who, |
33 | struct nlmsghdr *n, void *arg); | |
34 | int print_addrlabel(const struct sockaddr_nl *who, | |
35 | struct nlmsghdr *n, void *arg); | |
36 | int print_neigh(const struct sockaddr_nl *who, | |
90353c33 | 37 | struct nlmsghdr *n, void *arg); |
f7b49a3f | 38 | int ipaddr_list_link(int argc, char **argv); |
65083b5f | 39 | void ipaddr_get_vf_rate(int, int *, int *, const char *); |
f7b49a3f | 40 | void iplink_usage(void) __attribute__((noreturn)); |
093b7646 | 41 | |
f7b49a3f PS |
42 | void iproute_reset_filter(int ifindex); |
43 | void ipmroute_reset_filter(int ifindex); | |
44 | void ipaddr_reset_filter(int oneline, int ifindex); | |
45 | void ipneigh_reset_filter(int ifindex); | |
46 | void ipnetconf_reset_filter(int ifindex); | |
093b7646 | 47 | |
f7b49a3f PS |
48 | int print_route(const struct sockaddr_nl *who, |
49 | struct nlmsghdr *n, void *arg); | |
50 | int print_mroute(const struct sockaddr_nl *who, | |
51 | struct nlmsghdr *n, void *arg); | |
52 | int print_prefix(const struct sockaddr_nl *who, | |
53 | struct nlmsghdr *n, void *arg); | |
54 | int print_rule(const struct sockaddr_nl *who, | |
55 | struct nlmsghdr *n, void *arg); | |
56 | int print_netconf(const struct sockaddr_nl *who, | |
57 | struct rtnl_ctrl_data *ctrl, | |
58 | struct nlmsghdr *n, void *arg); | |
59 | void netns_map_init(void); | |
e29a8e05 | 60 | void netns_nsid_socket_init(void); |
f7b49a3f PS |
61 | int print_nsid(const struct sockaddr_nl *who, |
62 | struct nlmsghdr *n, void *arg); | |
63 | int do_ipaddr(int argc, char **argv); | |
64 | int do_ipaddrlabel(int argc, char **argv); | |
65 | int do_iproute(int argc, char **argv); | |
66 | int do_iprule(int argc, char **argv); | |
67 | int do_ipneigh(int argc, char **argv); | |
68 | int do_ipntable(int argc, char **argv); | |
69 | int do_iptunnel(int argc, char **argv); | |
70 | int do_ip6tunnel(int argc, char **argv); | |
71 | int do_iptuntap(int argc, char **argv); | |
72 | int do_iplink(int argc, char **argv); | |
b26fc590 | 73 | int do_ipmacsec(int argc, char **argv); |
f7b49a3f PS |
74 | int do_ipmonitor(int argc, char **argv); |
75 | int do_multiaddr(int argc, char **argv); | |
76 | int do_multiroute(int argc, char **argv); | |
77 | int do_multirule(int argc, char **argv); | |
78 | int do_netns(int argc, char **argv); | |
79 | int do_xfrm(int argc, char **argv); | |
80 | int do_ipl2tp(int argc, char **argv); | |
81 | int do_ipfou(int argc, char **argv); | |
ec71cae0 | 82 | extern int do_ipila(int argc, char **argv); |
f7b49a3f PS |
83 | int do_tcp_metrics(int argc, char **argv); |
84 | int do_ipnetconf(int argc, char **argv); | |
85 | int do_iptoken(int argc, char **argv); | |
1949f82c | 86 | int do_ipvrf(int argc, char **argv); |
ee9369a0 | 87 | void vrf_reset(void); |
9c49438a | 88 | int netns_identify_pid(const char *pidstr, char *name, int len); |
93863328 | 89 | int do_seg6(int argc, char **argv); |
1949f82c | 90 | |
f7b49a3f | 91 | int iplink_get(unsigned int flags, char *name, __u32 filt_mask); |
94f1a22a | 92 | int iplink_ifla_xstats(int argc, char **argv); |
351efcde | 93 | |
4ad87594 DA |
94 | int ip_linkaddr_list(int family, req_filter_fn_t filter_fn, |
95 | struct nlmsg_chain *linfo, struct nlmsg_chain *ainfo); | |
96 | void free_nlmsg_chain(struct nlmsg_chain *info); | |
97 | ||
34e95647 PM |
98 | static inline int rtm_get_table(struct rtmsg *r, struct rtattr **tb) |
99 | { | |
100 | __u32 table = r->rtm_table; | |
90353c33 | 101 | |
34e95647 | 102 | if (tb[RTA_TABLE]) |
ff24746c | 103 | table = rta_getattr_u32(tb[RTA_TABLE]); |
34e95647 PM |
104 | return table; |
105 | } | |
106 | ||
351efcde | 107 | extern struct rtnl_handle rth; |
141bb606 | 108 | |
f7af0dc5 SP |
109 | struct iplink_req { |
110 | struct nlmsghdr n; | |
111 | struct ifinfomsg i; | |
112 | char buf[1024]; | |
113 | }; | |
114 | ||
90353c33 | 115 | struct link_util { |
1d934839 PM |
116 | struct link_util *next; |
117 | const char *id; | |
118 | int maxattr; | |
119 | int (*parse_opt)(struct link_util *, int, char **, | |
120 | struct nlmsghdr *); | |
121 | void (*print_opt)(struct link_util *, FILE *, | |
122 | struct rtattr *[]); | |
123 | void (*print_xstats)(struct link_util *, FILE *, | |
94f1a22a | 124 | struct rtattr *); |
561e650e | 125 | void (*print_help)(struct link_util *, int, char **, |
94f1a22a NA |
126 | FILE *); |
127 | int (*parse_ifla_xstats)(struct link_util *, | |
128 | int, char **); | |
129 | int (*print_ifla_xstats)(const struct sockaddr_nl *, | |
130 | struct nlmsghdr *, void *); | |
1d934839 PM |
131 | }; |
132 | ||
133 | struct link_util *get_link_kind(const char *kind); | |
134 | ||
c58213f6 | 135 | int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type); |
f7af0dc5 SP |
136 | |
137 | /* iplink_bridge.c */ | |
3069539f | 138 | void br_dump_bridge_id(const struct ifla_bridge_id *id, char *buf, size_t len); |
217264a0 NA |
139 | int bridge_parse_xstats(struct link_util *lu, int argc, char **argv); |
140 | int bridge_print_xstats(const struct sockaddr_nl *who, | |
141 | struct nlmsghdr *n, void *arg); | |
3069539f | 142 | |
f7af0dc5 SP |
143 | /* iproute_lwtunnel.c */ |
144 | int lwt_parse_encap(struct rtattr *rta, size_t len, int *argcp, char ***argvp); | |
145 | void lwt_print_encap(FILE *fp, struct rtattr *encap_type, struct rtattr *encap); | |
146 | ||
147 | /* iplink_xdp.c */ | |
65083b5f | 148 | int xdp_parse(int *argc, char ***argv, struct iplink_req *req, const char *ifname, |
f7af0dc5 SP |
149 | bool generic, bool drv, bool offload); |
150 | void xdp_dump(FILE *fp, struct rtattr *tb, bool link, bool details); | |
151 | ||
152 | /* iplink_vrf.c */ | |
9b765770 | 153 | __u32 ipvrf_get_table(const char *name); |
2330490f | 154 | int name_is_vrf(const char *name); |
7dc0e974 | 155 | |
141bb606 MN |
156 | #ifndef INFINITY_LIFE_TIME |
157 | #define INFINITY_LIFE_TIME 0xFFFFFFFFU | |
158 | #endif | |
f8eb79a6 DB |
159 | |
160 | #ifndef LABEL_MAX_MASK | |
161 | #define LABEL_MAX_MASK 0xFFFFFU | |
162 | #endif | |
837552b4 RS |
163 | |
164 | void print_num(FILE *fp, unsigned int width, uint64_t count); | |
6377572f | 165 | |
0b4b35e1 | 166 | #endif /* _IP_COMMON_H_ */ |