Import Upstream version 1.2.2
[quagga-debian.git] / zebra / interface.h
1 /* 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
22 #ifndef _ZEBRA_INTERFACE_H
23 #define _ZEBRA_INTERFACE_H
24
25 #include "redistribute.h"
26 #include "event_counter.h"
27
28 #ifdef HAVE_IRDP
29 #include "zebra/irdp.h"
30 #endif
31
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
36
37 /* For interface shutdown configuration. */
38 #define IF_ZEBRA_SHUTDOWN_OFF    0
39 #define IF_ZEBRA_SHUTDOWN_ON     1
40
41 /* Global user-configured default for interface link-detect */
42 typedef enum {
43   IF_LINKDETECT_UNSPEC = 0,
44   IF_LINKDETECT_ON,
45   IF_LINKDETECT_OFF,
46 } zebra_if_linkdetect;
47
48 /* Global defaults for interfaces */
49 struct zebra_if_defaults {
50   /* Link-detect default configuration */
51   zebra_if_linkdetect linkdetect;
52 };
53
54 #if defined (HAVE_RTADV)
55 /* Router advertisement parameter.  From RFC4861, RFC6275 and RFC4191. */
56 struct 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
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].
67
68      Default: 600000 milliseconds */
69   int MaxRtrAdvInterval;
70 #define RTADV_MAX_RTR_ADV_INTERVAL 600000
71
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.
76
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)
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;
140 #define RTADV_MAX_RTRLIFETIME 9000 /* 2.5 hours */
141
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. */
149   struct list *AdvPrefixList;
150
151   /* The TRUE/FALSE value to be placed in the "Home agent"
152      flag field in the Router Advertisement.  See [RFC6275 7.1].
153
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
175      option. See [RFC 6275 7.3]
176
177      Default: FALSE */
178   int AdvIntervalOption;
179
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. */
186 };
187
188 #endif /* HAVE_RTADV */
189
190 /* `zebra' daemon local interface structure. */
191 struct 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;
201   
202   /* Interface specific link-detect configuration state */
203   zebra_if_linkdetect linkdetect;
204   
205   /* Installed addresses chains tree. */
206   struct route_table *ipv4_subnets;
207
208   /* Information about up/down changes */
209   struct event_counter up_events;
210   struct event_counter down_events;
211
212 #if defined(HAVE_RTADV)
213   struct rtadvconf rtadv;
214 #endif /* RTADV */
215
216 #ifdef HAVE_IRDP
217   struct irdp_interface irdp;
218 #endif
219
220 #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
230 #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 */
238 };
239
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 *);
249
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);
255
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 */
263
264 #endif /* _ZEBRA_INTERFACE_H */