paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 22 | /* |
| 23 | * This file is modified and completed for the Zebra IRDP implementation |
| 24 | * by Robert Olsson, Swedish University of Agricultural Sciences |
| 25 | */ |
| 26 | |
| 27 | #ifndef _IRDP_H |
| 28 | #define _IRDP_H |
| 29 | |
| 30 | #include "lib/vty.h" |
| 31 | |
| 32 | #define TRUE 1 |
| 33 | #define FALSE 0 |
| 34 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 35 | /* ICMP Messages */ |
| 36 | #ifndef ICMP_ROUTERADVERT |
| 37 | #define ICMP_ROUTERADVERT 9 |
| 38 | #endif /* ICMP_ROUTERADVERT */ |
| 39 | |
| 40 | #ifndef ICMP_ROUTERSOLICIT |
| 41 | #define ICMP_ROUTERSOLICIT 10 |
| 42 | #endif /* ICMP_ROUTERSOLICT */ |
| 43 | |
| 44 | /* Multicast groups */ |
| 45 | #ifndef INADDR_ALLHOSTS_GROUP |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 46 | #define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 47 | #endif /* INADDR_ALLHOSTS_GROUP */ |
| 48 | |
| 49 | #ifndef INADDR_ALLRTRS_GROUP |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 50 | #define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 51 | #endif /* INADDR_ALLRTRS_GROUP */ |
| 52 | |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 53 | /* Default irdp packet interval */ |
| 54 | #define IRDP_DEFAULT_INTERVAL 300 |
| 55 | |
| 56 | /* Router constants from RFC1256 */ |
| 57 | #define MAX_INITIAL_ADVERT_INTERVAL 16 |
| 58 | #define MAX_INITIAL_ADVERTISEMENTS 3 |
| 59 | #define MAX_RESPONSE_DELAY 2 |
| 60 | |
| 61 | #define IRDP_MAXADVERTINTERVAL 600 |
| 62 | #define IRDP_MINADVERTINTERVAL 450 /* 0.75*600 */ |
| 63 | #define IRDP_LIFETIME 1350 /* 3*450 */ |
| 64 | #define IRDP_PREFERENCE 0 |
| 65 | |
| 66 | #define ICMP_MINLEN 8 |
| 67 | |
| 68 | #define IRDP_LAST_ADVERT_MESSAGES 2 /* The last adverts with Holdtime 0 */ |
| 69 | |
| 70 | #define IRDP_RX_BUF 1500 |
| 71 | |
| 72 | /* |
| 73 | Comments comes from RFC1256 ICMP Router Discovery Messages. |
| 74 | |
| 75 | The IP destination address to be used for multicast Router |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 76 | Advertisements sent from the interface. The only permissible |
| 77 | values are the all-systems multicast address, 224.0.0.1, or the |
| 78 | limited-broadcast address, 255.255.255.255. (The all-systems |
| 79 | address is preferred wherever possible, i.e., on any link where |
| 80 | all listening hosts support IP multicast.) |
| 81 | |
| 82 | Default: 224.0.0.1 if the router supports IP multicast on the |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 83 | interface, else 255.255.255.255 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 84 | |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 85 | The maximum time allowed between sending multicast Router |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 86 | Advertisements from the interface, in seconds. Must be no less |
| 87 | than 4 seconds and no greater than 1800 seconds. |
| 88 | |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 89 | Default: 600 seconds |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 90 | |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 91 | The minimum time allowed between sending unsolicited multicast |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 92 | Router Advertisements from the interface, in seconds. Must be no |
| 93 | less than 3 seconds and no greater than MaxAdvertisementInterval. |
| 94 | |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 95 | Default: 0.75 * MaxAdvertisementInterval |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 96 | |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 97 | The value to be placed in the Lifetime field of Router |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 98 | Advertisements sent from the interface, in seconds. Must be no |
| 99 | less than MaxAdvertisementInterval and no greater than 9000 |
| 100 | seconds. |
| 101 | |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 102 | Default: 3 * MaxAdvertisementInterval |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 103 | |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 104 | The preferability of the address as a default router address, |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 105 | relative to other router addresses on the same subnet. A 32-bit, |
| 106 | signed, twos-complement integer, with higher values meaning more |
| 107 | preferable. The minimum value (hex 80000000) is used to indicate |
| 108 | that the address, even though it may be advertised, is not to be |
| 109 | used by neighboring hosts as a default router address. |
| 110 | |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 111 | Default: 0 |
| 112 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 113 | |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 114 | struct irdp_interface |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 115 | { |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 116 | unsigned long MaxAdvertInterval; |
| 117 | unsigned long MinAdvertInterval; |
| 118 | unsigned long Preference; |
| 119 | |
| 120 | u_int32_t flags; |
| 121 | |
| 122 | #define IF_ACTIVE (1<<0) /* ICMP Active */ |
| 123 | #define IF_BROADCAST (1<<1) /* 255.255.255.255 */ |
| 124 | #define IF_SOLICIT (1<<2) /* Solicit active */ |
| 125 | #define IF_DEBUG_MESSAGES (1<<3) |
| 126 | #define IF_DEBUG_PACKET (1<<4) |
| 127 | #define IF_DEBUG_MISC (1<<5) |
| 128 | #define IF_SHUTDOWN (1<<6) |
| 129 | |
| 130 | struct interface *ifp; |
| 131 | struct thread *t_advertise; |
| 132 | unsigned long irdp_sent; |
| 133 | u_int16_t Lifetime; |
| 134 | |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 135 | struct list *AdvPrefList; |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 136 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 137 | }; |
| 138 | |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 139 | struct Adv |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 140 | { |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 141 | struct in_addr ip; |
| 142 | int pref; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 143 | }; |
| 144 | |
ajs | 2da40f4 | 2005-03-30 16:33:13 +0000 | [diff] [blame^] | 145 | extern void irdp_init(void); |
| 146 | extern int irdp_sock_init(void); |
| 147 | extern void irdp_finish(void); |
| 148 | extern void irdp_config_write (struct vty *, struct interface *); |
| 149 | |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 150 | #endif /* _IRDP_H */ |