]> git.proxmox.com Git - mirror_frr.git/blame - ldpd/lde.h
ldpd: remove the interface vty node
[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
eac6e3f0
RW
24#include "openbsd-queue.h"
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;
98 struct fec_tree sent_wdraw;
99 TAILQ_HEAD(, lde_addr) addr_list;
100};
101RB_HEAD(nbr_tree, lde_nbr);
102RB_PROTOTYPE(nbr_tree, lde_nbr, entry, lde_nbr_compare)
103
104struct fec_nh {
105 LIST_ENTRY(fec_nh) entry;
106 int af;
107 union ldpd_addr nexthop;
88d88a9c 108 ifindex_t ifindex;
8429abe0
RW
109 uint32_t remote_label;
110 uint8_t priority;
134970a2 111 uint8_t flags;
8429abe0 112};
134970a2 113#define F_FEC_NH_NEW 0x01
8cb1fc45 114#define F_FEC_NH_CONNECTED 0x02
8429abe0
RW
115
116struct fec_node {
117 struct fec fec;
118
119 LIST_HEAD(, fec_nh) nexthops; /* fib nexthops */
d3e1887a
RW
120 struct lde_map_head downstream; /* recv mappings */
121 struct lde_map_head upstream; /* sent mappings */
8429abe0
RW
122
123 uint32_t local_label;
124 void *data; /* fec specific data */
125};
126
fea12efb 127#define CHUNK_SIZE 64
128struct label_chunk {
129 uint32_t start;
130 uint32_t end;
131 uint64_t used_mask;
132};
133
8429abe0
RW
134#define LDE_GC_INTERVAL 300
135
136extern struct ldpd_conf *ldeconf;
137extern struct fec_tree ft;
138extern struct nbr_tree lde_nbrs;
eac6e3f0 139extern struct thread *gc_timer;
8429abe0
RW
140
141/* lde.c */
fea12efb 142void lde(const char *, const char *, u_short instance);
eac6e3f0 143int lde_imsg_compose_parent(int, pid_t, void *, uint16_t);
8429abe0 144int lde_imsg_compose_ldpe(int, uint32_t, pid_t, void *, uint16_t);
45a8eba9 145int lde_acl_check(char *, int, union ldpd_addr *, uint8_t);
8cb1fc45 146uint32_t lde_update_label(struct fec_node *);
8429abe0
RW
147void lde_send_change_klabel(struct fec_node *, struct fec_nh *);
148void lde_send_delete_klabel(struct fec_node *, struct fec_nh *);
149void lde_fec2map(struct fec *, struct map *);
150void lde_map2fec(struct map *, struct in_addr, struct fec *);
151void lde_send_labelmapping(struct lde_nbr *, struct fec_node *,
152 int);
153void lde_send_labelwithdraw(struct lde_nbr *, struct fec_node *,
0bcc2916
RW
154 struct map *, struct status_tlv *);
155void lde_send_labelwithdraw_wcard(struct lde_nbr *, uint32_t);
d4afb819
RW
156void lde_send_labelwithdraw_twcard_prefix(struct lde_nbr *,
157 uint16_t, uint32_t);
aba50a83
RW
158void lde_send_labelwithdraw_twcard_pwid(struct lde_nbr *, uint16_t,
159 uint32_t);
0bcc2916 160void lde_send_labelwithdraw_pwid_wcard(struct lde_nbr *, uint16_t,
8429abe0 161 uint32_t);
0bcc2916
RW
162void lde_send_labelrelease(struct lde_nbr *, struct fec_node *,
163 struct map *, uint32_t);
05aac414
RW
164void lde_send_notification(struct lde_nbr *, uint32_t, uint32_t,
165 uint16_t);
257799cd
RW
166void lde_send_notification_eol_prefix(struct lde_nbr *, int);
167void lde_send_notification_eol_pwid(struct lde_nbr *, uint16_t);
8429abe0
RW
168struct lde_nbr *lde_nbr_find_by_lsrid(struct in_addr);
169struct lde_nbr *lde_nbr_find_by_addr(int, union ldpd_addr *);
170struct lde_map *lde_map_add(struct lde_nbr *, struct fec_node *, int);
171void lde_map_del(struct lde_nbr *, struct lde_map *, int);
172struct lde_req *lde_req_add(struct lde_nbr *, struct fec *, int);
173void lde_req_del(struct lde_nbr *, struct lde_req *, int);
174struct lde_wdraw *lde_wdraw_add(struct lde_nbr *, struct fec_node *);
175void lde_wdraw_del(struct lde_nbr *, struct lde_wdraw *);
45a8eba9 176void lde_change_egress_label(int);
8429abe0
RW
177struct lde_addr *lde_address_find(struct lde_nbr *, int,
178 union ldpd_addr *);
179
180/* lde_lib.c */
181void fec_init(struct fec_tree *);
182struct fec *fec_find(struct fec_tree *, struct fec *);
183int fec_insert(struct fec_tree *, struct fec *);
184int fec_remove(struct fec_tree *, struct fec *);
185void fec_clear(struct fec_tree *, void (*)(void *));
186void rt_dump(pid_t);
187void fec_snap(struct lde_nbr *);
188void fec_tree_clear(void);
189struct fec_nh *fec_nh_find(struct fec_node *, int, union ldpd_addr *,
88d88a9c 190 ifindex_t, uint8_t);
8429abe0 191void lde_kernel_insert(struct fec *, int, union ldpd_addr *,
88d88a9c 192 ifindex_t, uint8_t, int, void *);
8429abe0 193void lde_kernel_remove(struct fec *, int, union ldpd_addr *,
88d88a9c 194 ifindex_t, uint8_t);
8cb1fc45 195void lde_kernel_update(struct fec *);
8429abe0
RW
196void lde_check_mapping(struct map *, struct lde_nbr *);
197void lde_check_request(struct map *, struct lde_nbr *);
d4afb819 198void lde_check_request_wcard(struct map *, struct lde_nbr *);
8429abe0
RW
199void lde_check_release(struct map *, struct lde_nbr *);
200void lde_check_release_wcard(struct map *, struct lde_nbr *);
201void lde_check_withdraw(struct map *, struct lde_nbr *);
202void lde_check_withdraw_wcard(struct map *, struct lde_nbr *);
0bcc2916
RW
203int lde_wildcard_apply(struct map *, struct fec *,
204 struct lde_map *);
eac6e3f0 205int lde_gc_timer(struct thread *);
8429abe0
RW
206void lde_gc_start_timer(void);
207void lde_gc_stop_timer(void);
208
209/* l2vpn.c */
210struct l2vpn *l2vpn_new(const char *);
211struct l2vpn *l2vpn_find(struct ldpd_conf *, const char *);
212void l2vpn_del(struct l2vpn *);
213void l2vpn_init(struct l2vpn *);
214void l2vpn_exit(struct l2vpn *);
215struct l2vpn_if *l2vpn_if_new(struct l2vpn *, struct kif *);
52bd4c23 216struct l2vpn_if *l2vpn_if_find(struct l2vpn *, const char *);
26519d8c 217void l2vpn_if_update(struct l2vpn_if *);
8429abe0 218struct l2vpn_pw *l2vpn_pw_new(struct l2vpn *, struct kif *);
52bd4c23 219struct l2vpn_pw *l2vpn_pw_find(struct l2vpn *, const char *);
5c3f00af
RW
220struct l2vpn_pw *l2vpn_pw_find_active(struct l2vpn *, const char *);
221struct l2vpn_pw *l2vpn_pw_find_inactive(struct l2vpn *, const char *);
8429abe0
RW
222void l2vpn_pw_init(struct l2vpn_pw *);
223void l2vpn_pw_exit(struct l2vpn_pw *);
224void l2vpn_pw_reset(struct l2vpn_pw *);
225int l2vpn_pw_ok(struct l2vpn_pw *, struct fec_nh *);
226int l2vpn_pw_negotiate(struct lde_nbr *, struct fec_node *,
227 struct map *);
0bcc2916
RW
228void l2vpn_send_pw_status(struct lde_nbr *, uint32_t, struct fec *);
229void l2vpn_send_pw_status_wcard(struct lde_nbr *, uint32_t,
230 uint16_t, uint32_t);
8429abe0 231void l2vpn_recv_pw_status(struct lde_nbr *, struct notify_msg *);
0bcc2916
RW
232void l2vpn_recv_pw_status_wcard(struct lde_nbr *,
233 struct notify_msg *);
8429abe0
RW
234void l2vpn_pw_ctl(pid_t);
235void l2vpn_binding_ctl(pid_t);
236
237#endif /* _LDE_H_ */