PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/uClinux-dist/user/zebra/ospfd/ospf_interface.h

https://github.com/labx-technologies-llc/mb-linux-labx
C Header | 249 lines | 169 code | 42 blank | 38 comment | 1 complexity | f887108d13a7637777a6068c37cac033 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, LGPL-2.1, MPL-2.0-no-copyleft-exception, ISC, AGPL-1.0, LGPL-2.0, GPL-3.0, LGPL-3.0, 0BSD
  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. #ifndef _ZEBRA_OSPF_INTERFACE_H
  23. #define _ZEBRA_OSPF_INTERFACE_H
  24. #define OSPF_AUTH_SIMPLE_SIZE 8
  25. #define OSPF_AUTH_MD5_SIZE 16
  26. #define IF_OSPF_IF_INFO(I) ((struct ospf_if_info *)((I)->info))
  27. #define IF_DEF_PARAMS(I) (IF_OSPF_IF_INFO (I)->def_params)
  28. #define IF_OIFS(I) (IF_OSPF_IF_INFO (I)->oifs)
  29. #define IF_OIFS_PARAMS(I) (IF_OSPF_IF_INFO (I)->params)
  30. #define OSPF_IF_PARAM_CONFIGURED(S, P) ((S) && (S)->P##__config)
  31. #define OSPF_IF_PARAM(O, P) \
  32. (OSPF_IF_PARAM_CONFIGURED ((O)->params, P)?\
  33. (O)->params->P:IF_DEF_PARAMS((O)->ifp)->P)
  34. #define DECLARE_IF_PARAM(T, P) T P; u_char P##__config:1
  35. #define UNSET_IF_PARAM(S, P) ((S)->P##__config) = 0
  36. #define SET_IF_PARAM(S, P) ((S)->P##__config) = 1
  37. struct ospf_if_params
  38. {
  39. DECLARE_IF_PARAM (u_int32_t, transmit_delay); /* Interface Transmisson Delay */
  40. DECLARE_IF_PARAM (u_int32_t, output_cost_cmd);/* Command Interface Output Cost */
  41. DECLARE_IF_PARAM (u_int32_t, retransmit_interval); /* Retransmission Interval */
  42. DECLARE_IF_PARAM (u_char, passive_interface); /* OSPF Interface is passive */
  43. DECLARE_IF_PARAM (u_char, priority); /* OSPF Interface priority */
  44. DECLARE_IF_PARAM (u_char, type); /* type of interface */
  45. #define OSPF_IF_ACTIVE 0
  46. #define OSPF_IF_PASSIVE 1
  47. DECLARE_IF_PARAM (u_int32_t, v_hello); /* Hello Interval */
  48. DECLARE_IF_PARAM (u_int32_t, v_wait); /* Router Dead Interval */
  49. /* Authentication data. */
  50. u_char auth_simple[OSPF_AUTH_SIMPLE_SIZE + 1]; /* Simple password. */
  51. u_char auth_simple__config:1;
  52. DECLARE_IF_PARAM (list, auth_crypt); /* List of Auth cryptographic data. */
  53. DECLARE_IF_PARAM (int, auth_type); /* OSPF authentication type */
  54. };
  55. struct ospf_if_info
  56. {
  57. struct ospf_if_params *def_params;
  58. struct route_table *params;
  59. struct route_table *oifs;
  60. };
  61. struct ospf_interface;
  62. struct ospf_vl_data
  63. {
  64. struct in_addr vl_peer; /* Router-ID of the peer for VLs. */
  65. struct in_addr vl_area_id; /* Transit area for this VL. */
  66. int format; /* area ID format */
  67. struct ospf_interface *vl_oi; /* Interface data structure for the VL. */
  68. struct ospf_interface *out_oi; /* The interface to go out. */
  69. struct in_addr peer_addr; /* Address used to reach the peer. */
  70. u_char flags;
  71. };
  72. #define OSPF_VL_MAX_COUNT 256
  73. #define OSPF_VL_MTU 1500
  74. #define OSPF_VL_FLAG_APPROVED 0x01
  75. struct crypt_key
  76. {
  77. u_char key_id;
  78. u_char auth_key[OSPF_AUTH_MD5_SIZE + 1];
  79. };
  80. /* OSPF interface structure. */
  81. struct ospf_interface
  82. {
  83. /* This interface's parent ospf instance. */
  84. struct ospf *ospf;
  85. /* OSPF Area. */
  86. struct ospf_area *area;
  87. /* Interface data from zebra. */
  88. struct interface *ifp;
  89. struct ospf_vl_data *vl_data; /* Data for Virtual Link */
  90. /* Packet send buffer. */
  91. struct ospf_fifo *obuf; /* Output queue */
  92. /* OSPF Network Type. */
  93. u_char type;
  94. #define OSPF_IFTYPE_NONE 0
  95. #define OSPF_IFTYPE_POINTOPOINT 1
  96. #define OSPF_IFTYPE_BROADCAST 2
  97. #define OSPF_IFTYPE_NBMA 3
  98. #define OSPF_IFTYPE_POINTOMULTIPOINT 4
  99. #define OSPF_IFTYPE_VIRTUALLINK 5
  100. #define OSPF_IFTYPE_LOOPBACK 6
  101. #define OSPF_IFTYPE_MAX 7
  102. /* State of Interface State Machine. */
  103. u_char state;
  104. struct prefix *address; /* Interface prefix */
  105. struct connected *connected; /* Pointer to connected */
  106. /* Configured varables. */
  107. struct ospf_if_params *params;
  108. u_int32_t crypt_seqnum; /* Cryptographic Sequence Number */
  109. u_int32_t output_cost; /* Acutual Interface Output Cost */
  110. /* Neighbor information. */
  111. struct route_table *nbrs; /* OSPF Neighbor List */
  112. struct ospf_neighbor *nbr_self; /* Neighbor Self */
  113. #define DR(I) ((I)->nbr_self->d_router)
  114. #define BDR(I) ((I)->nbr_self->bd_router)
  115. #define OPTIONS(I) ((I)->nbr_self->options)
  116. #define PRIORITY(I) ((I)->nbr_self->priority)
  117. /* List of configured NBMA neighbor. */
  118. list nbr_nbma;
  119. /* self-originated LSAs. */
  120. struct ospf_lsa *network_lsa_self; /* network-LSA. */
  121. #ifdef HAVE_OPAQUE_LSA
  122. list opaque_lsa_self; /* Type-9 Opaque-LSAs */
  123. #endif /* HAVE_OPAQUE_LSA */
  124. struct route_table *ls_upd_queue;
  125. list ls_ack; /* Link State Acknowledgment list. */
  126. struct
  127. {
  128. list ls_ack;
  129. struct in_addr dst;
  130. } ls_ack_direct;
  131. /* Timer values. */
  132. u_int32_t v_ls_ack; /* Delayed Link State Acknowledgment */
  133. /* Threads. */
  134. struct thread *t_hello; /* timer */
  135. struct thread *t_wait; /* timer */
  136. struct thread *t_ls_ack; /* timer */
  137. struct thread *t_ls_ack_direct; /* event */
  138. struct thread *t_ls_upd_event; /* event */
  139. struct thread *t_network_lsa_self; /* self-originated network-LSA
  140. reflesh thread. timer */
  141. #ifdef HAVE_OPAQUE_LSA
  142. struct thread *t_opaque_lsa_self; /* Type-9 Opaque-LSAs */
  143. #endif /* HAVE_OPAQUE_LSA */
  144. int on_write_q;
  145. /* Statistics fields. */
  146. u_int32_t hello_in; /* Hello message input count. */
  147. u_int32_t hello_out; /* Hello message output count. */
  148. u_int32_t db_desc_in; /* database desc. message input count. */
  149. u_int32_t db_desc_out; /* database desc. message output count. */
  150. u_int32_t ls_req_in; /* LS request message input count. */
  151. u_int32_t ls_req_out; /* LS request message output count. */
  152. u_int32_t ls_upd_in; /* LS update message input count. */
  153. u_int32_t ls_upd_out; /* LS update message output count. */
  154. u_int32_t ls_ack_in; /* LS Ack message input count. */
  155. u_int32_t ls_ack_out; /* LS Ack message output count. */
  156. u_int32_t discarded; /* discarded input count by error. */
  157. u_int32_t state_change; /* Number of status change. */
  158. u_int32_t full_nbrs;
  159. };
  160. /* Prototypes. */
  161. char *ospf_if_name (struct ospf_interface *);
  162. struct ospf_interface *ospf_if_new (struct ospf *, struct interface *,
  163. struct prefix *);
  164. void ospf_if_cleanup (struct ospf_interface *);
  165. void ospf_if_free (struct ospf_interface *);
  166. int ospf_if_up (struct ospf_interface *);
  167. int ospf_if_down (struct ospf_interface *);
  168. int ospf_if_is_up (struct ospf_interface *);
  169. struct ospf_interface *ospf_if_lookup_by_name (char *);
  170. struct ospf_interface *ospf_if_lookup_by_local_addr (struct ospf *,
  171. struct interface *,
  172. struct in_addr);
  173. struct ospf_interface *ospf_if_lookup_by_prefix (struct ospf *,
  174. struct prefix_ipv4 *);
  175. struct ospf_interface *ospf_if_addr_local (struct in_addr);
  176. struct ospf_interface *ospf_if_lookup_recv_if (struct ospf *, struct in_addr);
  177. struct ospf_interface *ospf_if_is_configured (struct ospf *, struct in_addr *);
  178. struct ospf_if_params *ospf_lookup_if_params (struct interface *,
  179. struct in_addr);
  180. struct ospf_if_params *ospf_get_if_params (struct interface *, struct in_addr);
  181. void ospf_del_if_params (struct ospf_if_params *);
  182. void ospf_free_if_params (struct interface *, struct in_addr);
  183. void ospf_if_update_params (struct interface *, struct in_addr);
  184. int ospf_if_new_hook (struct interface *);
  185. void ospf_if_init ();
  186. void ospf_if_stream_set (struct ospf_interface *);
  187. void ospf_if_stream_unset (struct ospf_interface *);
  188. void ospf_if_reset_variables (struct ospf_interface *);
  189. int ospf_if_is_enable (struct ospf_interface *);
  190. int ospf_if_get_output_cost (struct ospf_interface *);
  191. void ospf_if_recalculate_output_cost (struct interface *);
  192. struct ospf_interface *ospf_vl_new (struct ospf *, struct ospf_vl_data *);
  193. struct ospf_vl_data *ospf_vl_data_new (struct ospf_area *, struct in_addr);
  194. struct ospf_vl_data *ospf_vl_lookup (struct ospf_area *, struct in_addr);
  195. void ospf_vl_data_free (struct ospf_vl_data *);
  196. void ospf_vl_add (struct ospf *, struct ospf_vl_data *);
  197. void ospf_vl_delete (struct ospf *, struct ospf_vl_data *);
  198. void ospf_vl_up_check (struct ospf_area *, struct in_addr, struct vertex *);
  199. void ospf_vl_unapprove (struct ospf *);
  200. void ospf_vl_shut_unapproved (struct ospf *);
  201. int ospf_full_virtual_nbrs (struct ospf_area *);
  202. int ospf_vls_in_area (struct ospf_area *);
  203. struct crypt_key *ospf_crypt_key_lookup (list, u_char);
  204. struct crypt_key *ospf_crypt_key_new ();
  205. void ospf_crypt_key_add (list, struct crypt_key *);
  206. int ospf_crypt_key_delete (list, u_char);
  207. #endif /* _ZEBRA_OSPF_INTERFACE_H */