ospf_neighbor.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. #ifndef _ZEBRA_OSPF_NEIGHBOR_H
  23. #define _ZEBRA_OSPF_NEIGHBOR_H
  24. #include <ospfd/ospf_packet.h>
  25. /* Neighbor Data Structure */
  26. struct ospf_neighbor
  27. {
  28. /* This neighbor's parent ospf interface. */
  29. struct ospf_interface *oi;
  30. /* OSPF neighbor Information */
  31. u_char state; /* NSM status. */
  32. u_char dd_flags; /* DD bit flags. */
  33. u_int32_t dd_seqnum; /* DD Sequence Number. */
  34. /* Neighbor Information from Hello. */
  35. struct prefix address; /* Neighbor Interface Address. */
  36. struct in_addr src; /* Src address. */
  37. struct in_addr router_id; /* Router ID. */
  38. u_char options; /* Options. */
  39. int priority; /* Router Priority. */
  40. struct in_addr d_router; /* Designated Router. */
  41. struct in_addr bd_router; /* Backup Designated Router. */
  42. /* Last sent Database Description packet. */
  43. struct ospf_packet *last_send;
  44. /* Timestemp when last Database Description packet was sent */
  45. struct timeval last_send_ts;
  46. /* Last received Databse Description packet. */
  47. struct
  48. {
  49. u_char options;
  50. u_char flags;
  51. u_int32_t dd_seqnum;
  52. } last_recv;
  53. /* LSA data. */
  54. struct ospf_lsdb ls_rxmt;
  55. struct ospf_lsdb db_sum;
  56. struct ospf_lsdb ls_req;
  57. struct ospf_lsa *ls_req_last;
  58. u_int32_t crypt_seqnum; /* Cryptographic Sequence Number. */
  59. /* Timer values. */
  60. u_int32_t v_inactivity;
  61. u_int32_t v_db_desc;
  62. u_int32_t v_ls_req;
  63. u_int32_t v_ls_upd;
  64. /* Threads. */
  65. struct thread *t_inactivity;
  66. struct thread *t_db_desc;
  67. struct thread *t_ls_req;
  68. struct thread *t_ls_upd;
  69. struct thread *t_hello_reply;
  70. /* NBMA configured neighbour */
  71. struct ospf_nbr_nbma *nbr_nbma;
  72. /* Statistics */
  73. struct timeval ts_last_progress; /* last advance of NSM */
  74. struct timeval ts_last_regress; /* last regressive NSM change */
  75. const char *last_regress_str; /* Event which last regressed NSM */
  76. u_int32_t state_change; /* NSM state change counter */
  77. };
  78. /* Macros. */
  79. #define NBR_IS_DR(n) IPV4_ADDR_SAME (&n->address.u.prefix4, &n->d_router)
  80. #define NBR_IS_BDR(n) IPV4_ADDR_SAME (&n->address.u.prefix4, &n->bd_router)
  81. /* Prototypes. */
  82. extern struct ospf_neighbor *ospf_nbr_new (struct ospf_interface *);
  83. extern void ospf_nbr_free (struct ospf_neighbor *);
  84. extern void ospf_nbr_delete (struct ospf_neighbor *);
  85. extern int ospf_nbr_bidirectional (struct in_addr *, struct in_addr *, int);
  86. extern void ospf_nbr_self_reset (struct ospf_interface *);
  87. extern void ospf_nbr_add_self (struct ospf_interface *);
  88. extern int ospf_nbr_count (struct ospf_interface *, int);
  89. extern int ospf_nbr_count_opaque_capable (struct ospf_interface *);
  90. extern struct ospf_neighbor *ospf_nbr_get (struct ospf_interface *,
  91. struct ospf_header *,
  92. struct ip *, struct prefix *);
  93. extern struct ospf_neighbor *ospf_nbr_lookup (struct ospf_interface *,
  94. struct ip *,
  95. struct ospf_header *);
  96. extern struct ospf_neighbor *ospf_nbr_lookup_by_addr (struct route_table *,
  97. struct in_addr *);
  98. extern struct ospf_neighbor *ospf_nbr_lookup_by_routerid (struct route_table
  99. *,
  100. struct in_addr *);
  101. extern void ospf_renegotiate_optional_capabilities (struct ospf *top);
  102. #endif /* _ZEBRA_OSPF_NEIGHBOR_H */