]> git.proxmox.com Git - mirror_frr.git/blob - zebra/rt_netlink.h
bgpd: Refactor subgroup_announce_table() to reuse an existing helpers
[mirror_frr.git] / zebra / rt_netlink.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /* Header file exported by rt_netlink.c to zebra.
3 * Copyright (C) 1997, 98, 99 Kunihiro Ishiguro
4 */
5
6 #ifndef _ZEBRA_RT_NETLINK_H
7 #define _ZEBRA_RT_NETLINK_H
8
9 #ifdef HAVE_NETLINK
10
11 #include "zebra/zebra_mpls.h"
12 #include "zebra/zebra_dplane.h"
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18
19 /*
20 * Additional protocol strings to push into routes
21 * If we add anything new here please make sure
22 * to update:
23 * zebra2proto Function
24 * proto2zebra Function
25 * is_selfroute Function
26 * tools/frr To flush the route upon exit
27 *
28 * Finally update this file to allow iproute2 to
29 * know about this new route.
30 * tools/etc/iproute2/rt_protos.d
31 */
32 #define RTPROT_BGP 186
33 #define RTPROT_ISIS 187
34 #define RTPROT_OSPF 188
35 #define RTPROT_RIP 189
36 #define RTPROT_RIPNG 190
37 #if !defined(RTPROT_BABEL)
38 #define RTPROT_BABEL 42
39 #endif
40 #define RTPROT_NHRP 191
41 #define RTPROT_EIGRP 192
42 #define RTPROT_LDP 193
43 #define RTPROT_SHARP 194
44 #define RTPROT_PBR 195
45 #define RTPROT_ZSTATIC 196
46 #define RTPROT_OPENFABRIC 197
47 #define RTPROT_SRTE 198
48
49 void rt_netlink_init(void);
50
51 /* MPLS label forwarding table change, using dataplane context information. */
52 extern ssize_t netlink_mpls_multipath_msg_encode(int cmd,
53 struct zebra_dplane_ctx *ctx,
54 void *buf, size_t buflen);
55
56 extern ssize_t netlink_route_multipath_msg_encode(int cmd,
57 struct zebra_dplane_ctx *ctx,
58 uint8_t *data, size_t datalen,
59 bool fpm, bool force_nhg);
60 extern ssize_t netlink_macfdb_update_ctx(struct zebra_dplane_ctx *ctx,
61 void *data, size_t datalen);
62
63 extern int netlink_route_change(struct nlmsghdr *h, ns_id_t ns_id, int startup);
64 extern int netlink_route_read(struct zebra_ns *zns);
65
66 extern int netlink_nexthop_change(struct nlmsghdr *h, ns_id_t ns_id,
67 int startup);
68 extern int netlink_nexthop_read(struct zebra_ns *zns);
69 extern ssize_t netlink_nexthop_msg_encode(uint16_t cmd,
70 const struct zebra_dplane_ctx *ctx,
71 void *buf, size_t buflen, bool fpm);
72
73 extern ssize_t netlink_lsp_msg_encoder(struct zebra_dplane_ctx *ctx, void *buf,
74 size_t buflen);
75
76 extern int netlink_neigh_change(struct nlmsghdr *h, ns_id_t ns_id);
77 extern int netlink_macfdb_read(struct zebra_ns *zns);
78 extern int netlink_macfdb_read_for_bridge(struct zebra_ns *zns,
79 struct interface *ifp,
80 struct interface *br_if,
81 vlanid_t vid);
82 extern int netlink_macfdb_read_mcast_for_vni(struct zebra_ns *zns,
83 struct interface *ifp, vni_t vni);
84 extern int netlink_neigh_read(struct zebra_ns *zns);
85 extern int netlink_neigh_read_for_vlan(struct zebra_ns *zns,
86 struct interface *vlan_if);
87 extern int netlink_macfdb_read_specific_mac(struct zebra_ns *zns,
88 struct interface *br_if,
89 const struct ethaddr *mac,
90 uint16_t vid);
91 extern int netlink_neigh_read_specific_ip(const struct ipaddr *ip,
92 struct interface *vlan_if);
93 extern vrf_id_t vrf_lookup_by_table(uint32_t table_id, ns_id_t ns_id);
94
95 struct nl_batch;
96 extern enum netlink_msg_status
97 netlink_put_route_update_msg(struct nl_batch *bth,
98 struct zebra_dplane_ctx *ctx);
99 extern enum netlink_msg_status
100 netlink_put_nexthop_update_msg(struct nl_batch *bth,
101 struct zebra_dplane_ctx *ctx);
102 extern enum netlink_msg_status
103 netlink_put_mac_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx);
104 extern enum netlink_msg_status
105 netlink_put_neigh_update_msg(struct nl_batch *bth,
106 struct zebra_dplane_ctx *ctx);
107 extern enum netlink_msg_status
108 netlink_put_lsp_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx);
109 extern enum netlink_msg_status
110 netlink_put_pw_update_msg(struct nl_batch *bth, struct zebra_dplane_ctx *ctx);
111
112 int netlink_route_change_read_unicast_internal(struct nlmsghdr *h,
113 ns_id_t ns_id, int startup,
114 struct zebra_dplane_ctx *ctx);
115
116 #ifdef NETLINK_DEBUG
117 const char *nlmsg_type2str(uint16_t type);
118 const char *af_type2str(int type);
119 const char *ifi_type2str(int type);
120 const char *rta_type2str(int type);
121 const char *rtm_type2str(int type);
122 const char *ifla_pdr_type2str(int type);
123 const char *ifla_info_type2str(int type);
124 const char *rtm_protocol2str(int type);
125 const char *rtm_scope2str(int type);
126 const char *rtm_rta2str(int type);
127 const char *neigh_rta2str(int type);
128 const char *ifa_rta2str(int type);
129 const char *nhm_rta2str(int type);
130 const char *frh_rta2str(int type);
131 const char *frh_action2str(uint8_t action);
132 const char *nlmsg_flags2str(uint16_t flags, char *buf, size_t buflen);
133 const char *if_flags2str(uint32_t flags, char *buf, size_t buflen);
134 const char *rtm_flags2str(uint32_t flags, char *buf, size_t buflen);
135 const char *neigh_state2str(uint32_t flags, char *buf, size_t buflen);
136 const char *neigh_flags2str(uint32_t flags, char *buf, size_t buflen);
137 const char *ifa_flags2str(uint32_t flags, char *buf, size_t buflen);
138 const char *nh_flags2str(uint32_t flags, char *buf, size_t buflen);
139
140 void nl_dump(void *msg, size_t msglen);
141
142 extern int zebra2proto(int proto);
143
144 #endif /* NETLINK_DEBUG */
145
146 #ifdef __cplusplus
147 }
148 #endif
149
150 #endif /* HAVE_NETLINK */
151
152 #endif /* _ZEBRA_RT_NETLINK_H */