]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_neighbor.h
*: make consistent & update GPLv2 file headers
[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) \
31 (conf_debug_ospf6_neighbor |= (level))
32 #define OSPF6_DEBUG_NEIGHBOR_OFF(level) \
33 (conf_debug_ospf6_neighbor &= ~(level))
34 #define IS_OSPF6_DEBUG_NEIGHBOR(level) \
35 (conf_debug_ospf6_neighbor & OSPF6_DEBUG_NEIGHBOR_ ## level)
36
37 /* Neighbor structure */
38 struct ospf6_neighbor
39 {
40 /* Neighbor Router ID String */
41 char name[32];
42
43 /* OSPFv3 Interface this neighbor belongs to */
44 struct ospf6_interface *ospf6_if;
45
46 /* Neighbor state */
47 u_char state;
48
49 /* timestamp of last changing state */
50 u_int32_t state_change;
51 struct timeval last_changed;
52
53 /* Neighbor Router ID */
54 u_int32_t router_id;
55
56 /* Neighbor Interface ID */
57 ifindex_t ifindex;
58
59 /* Router Priority of this neighbor */
60 u_char priority;
61
62 u_int32_t drouter;
63 u_int32_t bdrouter;
64 u_int32_t prev_drouter;
65 u_int32_t prev_bdrouter;
66
67 /* Options field (Capability) */
68 char options[3];
69
70 /* IPaddr of I/F on our side link */
71 struct in6_addr linklocal_addr;
72
73 /* For Database Exchange */
74 u_char dbdesc_bits;
75 u_int32_t dbdesc_seqnum;
76 /* Last received Database Description packet */
77 struct ospf6_dbdesc dbdesc_last;
78
79 /* LS-list */
80 struct ospf6_lsdb *summary_list;
81 struct ospf6_lsdb *request_list;
82 struct ospf6_lsdb *retrans_list;
83
84 /* LSA list for message transmission */
85 struct ospf6_lsdb *dbdesc_list;
86 struct ospf6_lsdb *lsreq_list;
87 struct ospf6_lsdb *lsupdate_list;
88 struct ospf6_lsdb *lsack_list;
89
90 struct ospf6_lsa *last_ls_req;
91
92 /* Inactivity timer */
93 struct thread *inactivity_timer;
94
95 /* Thread for sending message */
96 struct thread *thread_send_dbdesc;
97 struct thread *thread_send_lsreq;
98 struct thread *thread_send_lsupdate;
99 struct thread *thread_send_lsack;
100
101 /* BFD information */
102 void *bfd_info;
103 };
104
105 /* Neighbor state */
106 #define OSPF6_NEIGHBOR_DOWN 1
107 #define OSPF6_NEIGHBOR_ATTEMPT 2
108 #define OSPF6_NEIGHBOR_INIT 3
109 #define OSPF6_NEIGHBOR_TWOWAY 4
110 #define OSPF6_NEIGHBOR_EXSTART 5
111 #define OSPF6_NEIGHBOR_EXCHANGE 6
112 #define OSPF6_NEIGHBOR_LOADING 7
113 #define OSPF6_NEIGHBOR_FULL 8
114
115 /* Neighbor Events */
116 #define OSPF6_NEIGHBOR_EVENT_NO_EVENT 0
117 #define OSPF6_NEIGHBOR_EVENT_HELLO_RCVD 1
118 #define OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD 2
119 #define OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE 3
120 #define OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE 4
121 #define OSPF6_NEIGHBOR_EVENT_LOADING_DONE 5
122 #define OSPF6_NEIGHBOR_EVENT_ADJ_OK 6
123 #define OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH 7
124 #define OSPF6_NEIGHBOR_EVENT_BAD_LSREQ 8
125 #define OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD 9
126 #define OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER 10
127 #define OSPF6_NEIGHBOR_EVENT_MAX_EVENT 11
128
129 static const char *ospf6_neighbor_event_str[] =
130 {
131 "NoEvent",
132 "HelloReceived",
133 "2-WayReceived",
134 "NegotiationDone",
135 "ExchangeDone",
136 "LoadingDone",
137 "AdjOK?",
138 "SeqNumberMismatch",
139 "BadLSReq",
140 "1-WayReceived",
141 "InactivityTimer",
142 };
143
144 static inline const char *ospf6_neighbor_event_string (int event)
145 {
146 #define OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING "UnknownEvent"
147
148 if (event < OSPF6_NEIGHBOR_EVENT_MAX_EVENT)
149 return ospf6_neighbor_event_str[event];
150 return OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING;
151 }
152
153 extern const char *ospf6_neighbor_state_str[];
154
155
156 /* Function Prototypes */
157 int ospf6_neighbor_cmp (void *va, void *vb);
158 void ospf6_neighbor_dbex_init (struct ospf6_neighbor *on);
159
160 struct ospf6_neighbor *ospf6_neighbor_lookup (u_int32_t,
161 struct ospf6_interface *);
162 struct ospf6_neighbor *ospf6_neighbor_create (u_int32_t,
163 struct ospf6_interface *);
164 void ospf6_neighbor_delete (struct ospf6_neighbor *);
165
166 /* Neighbor event */
167 extern int hello_received (struct thread *);
168 extern int twoway_received (struct thread *);
169 extern int negotiation_done (struct thread *);
170 extern int exchange_done (struct thread *);
171 extern int loading_done (struct thread *);
172 extern int adj_ok (struct thread *);
173 extern int seqnumber_mismatch (struct thread *);
174 extern int bad_lsreq (struct thread *);
175 extern int oneway_received (struct thread *);
176 extern int inactivity_timer (struct thread *);
177 extern void ospf6_check_nbr_loading (struct ospf6_neighbor *);
178
179 extern void ospf6_neighbor_init (void);
180 extern int config_write_ospf6_debug_neighbor (struct vty *vty);
181 extern void install_element_ospf6_debug_neighbor (void);
182
183 DECLARE_HOOK(ospf6_neighbor_change,
184 (struct ospf6_neighbor *on, int state, int next_state),
185 (on, state, next_state))
186
187 #endif /* OSPF6_NEIGHBOR_H */