blob: 3c759405154accd3d5b66149a218ce4ea56fb156 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
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
paul6c835672004-10-11 11:00:30 +000026#include "ospfd/ospf_packet.h"
Paul Jakma9c27ef92006-05-04 07:32:57 +000027#include "ospfd/ospf_spf.h"
paul718e3742002-12-13 20:15:29 +000028
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
43struct 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 */
ajsba6454e2005-02-08 15:37:30 +000048 DECLARE_IF_PARAM (u_char, passive_interface); /* OSPF Interface is passive: no sending or receiving (no need to join multicast groups) */
paul718e3742002-12-13 20:15:29 +000049 DECLARE_IF_PARAM (u_char, priority); /* OSPF Interface priority */
50 DECLARE_IF_PARAM (u_char, type); /* type of interface */
51#define OSPF_IF_ACTIVE 0
52#define OSPF_IF_PASSIVE 1
53
54 DECLARE_IF_PARAM (u_int32_t, v_hello); /* Hello Interval */
55 DECLARE_IF_PARAM (u_int32_t, v_wait); /* Router Dead Interval */
56
vincentba682532005-09-29 13:52:57 +000057 /* MTU mismatch check (see RFC2328, chap 10.6) */
58 DECLARE_IF_PARAM (u_char, mtu_ignore);
paulf9ad9372005-10-21 00:45:17 +000059
60 /* Fast-Hellos */
61 DECLARE_IF_PARAM (u_char, fast_hello);
62
paul718e3742002-12-13 20:15:29 +000063 /* Authentication data. */
64 u_char auth_simple[OSPF_AUTH_SIMPLE_SIZE + 1]; /* Simple password. */
65 u_char auth_simple__config:1;
66
hasso52dc7ee2004-09-23 19:18:23 +000067 DECLARE_IF_PARAM (struct list *, auth_crypt); /* List of Auth cryptographic data. */
paul718e3742002-12-13 20:15:29 +000068 DECLARE_IF_PARAM (int, auth_type); /* OSPF authentication type */
69};
70
71struct ospf_if_info
72{
73 struct ospf_if_params *def_params;
74 struct route_table *params;
75 struct route_table *oifs;
76};
77
78struct ospf_interface;
79
80struct ospf_vl_data
81{
82 struct in_addr vl_peer; /* Router-ID of the peer for VLs. */
83 struct in_addr vl_area_id; /* Transit area for this VL. */
84 int format; /* area ID format */
85 struct ospf_interface *vl_oi; /* Interface data structure for the VL. */
Paul Jakma9c27ef92006-05-04 07:32:57 +000086 struct vertex_nexthop nexthop; /* Nexthop router and oi to use */
paul718e3742002-12-13 20:15:29 +000087 struct in_addr peer_addr; /* Address used to reach the peer. */
88 u_char flags;
89};
90
91
92#define OSPF_VL_MAX_COUNT 256
93#define OSPF_VL_MTU 1500
94
95#define OSPF_VL_FLAG_APPROVED 0x01
96
97struct crypt_key
98{
99 u_char key_id;
100 u_char auth_key[OSPF_AUTH_MD5_SIZE + 1];
101};
102
103/* OSPF interface structure. */
104struct ospf_interface
105{
106 /* This interface's parent ospf instance. */
107 struct ospf *ospf;
108
109 /* OSPF Area. */
110 struct ospf_area *area;
111
112 /* Interface data from zebra. */
113 struct interface *ifp;
114 struct ospf_vl_data *vl_data; /* Data for Virtual Link */
115
116 /* Packet send buffer. */
117 struct ospf_fifo *obuf; /* Output queue */
118
119 /* OSPF Network Type. */
120 u_char type;
121#define OSPF_IFTYPE_NONE 0
122#define OSPF_IFTYPE_POINTOPOINT 1
123#define OSPF_IFTYPE_BROADCAST 2
124#define OSPF_IFTYPE_NBMA 3
125#define OSPF_IFTYPE_POINTOMULTIPOINT 4
126#define OSPF_IFTYPE_VIRTUALLINK 5
127#define OSPF_IFTYPE_LOOPBACK 6
128#define OSPF_IFTYPE_MAX 7
129
130 /* State of Interface State Machine. */
131 u_char state;
132
ajsba6454e2005-02-08 15:37:30 +0000133 /* To which multicast groups do we currently belong? */
134 u_char multicast_memberships;
135#define MEMBER_ALLROUTERS 0x1
136#define MEMBER_DROUTERS 0x2
137
ajs8cfde372005-02-08 15:59:16 +0000138 struct prefix *address; /* Interface prefix */
139 struct connected *connected; /* Pointer to connected */
140
paul718e3742002-12-13 20:15:29 +0000141 /* Configured varables. */
142 struct ospf_if_params *params;
143 u_int32_t crypt_seqnum; /* Cryptographic Sequence Number */
144 u_int32_t output_cost; /* Acutual Interface Output Cost */
145
146 /* Neighbor information. */
147 struct route_table *nbrs; /* OSPF Neighbor List */
148 struct ospf_neighbor *nbr_self; /* Neighbor Self */
149#define DR(I) ((I)->nbr_self->d_router)
150#define BDR(I) ((I)->nbr_self->bd_router)
151#define OPTIONS(I) ((I)->nbr_self->options)
152#define PRIORITY(I) ((I)->nbr_self->priority)
153
154 /* List of configured NBMA neighbor. */
hasso52dc7ee2004-09-23 19:18:23 +0000155 struct list *nbr_nbma;
paul718e3742002-12-13 20:15:29 +0000156
157 /* self-originated LSAs. */
158 struct ospf_lsa *network_lsa_self; /* network-LSA. */
159#ifdef HAVE_OPAQUE_LSA
paul87d6f872004-09-24 08:01:38 +0000160 struct list *opaque_lsa_self; /* Type-9 Opaque-LSAs */
paul718e3742002-12-13 20:15:29 +0000161#endif /* HAVE_OPAQUE_LSA */
162
163 struct route_table *ls_upd_queue;
164
hasso52dc7ee2004-09-23 19:18:23 +0000165 struct list *ls_ack; /* Link State Acknowledgment list. */
paul718e3742002-12-13 20:15:29 +0000166
167 struct
168 {
hasso52dc7ee2004-09-23 19:18:23 +0000169 struct list *ls_ack;
paul718e3742002-12-13 20:15:29 +0000170 struct in_addr dst;
171 } ls_ack_direct;
172
173 /* Timer values. */
174 u_int32_t v_ls_ack; /* Delayed Link State Acknowledgment */
175
176 /* Threads. */
177 struct thread *t_hello; /* timer */
178 struct thread *t_wait; /* timer */
179 struct thread *t_ls_ack; /* timer */
180 struct thread *t_ls_ack_direct; /* event */
181 struct thread *t_ls_upd_event; /* event */
182 struct thread *t_network_lsa_self; /* self-originated network-LSA
183 reflesh thread. timer */
184#ifdef HAVE_OPAQUE_LSA
185 struct thread *t_opaque_lsa_self; /* Type-9 Opaque-LSAs */
186#endif /* HAVE_OPAQUE_LSA */
187
188 int on_write_q;
189
190 /* Statistics fields. */
191 u_int32_t hello_in; /* Hello message input count. */
192 u_int32_t hello_out; /* Hello message output count. */
193 u_int32_t db_desc_in; /* database desc. message input count. */
194 u_int32_t db_desc_out; /* database desc. message output count. */
195 u_int32_t ls_req_in; /* LS request message input count. */
196 u_int32_t ls_req_out; /* LS request message output count. */
197 u_int32_t ls_upd_in; /* LS update message input count. */
198 u_int32_t ls_upd_out; /* LS update message output count. */
199 u_int32_t ls_ack_in; /* LS Ack message input count. */
200 u_int32_t ls_ack_out; /* LS Ack message output count. */
201 u_int32_t discarded; /* discarded input count by error. */
202 u_int32_t state_change; /* Number of status change. */
203
hasso2db3d052004-02-11 21:52:13 +0000204 u_int32_t full_nbrs;
paul718e3742002-12-13 20:15:29 +0000205};
206
207/* Prototypes. */
paul4dadc292005-05-06 21:37:42 +0000208extern char *ospf_if_name (struct ospf_interface *);
209extern struct ospf_interface *ospf_if_new (struct ospf *, struct interface *,
210 struct prefix *);
211extern void ospf_if_cleanup (struct ospf_interface *);
212extern void ospf_if_free (struct ospf_interface *);
213extern int ospf_if_up (struct ospf_interface *);
214extern int ospf_if_down (struct ospf_interface *);
paul718e3742002-12-13 20:15:29 +0000215
paul4dadc292005-05-06 21:37:42 +0000216extern int ospf_if_is_up (struct ospf_interface *);
217extern struct ospf_interface *ospf_if_exists (struct ospf_interface *);
218extern struct ospf_interface *ospf_if_lookup_by_local_addr (struct ospf *,
219 struct interface
220 *,
221 struct in_addr);
222extern struct ospf_interface *ospf_if_lookup_by_prefix (struct ospf *,
223 struct prefix_ipv4 *);
224extern struct ospf_interface *ospf_if_addr_local (struct in_addr);
225extern struct ospf_interface *ospf_if_lookup_recv_if (struct ospf *,
226 struct in_addr);
227extern struct ospf_interface *ospf_if_is_configured (struct ospf *,
228 struct in_addr *);
229
230extern struct ospf_if_params *ospf_lookup_if_params (struct interface *,
hasso2db3d052004-02-11 21:52:13 +0000231 struct in_addr);
paul4dadc292005-05-06 21:37:42 +0000232extern struct ospf_if_params *ospf_get_if_params (struct interface *,
233 struct in_addr);
234extern void ospf_del_if_params (struct ospf_if_params *);
235extern void ospf_free_if_params (struct interface *, struct in_addr);
236extern void ospf_if_update_params (struct interface *, struct in_addr);
paul718e3742002-12-13 20:15:29 +0000237
paul4dadc292005-05-06 21:37:42 +0000238extern int ospf_if_new_hook (struct interface *);
239extern void ospf_if_init (void);
240extern void ospf_if_stream_set (struct ospf_interface *);
241extern void ospf_if_stream_unset (struct ospf_interface *);
242extern void ospf_if_reset_variables (struct ospf_interface *);
243extern int ospf_if_is_enable (struct ospf_interface *);
244extern int ospf_if_get_output_cost (struct ospf_interface *);
245extern void ospf_if_recalculate_output_cost (struct interface *);
paul718e3742002-12-13 20:15:29 +0000246
ajsa608bbf2005-03-29 17:03:49 +0000247/* Simulate down/up on the interface. */
248extern void ospf_if_reset (struct interface *);
249
paul4dadc292005-05-06 21:37:42 +0000250extern struct ospf_interface *ospf_vl_new (struct ospf *,
251 struct ospf_vl_data *);
252extern struct ospf_vl_data *ospf_vl_data_new (struct ospf_area *,
253 struct in_addr);
Paul Jakma9c27ef92006-05-04 07:32:57 +0000254extern struct ospf_vl_data *ospf_vl_lookup (struct ospf *, struct ospf_area *,
paul4dadc292005-05-06 21:37:42 +0000255 struct in_addr);
256extern void ospf_vl_data_free (struct ospf_vl_data *);
257extern void ospf_vl_add (struct ospf *, struct ospf_vl_data *);
258extern void ospf_vl_delete (struct ospf *, struct ospf_vl_data *);
259extern void ospf_vl_up_check (struct ospf_area *, struct in_addr,
260 struct vertex *);
261extern void ospf_vl_unapprove (struct ospf *);
262extern void ospf_vl_shut_unapproved (struct ospf *);
263extern int ospf_full_virtual_nbrs (struct ospf_area *);
264extern int ospf_vls_in_area (struct ospf_area *);
paul718e3742002-12-13 20:15:29 +0000265
paul4dadc292005-05-06 21:37:42 +0000266extern struct crypt_key *ospf_crypt_key_lookup (struct list *, u_char);
267extern struct crypt_key *ospf_crypt_key_new (void);
268extern void ospf_crypt_key_add (struct list *, struct crypt_key *);
269extern int ospf_crypt_key_delete (struct list *, u_char);
paul718e3742002-12-13 20:15:29 +0000270
paul4dadc292005-05-06 21:37:42 +0000271extern u_char ospf_default_iftype (struct interface *ifp);
ajsbc18d612004-12-15 15:07:19 +0000272
ajsba6454e2005-02-08 15:37:30 +0000273/* Set all multicast memberships appropriately based on the type and
274 state of the interface. */
paul4dadc292005-05-06 21:37:42 +0000275extern void ospf_if_set_multicast (struct ospf_interface *);
ajsba6454e2005-02-08 15:37:30 +0000276
paul718e3742002-12-13 20:15:29 +0000277#endif /* _ZEBRA_OSPF_INTERFACE_H */