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