ospf_ism.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * OSPF version 2 Interface State Machine.
  3. * From RFC2328 [OSPF Version 2]
  4. * Copyright (C) 1999 Toshiaki Takada
  5. *
  6. * This file is part of GNU Zebra.
  7. *
  8. * GNU Zebra is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation; either version 2, or (at your option) any
  11. * later version.
  12. *
  13. * GNU Zebra is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with GNU Zebra; see the file COPYING. If not, write to the Free
  20. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  21. * 02111-1307, USA.
  22. */
  23. #ifndef _ZEBRA_OSPF_ISM_H
  24. #define _ZEBRA_OSPF_ISM_H
  25. /* OSPF Interface State Machine Status. */
  26. #define ISM_DependUpon 0
  27. #define ISM_Down 1
  28. #define ISM_Loopback 2
  29. #define ISM_Waiting 3
  30. #define ISM_PointToPoint 4
  31. #define ISM_DROther 5
  32. #define ISM_Backup 6
  33. #define ISM_DR 7
  34. #define OSPF_ISM_STATE_MAX 8
  35. /* Because DR/DROther values are exhanged wrt RFC */
  36. #define ISM_SNMP(x) (((x) == ISM_DROther) ? ISM_DR : \
  37. ((x) == ISM_DR) ? ISM_DROther : (x))
  38. /* OSPF Interface State Machine Event. */
  39. #define ISM_NoEvent 0
  40. #define ISM_InterfaceUp 1
  41. #define ISM_WaitTimer 2
  42. #define ISM_BackupSeen 3
  43. #define ISM_NeighborChange 4
  44. #define ISM_LoopInd 5
  45. #define ISM_UnloopInd 6
  46. #define ISM_InterfaceDown 7
  47. #define OSPF_ISM_EVENT_MAX 8
  48. #define OSPF_ISM_WRITE_ON(O) \
  49. do \
  50. { \
  51. if (oi->on_write_q == 0) \
  52. { \
  53. listnode_add ((O)->oi_write_q, oi); \
  54. oi->on_write_q = 1; \
  55. } \
  56. if ((O)->t_write == NULL) \
  57. (O)->t_write = \
  58. thread_add_write (master, ospf_write, (O), (O)->fd); \
  59. } while (0)
  60. /* Macro for OSPF ISM timer turn on. */
  61. #define OSPF_ISM_TIMER_ON(T,F,V) \
  62. do { \
  63. if (!(T)) \
  64. (T) = thread_add_timer (master, (F), oi, (V)); \
  65. } while (0)
  66. #define OSPF_ISM_TIMER_MSEC_ON(T,F,V) \
  67. do { \
  68. if (!(T)) \
  69. (T) = thread_add_timer_msec (master, (F), oi, (V)); \
  70. } while (0)
  71. /* convenience macro to set hello timer correctly, according to
  72. * whether fast-hello is set or not
  73. */
  74. #define OSPF_HELLO_TIMER_ON(O) \
  75. do { \
  76. if (OSPF_IF_PARAM ((O), fast_hello)) \
  77. OSPF_ISM_TIMER_MSEC_ON ((O)->t_hello, ospf_hello_timer, \
  78. 1000 / OSPF_IF_PARAM ((O), fast_hello)); \
  79. else \
  80. OSPF_ISM_TIMER_ON ((O)->t_hello, ospf_hello_timer, \
  81. OSPF_IF_PARAM ((O), v_hello)); \
  82. } while (0)
  83. /* Macro for OSPF ISM timer turn off. */
  84. #define OSPF_ISM_TIMER_OFF(X) \
  85. do { \
  86. if (X) \
  87. { \
  88. thread_cancel (X); \
  89. (X) = NULL; \
  90. } \
  91. } while (0)
  92. /* Macro for OSPF schedule event. */
  93. #define OSPF_ISM_EVENT_SCHEDULE(I,E) \
  94. thread_add_event (master, ospf_ism_event, (I), (E))
  95. /* Macro for OSPF execute event. */
  96. #define OSPF_ISM_EVENT_EXECUTE(I,E) \
  97. thread_execute (master, ospf_ism_event, (I), (E))
  98. /* Prototypes. */
  99. extern int ospf_ism_event (struct thread *);
  100. extern void ism_change_status (struct ospf_interface *, int);
  101. extern int ospf_hello_timer (struct thread *thread);
  102. #endif /* _ZEBRA_OSPF_ISM_H */