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