ospf6d.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (C) 2003 Yasuhiro Ohara
  3. *
  4. * This file is part of GNU Zebra.
  5. *
  6. * GNU Zebra is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation; either version 2, or (at your option) any
  9. * later version.
  10. *
  11. * GNU Zebra is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GNU Zebra; see the file COPYING. If not, write to the
  18. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  19. * Boston, MA 02111-1307, USA.
  20. */
  21. #ifndef OSPF6D_H
  22. #define OSPF6D_H
  23. #define OSPF6_DAEMON_VERSION "0.9.7r"
  24. #include "libospf.h"
  25. #include "thread.h"
  26. /* global variables */
  27. extern struct thread_master *master;
  28. /* Historical for KAME. */
  29. #ifndef IPV6_JOIN_GROUP
  30. #ifdef IPV6_ADD_MEMBERSHIP
  31. #define IPV6_JOIN_GROUP IPV6_ADD_MEMBERSHIP
  32. #endif /* IPV6_ADD_MEMBERSHIP. */
  33. #ifdef IPV6_JOIN_MEMBERSHIP
  34. #define IPV6_JOIN_GROUP IPV6_JOIN_MEMBERSHIP
  35. #endif /* IPV6_JOIN_MEMBERSHIP. */
  36. #endif /* ! IPV6_JOIN_GROUP*/
  37. #ifndef IPV6_LEAVE_GROUP
  38. #ifdef IPV6_DROP_MEMBERSHIP
  39. #define IPV6_LEAVE_GROUP IPV6_DROP_MEMBERSHIP
  40. #endif /* IPV6_DROP_MEMBERSHIP */
  41. #endif /* ! IPV6_LEAVE_GROUP */
  42. #define MSG_OK 0
  43. #define MSG_NG 1
  44. /* cast macro: XXX - these *must* die, ick ick. */
  45. #define OSPF6_PROCESS(x) ((struct ospf6 *) (x))
  46. #define OSPF6_AREA(x) ((struct ospf6_area *) (x))
  47. #define OSPF6_INTERFACE(x) ((struct ospf6_interface *) (x))
  48. #define OSPF6_NEIGHBOR(x) ((struct ospf6_neighbor *) (x))
  49. /* operation on timeval structure */
  50. #ifndef timerclear
  51. #define timerclear(a) (a)->tv_sec = (tvp)->tv_usec = 0
  52. #endif /*timerclear*/
  53. #ifndef timersub
  54. #define timersub(a, b, res) \
  55. do { \
  56. (res)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
  57. (res)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
  58. if ((res)->tv_usec < 0) \
  59. { \
  60. (res)->tv_sec--; \
  61. (res)->tv_usec += 1000000; \
  62. } \
  63. } while (0)
  64. #endif /*timersub*/
  65. #define timerstring(tv, buf, size) \
  66. do { \
  67. if ((tv)->tv_sec / 60 / 60 / 24) \
  68. snprintf (buf, size, "%lldd%02lld:%02lld:%02lld", \
  69. (tv)->tv_sec / 60LL / 60 / 24, \
  70. (tv)->tv_sec / 60LL / 60 % 24, \
  71. (tv)->tv_sec / 60LL % 60, \
  72. (tv)->tv_sec % 60LL); \
  73. else \
  74. snprintf (buf, size, "%02lld:%02lld:%02lld", \
  75. (tv)->tv_sec / 60LL / 60 % 24, \
  76. (tv)->tv_sec / 60LL % 60, \
  77. (tv)->tv_sec % 60LL); \
  78. } while (0)
  79. #define timerstring_local(tv, buf, size) \
  80. do { \
  81. int ret; \
  82. struct tm *tm; \
  83. tm = localtime (&(tv)->tv_sec); \
  84. ret = strftime (buf, size, "%Y/%m/%d %H:%M:%S", tm); \
  85. if (ret == 0) \
  86. zlog_warn ("strftime error"); \
  87. } while (0)
  88. #define threadtimer_string(now, t, buf, size) \
  89. do { \
  90. struct timeval result; \
  91. if (!t) \
  92. snprintf(buf, size, "inactive"); \
  93. else { \
  94. timersub(&t->u.sands, &now, &result); \
  95. timerstring(&result, buf, size); \
  96. } \
  97. } while (0)
  98. /* for commands */
  99. #define OSPF6_AREA_STR "Area information\n"
  100. #define OSPF6_AREA_ID_STR "Area ID (as an IPv4 notation)\n"
  101. #define OSPF6_SPF_STR "Shortest Path First tree information\n"
  102. #define OSPF6_ROUTER_ID_STR "Specify Router-ID\n"
  103. #define OSPF6_LS_ID_STR "Specify Link State ID\n"
  104. #define VNL VTY_NEWLINE
  105. #define OSPF6_CMD_CHECK_RUNNING() \
  106. if (ospf6 == NULL) \
  107. { \
  108. vty_out (vty, "OSPFv3 is not running%s", VTY_NEWLINE); \
  109. return CMD_SUCCESS; \
  110. }
  111. /* Function Prototypes */
  112. extern struct route_node *route_prev (struct route_node *node);
  113. extern void ospf6_debug (void);
  114. extern void ospf6_init (void);
  115. #endif /* OSPF6D_H */