2 * OSPF Interface functions.
3 * Copyright (C) 1999 Toshiaki Takada
5 * This file is part of GNU Zebra.
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.
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.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; see the file COPYING; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef _ZEBRA_OSPF_INTERFACE_H
23 #define _ZEBRA_OSPF_INTERFACE_H
27 #include "ospfd/ospf_packet.h"
28 #include "ospfd/ospf_spf.h"
30 #define IF_OSPF_IF_INFO(I) ((struct ospf_if_info *)((I)->info))
31 #define IF_DEF_PARAMS(I) (IF_OSPF_IF_INFO (I)->def_params)
32 #define IF_OIFS(I) (IF_OSPF_IF_INFO (I)->oifs)
33 #define IF_OIFS_PARAMS(I) (IF_OSPF_IF_INFO (I)->params)
35 /* Despite the name, this macro probably is for specialist use only */
36 #define OSPF_IF_PARAM_CONFIGURED(S, P) ((S) && (S)->P##__config)
38 /* Test whether an OSPF interface parameter is set, generally, given some
39 * existing ospf interface
41 #define OSPF_IF_PARAM_IS_SET(O,P) \
42 (OSPF_IF_PARAM_CONFIGURED ((O)->params, P) || \
43 OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS((O)->ifp)->P))
45 #define OSPF_IF_PARAM(O, P) \
46 (OSPF_IF_PARAM_CONFIGURED ((O)->params, P)?\
47 (O)->params->P:IF_DEF_PARAMS((O)->ifp)->P)
49 #define DECLARE_IF_PARAM(T, P) T P; u_char P##__config:1
50 #define UNSET_IF_PARAM(S, P) ((S)->P##__config) = 0
51 #define SET_IF_PARAM(S, P) ((S)->P##__config) = 1
55 DECLARE_IF_PARAM (u_int32_t
, transmit_delay
); /* Interface Transmisson Delay */
56 DECLARE_IF_PARAM (u_int32_t
, output_cost_cmd
);/* Command Interface Output Cost */
57 DECLARE_IF_PARAM (u_int32_t
, retransmit_interval
); /* Retransmission Interval */
58 DECLARE_IF_PARAM (u_char
, passive_interface
); /* OSPF Interface is passive: no sending or receiving (no need to join multicast groups) */
59 DECLARE_IF_PARAM (u_char
, priority
); /* OSPF Interface priority */
60 /* Enable OSPF on this interface with area if_area */
61 DECLARE_IF_PARAM (struct in_addr
, if_area
);
62 DECLARE_IF_PARAM (u_char
, type
); /* type of interface */
63 #define OSPF_IF_ACTIVE 0
64 #define OSPF_IF_PASSIVE 1
66 #define OSPF_IF_PASSIVE_STATUS(O) \
67 (OSPF_IF_PARAM_CONFIGURED((O)->params, passive_interface) ? \
68 (O)->params->passive_interface : \
69 (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS((O)->ifp), passive_interface) ? \
70 IF_DEF_PARAMS((O)->ifp)->passive_interface : \
71 (O)->ospf->passive_interface_default))
73 DECLARE_IF_PARAM (u_int32_t
, v_hello
); /* Hello Interval */
74 DECLARE_IF_PARAM (u_int32_t
, v_wait
); /* Router Dead Interval */
76 /* MTU mismatch check (see RFC2328, chap 10.6) */
77 DECLARE_IF_PARAM (u_char
, mtu_ignore
);
80 DECLARE_IF_PARAM (u_char
, fast_hello
);
82 /* Authentication data. */
83 u_char auth_simple
[OSPF_AUTH_SIMPLE_SIZE
+ 1]; /* Simple password. */
84 u_char auth_simple__config
:1;
86 DECLARE_IF_PARAM (struct list
*, auth_crypt
); /* List of Auth cryptographic data. */
87 DECLARE_IF_PARAM (int, auth_type
); /* OSPF authentication type */
89 /* Other, non-configuration state */
90 u_int32_t network_lsa_seqnum
; /* Network LSA seqnum */
92 /* BFD configuration */
93 struct bfd_info
*bfd_info
;
98 MEMBER_ALLROUTERS
= 0,
105 struct ospf_if_params
*def_params
;
106 struct route_table
*params
;
107 struct route_table
*oifs
;
108 unsigned int membership_counts
[MEMBER_MAX
]; /* multicast group refcnts */
111 struct ospf_interface
;
115 struct in_addr vl_peer
; /* Router-ID of the peer */
116 struct in_addr vl_area_id
; /* Transit area */
117 int vl_area_id_fmt
; /* Area ID format */
118 struct ospf_interface
*vl_oi
; /* Interface data structure */
119 struct vertex_nexthop nexthop
; /* Nexthop router and oi to use */
120 struct in_addr peer_addr
; /* Address used to reach the peer */
125 #define OSPF_VL_MAX_COUNT 256
126 #define OSPF_VL_MTU 1500
128 #define OSPF_VL_FLAG_APPROVED 0x01
133 u_char auth_key
[OSPF_AUTH_MD5_SIZE
+ 1];
136 /* OSPF interface structure. */
137 struct ospf_interface
139 /* This interface's parent ospf instance. */
143 struct ospf_area
*area
;
145 /* Position range in Router LSA */
146 uint16_t lsa_pos_beg
; /* inclusive, >= */
147 uint16_t lsa_pos_end
; /* exclusive, < */
149 /* Interface data from zebra. */
150 struct interface
*ifp
;
151 struct ospf_vl_data
*vl_data
; /* Data for Virtual Link */
153 /* Packet send buffer. */
154 struct ospf_fifo
*obuf
; /* Output queue */
156 /* OSPF Network Type. */
159 /* State of Interface State Machine. */
162 /* To which multicast groups do we currently belong? */
163 u_char multicast_memberships
;
164 #define OI_MEMBER_FLAG(M) (1 << (M))
165 #define OI_MEMBER_COUNT(O,M) (IF_OSPF_IF_INFO(oi->ifp)->membership_counts[(M)])
166 #define OI_MEMBER_CHECK(O,M) \
167 (CHECK_FLAG((O)->multicast_memberships, OI_MEMBER_FLAG(M)))
168 #define OI_MEMBER_JOINED(O,M) \
170 SET_FLAG ((O)->multicast_memberships, OI_MEMBER_FLAG(M)); \
171 IF_OSPF_IF_INFO((O)->ifp)->membership_counts[(M)]++; \
173 #define OI_MEMBER_LEFT(O,M) \
175 UNSET_FLAG ((O)->multicast_memberships, OI_MEMBER_FLAG(M)); \
176 IF_OSPF_IF_INFO((O)->ifp)->membership_counts[(M)]--; \
179 struct prefix
*address
; /* Interface prefix */
180 struct connected
*connected
; /* Pointer to connected */
182 /* Configured varables. */
183 struct ospf_if_params
*params
;
185 u_int32_t crypt_seqnum
; /* Cryptographic Sequence Number */
186 u_int32_t output_cost
; /* Acutual Interface Output Cost */
188 /* Neighbor information. */
189 struct route_table
*nbrs
; /* OSPF Neighbor List */
190 struct ospf_neighbor
*nbr_self
; /* Neighbor Self */
191 #define DR(I) ((I)->nbr_self->d_router)
192 #define BDR(I) ((I)->nbr_self->bd_router)
193 #define OPTIONS(I) ((I)->nbr_self->options)
194 #define PRIORITY(I) ((I)->nbr_self->priority)
196 /* List of configured NBMA neighbor. */
197 struct list
*nbr_nbma
;
199 /* self-originated LSAs. */
200 struct ospf_lsa
*network_lsa_self
; /* network-LSA. */
201 struct list
*opaque_lsa_self
; /* Type-9 Opaque-LSAs */
203 struct route_table
*ls_upd_queue
;
205 struct list
*ls_ack
; /* Link State Acknowledgment list. */
214 u_int32_t v_ls_ack
; /* Delayed Link State Acknowledgment */
217 struct thread
*t_hello
; /* timer */
218 struct thread
*t_wait
; /* timer */
219 struct thread
*t_ls_ack
; /* timer */
220 struct thread
*t_ls_ack_direct
; /* event */
221 struct thread
*t_ls_upd_event
; /* event */
222 struct thread
*t_opaque_lsa_self
; /* Type-9 Opaque-LSAs */
226 /* Statistics fields. */
227 u_int32_t hello_in
; /* Hello message input count. */
228 u_int32_t hello_out
; /* Hello message output count. */
229 u_int32_t db_desc_in
; /* database desc. message input count. */
230 u_int32_t db_desc_out
; /* database desc. message output count. */
231 u_int32_t ls_req_in
; /* LS request message input count. */
232 u_int32_t ls_req_out
; /* LS request message output count. */
233 u_int32_t ls_upd_in
; /* LS update message input count. */
234 u_int32_t ls_upd_out
; /* LS update message output count. */
235 u_int32_t ls_ack_in
; /* LS Ack message input count. */
236 u_int32_t ls_ack_out
; /* LS Ack message output count. */
237 u_int32_t discarded
; /* discarded input count by error. */
238 u_int32_t state_change
; /* Number of status change. */
244 DECLARE_QOBJ_TYPE(ospf_interface
)
247 extern char *ospf_if_name (struct ospf_interface
*);
248 extern struct ospf_interface
*ospf_if_new (struct ospf
*, struct interface
*,
250 extern void ospf_if_cleanup (struct ospf_interface
*);
251 extern void ospf_if_free (struct ospf_interface
*);
252 extern int ospf_if_up (struct ospf_interface
*);
253 extern int ospf_if_down (struct ospf_interface
*);
255 extern int ospf_if_is_up (struct ospf_interface
*);
256 extern struct ospf_interface
*ospf_if_exists (struct ospf_interface
*);
257 extern struct ospf_interface
*ospf_if_lookup_by_lsa_pos (struct ospf_area
*,
259 extern struct ospf_interface
*ospf_if_lookup_by_local_addr (struct ospf
*,
263 extern struct ospf_interface
*ospf_if_lookup_by_prefix (struct ospf
*,
264 struct prefix_ipv4
*);
265 extern struct ospf_interface
*ospf_if_table_lookup (struct interface
*,
267 extern struct ospf_interface
*ospf_if_addr_local (struct in_addr
);
268 extern struct ospf_interface
*ospf_if_lookup_recv_if (struct ospf
*,
271 extern struct ospf_interface
*ospf_if_is_configured (struct ospf
*,
274 extern struct ospf_if_params
*ospf_lookup_if_params (struct interface
*,
276 extern struct ospf_if_params
*ospf_get_if_params (struct interface
*,
278 extern void ospf_del_if_params (struct ospf_if_params
*);
279 extern void ospf_free_if_params (struct interface
*, struct in_addr
);
280 extern void ospf_if_update_params (struct interface
*, struct in_addr
);
282 extern int ospf_if_new_hook (struct interface
*);
283 extern void ospf_if_init (void);
284 extern void ospf_if_stream_set (struct ospf_interface
*);
285 extern void ospf_if_stream_unset (struct ospf_interface
*);
286 extern void ospf_if_reset_variables (struct ospf_interface
*);
287 extern int ospf_if_is_enable (struct ospf_interface
*);
288 extern int ospf_if_get_output_cost (struct ospf_interface
*);
289 extern void ospf_if_recalculate_output_cost (struct interface
*);
291 /* Simulate down/up on the interface. */
292 extern void ospf_if_reset (struct interface
*);
294 extern struct ospf_interface
*ospf_vl_new (struct ospf
*,
295 struct ospf_vl_data
*);
296 extern struct ospf_vl_data
*ospf_vl_data_new (struct ospf_area
*,
298 extern struct ospf_vl_data
*ospf_vl_lookup (struct ospf
*, struct ospf_area
*,
300 extern void ospf_vl_data_free (struct ospf_vl_data
*);
301 extern void ospf_vl_add (struct ospf
*, struct ospf_vl_data
*);
302 extern void ospf_vl_delete (struct ospf
*, struct ospf_vl_data
*);
303 extern void ospf_vl_up_check (struct ospf_area
*, struct in_addr
,
305 extern void ospf_vl_unapprove (struct ospf
*);
306 extern void ospf_vl_shut_unapproved (struct ospf
*);
307 extern int ospf_full_virtual_nbrs (struct ospf_area
*);
308 extern int ospf_vls_in_area (struct ospf_area
*);
310 extern struct crypt_key
*ospf_crypt_key_lookup (struct list
*, u_char
);
311 extern struct crypt_key
*ospf_crypt_key_new (void);
312 extern void ospf_crypt_key_add (struct list
*, struct crypt_key
*);
313 extern int ospf_crypt_key_delete (struct list
*, u_char
);
315 extern u_char
ospf_default_iftype (struct interface
*ifp
);
317 /* Set all multicast memberships appropriately based on the type and
318 state of the interface. */
319 extern void ospf_if_set_multicast (struct ospf_interface
*);
321 DECLARE_HOOK(ospf_vl_add
, (struct ospf_vl_data
*vd
), (vd
))
322 DECLARE_HOOK(ospf_vl_delete
, (struct ospf_vl_data
*vd
), (vd
))
324 #endif /* _ZEBRA_OSPF_INTERFACE_H */