]> git.proxmox.com Git - mirror_frr.git/blob - zebra/irdp.h
3f4fa93460ac5f9ba743450d868f0748927a7501
[mirror_frr.git] / zebra / irdp.h
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 along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
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
26 #ifndef _IRDP_H
27 #define _IRDP_H
28
29 #include "lib/vty.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #define TRUE 1
36 #define FALSE 0
37
38 /* ICMP Messages */
39 #ifndef ICMP_ROUTERADVERT
40 #define ICMP_ROUTERADVERT 9
41 #endif /* ICMP_ROUTERADVERT */
42
43 #ifndef ICMP_ROUTERSOLICIT
44 #define ICMP_ROUTERSOLICIT 10
45 #endif /* ICMP_ROUTERSOLICT */
46
47 /* Multicast groups */
48 #ifndef INADDR_ALLHOSTS_GROUP
49 #define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */
50 #endif /* INADDR_ALLHOSTS_GROUP */
51
52 #ifndef INADDR_ALLRTRS_GROUP
53 #define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */
54 #endif /* INADDR_ALLRTRS_GROUP */
55
56 /* Default irdp packet interval */
57 #define IRDP_DEFAULT_INTERVAL 300
58
59 /* Router constants from RFC1256 */
60 #define MAX_INITIAL_ADVERT_INTERVAL 16
61 #define MAX_INITIAL_ADVERTISEMENTS 3
62 #define MAX_RESPONSE_DELAY 2
63
64 #define IRDP_MAXADVERTINTERVAL 600
65 #define IRDP_MINADVERTINTERVAL 450 /* 0.75*600 */
66 #define IRDP_LIFETIME 1350 /* 3*450 */
67 #define IRDP_PREFERENCE 0
68
69 #define ICMP_MINLEN 8
70
71 #define IRDP_LAST_ADVERT_MESSAGES 2 /* The last adverts with Holdtime 0 */
72
73 #define IRDP_RX_BUF 1500
74
75 /*
76 Comments comes from RFC1256 ICMP Router Discovery Messages.
77
78 The IP destination address to be used for multicast Router
79 Advertisements sent from the interface. The only permissible
80 values are the all-systems multicast address, 224.0.0.1, or the
81 limited-broadcast address, 255.255.255.255. (The all-systems
82 address is preferred wherever possible, i.e., on any link where
83 all listening hosts support IP multicast.)
84
85 Default: 224.0.0.1 if the router supports IP multicast on the
86 interface, else 255.255.255.255
87
88 The maximum time allowed between sending multicast Router
89 Advertisements from the interface, in seconds. Must be no less
90 than 4 seconds and no greater than 1800 seconds.
91
92 Default: 600 seconds
93
94 The minimum time allowed between sending unsolicited multicast
95 Router Advertisements from the interface, in seconds. Must be no
96 less than 3 seconds and no greater than MaxAdvertisementInterval.
97
98 Default: 0.75 * MaxAdvertisementInterval
99
100 The value to be placed in the Lifetime field of Router
101 Advertisements sent from the interface, in seconds. Must be no
102 less than MaxAdvertisementInterval and no greater than 9000
103 seconds.
104
105 Default: 3 * MaxAdvertisementInterval
106
107 The preferability of the address as a default router address,
108 relative to other router addresses on the same subnet. A 32-bit,
109 signed, twos-complement integer, with higher values meaning more
110 preferable. The minimum value (hex 80000000) is used to indicate
111 that the address, even though it may be advertised, is not to be
112 used by neighboring hosts as a default router address.
113
114 Default: 0
115 */
116
117 struct irdp_interface {
118 bool started;
119
120 unsigned long MaxAdvertInterval;
121 unsigned long MinAdvertInterval;
122 unsigned long Preference;
123
124 uint32_t flags;
125
126 #define IF_ACTIVE (1<<0) /* ICMP Active */
127 #define IF_BROADCAST (1<<1) /* 255.255.255.255 */
128 #define IF_SOLICIT (1<<2) /* Solicit active */
129 #define IF_DEBUG_MESSAGES (1<<3)
130 #define IF_DEBUG_PACKET (1<<4)
131 #define IF_DEBUG_MISC (1<<5)
132 #define IF_SHUTDOWN (1<<6)
133
134 struct interface *ifp;
135 struct thread *t_advertise;
136 unsigned long irdp_sent;
137 uint16_t Lifetime;
138
139 struct list *AdvPrefList;
140 };
141
142 struct Adv {
143 struct in_addr ip;
144 int pref;
145 };
146
147 extern void irdp_if_init(void);
148 extern int irdp_sock_init(void);
149 extern int irdp_config_write(struct vty *, struct interface *);
150 extern int irdp_send_thread(struct thread *t_advert);
151 extern void irdp_advert_off(struct interface *ifp);
152 extern void process_solicit(struct interface *ifp);
153 extern int irdp_read_raw(struct thread *r);
154 extern void send_packet(struct interface *ifp, struct stream *s, uint32_t dst,
155 struct prefix *p, uint32_t ttl);
156
157 #ifdef __cplusplus
158 }
159 #endif
160
161 #endif /* _IRDP_H */