]> git.proxmox.com Git - mirror_frr.git/blame - ldpd/lde.h
Merge pull request #10447 from ton31337/fix/json_with_whitespaces
[mirror_frr.git] / ldpd / lde.h
CommitLineData
8429abe0
RW
1/* $OpenBSD$ */
2
3/*
4 * Copyright (c) 2013, 2016 Renato Westphal <renato@openbsd.org>
5 * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
6 * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
7 *
8 * Permission to use, copy, modify, and distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */
20
21#ifndef _LDE_H_
22#define _LDE_H_
23
cd85bc2e 24#include "queue.h"
eac6e3f0 25#include "openbsd-tree.h"
88d88a9c 26#include "if.h"
8429abe0
RW
27
28enum fec_type {
29 FEC_TYPE_IPV4,
30 FEC_TYPE_IPV6,
31 FEC_TYPE_PWID
32};
33
34struct fec {
35 RB_ENTRY(fec) entry;
36 enum fec_type type;
37 union {
38 struct {
39 struct in_addr prefix;
40 uint8_t prefixlen;
41 } ipv4;
42 struct {
43 struct in6_addr prefix;
44 uint8_t prefixlen;
45 } ipv6;
46 struct {
47 uint16_t type;
48 uint32_t pwid;
49 struct in_addr lsr_id;
50 } pwid;
51 } u;
52};
53RB_HEAD(fec_tree, fec);
54RB_PROTOTYPE(fec_tree, fec, entry, fec_compare)
55
56/* request entries */
57struct lde_req {
58 struct fec fec;
59 uint32_t msg_id;
60};
61
62/* mapping entries */
63struct lde_map {
64 struct fec fec;
d3e1887a
RW
65 struct lde_map_head *head; /* fec_node's upstream/downstream */
66 RB_ENTRY(lde_map) entry;
8429abe0
RW
67 struct lde_nbr *nexthop;
68 struct map map;
69};
d3e1887a
RW
70RB_HEAD(lde_map_head, lde_map);
71RB_PROTOTYPE(lde_map_head, lde_map, entry, lde_map_cmp);
8429abe0
RW
72
73/* withdraw entries */
74struct lde_wdraw {
75 struct fec fec;
76 uint32_t label;
77};
78
79/* Addresses belonging to neighbor */
80struct lde_addr {
81 TAILQ_ENTRY(lde_addr) entry;
82 int af;
83 union ldpd_addr addr;
84};
85
86/* just the info LDE needs */
87struct lde_nbr {
88 RB_ENTRY(lde_nbr) entry;
89 uint32_t peerid;
90 struct in_addr id;
91 int v4_enabled; /* announce/process v4 msgs */
92 int v6_enabled; /* announce/process v6 msgs */
257799cd 93 int flags; /* capabilities */
8429abe0
RW
94 struct fec_tree recv_req;
95 struct fec_tree sent_req;
96 struct fec_tree recv_map;
97 struct fec_tree sent_map;
7c2abbd7 98 struct fec_tree sent_map_pending;
8429abe0
RW
99 struct fec_tree sent_wdraw;
100 TAILQ_HEAD(, lde_addr) addr_list;
101};
102RB_HEAD(nbr_tree, lde_nbr);
103RB_PROTOTYPE(nbr_tree, lde_nbr, entry, lde_nbr_compare)
104
105struct fec_nh {
106 LIST_ENTRY(fec_nh) entry;
107 int af;
108 union ldpd_addr nexthop;
88d88a9c 109 ifindex_t ifindex;
8429abe0 110 uint32_t remote_label;
e132dea0
RW
111 uint8_t route_type;
112 unsigned short route_instance;
134970a2 113 uint8_t flags;
8429abe0 114};
134970a2 115#define F_FEC_NH_NEW 0x01
8cb1fc45 116#define F_FEC_NH_CONNECTED 0x02
aff1743c
KS
117#define F_FEC_NH_DEFER 0x04 /* running ordered control */
118#define F_FEC_NH_NO_LDP 0x08 /* no ldp on this interface */
8429abe0
RW
119
120struct fec_node {
121 struct fec fec;
122
123 LIST_HEAD(, fec_nh) nexthops; /* fib nexthops */
d3e1887a
RW
124 struct lde_map_head downstream; /* recv mappings */
125 struct lde_map_head upstream; /* sent mappings */
8429abe0
RW
126
127 uint32_t local_label;
4272a064
KS
128
129 uint32_t pw_remote_status;
130
8429abe0
RW
131 void *data; /* fec specific data */
132};
133
fea12efb 134#define CHUNK_SIZE 64
135struct label_chunk {
136 uint32_t start;
137 uint32_t end;
138 uint64_t used_mask;
139};
140
8429abe0
RW
141#define LDE_GC_INTERVAL 300
142
143extern struct ldpd_conf *ldeconf;
144extern struct fec_tree ft;
145extern struct nbr_tree lde_nbrs;
eac6e3f0 146extern struct thread *gc_timer;
8429abe0
RW
147
148/* lde.c */
274f5abf
RW
149void lde(void);
150void lde_init(struct ldpd_init *);
eac6e3f0 151int lde_imsg_compose_parent(int, pid_t, void *, uint16_t);
f2232fdf 152void lde_imsg_compose_parent_sync(int, pid_t, void *, uint16_t);
8429abe0 153int lde_imsg_compose_ldpe(int, uint32_t, pid_t, void *, uint16_t);
45a8eba9 154int lde_acl_check(char *, int, union ldpd_addr *, uint8_t);
8cb1fc45 155uint32_t lde_update_label(struct fec_node *);
f4ec681c 156void lde_free_label(uint32_t label);
8429abe0
RW
157void lde_send_change_klabel(struct fec_node *, struct fec_nh *);
158void lde_send_delete_klabel(struct fec_node *, struct fec_nh *);
077d336a
RW
159void lde_fec2prefix(const struct fec *fec, struct prefix *prefix);
160void lde_prefix2fec(const struct prefix *prefix, struct fec *fec);
8429abe0
RW
161void lde_fec2map(struct fec *, struct map *);
162void lde_map2fec(struct map *, struct in_addr, struct fec *);
163void lde_send_labelmapping(struct lde_nbr *, struct fec_node *,
164 int);
165void lde_send_labelwithdraw(struct lde_nbr *, struct fec_node *,
0bcc2916
RW
166 struct map *, struct status_tlv *);
167void lde_send_labelwithdraw_wcard(struct lde_nbr *, uint32_t);
d4afb819
RW
168void lde_send_labelwithdraw_twcard_prefix(struct lde_nbr *,
169 uint16_t, uint32_t);
aba50a83
RW
170void lde_send_labelwithdraw_twcard_pwid(struct lde_nbr *, uint16_t,
171 uint32_t);
0bcc2916 172void lde_send_labelwithdraw_pwid_wcard(struct lde_nbr *, uint16_t,
8429abe0 173 uint32_t);
0bcc2916
RW
174void lde_send_labelrelease(struct lde_nbr *, struct fec_node *,
175 struct map *, uint32_t);
2d1aa1e8 176void lde_send_labelrequest(struct lde_nbr *, struct fec_node *,
177 struct map *, int);
178void lde_send_labelrequest_wcard(struct lde_nbr *, uint16_t af);
05aac414
RW
179void lde_send_notification(struct lde_nbr *, uint32_t, uint32_t,
180 uint16_t);
257799cd
RW
181void lde_send_notification_eol_prefix(struct lde_nbr *, int);
182void lde_send_notification_eol_pwid(struct lde_nbr *, uint16_t);
8429abe0
RW
183struct lde_nbr *lde_nbr_find_by_lsrid(struct in_addr);
184struct lde_nbr *lde_nbr_find_by_addr(int, union ldpd_addr *);
185struct lde_map *lde_map_add(struct lde_nbr *, struct fec_node *, int);
186void lde_map_del(struct lde_nbr *, struct lde_map *, int);
7c2abbd7
RW
187struct fec *lde_map_pending_add(struct lde_nbr *, struct fec_node *);
188void lde_map_pending_del(struct lde_nbr *, struct fec *);
8429abe0
RW
189struct lde_req *lde_req_add(struct lde_nbr *, struct fec *, int);
190void lde_req_del(struct lde_nbr *, struct lde_req *, int);
191struct lde_wdraw *lde_wdraw_add(struct lde_nbr *, struct fec_node *);
192void lde_wdraw_del(struct lde_nbr *, struct lde_wdraw *);
45a8eba9 193void lde_change_egress_label(int);
2d1aa1e8 194void lde_change_allocate_filter(int);
195void lde_change_advertise_filter(int);
196void lde_change_accept_filter(int);
197void lde_change_expnull_for_filter(int);
95535717 198void lde_route_update(struct iface *, int);
199void lde_route_update_release(struct iface *, int);
200void lde_route_update_release_all(int);
8429abe0
RW
201struct lde_addr *lde_address_find(struct lde_nbr *, int,
202 union ldpd_addr *);
ff5279ba 203void lde_allow_broken_lsp_update(int new_config);
8429abe0
RW
204
205/* lde_lib.c */
206void fec_init(struct fec_tree *);
207struct fec *fec_find(struct fec_tree *, struct fec *);
208int fec_insert(struct fec_tree *, struct fec *);
209int fec_remove(struct fec_tree *, struct fec *);
210void fec_clear(struct fec_tree *, void (*)(void *));
211void rt_dump(pid_t);
212void fec_snap(struct lde_nbr *);
213void fec_tree_clear(void);
214struct fec_nh *fec_nh_find(struct fec_node *, int, union ldpd_addr *,
e132dea0 215 ifindex_t, uint8_t, unsigned short);
8429abe0 216void lde_kernel_insert(struct fec *, int, union ldpd_addr *,
e132dea0 217 ifindex_t, uint8_t, unsigned short, int, void *);
8429abe0 218void lde_kernel_remove(struct fec *, int, union ldpd_addr *,
e132dea0 219 ifindex_t, uint8_t, unsigned short);
8cb1fc45 220void lde_kernel_update(struct fec *);
4272a064 221void lde_check_mapping(struct map *, struct lde_nbr *, int);
8429abe0 222void lde_check_request(struct map *, struct lde_nbr *);
d4afb819 223void lde_check_request_wcard(struct map *, struct lde_nbr *);
8429abe0
RW
224void lde_check_release(struct map *, struct lde_nbr *);
225void lde_check_release_wcard(struct map *, struct lde_nbr *);
226void lde_check_withdraw(struct map *, struct lde_nbr *);
227void lde_check_withdraw_wcard(struct map *, struct lde_nbr *);
0bcc2916
RW
228int lde_wildcard_apply(struct map *, struct fec *,
229 struct lde_map *);
cc9f21da 230void lde_gc_timer(struct thread *thread);
8429abe0
RW
231void lde_gc_start_timer(void);
232void lde_gc_stop_timer(void);
233
234/* l2vpn.c */
235struct l2vpn *l2vpn_new(const char *);
236struct l2vpn *l2vpn_find(struct ldpd_conf *, const char *);
237void l2vpn_del(struct l2vpn *);
238void l2vpn_init(struct l2vpn *);
239void l2vpn_exit(struct l2vpn *);
52b530fc 240struct l2vpn_if *l2vpn_if_new(struct l2vpn *, const char *);
52bd4c23 241struct l2vpn_if *l2vpn_if_find(struct l2vpn *, const char *);
52b530fc 242void l2vpn_if_update_info(struct l2vpn_if *, struct kif *);
26519d8c 243void l2vpn_if_update(struct l2vpn_if *);
52b530fc 244struct l2vpn_pw *l2vpn_pw_new(struct l2vpn *, const char *);
52bd4c23 245struct l2vpn_pw *l2vpn_pw_find(struct l2vpn *, const char *);
5c3f00af
RW
246struct l2vpn_pw *l2vpn_pw_find_active(struct l2vpn *, const char *);
247struct l2vpn_pw *l2vpn_pw_find_inactive(struct l2vpn *, const char *);
52b530fc 248void l2vpn_pw_update_info(struct l2vpn_pw *, struct kif *);
8429abe0
RW
249void l2vpn_pw_init(struct l2vpn_pw *);
250void l2vpn_pw_exit(struct l2vpn_pw *);
251void l2vpn_pw_reset(struct l2vpn_pw *);
252int l2vpn_pw_ok(struct l2vpn_pw *, struct fec_nh *);
253int l2vpn_pw_negotiate(struct lde_nbr *, struct fec_node *,
254 struct map *);
0bcc2916
RW
255void l2vpn_send_pw_status(struct lde_nbr *, uint32_t, struct fec *);
256void l2vpn_send_pw_status_wcard(struct lde_nbr *, uint32_t,
257 uint16_t, uint32_t);
8429abe0 258void l2vpn_recv_pw_status(struct lde_nbr *, struct notify_msg *);
0bcc2916
RW
259void l2vpn_recv_pw_status_wcard(struct lde_nbr *,
260 struct notify_msg *);
87b5f1b7 261int l2vpn_pw_status_update(struct zapi_pw_status *);
8429abe0
RW
262void l2vpn_pw_ctl(pid_t);
263void l2vpn_binding_ctl(pid_t);
264
265#endif /* _LDE_H_ */