paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 | |
paul | 5b73a67 | 2004-07-23 15:26:14 +0000 | [diff] [blame] | 22 | #ifndef _ZEBRA_INTERFACE_H |
| 23 | #define _ZEBRA_INTERFACE_H |
| 24 | |
| 25 | #include "redistribute.h" |
Christian Franke | 581ecbf | 2016-05-03 19:59:43 +0200 | [diff] [blame] | 26 | #include "event_counter.h" |
paul | 5b73a67 | 2004-07-23 15:26:14 +0000 | [diff] [blame] | 27 | |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 28 | #ifdef HAVE_IRDP |
| 29 | #include "zebra/irdp.h" |
| 30 | #endif |
| 31 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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. */ |
Christian Franke | bfac8dc | 2013-01-24 14:04:50 +0000 | [diff] [blame] | 38 | #define IF_ZEBRA_SHUTDOWN_OFF 0 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 39 | #define IF_ZEBRA_SHUTDOWN_ON 1 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 40 | |
Paul Jakma | 8f4269d | 2015-09-18 11:50:33 +0100 | [diff] [blame] | 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 | |
Donald Sharp | 6425773 | 2015-11-20 08:33:30 -0500 | [diff] [blame] | 54 | #if defined (HAVE_RTADV) |
Denis Ovsienko | 6eb0c5a | 2012-01-24 11:02:03 +0400 | [diff] [blame] | 55 | /* Router advertisement parameter. From RFC4861, RFC6275 and RFC4191. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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 |
vincent | 7cee1bb | 2005-03-25 13:08:53 +0000 | [diff] [blame] | 64 | Router Advertisements from the interface, in milliseconds. |
Denis Ovsienko | 6eb0c5a | 2012-01-24 11:02:03 +0400 | [diff] [blame] | 65 | MUST be no less than 70 ms [RFC6275 7.5] and no greater |
| 66 | than 1800000 ms [RFC4861 6.2.1]. |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 67 | |
vincent | 7cee1bb | 2005-03-25 13:08:53 +0000 | [diff] [blame] | 68 | Default: 600000 milliseconds */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 69 | int MaxRtrAdvInterval; |
vincent | 7cee1bb | 2005-03-25 13:08:53 +0000 | [diff] [blame] | 70 | #define RTADV_MAX_RTR_ADV_INTERVAL 600000 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 71 | |
| 72 | /* The minimum time allowed between sending unsolicited multicast |
vincent | 7cee1bb | 2005-03-25 13:08:53 +0000 | [diff] [blame] | 73 | Router Advertisements from the interface, in milliseconds. |
Denis Ovsienko | 6eb0c5a | 2012-01-24 11:02:03 +0400 | [diff] [blame] | 74 | MUST be no less than 30 ms [RFC6275 7.5]. |
vincent | 7cee1bb | 2005-03-25 13:08:53 +0000 | [diff] [blame] | 75 | MUST be no greater than .75 * MaxRtrAdvInterval. |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 76 | |
| 77 | Default: 0.33 * MaxRtrAdvInterval */ |
Denis Ovsienko | d660f69 | 2011-12-30 21:55:49 +0400 | [diff] [blame] | 78 | int MinRtrAdvInterval; /* This field is currently unused. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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; |
Denis Ovsienko | d660f69 | 2011-12-30 21:55:49 +0400 | [diff] [blame] | 140 | #define RTADV_MAX_RTRLIFETIME 9000 /* 2.5 hours */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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. */ |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 149 | struct list *AdvPrefixList; |
vincent | 7cee1bb | 2005-03-25 13:08:53 +0000 | [diff] [blame] | 150 | |
| 151 | /* The TRUE/FALSE value to be placed in the "Home agent" |
Denis Ovsienko | 6eb0c5a | 2012-01-24 11:02:03 +0400 | [diff] [blame] | 152 | flag field in the Router Advertisement. See [RFC6275 7.1]. |
vincent | 7cee1bb | 2005-03-25 13:08:53 +0000 | [diff] [blame] | 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 |
Denis Ovsienko | 6eb0c5a | 2012-01-24 11:02:03 +0400 | [diff] [blame] | 175 | option. See [RFC 6275 7.3] |
vincent | 7cee1bb | 2005-03-25 13:08:53 +0000 | [diff] [blame] | 176 | |
| 177 | Default: FALSE */ |
| 178 | int AdvIntervalOption; |
Chris Caputo | b60668d | 2009-05-03 04:40:57 +0000 | [diff] [blame] | 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. */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 186 | }; |
| 187 | |
Donald Sharp | 6425773 | 2015-11-20 08:33:30 -0500 | [diff] [blame] | 188 | #endif /* HAVE_RTADV */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 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; |
Paul Jakma | 8f4269d | 2015-09-18 11:50:33 +0100 | [diff] [blame] | 201 | |
| 202 | /* Interface specific link-detect configuration state */ |
| 203 | zebra_if_linkdetect linkdetect; |
| 204 | |
hasso | eef1fe1 | 2004-10-03 18:46:08 +0000 | [diff] [blame] | 205 | /* Installed addresses chains tree. */ |
| 206 | struct route_table *ipv4_subnets; |
| 207 | |
Christian Franke | 581ecbf | 2016-05-03 19:59:43 +0200 | [diff] [blame] | 208 | /* Information about up/down changes */ |
| 209 | struct event_counter up_events; |
| 210 | struct event_counter down_events; |
| 211 | |
Donald Sharp | 6425773 | 2015-11-20 08:33:30 -0500 | [diff] [blame] | 212 | #if defined(HAVE_RTADV) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 213 | struct rtadvconf rtadv; |
| 214 | #endif /* RTADV */ |
hasso | ca77698 | 2004-06-12 14:33:05 +0000 | [diff] [blame] | 215 | |
| 216 | #ifdef HAVE_IRDP |
| 217 | struct irdp_interface irdp; |
| 218 | #endif |
| 219 | |
Timo Teräs | 954c7d6 | 2016-01-15 17:36:33 +0200 | [diff] [blame] | 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 | |
paul | 5c78b3d | 2006-01-25 04:31:40 +0000 | [diff] [blame] | 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 */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 238 | }; |
| 239 | |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 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 *); |
paul | 5c78b3d | 2006-01-25 04:31:40 +0000 | [diff] [blame] | 245 | extern void if_flags_update (struct interface *, uint64_t); |
Christian Franke | 581ecbf | 2016-05-03 19:59:43 +0200 | [diff] [blame] | 246 | extern void if_startup_count_up (void); |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 247 | extern int if_subnet_add (struct interface *, struct connected *); |
| 248 | extern int if_subnet_delete (struct interface *, struct connected *); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 249 | |
| 250 | #ifdef HAVE_PROC_NET_DEV |
Paul Jakma | f28b0e5 | 2006-08-06 15:57:59 +0000 | [diff] [blame] | 251 | extern void ifstat_update_proc (void); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 252 | #endif /* HAVE_PROC_NET_DEV */ |
| 253 | #ifdef HAVE_NET_RT_IFLIST |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 254 | extern void ifstat_update_sysctl (void); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 255 | |
| 256 | #endif /* HAVE_NET_RT_IFLIST */ |
| 257 | #ifdef HAVE_PROC_NET_DEV |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 258 | extern int interface_list_proc (void); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 259 | #endif /* HAVE_PROC_NET_DEV */ |
| 260 | #ifdef HAVE_PROC_NET_IF_INET6 |
paul | a1ac18c | 2005-06-28 17:17:12 +0000 | [diff] [blame] | 261 | extern int ifaddr_proc_ipv6 (void); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 262 | #endif /* HAVE_PROC_NET_IF_INET6 */ |
| 263 | |
paul | 5b73a67 | 2004-07-23 15:26:14 +0000 | [diff] [blame] | 264 | #endif /* _ZEBRA_INTERFACE_H */ |