]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_neighbor.h
Merge pull request #9486 from slankdev/slankdev-srv6-no-cli-1
[mirror_frr.git] / ospf6d / ospf6_neighbor.h
1 /*
2 * Copyright (C) 2003 Yasuhiro Ohara
3 *
4 * This file is part of GNU Zebra.
5 *
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #ifndef OSPF6_NEIGHBOR_H
22 #define OSPF6_NEIGHBOR_H
23
24 #include "hook.h"
25
26 /* Debug option */
27 extern unsigned char conf_debug_ospf6_neighbor;
28 #define OSPF6_DEBUG_NEIGHBOR_STATE 0x01
29 #define OSPF6_DEBUG_NEIGHBOR_EVENT 0x02
30 #define OSPF6_DEBUG_NEIGHBOR_ON(level) (conf_debug_ospf6_neighbor |= (level))
31 #define OSPF6_DEBUG_NEIGHBOR_OFF(level) (conf_debug_ospf6_neighbor &= ~(level))
32 #define IS_OSPF6_DEBUG_NEIGHBOR(level) \
33 (conf_debug_ospf6_neighbor & OSPF6_DEBUG_NEIGHBOR_##level)
34
35 struct ospf6_helper_info {
36
37 /* Grace interval received from
38 * Restarting Router.
39 */
40 uint32_t recvd_grace_period;
41
42 /* Grace interval used for grace
43 * gracetimer.
44 */
45 uint32_t actual_grace_period;
46
47 /* Grace timer,This Router acts as
48 * helper until this timer until
49 * this timer expires.
50 */
51 struct thread *t_grace_timer;
52
53 /* Helper status */
54 uint32_t gr_helper_status;
55
56 /* Helper exit reason*/
57 uint32_t helper_exit_reason;
58
59 /* Planned/Unplanned restart*/
60 uint32_t gr_restart_reason;
61
62
63 /* Helper rejected reason */
64 uint32_t rejected_reason;
65 };
66
67 /* Neighbor structure */
68 struct ospf6_neighbor {
69 /* Neighbor Router ID String */
70 char name[36];
71
72 /* OSPFv3 Interface this neighbor belongs to */
73 struct ospf6_interface *ospf6_if;
74
75 /* Neighbor state */
76 uint8_t state;
77
78 /* timestamp of last changing state */
79 uint32_t state_change;
80 struct timeval last_changed;
81
82 /* last received hello */
83 struct timeval last_hello;
84 uint32_t hello_in;
85
86 /* Neighbor Router ID */
87 in_addr_t router_id;
88
89 /* Neighbor Interface ID */
90 ifindex_t ifindex;
91
92 /* Router Priority of this neighbor */
93 uint8_t priority;
94
95 in_addr_t drouter;
96 in_addr_t bdrouter;
97 in_addr_t prev_drouter;
98 in_addr_t prev_bdrouter;
99
100 /* Options field (Capability) */
101 char options[3];
102
103 /* IPaddr of I/F on neighbour's link */
104 struct in6_addr linklocal_addr;
105
106 /* For Database Exchange */
107 uint8_t dbdesc_bits;
108 uint32_t dbdesc_seqnum;
109 /* Last received Database Description packet */
110 struct ospf6_dbdesc dbdesc_last;
111
112 /* LS-list */
113 struct ospf6_lsdb *summary_list;
114 struct ospf6_lsdb *request_list;
115 struct ospf6_lsdb *retrans_list;
116
117 /* LSA list for message transmission */
118 struct ospf6_lsdb *dbdesc_list;
119 struct ospf6_lsdb *lsreq_list;
120 struct ospf6_lsdb *lsupdate_list;
121 struct ospf6_lsdb *lsack_list;
122
123 struct ospf6_lsa *last_ls_req;
124
125 /* Inactivity timer */
126 struct thread *inactivity_timer;
127
128 /* Timer to release the last dbdesc packet */
129 struct thread *last_dbdesc_release_timer;
130
131 /* Thread for sending message */
132 struct thread *thread_send_dbdesc;
133 struct thread *thread_send_lsreq;
134 struct thread *thread_send_lsupdate;
135 struct thread *thread_send_lsack;
136
137 /* BFD information */
138 struct bfd_session_params *bfd_session;
139
140 /* ospf6 graceful restart HELPER info */
141 struct ospf6_helper_info gr_helper_info;
142 };
143
144 /* Neighbor state */
145 #define OSPF6_NEIGHBOR_DOWN 1
146 #define OSPF6_NEIGHBOR_ATTEMPT 2
147 #define OSPF6_NEIGHBOR_INIT 3
148 #define OSPF6_NEIGHBOR_TWOWAY 4
149 #define OSPF6_NEIGHBOR_EXSTART 5
150 #define OSPF6_NEIGHBOR_EXCHANGE 6
151 #define OSPF6_NEIGHBOR_LOADING 7
152 #define OSPF6_NEIGHBOR_FULL 8
153
154 /* Neighbor Events */
155 #define OSPF6_NEIGHBOR_EVENT_NO_EVENT 0
156 #define OSPF6_NEIGHBOR_EVENT_HELLO_RCVD 1
157 #define OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD 2
158 #define OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE 3
159 #define OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE 4
160 #define OSPF6_NEIGHBOR_EVENT_LOADING_DONE 5
161 #define OSPF6_NEIGHBOR_EVENT_ADJ_OK 6
162 #define OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH 7
163 #define OSPF6_NEIGHBOR_EVENT_BAD_LSREQ 8
164 #define OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD 9
165 #define OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER 10
166 #define OSPF6_NEIGHBOR_EVENT_MAX_EVENT 11
167
168 extern const char *const ospf6_neighbor_event_str[];
169
170 static inline const char *ospf6_neighbor_event_string(int event)
171 {
172 #define OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING "UnknownEvent"
173
174 if (event < OSPF6_NEIGHBOR_EVENT_MAX_EVENT)
175 return ospf6_neighbor_event_str[event];
176 return OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING;
177 }
178
179 extern const char *const ospf6_neighbor_state_str[];
180
181
182 /* Function Prototypes */
183 int ospf6_neighbor_cmp(void *va, void *vb);
184 void ospf6_neighbor_dbex_init(struct ospf6_neighbor *on);
185
186 struct ospf6_neighbor *ospf6_neighbor_lookup(uint32_t router_id,
187 struct ospf6_interface *oi);
188 struct ospf6_neighbor *ospf6_neighbor_create(uint32_t router_id,
189 struct ospf6_interface *oi);
190 void ospf6_neighbor_delete(struct ospf6_neighbor *on);
191
192 /* Neighbor event */
193 extern int hello_received(struct thread *thread);
194 extern int twoway_received(struct thread *thread);
195 extern int negotiation_done(struct thread *thread);
196 extern int exchange_done(struct thread *thread);
197 extern int loading_done(struct thread *thread);
198 extern int adj_ok(struct thread *thread);
199 extern int seqnumber_mismatch(struct thread *thread);
200 extern int bad_lsreq(struct thread *thread);
201 extern int oneway_received(struct thread *thread);
202 extern int inactivity_timer(struct thread *thread);
203 extern void ospf6_check_nbr_loading(struct ospf6_neighbor *on);
204
205 extern void ospf6_neighbor_init(void);
206 extern int config_write_ospf6_debug_neighbor(struct vty *vty);
207 extern void install_element_ospf6_debug_neighbor(void);
208
209 DECLARE_HOOK(ospf6_neighbor_change,
210 (struct ospf6_neighbor * on, int state, int next_state),
211 (on, state, next_state));
212
213 #endif /* OSPF6_NEIGHBOR_H */