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