paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * OSPF Neighbor functions. |
| 3 | * Copyright (C) 1999, 2000 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_NEIGHBOR_H |
| 24 | #define _ZEBRA_OSPF_NEIGHBOR_H |
| 25 | |
paul | d3f0d62 | 2004-05-05 15:27:15 +0000 | [diff] [blame] | 26 | #include <ospfd/ospf_packet.h> |
| 27 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 28 | /* Neighbor Data Structure */ |
| 29 | struct ospf_neighbor |
| 30 | { |
| 31 | /* This neighbor's parent ospf interface. */ |
| 32 | struct ospf_interface *oi; |
| 33 | |
| 34 | /* OSPF neighbor Information */ |
| 35 | u_char state; /* NSM status. */ |
| 36 | u_char dd_flags; /* DD bit flags. */ |
| 37 | u_int32_t dd_seqnum; /* DD Sequence Number. */ |
| 38 | |
| 39 | /* Neighbor Information from Hello. */ |
| 40 | struct prefix address; /* Neighbor Interface Address. */ |
| 41 | |
| 42 | struct in_addr src; /* Src address. */ |
| 43 | struct in_addr router_id; /* Router ID. */ |
| 44 | u_char options; /* Options. */ |
| 45 | int priority; /* Router Priority. */ |
| 46 | struct in_addr d_router; /* Designated Router. */ |
| 47 | struct in_addr bd_router; /* Backup Designated Router. */ |
| 48 | |
| 49 | /* Last sent Database Description packet. */ |
| 50 | struct ospf_packet *last_send; |
| 51 | /* Timestemp when last Database Description packet was sent */ |
| 52 | struct timeval last_send_ts; |
| 53 | |
| 54 | /* Last received Databse Description packet. */ |
| 55 | struct |
| 56 | { |
| 57 | u_char options; |
| 58 | u_char flags; |
| 59 | u_int32_t dd_seqnum; |
| 60 | } last_recv; |
| 61 | |
| 62 | /* LSA data. */ |
| 63 | struct ospf_lsdb ls_rxmt; |
| 64 | struct ospf_lsdb db_sum; |
| 65 | struct ospf_lsdb ls_req; |
| 66 | struct ospf_lsa *ls_req_last; |
| 67 | |
| 68 | u_int32_t crypt_seqnum; /* Cryptographic Sequence Number. */ |
| 69 | |
| 70 | /* Timer values. */ |
| 71 | u_int32_t v_inactivity; |
| 72 | u_int32_t v_db_desc; |
| 73 | u_int32_t v_ls_req; |
| 74 | u_int32_t v_ls_upd; |
| 75 | |
| 76 | /* Threads. */ |
| 77 | struct thread *t_inactivity; |
| 78 | struct thread *t_db_desc; |
| 79 | struct thread *t_ls_req; |
| 80 | struct thread *t_ls_upd; |
| 81 | struct thread *t_hello_reply; |
| 82 | |
| 83 | /* Statistics Field */ |
| 84 | u_int32_t state_change; |
| 85 | struct ospf_nbr_nbma *nbr_nbma; |
| 86 | }; |
| 87 | |
| 88 | /* Macros. */ |
| 89 | #define NBR_IS_DR(n) IPV4_ADDR_SAME (&n->address.u.prefix4, &n->d_router) |
| 90 | #define NBR_IS_BDR(n) IPV4_ADDR_SAME (&n->address.u.prefix4, &n->bd_router) |
| 91 | |
| 92 | /* Prototypes. */ |
| 93 | struct ospf_neighbor *ospf_nbr_new (struct ospf_interface *); |
| 94 | void ospf_nbr_free (struct ospf_neighbor *); |
| 95 | void ospf_nbr_delete (struct ospf_neighbor *); |
| 96 | int ospf_nbr_bidirectional (struct in_addr *, struct in_addr *, int); |
| 97 | void ospf_nbr_add_self (struct ospf_interface *); |
paul | d3f0d62 | 2004-05-05 15:27:15 +0000 | [diff] [blame] | 98 | int ospf_nbr_count (struct ospf_interface *, int); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 99 | #ifdef HAVE_OPAQUE_LSA |
paul | d3f0d62 | 2004-05-05 15:27:15 +0000 | [diff] [blame] | 100 | int ospf_nbr_count_opaque_capable (struct ospf_interface *); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 101 | #endif /* HAVE_OPAQUE_LSA */ |
paul | d3f0d62 | 2004-05-05 15:27:15 +0000 | [diff] [blame] | 102 | struct ospf_neighbor *ospf_nbr_get (struct ospf_interface *, |
| 103 | struct ospf_header *, |
| 104 | struct ip *, |
| 105 | struct prefix *); |
| 106 | struct ospf_neighbor *ospf_nbr_lookup (struct ospf_interface *, struct ip *, |
| 107 | struct ospf_header *); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 108 | struct ospf_neighbor *ospf_nbr_lookup_by_addr (struct route_table *, |
| 109 | struct in_addr *); |
| 110 | struct ospf_neighbor *ospf_nbr_lookup_by_routerid (struct route_table *, |
| 111 | struct in_addr *); |
| 112 | void ospf_renegotiate_optional_capabilities (struct ospf *top); |
| 113 | |
| 114 | #endif /* _ZEBRA_OSPF_NEIGHBOR_H */ |