]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_interface.h
Added -p to the recommended diff flags.
[mirror_frr.git] / ospfd / ospf_interface.h
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
26 #include "ospfd/ospf_packet.h"
27
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
42 struct 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 */
47 DECLARE_IF_PARAM (u_char, passive_interface); /* OSPF Interface is passive: no sending or receiving (no need to join multicast groups) */
48 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
56 /* Authentication data. */
57 u_char auth_simple[OSPF_AUTH_SIMPLE_SIZE + 1]; /* Simple password. */
58 u_char auth_simple__config:1;
59
60 DECLARE_IF_PARAM (struct list *, auth_crypt); /* List of Auth cryptographic data. */
61 DECLARE_IF_PARAM (int, auth_type); /* OSPF authentication type */
62 };
63
64 struct ospf_if_info
65 {
66 struct ospf_if_params *def_params;
67 struct route_table *params;
68 struct route_table *oifs;
69 };
70
71 struct ospf_interface;
72
73 struct ospf_vl_data
74 {
75 struct in_addr vl_peer; /* Router-ID of the peer for VLs. */
76 struct in_addr vl_area_id; /* Transit area for this VL. */
77 int format; /* area ID format */
78 struct ospf_interface *vl_oi; /* Interface data structure for the VL. */
79 struct ospf_interface *out_oi; /* The interface to go out. */
80 struct in_addr peer_addr; /* Address used to reach the peer. */
81 u_char flags;
82 };
83
84
85 #define OSPF_VL_MAX_COUNT 256
86 #define OSPF_VL_MTU 1500
87
88 #define OSPF_VL_FLAG_APPROVED 0x01
89
90 struct crypt_key
91 {
92 u_char key_id;
93 u_char auth_key[OSPF_AUTH_MD5_SIZE + 1];
94 };
95
96 /* OSPF interface structure. */
97 struct ospf_interface
98 {
99 /* This interface's parent ospf instance. */
100 struct ospf *ospf;
101
102 /* OSPF Area. */
103 struct ospf_area *area;
104
105 /* Interface data from zebra. */
106 struct interface *ifp;
107 struct ospf_vl_data *vl_data; /* Data for Virtual Link */
108
109 /* Packet send buffer. */
110 struct ospf_fifo *obuf; /* Output queue */
111
112 /* OSPF Network Type. */
113 u_char type;
114 #define OSPF_IFTYPE_NONE 0
115 #define OSPF_IFTYPE_POINTOPOINT 1
116 #define OSPF_IFTYPE_BROADCAST 2
117 #define OSPF_IFTYPE_NBMA 3
118 #define OSPF_IFTYPE_POINTOMULTIPOINT 4
119 #define OSPF_IFTYPE_VIRTUALLINK 5
120 #define OSPF_IFTYPE_LOOPBACK 6
121 #define OSPF_IFTYPE_MAX 7
122
123 /* State of Interface State Machine. */
124 u_char state;
125
126 /* To which multicast groups do we currently belong? */
127 u_char multicast_memberships;
128 #define MEMBER_ALLROUTERS 0x1
129 #define MEMBER_DROUTERS 0x2
130
131 struct prefix *address; /* Interface prefix */
132 struct connected *connected; /* Pointer to connected */
133
134 /* Configured varables. */
135 struct ospf_if_params *params;
136 u_int32_t crypt_seqnum; /* Cryptographic Sequence Number */
137 u_int32_t output_cost; /* Acutual Interface Output Cost */
138
139 /* Neighbor information. */
140 struct route_table *nbrs; /* OSPF Neighbor List */
141 struct ospf_neighbor *nbr_self; /* Neighbor Self */
142 #define DR(I) ((I)->nbr_self->d_router)
143 #define BDR(I) ((I)->nbr_self->bd_router)
144 #define OPTIONS(I) ((I)->nbr_self->options)
145 #define PRIORITY(I) ((I)->nbr_self->priority)
146
147 /* List of configured NBMA neighbor. */
148 struct list *nbr_nbma;
149
150 /* self-originated LSAs. */
151 struct ospf_lsa *network_lsa_self; /* network-LSA. */
152 #ifdef HAVE_OPAQUE_LSA
153 struct list *opaque_lsa_self; /* Type-9 Opaque-LSAs */
154 #endif /* HAVE_OPAQUE_LSA */
155
156 struct route_table *ls_upd_queue;
157
158 struct list *ls_ack; /* Link State Acknowledgment list. */
159
160 struct
161 {
162 struct list *ls_ack;
163 struct in_addr dst;
164 } ls_ack_direct;
165
166 /* Timer values. */
167 u_int32_t v_ls_ack; /* Delayed Link State Acknowledgment */
168
169 /* Threads. */
170 struct thread *t_hello; /* timer */
171 struct thread *t_wait; /* timer */
172 struct thread *t_ls_ack; /* timer */
173 struct thread *t_ls_ack_direct; /* event */
174 struct thread *t_ls_upd_event; /* event */
175 struct thread *t_network_lsa_self; /* self-originated network-LSA
176 reflesh thread. timer */
177 #ifdef HAVE_OPAQUE_LSA
178 struct thread *t_opaque_lsa_self; /* Type-9 Opaque-LSAs */
179 #endif /* HAVE_OPAQUE_LSA */
180
181 int on_write_q;
182
183 /* Statistics fields. */
184 u_int32_t hello_in; /* Hello message input count. */
185 u_int32_t hello_out; /* Hello message output count. */
186 u_int32_t db_desc_in; /* database desc. message input count. */
187 u_int32_t db_desc_out; /* database desc. message output count. */
188 u_int32_t ls_req_in; /* LS request message input count. */
189 u_int32_t ls_req_out; /* LS request message output count. */
190 u_int32_t ls_upd_in; /* LS update message input count. */
191 u_int32_t ls_upd_out; /* LS update message output count. */
192 u_int32_t ls_ack_in; /* LS Ack message input count. */
193 u_int32_t ls_ack_out; /* LS Ack message output count. */
194 u_int32_t discarded; /* discarded input count by error. */
195 u_int32_t state_change; /* Number of status change. */
196
197 u_int32_t full_nbrs;
198 };
199
200 /* Prototypes. */
201 char *ospf_if_name (struct ospf_interface *);
202 struct ospf_interface *ospf_if_new (struct ospf *, struct interface *,
203 struct prefix *);
204 void ospf_if_cleanup (struct ospf_interface *);
205 void ospf_if_free (struct ospf_interface *);
206 int ospf_if_up (struct ospf_interface *);
207 int ospf_if_down (struct ospf_interface *);
208
209 int ospf_if_is_up (struct ospf_interface *);
210 struct ospf_interface *ospf_if_exists (struct ospf_interface *);
211 struct ospf_interface *ospf_if_lookup_by_name (char *);
212 struct ospf_interface *ospf_if_lookup_by_local_addr (struct ospf *,
213 struct interface *,
214 struct in_addr);
215 struct ospf_interface *ospf_if_lookup_by_prefix (struct ospf *,
216 struct prefix_ipv4 *);
217 struct ospf_interface *ospf_if_addr_local (struct in_addr);
218 struct ospf_interface *ospf_if_lookup_recv_if (struct ospf *, struct in_addr);
219 struct ospf_interface *ospf_if_is_configured (struct ospf *, struct in_addr *);
220
221 struct ospf_if_params *ospf_lookup_if_params (struct interface *,
222 struct in_addr);
223 struct ospf_if_params *ospf_get_if_params (struct interface *, struct in_addr);
224 void ospf_del_if_params (struct ospf_if_params *);
225 void ospf_free_if_params (struct interface *, struct in_addr);
226 void ospf_if_update_params (struct interface *, struct in_addr);
227
228 int ospf_if_new_hook (struct interface *);
229 void ospf_if_init ();
230 void ospf_if_stream_set (struct ospf_interface *);
231 void ospf_if_stream_unset (struct ospf_interface *);
232 void ospf_if_reset_variables (struct ospf_interface *);
233 int ospf_if_is_enable (struct ospf_interface *);
234 int ospf_if_get_output_cost (struct ospf_interface *);
235 void ospf_if_recalculate_output_cost (struct interface *);
236
237 struct ospf_interface *ospf_vl_new (struct ospf *, struct ospf_vl_data *);
238 struct ospf_vl_data *ospf_vl_data_new (struct ospf_area *, struct in_addr);
239 struct ospf_vl_data *ospf_vl_lookup (struct ospf_area *, struct in_addr);
240 void ospf_vl_data_free (struct ospf_vl_data *);
241 void ospf_vl_add (struct ospf *, struct ospf_vl_data *);
242 void ospf_vl_delete (struct ospf *, struct ospf_vl_data *);
243 void ospf_vl_up_check (struct ospf_area *, struct in_addr, struct vertex *);
244 void ospf_vl_unapprove (struct ospf *);
245 void ospf_vl_shut_unapproved (struct ospf *);
246 int ospf_full_virtual_nbrs (struct ospf_area *);
247 int ospf_vls_in_area (struct ospf_area *);
248
249 struct crypt_key *ospf_crypt_key_lookup (struct list *, u_char);
250 struct crypt_key *ospf_crypt_key_new ();
251 void ospf_crypt_key_add (struct list *, struct crypt_key *);
252 int ospf_crypt_key_delete (struct list *, u_char);
253
254 u_char ospf_default_iftype(struct interface *ifp);
255
256 /* Set all multicast memberships appropriately based on the type and
257 state of the interface. */
258 extern void ospf_if_set_multicast(struct ospf_interface *);
259
260 #endif /* _ZEBRA_OSPF_INTERFACE_H */