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