irdp.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /* ICMP Router Discovery Messages
  2. * Copyright (C) 1997, 2000 Kunihiro Ishiguro
  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 Free
  18. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  19. * 02111-1307, USA.
  20. */
  21. /*
  22. * This file is modified and completed for the Zebra IRDP implementation
  23. * by Robert Olsson, Swedish University of Agricultural Sciences
  24. */
  25. #ifndef _IRDP_H
  26. #define _IRDP_H
  27. #include "lib/vty.h"
  28. #define TRUE 1
  29. #define FALSE 0
  30. /* ICMP Messages */
  31. #ifndef ICMP_ROUTERADVERT
  32. #define ICMP_ROUTERADVERT 9
  33. #endif /* ICMP_ROUTERADVERT */
  34. #ifndef ICMP_ROUTERSOLICIT
  35. #define ICMP_ROUTERSOLICIT 10
  36. #endif /* ICMP_ROUTERSOLICT */
  37. /* Multicast groups */
  38. #ifndef INADDR_ALLHOSTS_GROUP
  39. #define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */
  40. #endif /* INADDR_ALLHOSTS_GROUP */
  41. #ifndef INADDR_ALLRTRS_GROUP
  42. #define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */
  43. #endif /* INADDR_ALLRTRS_GROUP */
  44. /* Default irdp packet interval */
  45. #define IRDP_DEFAULT_INTERVAL 300
  46. /* Router constants from RFC1256 */
  47. #define MAX_INITIAL_ADVERT_INTERVAL 16
  48. #define MAX_INITIAL_ADVERTISEMENTS 3
  49. #define MAX_RESPONSE_DELAY 2
  50. #define IRDP_MAXADVERTINTERVAL 600
  51. #define IRDP_MINADVERTINTERVAL 450 /* 0.75*600 */
  52. #define IRDP_LIFETIME 1350 /* 3*450 */
  53. #define IRDP_PREFERENCE 0
  54. #define ICMP_MINLEN 8
  55. #define IRDP_LAST_ADVERT_MESSAGES 2 /* The last adverts with Holdtime 0 */
  56. #define IRDP_RX_BUF 1500
  57. /*
  58. Comments comes from RFC1256 ICMP Router Discovery Messages.
  59. The IP destination address to be used for multicast Router
  60. Advertisements sent from the interface. The only permissible
  61. values are the all-systems multicast address, 224.0.0.1, or the
  62. limited-broadcast address, 255.255.255.255. (The all-systems
  63. address is preferred wherever possible, i.e., on any link where
  64. all listening hosts support IP multicast.)
  65. Default: 224.0.0.1 if the router supports IP multicast on the
  66. interface, else 255.255.255.255
  67. The maximum time allowed between sending multicast Router
  68. Advertisements from the interface, in seconds. Must be no less
  69. than 4 seconds and no greater than 1800 seconds.
  70. Default: 600 seconds
  71. The minimum time allowed between sending unsolicited multicast
  72. Router Advertisements from the interface, in seconds. Must be no
  73. less than 3 seconds and no greater than MaxAdvertisementInterval.
  74. Default: 0.75 * MaxAdvertisementInterval
  75. The value to be placed in the Lifetime field of Router
  76. Advertisements sent from the interface, in seconds. Must be no
  77. less than MaxAdvertisementInterval and no greater than 9000
  78. seconds.
  79. Default: 3 * MaxAdvertisementInterval
  80. The preferability of the address as a default router address,
  81. relative to other router addresses on the same subnet. A 32-bit,
  82. signed, twos-complement integer, with higher values meaning more
  83. preferable. The minimum value (hex 80000000) is used to indicate
  84. that the address, even though it may be advertised, is not to be
  85. used by neighboring hosts as a default router address.
  86. Default: 0
  87. */
  88. struct irdp_interface
  89. {
  90. unsigned long MaxAdvertInterval;
  91. unsigned long MinAdvertInterval;
  92. unsigned long Preference;
  93. u_int32_t flags;
  94. #define IF_ACTIVE (1<<0) /* ICMP Active */
  95. #define IF_BROADCAST (1<<1) /* 255.255.255.255 */
  96. #define IF_SOLICIT (1<<2) /* Solicit active */
  97. #define IF_DEBUG_MESSAGES (1<<3)
  98. #define IF_DEBUG_PACKET (1<<4)
  99. #define IF_DEBUG_MISC (1<<5)
  100. #define IF_SHUTDOWN (1<<6)
  101. struct interface *ifp;
  102. struct thread *t_advertise;
  103. unsigned long irdp_sent;
  104. u_int16_t Lifetime;
  105. struct list *AdvPrefList;
  106. };
  107. struct Adv
  108. {
  109. struct in_addr ip;
  110. int pref;
  111. };
  112. extern void irdp_init(void);
  113. extern int irdp_sock_init(void);
  114. extern void irdp_finish(void);
  115. extern void irdp_config_write (struct vty *, struct interface *);
  116. extern int irdp_send_thread(struct thread *t_advert);
  117. extern void irdp_advert_off(struct interface *ifp);
  118. extern void process_solicit (struct interface *ifp);
  119. extern int irdp_read_raw(struct thread *r);
  120. extern void send_packet(struct interface *ifp, struct stream *s,
  121. u_int32_t dst, struct prefix *p, u_int32_t ttl);
  122. #endif /* _IRDP_H */