]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
718e3744 | 2 | /* ICMP Router Discovery Messages |
3 | * Copyright (C) 1997, 2000 Kunihiro Ishiguro | |
718e3744 | 4 | */ |
5 | ||
d62a17ae | 6 | /* |
ca776988 | 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 | ||
51e94aa7 EDP |
16 | #ifdef __cplusplus |
17 | extern "C" { | |
18 | #endif | |
19 | ||
718e3744 | 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 | |
ca776988 | 31 | #define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */ |
718e3744 | 32 | #endif /* INADDR_ALLHOSTS_GROUP */ |
33 | ||
34 | #ifndef INADDR_ALLRTRS_GROUP | |
ca776988 | 35 | #define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */ |
718e3744 | 36 | #endif /* INADDR_ALLRTRS_GROUP */ |
37 | ||
ca776988 | 38 | /* Default irdp packet interval */ |
c258527b | 39 | #define IRDP_DEFAULT_INTERVAL 300 |
ca776988 | 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 | ||
d62a17ae | 57 | /* |
58 | Comments comes from RFC1256 ICMP Router Discovery Messages. | |
ca776988 | 59 | |
60 | The IP destination address to be used for multicast Router | |
718e3744 | 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 | |
d62a17ae | 68 | interface, else 255.255.255.255 |
718e3744 | 69 | |
ca776988 | 70 | The maximum time allowed between sending multicast Router |
718e3744 | 71 | Advertisements from the interface, in seconds. Must be no less |
72 | than 4 seconds and no greater than 1800 seconds. | |
73 | ||
d62a17ae | 74 | Default: 600 seconds |
718e3744 | 75 | |
ca776988 | 76 | The minimum time allowed between sending unsolicited multicast |
718e3744 | 77 | Router Advertisements from the interface, in seconds. Must be no |
78 | less than 3 seconds and no greater than MaxAdvertisementInterval. | |
79 | ||
d62a17ae | 80 | Default: 0.75 * MaxAdvertisementInterval |
718e3744 | 81 | |
ca776988 | 82 | The value to be placed in the Lifetime field of Router |
718e3744 | 83 | Advertisements sent from the interface, in seconds. Must be no |
84 | less than MaxAdvertisementInterval and no greater than 9000 | |
85 | seconds. | |
86 | ||
d62a17ae | 87 | Default: 3 * MaxAdvertisementInterval |
718e3744 | 88 | |
ca776988 | 89 | The preferability of the address as a default router address, |
718e3744 | 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 | ||
d62a17ae | 96 | Default: 0 |
ca776988 | 97 | */ |
718e3744 | 98 | |
d62a17ae | 99 | struct irdp_interface { |
e92044cd DS |
100 | bool started; |
101 | ||
d62a17ae | 102 | unsigned long MaxAdvertInterval; |
103 | unsigned long MinAdvertInterval; | |
104 | unsigned long Preference; | |
718e3744 | 105 | |
d7c0a89a | 106 | uint32_t flags; |
718e3744 | 107 | |
ca776988 | 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 */ | |
c258527b QY |
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) | |
718e3744 | 115 | |
d62a17ae | 116 | struct interface *ifp; |
e6685141 | 117 | struct event *t_advertise; |
d62a17ae | 118 | unsigned long irdp_sent; |
d7c0a89a | 119 | uint16_t Lifetime; |
718e3744 | 120 | |
d62a17ae | 121 | struct list *AdvPrefList; |
ca776988 | 122 | }; |
718e3744 | 123 | |
d62a17ae | 124 | struct Adv { |
125 | struct in_addr ip; | |
126 | int pref; | |
718e3744 | 127 | }; |
128 | ||
2eb27eec | 129 | extern void irdp_if_init(void); |
2da40f49 | 130 | extern int irdp_sock_init(void); |
2eb27eec | 131 | extern int irdp_config_write(struct vty *, struct interface *); |
e6685141 | 132 | extern void irdp_send_thread(struct event *t_advert); |
ab0f6155 | 133 | extern void irdp_advert_off(struct interface *ifp); |
d62a17ae | 134 | extern void process_solicit(struct interface *ifp); |
e6685141 | 135 | extern void irdp_read_raw(struct event *r); |
d7c0a89a QY |
136 | extern void send_packet(struct interface *ifp, struct stream *s, uint32_t dst, |
137 | struct prefix *p, uint32_t ttl); | |
ab0f6155 | 138 | |
51e94aa7 EDP |
139 | #ifdef __cplusplus |
140 | } | |
141 | #endif | |
ca776988 | 142 | |
2da40f49 | 143 | #endif /* _IRDP_H */ |