blob: 223caf80fd4dfb4324e2afacd4ac6b81cc43cea2 [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/* Interface function header.
2 * Copyright (C) 1999 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
paul5b73a672004-07-23 15:26:14 +000022#ifndef _ZEBRA_INTERFACE_H
23#define _ZEBRA_INTERFACE_H
24
25#include "redistribute.h"
Christian Franke581ecbf2016-05-03 19:59:43 +020026#include "event_counter.h"
paul5b73a672004-07-23 15:26:14 +000027
hassoca776982004-06-12 14:33:05 +000028#ifdef HAVE_IRDP
29#include "zebra/irdp.h"
30#endif
31
paul718e3742002-12-13 20:15:29 +000032/* 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
36
37/* For interface shutdown configuration. */
Christian Frankebfac8dc2013-01-24 14:04:50 +000038#define IF_ZEBRA_SHUTDOWN_OFF 0
paul718e3742002-12-13 20:15:29 +000039#define IF_ZEBRA_SHUTDOWN_ON 1
paul718e3742002-12-13 20:15:29 +000040
Paul Jakma8f4269d2015-09-18 11:50:33 +010041/* Global user-configured default for interface link-detect */
42typedef enum {
43 IF_LINKDETECT_UNSPEC = 0,
44 IF_LINKDETECT_ON,
45 IF_LINKDETECT_OFF,
46} zebra_if_linkdetect;
47
48/* Global defaults for interfaces */
49struct zebra_if_defaults {
50 /* Link-detect default configuration */
51 zebra_if_linkdetect linkdetect;
52};
53
Donald Sharp64257732015-11-20 08:33:30 -050054#if defined (HAVE_RTADV)
Denis Ovsienko6eb0c5a2012-01-24 11:02:03 +040055/* Router advertisement parameter. From RFC4861, RFC6275 and RFC4191. */
paul718e3742002-12-13 20:15:29 +000056struct rtadvconf
57{
58 /* A flag indicating whether or not the router sends periodic Router
59 Advertisements and responds to Router Solicitations.
60 Default: FALSE */
61 int AdvSendAdvertisements;
62
63 /* The maximum time allowed between sending unsolicited multicast
vincent7cee1bb2005-03-25 13:08:53 +000064 Router Advertisements from the interface, in milliseconds.
Denis Ovsienko6eb0c5a2012-01-24 11:02:03 +040065 MUST be no less than 70 ms [RFC6275 7.5] and no greater
66 than 1800000 ms [RFC4861 6.2.1].
paul718e3742002-12-13 20:15:29 +000067
vincent7cee1bb2005-03-25 13:08:53 +000068 Default: 600000 milliseconds */
paul718e3742002-12-13 20:15:29 +000069 int MaxRtrAdvInterval;
vincent7cee1bb2005-03-25 13:08:53 +000070#define RTADV_MAX_RTR_ADV_INTERVAL 600000
paul718e3742002-12-13 20:15:29 +000071
72 /* The minimum time allowed between sending unsolicited multicast
vincent7cee1bb2005-03-25 13:08:53 +000073 Router Advertisements from the interface, in milliseconds.
Denis Ovsienko6eb0c5a2012-01-24 11:02:03 +040074 MUST be no less than 30 ms [RFC6275 7.5].
vincent7cee1bb2005-03-25 13:08:53 +000075 MUST be no greater than .75 * MaxRtrAdvInterval.
paul718e3742002-12-13 20:15:29 +000076
77 Default: 0.33 * MaxRtrAdvInterval */
Denis Ovsienkod660f692011-12-30 21:55:49 +040078 int MinRtrAdvInterval; /* This field is currently unused. */
paul718e3742002-12-13 20:15:29 +000079#define RTADV_MIN_RTR_ADV_INTERVAL (0.33 * RTADV_MAX_RTR_ADV_INTERVAL)
80
81 /* Unsolicited Router Advertisements' interval timer. */
82 int AdvIntervalTimer;
83
84 /* The TRUE/FALSE value to be placed in the "Managed address
85 configuration" flag field in the Router Advertisement. See
86 [ADDRCONF].
87
88 Default: FALSE */
89 int AdvManagedFlag;
90
91
92 /* The TRUE/FALSE value to be placed in the "Other stateful
93 configuration" flag field in the Router Advertisement. See
94 [ADDRCONF].
95
96 Default: FALSE */
97 int AdvOtherConfigFlag;
98
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.
101
102 Default: 0 */
103 int AdvLinkMTU;
104
105
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).
110
111 Default: 0 */
112 u_int32_t AdvReachableTime;
113#define RTADV_MAX_REACHABLE_TIME 3600000
114
115
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).
119
120 Default: 0 */
121 int AdvRetransTimer;
122
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).
127
128 Default: The value specified in the "Assigned Numbers" RFC
129 [ASSIGNED] that was in effect at the time of implementation. */
130 int AdvCurHopLimit;
131
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
136 default router.
137
138 Default: 3 * MaxRtrAdvInterval */
139 int AdvDefaultLifetime;
Denis Ovsienkod660f692011-12-30 21:55:49 +0400140#define RTADV_MAX_RTRLIFETIME 9000 /* 2.5 hours */
paul718e3742002-12-13 20:15:29 +0000141
142 /* A list of prefixes to be placed in Prefix Information options in
143 Router Advertisement messages sent from the interface.
144
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. */
hasso52dc7ee2004-09-23 19:18:23 +0000149 struct list *AdvPrefixList;
vincent7cee1bb2005-03-25 13:08:53 +0000150
151 /* The TRUE/FALSE value to be placed in the "Home agent"
Denis Ovsienko6eb0c5a2012-01-24 11:02:03 +0400152 flag field in the Router Advertisement. See [RFC6275 7.1].
vincent7cee1bb2005-03-25 13:08:53 +0000153
154 Default: FALSE */
155 int AdvHomeAgentFlag;
156#ifndef ND_RA_FLAG_HOME_AGENT
157#define ND_RA_FLAG_HOME_AGENT 0x20
158#endif
159
160 /* The value to be placed in Home Agent Information option if Home
161 Flag is set.
162 Default: 0 */
163 int HomeAgentPreference;
164
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
167 hours.
168 The value 0 has special meaning: use of AdvDefaultLifetime value.
169
170 Default: 0 */
171 int HomeAgentLifetime;
172#define RTADV_MAX_HALIFETIME 65520 /* 18.2 hours */
173
174 /* The TRUE/FALSE value to insert or not an Advertisement Interval
Denis Ovsienko6eb0c5a2012-01-24 11:02:03 +0400175 option. See [RFC 6275 7.3]
vincent7cee1bb2005-03-25 13:08:53 +0000176
177 Default: FALSE */
178 int AdvIntervalOption;
Chris Caputob60668d2009-05-03 04:40:57 +0000179
180 /* The value to be placed in the Default Router Preference field of
181 a router advertisement. See [RFC 4191 2.1 & 2.2]
182
183 Default: 0 (medium) */
184 int DefaultPreference;
185#define RTADV_PREF_MEDIUM 0x0 /* Per RFC4191. */
paul718e3742002-12-13 20:15:29 +0000186};
187
Donald Sharp64257732015-11-20 08:33:30 -0500188#endif /* HAVE_RTADV */
paul718e3742002-12-13 20:15:29 +0000189
190/* `zebra' daemon local interface structure. */
191struct zebra_if
192{
193 /* Shutdown configuration. */
194 u_char shutdown;
195
196 /* Multicast configuration. */
197 u_char multicast;
198
199 /* Router advertise configuration. */
200 u_char rtadv_enable;
Paul Jakma8f4269d2015-09-18 11:50:33 +0100201
202 /* Interface specific link-detect configuration state */
203 zebra_if_linkdetect linkdetect;
204
hassoeef1fe12004-10-03 18:46:08 +0000205 /* Installed addresses chains tree. */
206 struct route_table *ipv4_subnets;
207
Christian Franke581ecbf2016-05-03 19:59:43 +0200208 /* Information about up/down changes */
209 struct event_counter up_events;
210 struct event_counter down_events;
211
Donald Sharp64257732015-11-20 08:33:30 -0500212#if defined(HAVE_RTADV)
paul718e3742002-12-13 20:15:29 +0000213 struct rtadvconf rtadv;
214#endif /* RTADV */
hassoca776982004-06-12 14:33:05 +0000215
216#ifdef HAVE_IRDP
217 struct irdp_interface irdp;
218#endif
219
Timo Teräs954c7d62016-01-15 17:36:33 +0200220#ifdef HAVE_STRUCT_SOCKADDR_DL
221 union {
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;
227 };
228#endif
229
paul5c78b3d2006-01-25 04:31:40 +0000230#ifdef SUNOS_5
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.
235 */
236 u_char primary_state;
237#endif /* SUNOS_5 */
paul718e3742002-12-13 20:15:29 +0000238};
239
paula1ac18c2005-06-28 17:17:12 +0000240extern void if_delete_update (struct interface *ifp);
241extern void if_add_update (struct interface *ifp);
242extern void if_up (struct interface *);
243extern void if_down (struct interface *);
244extern void if_refresh (struct interface *);
paul5c78b3d2006-01-25 04:31:40 +0000245extern void if_flags_update (struct interface *, uint64_t);
Christian Franke581ecbf2016-05-03 19:59:43 +0200246extern void if_startup_count_up (void);
paula1ac18c2005-06-28 17:17:12 +0000247extern int if_subnet_add (struct interface *, struct connected *);
248extern int if_subnet_delete (struct interface *, struct connected *);
paul718e3742002-12-13 20:15:29 +0000249
250#ifdef HAVE_PROC_NET_DEV
Paul Jakmaf28b0e52006-08-06 15:57:59 +0000251extern void ifstat_update_proc (void);
paul718e3742002-12-13 20:15:29 +0000252#endif /* HAVE_PROC_NET_DEV */
253#ifdef HAVE_NET_RT_IFLIST
paula1ac18c2005-06-28 17:17:12 +0000254extern void ifstat_update_sysctl (void);
paul718e3742002-12-13 20:15:29 +0000255
256#endif /* HAVE_NET_RT_IFLIST */
257#ifdef HAVE_PROC_NET_DEV
paula1ac18c2005-06-28 17:17:12 +0000258extern int interface_list_proc (void);
paul718e3742002-12-13 20:15:29 +0000259#endif /* HAVE_PROC_NET_DEV */
260#ifdef HAVE_PROC_NET_IF_INET6
paula1ac18c2005-06-28 17:17:12 +0000261extern int ifaddr_proc_ipv6 (void);
paul718e3742002-12-13 20:15:29 +0000262#endif /* HAVE_PROC_NET_IF_INET6 */
263
paul5b73a672004-07-23 15:26:14 +0000264#endif /* _ZEBRA_INTERFACE_H */