blob: 28d95d7edcffedcbf9bb551cfe4caf1dadfd666a [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"
paul718e3742002-12-13 20:15:29 +000027
28#define IF_OSPF_IF_INFO(I) ((struct ospf_if_info *)((I)->info))
29#define IF_DEF_PARAMS(I) (IF_OSPF_IF_INFO (I)->def_params)
30#define IF_OIFS(I) (IF_OSPF_IF_INFO (I)->oifs)
31#define IF_OIFS_PARAMS(I) (IF_OSPF_IF_INFO (I)->params)
32
33#define OSPF_IF_PARAM_CONFIGURED(S, P) ((S) && (S)->P##__config)
34#define OSPF_IF_PARAM(O, P) \
35 (OSPF_IF_PARAM_CONFIGURED ((O)->params, P)?\
36 (O)->params->P:IF_DEF_PARAMS((O)->ifp)->P)
37
38#define DECLARE_IF_PARAM(T, P) T P; u_char P##__config:1
39#define UNSET_IF_PARAM(S, P) ((S)->P##__config) = 0
40#define SET_IF_PARAM(S, P) ((S)->P##__config) = 1
41
42struct ospf_if_params
43{
44 DECLARE_IF_PARAM (u_int32_t, transmit_delay); /* Interface Transmisson Delay */
45 DECLARE_IF_PARAM (u_int32_t, output_cost_cmd);/* Command Interface Output Cost */
46 DECLARE_IF_PARAM (u_int32_t, retransmit_interval); /* Retransmission Interval */
ajsba6454e2005-02-08 15:37:30 +000047 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 +000048 DECLARE_IF_PARAM (u_char, priority); /* OSPF Interface priority */
49 DECLARE_IF_PARAM (u_char, type); /* type of interface */
50#define OSPF_IF_ACTIVE 0
51#define OSPF_IF_PASSIVE 1
52
53 DECLARE_IF_PARAM (u_int32_t, v_hello); /* Hello Interval */
54 DECLARE_IF_PARAM (u_int32_t, v_wait); /* Router Dead Interval */
55
vincentba682532005-09-29 13:52:57 +000056 /* MTU mismatch check (see RFC2328, chap 10.6) */
57 DECLARE_IF_PARAM (u_char, mtu_ignore);
paulf9ad9372005-10-21 00:45:17 +000058
59 /* Fast-Hellos */
60 DECLARE_IF_PARAM (u_char, fast_hello);
61
paul718e3742002-12-13 20:15:29 +000062 /* Authentication data. */
63 u_char auth_simple[OSPF_AUTH_SIMPLE_SIZE + 1]; /* Simple password. */
64 u_char auth_simple__config:1;
65
hasso52dc7ee2004-09-23 19:18:23 +000066 DECLARE_IF_PARAM (struct list *, auth_crypt); /* List of Auth cryptographic data. */
paul718e3742002-12-13 20:15:29 +000067 DECLARE_IF_PARAM (int, auth_type); /* OSPF authentication type */
68};
69
70struct ospf_if_info
71{
72 struct ospf_if_params *def_params;
73 struct route_table *params;
74 struct route_table *oifs;
75};
76
77struct ospf_interface;
78
79struct ospf_vl_data
80{
81 struct in_addr vl_peer; /* Router-ID of the peer for VLs. */
82 struct in_addr vl_area_id; /* Transit area for this VL. */
83 int format; /* area ID format */
84 struct ospf_interface *vl_oi; /* Interface data structure for the VL. */
85 struct ospf_interface *out_oi; /* The interface to go out. */
86 struct in_addr peer_addr; /* Address used to reach the peer. */
87 u_char flags;
88};
89
90
91#define OSPF_VL_MAX_COUNT 256
92#define OSPF_VL_MTU 1500
93
94#define OSPF_VL_FLAG_APPROVED 0x01
95
96struct crypt_key
97{
98 u_char key_id;
99 u_char auth_key[OSPF_AUTH_MD5_SIZE + 1];
100};
101
102/* OSPF interface structure. */
103struct ospf_interface
104{
105 /* This interface's parent ospf instance. */
106 struct ospf *ospf;
107
108 /* OSPF Area. */
109 struct ospf_area *area;
110
111 /* Interface data from zebra. */
112 struct interface *ifp;
113 struct ospf_vl_data *vl_data; /* Data for Virtual Link */
114
115 /* Packet send buffer. */
116 struct ospf_fifo *obuf; /* Output queue */
117
118 /* OSPF Network Type. */
119 u_char type;
120#define OSPF_IFTYPE_NONE 0
121#define OSPF_IFTYPE_POINTOPOINT 1
122#define OSPF_IFTYPE_BROADCAST 2
123#define OSPF_IFTYPE_NBMA 3
124#define OSPF_IFTYPE_POINTOMULTIPOINT 4
125#define OSPF_IFTYPE_VIRTUALLINK 5
126#define OSPF_IFTYPE_LOOPBACK 6
127#define OSPF_IFTYPE_MAX 7
128
129 /* State of Interface State Machine. */
130 u_char state;
131
ajsba6454e2005-02-08 15:37:30 +0000132 /* To which multicast groups do we currently belong? */
133 u_char multicast_memberships;
134#define MEMBER_ALLROUTERS 0x1
135#define MEMBER_DROUTERS 0x2
136
ajs8cfde372005-02-08 15:59:16 +0000137 struct prefix *address; /* Interface prefix */
138 struct connected *connected; /* Pointer to connected */
139
paul718e3742002-12-13 20:15:29 +0000140 /* Configured varables. */
141 struct ospf_if_params *params;
142 u_int32_t crypt_seqnum; /* Cryptographic Sequence Number */
143 u_int32_t output_cost; /* Acutual Interface Output Cost */
144
145 /* Neighbor information. */
146 struct route_table *nbrs; /* OSPF Neighbor List */
147 struct ospf_neighbor *nbr_self; /* Neighbor Self */
148#define DR(I) ((I)->nbr_self->d_router)
149#define BDR(I) ((I)->nbr_self->bd_router)
150#define OPTIONS(I) ((I)->nbr_self->options)
151#define PRIORITY(I) ((I)->nbr_self->priority)
152
153 /* List of configured NBMA neighbor. */
hasso52dc7ee2004-09-23 19:18:23 +0000154 struct list *nbr_nbma;
paul718e3742002-12-13 20:15:29 +0000155
156 /* self-originated LSAs. */
157 struct ospf_lsa *network_lsa_self; /* network-LSA. */
158#ifdef HAVE_OPAQUE_LSA
paul87d6f872004-09-24 08:01:38 +0000159 struct list *opaque_lsa_self; /* Type-9 Opaque-LSAs */
paul718e3742002-12-13 20:15:29 +0000160#endif /* HAVE_OPAQUE_LSA */
161
162 struct route_table *ls_upd_queue;
163
hasso52dc7ee2004-09-23 19:18:23 +0000164 struct list *ls_ack; /* Link State Acknowledgment list. */
paul718e3742002-12-13 20:15:29 +0000165
166 struct
167 {
hasso52dc7ee2004-09-23 19:18:23 +0000168 struct list *ls_ack;
paul718e3742002-12-13 20:15:29 +0000169 struct in_addr dst;
170 } ls_ack_direct;
171
172 /* Timer values. */
173 u_int32_t v_ls_ack; /* Delayed Link State Acknowledgment */
174
175 /* Threads. */
176 struct thread *t_hello; /* timer */
177 struct thread *t_wait; /* timer */
178 struct thread *t_ls_ack; /* timer */
179 struct thread *t_ls_ack_direct; /* event */
180 struct thread *t_ls_upd_event; /* event */
181 struct thread *t_network_lsa_self; /* self-originated network-LSA
182 reflesh thread. timer */
183#ifdef HAVE_OPAQUE_LSA
184 struct thread *t_opaque_lsa_self; /* Type-9 Opaque-LSAs */
185#endif /* HAVE_OPAQUE_LSA */
186
187 int on_write_q;
188
189 /* Statistics fields. */
190 u_int32_t hello_in; /* Hello message input count. */
191 u_int32_t hello_out; /* Hello message output count. */
192 u_int32_t db_desc_in; /* database desc. message input count. */
193 u_int32_t db_desc_out; /* database desc. message output count. */
194 u_int32_t ls_req_in; /* LS request message input count. */
195 u_int32_t ls_req_out; /* LS request message output count. */
196 u_int32_t ls_upd_in; /* LS update message input count. */
197 u_int32_t ls_upd_out; /* LS update message output count. */
198 u_int32_t ls_ack_in; /* LS Ack message input count. */
199 u_int32_t ls_ack_out; /* LS Ack message output count. */
200 u_int32_t discarded; /* discarded input count by error. */
201 u_int32_t state_change; /* Number of status change. */
202
hasso2db3d052004-02-11 21:52:13 +0000203 u_int32_t full_nbrs;
paul718e3742002-12-13 20:15:29 +0000204};
205
206/* Prototypes. */
paul4dadc292005-05-06 21:37:42 +0000207extern char *ospf_if_name (struct ospf_interface *);
208extern struct ospf_interface *ospf_if_new (struct ospf *, struct interface *,
209 struct prefix *);
210extern void ospf_if_cleanup (struct ospf_interface *);
211extern void ospf_if_free (struct ospf_interface *);
212extern int ospf_if_up (struct ospf_interface *);
213extern int ospf_if_down (struct ospf_interface *);
paul718e3742002-12-13 20:15:29 +0000214
paul4dadc292005-05-06 21:37:42 +0000215extern int ospf_if_is_up (struct ospf_interface *);
216extern struct ospf_interface *ospf_if_exists (struct ospf_interface *);
217extern struct ospf_interface *ospf_if_lookup_by_local_addr (struct ospf *,
218 struct interface
219 *,
220 struct in_addr);
221extern struct ospf_interface *ospf_if_lookup_by_prefix (struct ospf *,
222 struct prefix_ipv4 *);
223extern struct ospf_interface *ospf_if_addr_local (struct in_addr);
224extern struct ospf_interface *ospf_if_lookup_recv_if (struct ospf *,
225 struct in_addr);
226extern struct ospf_interface *ospf_if_is_configured (struct ospf *,
227 struct in_addr *);
228
229extern struct ospf_if_params *ospf_lookup_if_params (struct interface *,
hasso2db3d052004-02-11 21:52:13 +0000230 struct in_addr);
paul4dadc292005-05-06 21:37:42 +0000231extern struct ospf_if_params *ospf_get_if_params (struct interface *,
232 struct in_addr);
233extern void ospf_del_if_params (struct ospf_if_params *);
234extern void ospf_free_if_params (struct interface *, struct in_addr);
235extern void ospf_if_update_params (struct interface *, struct in_addr);
paul718e3742002-12-13 20:15:29 +0000236
paul4dadc292005-05-06 21:37:42 +0000237extern int ospf_if_new_hook (struct interface *);
238extern void ospf_if_init (void);
239extern void ospf_if_stream_set (struct ospf_interface *);
240extern void ospf_if_stream_unset (struct ospf_interface *);
241extern void ospf_if_reset_variables (struct ospf_interface *);
242extern int ospf_if_is_enable (struct ospf_interface *);
243extern int ospf_if_get_output_cost (struct ospf_interface *);
244extern void ospf_if_recalculate_output_cost (struct interface *);
paul718e3742002-12-13 20:15:29 +0000245
ajsa608bbf2005-03-29 17:03:49 +0000246/* Simulate down/up on the interface. */
247extern void ospf_if_reset (struct interface *);
248
paul4dadc292005-05-06 21:37:42 +0000249extern struct ospf_interface *ospf_vl_new (struct ospf *,
250 struct ospf_vl_data *);
251extern struct ospf_vl_data *ospf_vl_data_new (struct ospf_area *,
252 struct in_addr);
253extern struct ospf_vl_data *ospf_vl_lookup (struct ospf_area *,
254 struct in_addr);
255extern void ospf_vl_data_free (struct ospf_vl_data *);
256extern void ospf_vl_add (struct ospf *, struct ospf_vl_data *);
257extern void ospf_vl_delete (struct ospf *, struct ospf_vl_data *);
258extern void ospf_vl_up_check (struct ospf_area *, struct in_addr,
259 struct vertex *);
260extern void ospf_vl_unapprove (struct ospf *);
261extern void ospf_vl_shut_unapproved (struct ospf *);
262extern int ospf_full_virtual_nbrs (struct ospf_area *);
263extern int ospf_vls_in_area (struct ospf_area *);
paul718e3742002-12-13 20:15:29 +0000264
paul4dadc292005-05-06 21:37:42 +0000265extern struct crypt_key *ospf_crypt_key_lookup (struct list *, u_char);
266extern struct crypt_key *ospf_crypt_key_new (void);
267extern void ospf_crypt_key_add (struct list *, struct crypt_key *);
268extern int ospf_crypt_key_delete (struct list *, u_char);
paul718e3742002-12-13 20:15:29 +0000269
paul4dadc292005-05-06 21:37:42 +0000270extern u_char ospf_default_iftype (struct interface *ifp);
ajsbc18d612004-12-15 15:07:19 +0000271
ajsba6454e2005-02-08 15:37:30 +0000272/* Set all multicast memberships appropriately based on the type and
273 state of the interface. */
paul4dadc292005-05-06 21:37:42 +0000274extern void ospf_if_set_multicast (struct ospf_interface *);
ajsba6454e2005-02-08 15:37:30 +0000275
paul718e3742002-12-13 20:15:29 +0000276#endif /* _ZEBRA_OSPF_INTERFACE_H */