]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* |
2 | * OSPF Interface functions. | |
3 | * Copyright (C) 1999 Toshiaki Takada | |
4 | * | |
5 | * This file is part of GNU Zebra. | |
6 | * | |
7 | * GNU Zebra is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published | |
9 | * by the Free Software Foundation; either version 2, or (at your | |
10 | * option) any later version. | |
11 | * | |
12 | * GNU Zebra is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with GNU Zebra; see the file COPYING. If not, write to the | |
19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | * Boston, MA 02111-1307, USA. | |
21 | */ | |
22 | ||
23 | #ifndef _ZEBRA_OSPF_INTERFACE_H | |
24 | #define _ZEBRA_OSPF_INTERFACE_H | |
25 | ||
6c835671 | 26 | #include "ospfd/ospf_packet.h" |
9c27ef9b | 27 | #include "ospfd/ospf_spf.h" |
718e3744 | 28 | |
29 | #define IF_OSPF_IF_INFO(I) ((struct ospf_if_info *)((I)->info)) | |
30 | #define IF_DEF_PARAMS(I) (IF_OSPF_IF_INFO (I)->def_params) | |
31 | #define IF_OIFS(I) (IF_OSPF_IF_INFO (I)->oifs) | |
32 | #define IF_OIFS_PARAMS(I) (IF_OSPF_IF_INFO (I)->params) | |
33 | ||
34 | #define OSPF_IF_PARAM_CONFIGURED(S, P) ((S) && (S)->P##__config) | |
35 | #define OSPF_IF_PARAM(O, P) \ | |
36 | (OSPF_IF_PARAM_CONFIGURED ((O)->params, P)?\ | |
37 | (O)->params->P:IF_DEF_PARAMS((O)->ifp)->P) | |
38 | ||
39 | #define DECLARE_IF_PARAM(T, P) T P; u_char P##__config:1 | |
40 | #define UNSET_IF_PARAM(S, P) ((S)->P##__config) = 0 | |
41 | #define SET_IF_PARAM(S, P) ((S)->P##__config) = 1 | |
42 | ||
43 | struct ospf_if_params | |
44 | { | |
45 | DECLARE_IF_PARAM (u_int32_t, transmit_delay); /* Interface Transmisson Delay */ | |
46 | DECLARE_IF_PARAM (u_int32_t, output_cost_cmd);/* Command Interface Output Cost */ | |
47 | DECLARE_IF_PARAM (u_int32_t, retransmit_interval); /* Retransmission Interval */ | |
d5a5c8f0 | 48 | DECLARE_IF_PARAM (u_char, bfd); /* Respond to BFD events */ |
ba6454ec | 49 | DECLARE_IF_PARAM (u_char, passive_interface); /* OSPF Interface is passive: no sending or receiving (no need to join multicast groups) */ |
718e3744 | 50 | DECLARE_IF_PARAM (u_char, priority); /* OSPF Interface priority */ |
51 | DECLARE_IF_PARAM (u_char, type); /* type of interface */ | |
52 | #define OSPF_IF_ACTIVE 0 | |
53 | #define OSPF_IF_PASSIVE 1 | |
7ffa8fa2 PJ |
54 | |
55 | #define OSPF_IF_PASSIVE_STATUS(O) \ | |
56 | (OSPF_IF_PARAM_CONFIGURED((O)->params, passive_interface) ? \ | |
57 | (O)->params->passive_interface : \ | |
58 | (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS((O)->ifp), passive_interface) ? \ | |
59 | IF_DEF_PARAMS((O)->ifp)->passive_interface : \ | |
60 | (O)->ospf->passive_interface_default)) | |
718e3744 | 61 | |
62 | DECLARE_IF_PARAM (u_int32_t, v_hello); /* Hello Interval */ | |
63 | DECLARE_IF_PARAM (u_int32_t, v_wait); /* Router Dead Interval */ | |
64 | ||
ba682537 | 65 | /* MTU mismatch check (see RFC2328, chap 10.6) */ |
66 | DECLARE_IF_PARAM (u_char, mtu_ignore); | |
f9ad937f | 67 | |
68 | /* Fast-Hellos */ | |
69 | DECLARE_IF_PARAM (u_char, fast_hello); | |
70 | ||
718e3744 | 71 | /* Authentication data. */ |
72 | u_char auth_simple[OSPF_AUTH_SIMPLE_SIZE + 1]; /* Simple password. */ | |
73 | u_char auth_simple__config:1; | |
74 | ||
52dc7ee6 | 75 | DECLARE_IF_PARAM (struct list *, auth_crypt); /* List of Auth cryptographic data. */ |
718e3744 | 76 | DECLARE_IF_PARAM (int, auth_type); /* OSPF authentication type */ |
7eb5b47e PJ |
77 | |
78 | /* Other, non-configuration state */ | |
79 | u_int32_t network_lsa_seqnum; /* Network LSA seqnum */ | |
718e3744 | 80 | }; |
81 | ||
429ac78c PJ |
82 | enum |
83 | { | |
84 | MEMBER_ALLROUTERS = 0, | |
85 | MEMBER_DROUTERS, | |
86 | MEMBER_MAX, | |
87 | }; | |
88 | ||
718e3744 | 89 | struct ospf_if_info |
90 | { | |
91 | struct ospf_if_params *def_params; | |
92 | struct route_table *params; | |
93 | struct route_table *oifs; | |
429ac78c | 94 | unsigned int membership_counts[MEMBER_MAX]; /* multicast group refcnts */ |
718e3744 | 95 | }; |
96 | ||
97 | struct ospf_interface; | |
98 | ||
99 | struct ospf_vl_data | |
100 | { | |
101 | struct in_addr vl_peer; /* Router-ID of the peer for VLs. */ | |
102 | struct in_addr vl_area_id; /* Transit area for this VL. */ | |
103 | int format; /* area ID format */ | |
104 | struct ospf_interface *vl_oi; /* Interface data structure for the VL. */ | |
9c27ef9b | 105 | struct vertex_nexthop nexthop; /* Nexthop router and oi to use */ |
718e3744 | 106 | struct in_addr peer_addr; /* Address used to reach the peer. */ |
107 | u_char flags; | |
108 | }; | |
109 | ||
110 | ||
111 | #define OSPF_VL_MAX_COUNT 256 | |
112 | #define OSPF_VL_MTU 1500 | |
113 | ||
114 | #define OSPF_VL_FLAG_APPROVED 0x01 | |
115 | ||
116 | struct crypt_key | |
117 | { | |
118 | u_char key_id; | |
119 | u_char auth_key[OSPF_AUTH_MD5_SIZE + 1]; | |
120 | }; | |
121 | ||
122 | /* OSPF interface structure. */ | |
123 | struct ospf_interface | |
124 | { | |
125 | /* This interface's parent ospf instance. */ | |
126 | struct ospf *ospf; | |
127 | ||
128 | /* OSPF Area. */ | |
129 | struct ospf_area *area; | |
130 | ||
c81ee5c9 JT |
131 | /* Position range in Router LSA */ |
132 | uint16_t lsa_pos_beg; /* inclusive, >= */ | |
133 | uint16_t lsa_pos_end; /* exclusive, < */ | |
134 | ||
718e3744 | 135 | /* Interface data from zebra. */ |
136 | struct interface *ifp; | |
137 | struct ospf_vl_data *vl_data; /* Data for Virtual Link */ | |
138 | ||
139 | /* Packet send buffer. */ | |
140 | struct ospf_fifo *obuf; /* Output queue */ | |
141 | ||
142 | /* OSPF Network Type. */ | |
143 | u_char type; | |
718e3744 | 144 | |
145 | /* State of Interface State Machine. */ | |
146 | u_char state; | |
147 | ||
ba6454ec | 148 | /* To which multicast groups do we currently belong? */ |
149 | u_char multicast_memberships; | |
429ac78c PJ |
150 | #define OI_MEMBER_FLAG(M) (1 << (M)) |
151 | #define OI_MEMBER_COUNT(O,M) (IF_OSPF_IF_INFO(oi->ifp)->membership_counts[(M)]) | |
152 | #define OI_MEMBER_CHECK(O,M) \ | |
153 | (CHECK_FLAG((O)->multicast_memberships, OI_MEMBER_FLAG(M))) | |
154 | #define OI_MEMBER_JOINED(O,M) \ | |
155 | do { \ | |
156 | SET_FLAG ((O)->multicast_memberships, OI_MEMBER_FLAG(M)); \ | |
157 | IF_OSPF_IF_INFO((O)->ifp)->membership_counts[(M)]++; \ | |
158 | } while (0) | |
159 | #define OI_MEMBER_LEFT(O,M) \ | |
160 | do { \ | |
161 | UNSET_FLAG ((O)->multicast_memberships, OI_MEMBER_FLAG(M)); \ | |
162 | IF_OSPF_IF_INFO((O)->ifp)->membership_counts[(M)]--; \ | |
163 | } while (0) | |
ba6454ec | 164 | |
8cfde376 | 165 | struct prefix *address; /* Interface prefix */ |
166 | struct connected *connected; /* Pointer to connected */ | |
167 | ||
718e3744 | 168 | /* Configured varables. */ |
169 | struct ospf_if_params *params; | |
7eb5b47e | 170 | |
718e3744 | 171 | u_int32_t crypt_seqnum; /* Cryptographic Sequence Number */ |
172 | u_int32_t output_cost; /* Acutual Interface Output Cost */ | |
173 | ||
174 | /* Neighbor information. */ | |
175 | struct route_table *nbrs; /* OSPF Neighbor List */ | |
176 | struct ospf_neighbor *nbr_self; /* Neighbor Self */ | |
177 | #define DR(I) ((I)->nbr_self->d_router) | |
178 | #define BDR(I) ((I)->nbr_self->bd_router) | |
179 | #define OPTIONS(I) ((I)->nbr_self->options) | |
180 | #define PRIORITY(I) ((I)->nbr_self->priority) | |
181 | ||
182 | /* List of configured NBMA neighbor. */ | |
52dc7ee6 | 183 | struct list *nbr_nbma; |
718e3744 | 184 | |
185 | /* self-originated LSAs. */ | |
186 | struct ospf_lsa *network_lsa_self; /* network-LSA. */ | |
187 | #ifdef HAVE_OPAQUE_LSA | |
87d6f87a | 188 | struct list *opaque_lsa_self; /* Type-9 Opaque-LSAs */ |
718e3744 | 189 | #endif /* HAVE_OPAQUE_LSA */ |
190 | ||
191 | struct route_table *ls_upd_queue; | |
192 | ||
52dc7ee6 | 193 | struct list *ls_ack; /* Link State Acknowledgment list. */ |
718e3744 | 194 | |
195 | struct | |
196 | { | |
52dc7ee6 | 197 | struct list *ls_ack; |
718e3744 | 198 | struct in_addr dst; |
199 | } ls_ack_direct; | |
200 | ||
201 | /* Timer values. */ | |
202 | u_int32_t v_ls_ack; /* Delayed Link State Acknowledgment */ | |
203 | ||
204 | /* Threads. */ | |
205 | struct thread *t_hello; /* timer */ | |
206 | struct thread *t_wait; /* timer */ | |
207 | struct thread *t_ls_ack; /* timer */ | |
208 | struct thread *t_ls_ack_direct; /* event */ | |
209 | struct thread *t_ls_upd_event; /* event */ | |
718e3744 | 210 | #ifdef HAVE_OPAQUE_LSA |
211 | struct thread *t_opaque_lsa_self; /* Type-9 Opaque-LSAs */ | |
212 | #endif /* HAVE_OPAQUE_LSA */ | |
213 | ||
214 | int on_write_q; | |
215 | ||
216 | /* Statistics fields. */ | |
217 | u_int32_t hello_in; /* Hello message input count. */ | |
218 | u_int32_t hello_out; /* Hello message output count. */ | |
219 | u_int32_t db_desc_in; /* database desc. message input count. */ | |
220 | u_int32_t db_desc_out; /* database desc. message output count. */ | |
221 | u_int32_t ls_req_in; /* LS request message input count. */ | |
222 | u_int32_t ls_req_out; /* LS request message output count. */ | |
223 | u_int32_t ls_upd_in; /* LS update message input count. */ | |
224 | u_int32_t ls_upd_out; /* LS update message output count. */ | |
225 | u_int32_t ls_ack_in; /* LS Ack message input count. */ | |
226 | u_int32_t ls_ack_out; /* LS Ack message output count. */ | |
227 | u_int32_t discarded; /* discarded input count by error. */ | |
228 | u_int32_t state_change; /* Number of status change. */ | |
229 | ||
2db3d05d | 230 | u_int32_t full_nbrs; |
718e3744 | 231 | }; |
232 | ||
233 | /* Prototypes. */ | |
4dadc291 | 234 | extern char *ospf_if_name (struct ospf_interface *); |
235 | extern struct ospf_interface *ospf_if_new (struct ospf *, struct interface *, | |
236 | struct prefix *); | |
237 | extern void ospf_if_cleanup (struct ospf_interface *); | |
238 | extern void ospf_if_free (struct ospf_interface *); | |
239 | extern int ospf_if_up (struct ospf_interface *); | |
240 | extern int ospf_if_down (struct ospf_interface *); | |
241 | ||
242 | extern int ospf_if_is_up (struct ospf_interface *); | |
243 | extern struct ospf_interface *ospf_if_exists (struct ospf_interface *); | |
c81ee5c9 JT |
244 | extern struct ospf_interface *ospf_if_lookup_by_lsa_pos (struct ospf_area *, |
245 | int); | |
4dadc291 | 246 | extern struct ospf_interface *ospf_if_lookup_by_local_addr (struct ospf *, |
247 | struct interface | |
248 | *, | |
249 | struct in_addr); | |
250 | extern struct ospf_interface *ospf_if_lookup_by_prefix (struct ospf *, | |
251 | struct prefix_ipv4 *); | |
f0f63841 JT |
252 | extern struct ospf_interface *ospf_if_table_lookup (struct interface *, |
253 | struct prefix *); | |
4dadc291 | 254 | extern struct ospf_interface *ospf_if_addr_local (struct in_addr); |
255 | extern struct ospf_interface *ospf_if_lookup_recv_if (struct ospf *, | |
05cf46ba JT |
256 | struct in_addr, |
257 | struct interface *); | |
4dadc291 | 258 | extern struct ospf_interface *ospf_if_is_configured (struct ospf *, |
259 | struct in_addr *); | |
260 | ||
261 | extern struct ospf_if_params *ospf_lookup_if_params (struct interface *, | |
2db3d05d | 262 | struct in_addr); |
4dadc291 | 263 | extern struct ospf_if_params *ospf_get_if_params (struct interface *, |
264 | struct in_addr); | |
265 | extern void ospf_del_if_params (struct ospf_if_params *); | |
266 | extern void ospf_free_if_params (struct interface *, struct in_addr); | |
267 | extern void ospf_if_update_params (struct interface *, struct in_addr); | |
268 | ||
269 | extern int ospf_if_new_hook (struct interface *); | |
270 | extern void ospf_if_init (void); | |
271 | extern void ospf_if_stream_set (struct ospf_interface *); | |
272 | extern void ospf_if_stream_unset (struct ospf_interface *); | |
273 | extern void ospf_if_reset_variables (struct ospf_interface *); | |
274 | extern int ospf_if_is_enable (struct ospf_interface *); | |
275 | extern int ospf_if_get_output_cost (struct ospf_interface *); | |
276 | extern void ospf_if_recalculate_output_cost (struct interface *); | |
718e3744 | 277 | |
a608bbf2 | 278 | /* Simulate down/up on the interface. */ |
279 | extern void ospf_if_reset (struct interface *); | |
280 | ||
4dadc291 | 281 | extern struct ospf_interface *ospf_vl_new (struct ospf *, |
282 | struct ospf_vl_data *); | |
283 | extern struct ospf_vl_data *ospf_vl_data_new (struct ospf_area *, | |
284 | struct in_addr); | |
9c27ef9b | 285 | extern struct ospf_vl_data *ospf_vl_lookup (struct ospf *, struct ospf_area *, |
4dadc291 | 286 | struct in_addr); |
287 | extern void ospf_vl_data_free (struct ospf_vl_data *); | |
288 | extern void ospf_vl_add (struct ospf *, struct ospf_vl_data *); | |
289 | extern void ospf_vl_delete (struct ospf *, struct ospf_vl_data *); | |
290 | extern void ospf_vl_up_check (struct ospf_area *, struct in_addr, | |
291 | struct vertex *); | |
292 | extern void ospf_vl_unapprove (struct ospf *); | |
293 | extern void ospf_vl_shut_unapproved (struct ospf *); | |
294 | extern int ospf_full_virtual_nbrs (struct ospf_area *); | |
295 | extern int ospf_vls_in_area (struct ospf_area *); | |
296 | ||
297 | extern struct crypt_key *ospf_crypt_key_lookup (struct list *, u_char); | |
298 | extern struct crypt_key *ospf_crypt_key_new (void); | |
299 | extern void ospf_crypt_key_add (struct list *, struct crypt_key *); | |
300 | extern int ospf_crypt_key_delete (struct list *, u_char); | |
301 | ||
302 | extern u_char ospf_default_iftype (struct interface *ifp); | |
bc18d616 | 303 | |
ba6454ec | 304 | /* Set all multicast memberships appropriately based on the type and |
305 | state of the interface. */ | |
4dadc291 | 306 | extern void ospf_if_set_multicast (struct ospf_interface *); |
ba6454ec | 307 | |
718e3744 | 308 | #endif /* _ZEBRA_OSPF_INTERFACE_H */ |