1 /* Interface function header.
2 * Copyright (C) 1999 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
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
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.
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
22 #ifndef _ZEBRA_INTERFACE_H
23 #define _ZEBRA_INTERFACE_H
25 #include "redistribute.h"
26 #include "event_counter.h"
29 #include "zebra/irdp.h"
32 /* For interface multicast configuration. */
33 #define IF_ZEBRA_MULTICAST_UNSPEC 0
34 #define IF_ZEBRA_MULTICAST_ON 1
35 #define IF_ZEBRA_MULTICAST_OFF 2
37 /* For interface shutdown configuration. */
38 #define IF_ZEBRA_SHUTDOWN_OFF 0
39 #define IF_ZEBRA_SHUTDOWN_ON 1
41 /* Global user-configured default for interface link-detect */
43 IF_LINKDETECT_UNSPEC = 0,
46 } zebra_if_linkdetect;
48 /* Global defaults for interfaces */
49 struct zebra_if_defaults {
50 /* Link-detect default configuration */
51 zebra_if_linkdetect linkdetect;
54 #if defined (HAVE_RTADV)
55 /* Router advertisement parameter. From RFC4861, RFC6275 and RFC4191. */
58 /* A flag indicating whether or not the router sends periodic Router
59 Advertisements and responds to Router Solicitations.
61 int AdvSendAdvertisements;
63 /* The maximum time allowed between sending unsolicited multicast
64 Router Advertisements from the interface, in milliseconds.
65 MUST be no less than 70 ms [RFC6275 7.5] and no greater
66 than 1800000 ms [RFC4861 6.2.1].
68 Default: 600000 milliseconds */
69 int MaxRtrAdvInterval;
70 #define RTADV_MAX_RTR_ADV_INTERVAL 600000
72 /* The minimum time allowed between sending unsolicited multicast
73 Router Advertisements from the interface, in milliseconds.
74 MUST be no less than 30 ms [RFC6275 7.5].
75 MUST be no greater than .75 * MaxRtrAdvInterval.
77 Default: 0.33 * MaxRtrAdvInterval */
78 int MinRtrAdvInterval; /* This field is currently unused. */
79 #define RTADV_MIN_RTR_ADV_INTERVAL (0.33 * RTADV_MAX_RTR_ADV_INTERVAL)
81 /* Unsolicited Router Advertisements' interval timer. */
84 /* The TRUE/FALSE value to be placed in the "Managed address
85 configuration" flag field in the Router Advertisement. See
92 /* The TRUE/FALSE value to be placed in the "Other stateful
93 configuration" flag field in the Router Advertisement. See
97 int AdvOtherConfigFlag;
99 /* The value to be placed in MTU options sent by the router. A
100 value of zero indicates that no MTU options are sent.
106 /* The value to be placed in the Reachable Time field in the Router
107 Advertisement messages sent by the router. The value zero means
108 unspecified (by this router). MUST be no greater than 3,600,000
109 milliseconds (1 hour).
112 u_int32_t AdvReachableTime;
113 #define RTADV_MAX_REACHABLE_TIME 3600000
116 /* The value to be placed in the Retrans Timer field in the Router
117 Advertisement messages sent by the router. The value zero means
118 unspecified (by this router).
123 /* The default value to be placed in the Cur Hop Limit field in the
124 Router Advertisement messages sent by the router. The value
125 should be set to that current diameter of the Internet. The
126 value zero means unspecified (by this router).
128 Default: The value specified in the "Assigned Numbers" RFC
129 [ASSIGNED] that was in effect at the time of implementation. */
132 /* The value to be placed in the Router Lifetime field of Router
133 Advertisements sent from the interface, in seconds. MUST be
134 either zero or between MaxRtrAdvInterval and 9000 seconds. A
135 value of zero indicates that the router is not to be used as a
138 Default: 3 * MaxRtrAdvInterval */
139 int AdvDefaultLifetime;
140 #define RTADV_MAX_RTRLIFETIME 9000 /* 2.5 hours */
142 /* A list of prefixes to be placed in Prefix Information options in
143 Router Advertisement messages sent from the interface.
145 Default: all prefixes that the router advertises via routing
146 protocols as being on-link for the interface from which the
147 advertisement is sent. The link-local prefix SHOULD NOT be
148 included in the list of advertised prefixes. */
149 struct list *AdvPrefixList;
151 /* The TRUE/FALSE value to be placed in the "Home agent"
152 flag field in the Router Advertisement. See [RFC6275 7.1].
155 int AdvHomeAgentFlag;
156 #ifndef ND_RA_FLAG_HOME_AGENT
157 #define ND_RA_FLAG_HOME_AGENT 0x20
160 /* The value to be placed in Home Agent Information option if Home
163 int HomeAgentPreference;
165 /* The value to be placed in Home Agent Information option if Home
166 Flag is set. Lifetime (seconds) MUST not be greater than 18.2
168 The value 0 has special meaning: use of AdvDefaultLifetime value.
171 int HomeAgentLifetime;
172 #define RTADV_MAX_HALIFETIME 65520 /* 18.2 hours */
174 /* The TRUE/FALSE value to insert or not an Advertisement Interval
175 option. See [RFC 6275 7.3]
178 int AdvIntervalOption;
180 /* The value to be placed in the Default Router Preference field of
181 a router advertisement. See [RFC 4191 2.1 & 2.2]
183 Default: 0 (medium) */
184 int DefaultPreference;
185 #define RTADV_PREF_MEDIUM 0x0 /* Per RFC4191. */
188 #endif /* HAVE_RTADV */
190 /* `zebra' daemon local interface structure. */
193 /* Shutdown configuration. */
196 /* Multicast configuration. */
199 /* Router advertise configuration. */
202 /* Interface specific link-detect configuration state */
203 zebra_if_linkdetect linkdetect;
205 /* Installed addresses chains tree. */
206 struct route_table *ipv4_subnets;
208 /* Information about up/down changes */
209 struct event_counter up_events;
210 struct event_counter down_events;
212 #if defined(HAVE_RTADV)
213 struct rtadvconf rtadv;
217 struct irdp_interface irdp;
220 #ifdef HAVE_STRUCT_SOCKADDR_DL
222 /* note that sdl_storage is never accessed, it only exists to make space.
223 * all actual uses refer to sdl - but use sizeof(sdl_storage)! this fits
224 * best with C aliasing rules. */
225 struct sockaddr_dl sdl;
226 struct sockaddr_storage sdl_storage;
231 /* the real IFF_UP state of the primary interface.
232 * need this to differentiate between all interfaces being
233 * down (but primary still plumbed) and primary having gone
234 * ~IFF_UP, and all addresses gone.
236 u_char primary_state;
240 extern void if_delete_update (struct interface *ifp);
241 extern void if_add_update (struct interface *ifp);
242 extern void if_up (struct interface *);
243 extern void if_down (struct interface *);
244 extern void if_refresh (struct interface *);
245 extern void if_flags_update (struct interface *, uint64_t);
246 extern void if_startup_count_up (void);
247 extern int if_subnet_add (struct interface *, struct connected *);
248 extern int if_subnet_delete (struct interface *, struct connected *);
250 #ifdef HAVE_PROC_NET_DEV
251 extern void ifstat_update_proc (void);
252 #endif /* HAVE_PROC_NET_DEV */
253 #ifdef HAVE_NET_RT_IFLIST
254 extern void ifstat_update_sysctl (void);
256 #endif /* HAVE_NET_RT_IFLIST */
257 #ifdef HAVE_PROC_NET_DEV
258 extern int interface_list_proc (void);
259 #endif /* HAVE_PROC_NET_DEV */
260 #ifdef HAVE_PROC_NET_IF_INET6
261 extern int ifaddr_proc_ipv6 (void);
262 #endif /* HAVE_PROC_NET_IF_INET6 */
264 #endif /* _ZEBRA_INTERFACE_H */