blob: 65c43fd2e9d27093d7dcf857a61f9bc3037a6519 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
hasso508e53e2004-05-18 18:57:06 +00002 * Copyright (C) 2003 Yasuhiro Ohara
paul718e3742002-12-13 20:15:29 +00003 *
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
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22#ifndef OSPF6_NEIGHBOR_H
23#define OSPF6_NEIGHBOR_H
24
hasso508e53e2004-05-18 18:57:06 +000025/* Debug option */
26extern unsigned char conf_debug_ospf6_neighbor;
27#define OSPF6_DEBUG_NEIGHBOR_STATE 0x01
28#define OSPF6_DEBUG_NEIGHBOR_EVENT 0x02
29#define OSPF6_DEBUG_NEIGHBOR_ON(level) \
30 (conf_debug_ospf6_neighbor |= (level))
31#define OSPF6_DEBUG_NEIGHBOR_OFF(level) \
32 (conf_debug_ospf6_neighbor &= ~(level))
33#define IS_OSPF6_DEBUG_NEIGHBOR(level) \
34 (conf_debug_ospf6_neighbor & OSPF6_DEBUG_NEIGHBOR_ ## level)
35
paul718e3742002-12-13 20:15:29 +000036/* Neighbor structure */
37struct ospf6_neighbor
38{
39 /* Neighbor Router ID String */
hasso508e53e2004-05-18 18:57:06 +000040 char name[32];
paul718e3742002-12-13 20:15:29 +000041
42 /* OSPFv3 Interface this neighbor belongs to */
hasso508e53e2004-05-18 18:57:06 +000043 struct ospf6_interface *ospf6_if;
paul718e3742002-12-13 20:15:29 +000044
45 /* Neighbor state */
46 u_char state;
hasso508e53e2004-05-18 18:57:06 +000047
48 /* timestamp of last changing state */
Vincent Bernat061bc732012-05-31 20:21:15 +020049 u_int32_t state_change;
paul718e3742002-12-13 20:15:29 +000050 struct timeval last_changed;
51
52 /* Neighbor Router ID */
53 u_int32_t router_id;
54
hasso508e53e2004-05-18 18:57:06 +000055 /* Neighbor Interface ID */
56 u_int32_t ifindex;
57
paul718e3742002-12-13 20:15:29 +000058 /* Router Priority of this neighbor */
59 u_char priority;
60
hasso508e53e2004-05-18 18:57:06 +000061 u_int32_t drouter;
62 u_int32_t bdrouter;
63 u_int32_t prev_drouter;
64 u_int32_t prev_bdrouter;
paul718e3742002-12-13 20:15:29 +000065
hasso508e53e2004-05-18 18:57:06 +000066 /* Options field (Capability) */
paul718e3742002-12-13 20:15:29 +000067 char options[3];
68
69 /* IPaddr of I/F on our side link */
hasso508e53e2004-05-18 18:57:06 +000070 struct in6_addr linklocal_addr;
paul718e3742002-12-13 20:15:29 +000071
72 /* For Database Exchange */
73 u_char dbdesc_bits;
74 u_int32_t dbdesc_seqnum;
hasso508e53e2004-05-18 18:57:06 +000075 /* Last received Database Description packet */
76 struct ospf6_dbdesc dbdesc_last;
paul718e3742002-12-13 20:15:29 +000077
hasso508e53e2004-05-18 18:57:06 +000078 /* LS-list */
79 struct ospf6_lsdb *summary_list;
80 struct ospf6_lsdb *request_list;
81 struct ospf6_lsdb *retrans_list;
paul718e3742002-12-13 20:15:29 +000082
hasso508e53e2004-05-18 18:57:06 +000083 /* LSA list for message transmission */
84 struct ospf6_lsdb *dbdesc_list;
85 struct ospf6_lsdb *lsreq_list;
86 struct ospf6_lsdb *lsupdate_list;
87 struct ospf6_lsdb *lsack_list;
paul718e3742002-12-13 20:15:29 +000088
Dinesh Dutteb82e9e2013-08-24 07:55:07 +000089 struct ospf6_lsa *last_ls_req;
90
hasso508e53e2004-05-18 18:57:06 +000091 /* Inactivity timer */
paul718e3742002-12-13 20:15:29 +000092 struct thread *inactivity_timer;
93
hasso508e53e2004-05-18 18:57:06 +000094 /* Thread for sending message */
paul718e3742002-12-13 20:15:29 +000095 struct thread *thread_send_dbdesc;
paul718e3742002-12-13 20:15:29 +000096 struct thread *thread_send_lsreq;
hasso508e53e2004-05-18 18:57:06 +000097 struct thread *thread_send_lsupdate;
98 struct thread *thread_send_lsack;
paul718e3742002-12-13 20:15:29 +000099};
100
hasso508e53e2004-05-18 18:57:06 +0000101/* Neighbor state */
102#define OSPF6_NEIGHBOR_DOWN 1
103#define OSPF6_NEIGHBOR_ATTEMPT 2
104#define OSPF6_NEIGHBOR_INIT 3
105#define OSPF6_NEIGHBOR_TWOWAY 4
106#define OSPF6_NEIGHBOR_EXSTART 5
107#define OSPF6_NEIGHBOR_EXCHANGE 6
108#define OSPF6_NEIGHBOR_LOADING 7
109#define OSPF6_NEIGHBOR_FULL 8
110
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000111/* Neighbor Events */
112#define OSPF6_NEIGHBOR_EVENT_NO_EVENT 0
113#define OSPF6_NEIGHBOR_EVENT_HELLO_RCVD 1
114#define OSPF6_NEIGHBOR_EVENT_TWOWAY_RCVD 2
115#define OSPF6_NEIGHBOR_EVENT_NEGOTIATION_DONE 3
116#define OSPF6_NEIGHBOR_EVENT_EXCHANGE_DONE 4
117#define OSPF6_NEIGHBOR_EVENT_LOADING_DONE 5
118#define OSPF6_NEIGHBOR_EVENT_ADJ_OK 6
119#define OSPF6_NEIGHBOR_EVENT_SEQNUMBER_MISMATCH 7
120#define OSPF6_NEIGHBOR_EVENT_BAD_LSREQ 8
121#define OSPF6_NEIGHBOR_EVENT_ONEWAY_RCVD 9
122#define OSPF6_NEIGHBOR_EVENT_INACTIVITY_TIMER 10
123#define OSPF6_NEIGHBOR_EVENT_MAX_EVENT 11
124
125static const char *ospf6_neighbor_event_str[] =
126 {
127 "NoEvent",
128 "HelloReceived",
129 "2-WayReceived",
130 "NegotiationDone",
131 "ExchangeDone",
132 "LoadingDone",
133 "AdjOK?",
134 "SeqNumberMismatch",
135 "BadLSReq",
136 "1-WayReceived",
137 "InactivityTimer",
138 };
139
140static const char *ospf6_neighbor_event_string (int event)
141{
142 #define OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING "UnknownEvent"
143
144 if (event < OSPF6_NEIGHBOR_EVENT_MAX_EVENT)
145 return ospf6_neighbor_event_str[event];
146 return OSPF6_NEIGHBOR_UNKNOWN_EVENT_STRING;
147}
148
Paul Jakma6ac29a52008-08-15 13:45:30 +0100149extern const char *ospf6_neighbor_state_str[];
paul718e3742002-12-13 20:15:29 +0000150
David Lamparter6b0655a2014-06-04 06:53:35 +0200151
paul718e3742002-12-13 20:15:29 +0000152/* Function Prototypes */
hasso508e53e2004-05-18 18:57:06 +0000153int ospf6_neighbor_cmp (void *va, void *vb);
154void ospf6_neighbor_dbex_init (struct ospf6_neighbor *on);
paul718e3742002-12-13 20:15:29 +0000155
hasso508e53e2004-05-18 18:57:06 +0000156struct ospf6_neighbor *ospf6_neighbor_lookup (u_int32_t,
157 struct ospf6_interface *);
158struct ospf6_neighbor *ospf6_neighbor_create (u_int32_t,
159 struct ospf6_interface *);
160void ospf6_neighbor_delete (struct ospf6_neighbor *);
paul718e3742002-12-13 20:15:29 +0000161
hasso508e53e2004-05-18 18:57:06 +0000162/* Neighbor event */
Paul Jakma6ac29a52008-08-15 13:45:30 +0100163extern int hello_received (struct thread *);
164extern int twoway_received (struct thread *);
165extern int negotiation_done (struct thread *);
166extern int exchange_done (struct thread *);
167extern int loading_done (struct thread *);
168extern int adj_ok (struct thread *);
169extern int seqnumber_mismatch (struct thread *);
170extern int bad_lsreq (struct thread *);
171extern int oneway_received (struct thread *);
172extern int inactivity_timer (struct thread *);
Dinesh Dutteb82e9e2013-08-24 07:55:07 +0000173extern void ospf6_check_nbr_loading (struct ospf6_neighbor *);
paul718e3742002-12-13 20:15:29 +0000174
Paul Jakma6ac29a52008-08-15 13:45:30 +0100175extern void ospf6_neighbor_init (void);
176extern int config_write_ospf6_debug_neighbor (struct vty *vty);
177extern void install_element_ospf6_debug_neighbor (void);
paul718e3742002-12-13 20:15:29 +0000178
179#endif /* OSPF6_NEIGHBOR_H */