]>
git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_interface.h
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
28 #include "ospfd/ospf_packet.h"
29 #include "ospfd/ospf_spf.h"
31 #define IF_OSPF_IF_INFO(I) ((struct ospf_if_info *)((I)->info))
32 #define IF_DEF_PARAMS(I) (IF_OSPF_IF_INFO (I)->def_params)
33 #define IF_OIFS(I) (IF_OSPF_IF_INFO (I)->oifs)
34 #define IF_OIFS_PARAMS(I) (IF_OSPF_IF_INFO (I)->params)
36 /* Despite the name, this macro probably is for specialist use only */
37 #define OSPF_IF_PARAM_CONFIGURED(S, P) ((S) && (S)->P##__config)
39 /* Test whether an OSPF interface parameter is set, generally, given some
40 * existing ospf interface
42 #define OSPF_IF_PARAM_IS_SET(O, P) \
43 (OSPF_IF_PARAM_CONFIGURED((O)->params, P) \
44 || OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS((O)->ifp)->P))
46 #define OSPF_IF_PARAM(O, P) \
47 (OSPF_IF_PARAM_CONFIGURED((O)->params, P) \
49 : IF_DEF_PARAMS((O)->ifp)->P)
51 #define DECLARE_IF_PARAM(T, P) \
53 uint8_t P##__config : 1
54 #define UNSET_IF_PARAM(S, P) ((S)->P##__config) = 0
55 #define SET_IF_PARAM(S, P) ((S)->P##__config) = 1
57 struct ospf_if_params
{
58 DECLARE_IF_PARAM(uint32_t,
59 transmit_delay
); /* Interface Transmisson Delay */
60 DECLARE_IF_PARAM(uint32_t,
61 output_cost_cmd
); /* Command Interface Output Cost */
62 DECLARE_IF_PARAM(uint32_t,
63 retransmit_interval
); /* Retransmission Interval */
64 DECLARE_IF_PARAM(uint8_t, passive_interface
); /* OSPF Interface is
65 passive: no sending or
67 join multicast groups)
69 DECLARE_IF_PARAM(uint8_t, priority
); /* OSPF Interface priority */
70 /* Enable OSPF on this interface with area if_area */
71 DECLARE_IF_PARAM(struct in_addr
, if_area
);
72 uint32_t if_area_id_fmt
;
74 DECLARE_IF_PARAM(uint8_t, type
); /* type of interface */
75 #define OSPF_IF_ACTIVE 0
76 #define OSPF_IF_PASSIVE 1
78 #define OSPF_IF_PASSIVE_STATUS(O) \
79 (OSPF_IF_PARAM_CONFIGURED((O)->params, passive_interface) \
80 ? (O)->params->passive_interface \
81 : (OSPF_IF_PARAM_CONFIGURED(IF_DEF_PARAMS((O)->ifp), \
83 ? IF_DEF_PARAMS((O)->ifp)->passive_interface \
84 : (O)->ospf->passive_interface_default))
86 DECLARE_IF_PARAM(uint32_t, v_hello
); /* Hello Interval */
87 DECLARE_IF_PARAM(uint32_t, v_wait
); /* Router Dead Interval */
88 bool is_v_wait_set
; /* Check for Dead Interval set */
90 /* MTU mismatch check (see RFC2328, chap 10.6) */
91 DECLARE_IF_PARAM(uint8_t, mtu_ignore
);
94 DECLARE_IF_PARAM(uint8_t, fast_hello
);
96 /* Authentication data. */
97 uint8_t auth_simple
[OSPF_AUTH_SIMPLE_SIZE
+ 1]; /* Simple password. */
98 uint8_t auth_simple__config
: 1;
100 DECLARE_IF_PARAM(struct list
*,
101 auth_crypt
); /* List of Auth cryptographic data. */
102 DECLARE_IF_PARAM(int, auth_type
); /* OSPF authentication type */
104 /* Other, non-configuration state */
105 uint32_t network_lsa_seqnum
; /* Network LSA seqnum */
107 /* BFD configuration */
108 struct bfd_configuration
{
109 /** BFD session detection multiplier. */
110 uint8_t detection_multiplier
;
111 /** BFD session minimum required receive interval. */
113 /** BFD session minimum required transmission interval. */
116 char profile
[BFD_PROFILE_NAME_LEN
];
119 /* MPLS LDP-IGP Sync configuration */
120 struct ldp_sync_info
*ldp_sync_info
;
122 /* point-to-point DMVPN configuration */
126 enum { MEMBER_ALLROUTERS
= 0,
131 struct ospf_if_info
{
132 struct ospf_if_params
*def_params
;
133 struct route_table
*params
;
134 struct route_table
*oifs
;
136 membership_counts
[MEMBER_MAX
]; /* multicast group refcnts */
141 struct ospf_interface
;
143 struct ospf_vl_data
{
144 struct in_addr vl_peer
; /* Router-ID of the peer */
145 struct in_addr vl_area_id
; /* Transit area */
146 int vl_area_id_fmt
; /* Area ID format */
147 struct ospf_interface
*vl_oi
; /* Interface data structure */
148 struct vertex_nexthop nexthop
; /* Nexthop router and oi to use */
149 struct in_addr peer_addr
; /* Address used to reach the peer */
154 #define OSPF_VL_MAX_COUNT 256
155 #define OSPF_VL_MTU 1500
157 #define OSPF_VL_FLAG_APPROVED 0x01
161 uint8_t auth_key
[OSPF_AUTH_MD5_SIZE
+ 1];
164 /* OSPF interface structure. */
165 struct ospf_interface
{
166 /* This interface's parent ospf instance. */
170 struct ospf_area
*area
;
172 /* Position range in Router LSA */
173 uint16_t lsa_pos_beg
; /* inclusive, >= */
174 uint16_t lsa_pos_end
; /* exclusive, < */
176 /* Interface data from zebra. */
177 struct interface
*ifp
;
178 struct ospf_vl_data
*vl_data
; /* Data for Virtual Link */
180 /* Packet send buffer. */
181 struct ospf_fifo
*obuf
; /* Output queue */
183 /* OSPF Network Type. */
186 /* point-to-point DMVPN configuration */
189 /* State of Interface State Machine. */
192 /* To which multicast groups do we currently belong? */
193 uint8_t multicast_memberships
;
194 #define OI_MEMBER_FLAG(M) (1 << (M))
195 #define OI_MEMBER_COUNT(O,M) (IF_OSPF_IF_INFO(oi->ifp)->membership_counts[(M)])
196 #define OI_MEMBER_CHECK(O, M) \
197 (CHECK_FLAG((O)->multicast_memberships, OI_MEMBER_FLAG(M)))
198 #define OI_MEMBER_JOINED(O, M) \
200 SET_FLAG((O)->multicast_memberships, OI_MEMBER_FLAG(M)); \
201 IF_OSPF_IF_INFO((O)->ifp)->membership_counts[(M)]++; \
203 #define OI_MEMBER_LEFT(O, M) \
205 UNSET_FLAG((O)->multicast_memberships, OI_MEMBER_FLAG(M)); \
206 IF_OSPF_IF_INFO((O)->ifp)->membership_counts[(M)]--; \
209 struct prefix
*address
; /* Interface prefix */
210 struct connected
*connected
; /* Pointer to connected */
212 /* Configured varables. */
213 struct ospf_if_params
*params
;
215 uint32_t crypt_seqnum
; /* Cryptographic Sequence Number */
216 uint32_t output_cost
; /* Acutual Interface Output Cost */
218 /* Neighbor information. */
219 struct route_table
*nbrs
; /* OSPF Neighbor List */
220 struct ospf_neighbor
*nbr_self
; /* Neighbor Self */
221 #define DR(I) ((I)->nbr_self->d_router)
222 #define BDR(I) ((I)->nbr_self->bd_router)
223 #define OPTIONS(I) ((I)->nbr_self->options)
224 #define PRIORITY(I) ((I)->nbr_self->priority)
226 /* List of configured NBMA neighbor. */
227 struct list
*nbr_nbma
;
229 /* self-originated LSAs. */
230 struct ospf_lsa
*network_lsa_self
; /* network-LSA. */
231 struct list
*opaque_lsa_self
; /* Type-9 Opaque-LSAs */
233 struct route_table
*ls_upd_queue
;
235 struct list
*ls_ack
; /* Link State Acknowledgment list. */
243 uint32_t v_ls_ack
; /* Delayed Link State Acknowledgment */
246 struct thread
*t_hello
; /* timer */
247 struct thread
*t_wait
; /* timer */
248 struct thread
*t_ls_ack
; /* timer */
249 struct thread
*t_ls_ack_direct
; /* event */
250 struct thread
*t_ls_upd_event
; /* event */
251 struct thread
*t_opaque_lsa_self
; /* Type-9 Opaque-LSAs */
255 /* Statistics fields. */
256 uint32_t hello_in
; /* Hello message input count. */
257 uint32_t hello_out
; /* Hello message output count. */
258 uint32_t db_desc_in
; /* database desc. message input count. */
259 uint32_t db_desc_out
; /* database desc. message output count. */
260 uint32_t ls_req_in
; /* LS request message input count. */
261 uint32_t ls_req_out
; /* LS request message output count. */
262 uint32_t ls_upd_in
; /* LS update message input count. */
263 uint32_t ls_upd_out
; /* LS update message output count. */
264 uint32_t ls_ack_in
; /* LS Ack message input count. */
265 uint32_t ls_ack_out
; /* LS Ack message output count. */
266 uint32_t discarded
; /* discarded input count by error. */
267 uint32_t state_change
; /* Number of status change. */
273 DECLARE_QOBJ_TYPE(ospf_interface
);
276 extern char *ospf_if_name(struct ospf_interface
*oi
);
277 extern struct ospf_interface
*
278 ospf_if_new(struct ospf
*ospf
, struct interface
*ifp
, struct prefix
*p
);
279 extern void ospf_if_cleanup(struct ospf_interface
*oi
);
280 extern void ospf_if_free(struct ospf_interface
*oi
);
281 extern int ospf_if_up(struct ospf_interface
*oi
);
282 extern int ospf_if_down(struct ospf_interface
*oi
);
284 extern int ospf_if_is_up(struct ospf_interface
*oi
);
285 extern struct ospf_interface
*ospf_if_exists(struct ospf_interface
*oi
);
286 extern struct ospf_interface
*ospf_if_lookup_by_lsa_pos(struct ospf_area
*area
,
288 extern struct ospf_interface
*
289 ospf_if_lookup_by_local_addr(struct ospf
*ospf
, struct interface
*ifp
,
290 struct in_addr addr
);
291 extern struct ospf_interface
*ospf_if_lookup_by_prefix(struct ospf
*ospf
,
292 struct prefix_ipv4
*p
);
293 extern struct ospf_interface
*ospf_if_table_lookup(struct interface
*ifp
,
295 extern struct ospf_interface
*ospf_if_addr_local(struct in_addr addr
);
296 extern struct ospf_interface
*ospf_if_lookup_recv_if(struct ospf
*ospf
,
298 struct interface
*ifp
);
299 extern struct ospf_interface
*ospf_if_is_configured(struct ospf
*ospf
,
300 struct in_addr
*addr
);
302 extern struct ospf_if_params
*ospf_lookup_if_params(struct interface
*ifp
,
303 struct in_addr addr
);
304 extern struct ospf_if_params
*ospf_get_if_params(struct interface
*ifp
,
305 struct in_addr addr
);
306 extern void ospf_free_if_params(struct interface
*ifp
, struct in_addr addr
);
307 extern void ospf_if_update_params(struct interface
*ifp
, struct in_addr addr
);
309 extern int ospf_if_new_hook(struct interface
*ifp
);
310 extern void ospf_if_init(void);
311 extern void ospf_if_stream_unset(struct ospf_interface
*oi
);
312 extern void ospf_if_reset_variables(struct ospf_interface
*oi
);
313 extern int ospf_if_is_enable(struct ospf_interface
*oi
);
314 extern int ospf_if_get_output_cost(struct ospf_interface
*oi
);
315 extern void ospf_if_recalculate_output_cost(struct interface
*ifp
);
317 /* Simulate down/up on the interface. */
318 extern void ospf_if_reset(struct interface
*ifp
);
320 extern struct ospf_interface
*ospf_vl_new(struct ospf
*ospf
,
321 struct ospf_vl_data
*vl_data
);
322 extern struct ospf_vl_data
*ospf_vl_data_new(struct ospf_area
*area
,
323 struct in_addr addr
);
324 extern struct ospf_vl_data
*
325 ospf_vl_lookup(struct ospf
*ospf
, struct ospf_area
*area
, struct in_addr addr
);
326 extern int ospf_vl_count(struct ospf
*ospf
, struct ospf_area
*area
);
327 extern void ospf_vl_data_free(struct ospf_vl_data
*vl_data
);
328 extern void ospf_vl_add(struct ospf
*ospf
, struct ospf_vl_data
*vl_data
);
329 extern void ospf_vl_delete(struct ospf
*ospf
, struct ospf_vl_data
*vl_data
);
330 extern void ospf_vl_up_check(struct ospf_area
*area
, struct in_addr addr
,
331 struct vertex
*vertex
);
332 extern void ospf_vl_unapprove(struct ospf
*ospf
);
333 extern void ospf_vl_shut_unapproved(struct ospf
*ospf
);
334 extern int ospf_full_virtual_nbrs(struct ospf_area
*area
);
335 extern int ospf_vls_in_area(struct ospf_area
*area
);
337 extern struct crypt_key
*ospf_crypt_key_lookup(struct list
*list
,
339 extern struct crypt_key
*ospf_crypt_key_new(void);
340 extern void ospf_crypt_key_add(struct list
*list
, struct crypt_key
*key
);
341 extern int ospf_crypt_key_delete(struct list
*list
, uint8_t key_id
);
342 extern uint8_t ospf_default_iftype(struct interface
*ifp
);
343 extern int ospf_interface_neighbor_count(struct ospf_interface
*oi
);
345 /* Set all multicast memberships appropriately based on the type and
346 state of the interface. */
347 extern void ospf_if_set_multicast(struct ospf_interface
*oi
);
349 extern void ospf_if_interface(struct interface
*ifp
);
351 extern uint32_t ospf_if_count_area_params(struct interface
*ifp
);
352 extern void ospf_reset_hello_timer(struct interface
*ifp
, struct in_addr addr
,
355 extern void ospf_interface_fifo_flush(struct ospf_interface
*oi
);
356 DECLARE_HOOK(ospf_vl_add
, (struct ospf_vl_data
* vd
), (vd
));
357 DECLARE_HOOK(ospf_vl_delete
, (struct ospf_vl_data
* vd
), (vd
));
359 DECLARE_HOOK(ospf_if_update
, (struct interface
* ifp
), (ifp
));
360 DECLARE_HOOK(ospf_if_delete
, (struct interface
* ifp
), (ifp
));
362 #endif /* _ZEBRA_OSPF_INTERFACE_H */