paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* Interface related header. |
| 2 | Copyright (C) 1997, 98, 99 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 |
| 7 | it under the terms of the GNU General Public License as published |
| 8 | by the Free Software Foundation; either version 2, or (at your |
| 9 | option) any 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 |
| 18 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 19 | Boston, MA 02111-1307, USA. */ |
| 20 | |
| 21 | #ifndef _ZEBRA_IF_H |
| 22 | #define _ZEBRA_IF_H |
| 23 | |
Paul Jakma | 9099f9b | 2016-01-18 10:12:10 +0000 | [diff] [blame] | 24 | #include "zebra.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 25 | #include "linklist.h" |
| 26 | |
Timo Teräs | 954c7d6 | 2016-01-15 17:36:33 +0200 | [diff] [blame] | 27 | /* Interface link-layer type, if known. Derived from: |
| 28 | * |
| 29 | * net/if_arp.h on various platforms - Linux especially. |
| 30 | * http://www.iana.org/assignments/arp-parameters/arp-parameters.xhtml |
| 31 | * |
| 32 | * Some of the more obviously defunct technologies left out. |
| 33 | */ |
| 34 | enum zebra_link_type { |
| 35 | ZEBRA_LLT_UNKNOWN = 0, |
| 36 | ZEBRA_LLT_ETHER, |
| 37 | ZEBRA_LLT_EETHER, |
| 38 | ZEBRA_LLT_AX25, |
| 39 | ZEBRA_LLT_PRONET, |
| 40 | ZEBRA_LLT_IEEE802, |
| 41 | ZEBRA_LLT_ARCNET, |
| 42 | ZEBRA_LLT_APPLETLK, |
| 43 | ZEBRA_LLT_DLCI, |
| 44 | ZEBRA_LLT_ATM, |
| 45 | ZEBRA_LLT_METRICOM, |
| 46 | ZEBRA_LLT_IEEE1394, |
| 47 | ZEBRA_LLT_EUI64, |
| 48 | ZEBRA_LLT_INFINIBAND, |
| 49 | ZEBRA_LLT_SLIP, |
| 50 | ZEBRA_LLT_CSLIP, |
| 51 | ZEBRA_LLT_SLIP6, |
| 52 | ZEBRA_LLT_CSLIP6, |
| 53 | ZEBRA_LLT_RSRVD, |
| 54 | ZEBRA_LLT_ADAPT, |
| 55 | ZEBRA_LLT_ROSE, |
| 56 | ZEBRA_LLT_X25, |
| 57 | ZEBRA_LLT_PPP, |
| 58 | ZEBRA_LLT_CHDLC, |
| 59 | ZEBRA_LLT_LAPB, |
| 60 | ZEBRA_LLT_RAWHDLC, |
| 61 | ZEBRA_LLT_IPIP, |
| 62 | ZEBRA_LLT_IPIP6, |
| 63 | ZEBRA_LLT_FRAD, |
| 64 | ZEBRA_LLT_SKIP, |
| 65 | ZEBRA_LLT_LOOPBACK, |
| 66 | ZEBRA_LLT_LOCALTLK, |
| 67 | ZEBRA_LLT_FDDI, |
| 68 | ZEBRA_LLT_SIT, |
| 69 | ZEBRA_LLT_IPDDP, |
| 70 | ZEBRA_LLT_IPGRE, |
| 71 | ZEBRA_LLT_IP6GRE, |
| 72 | ZEBRA_LLT_PIMREG, |
| 73 | ZEBRA_LLT_HIPPI, |
| 74 | ZEBRA_LLT_ECONET, |
| 75 | ZEBRA_LLT_IRDA, |
| 76 | ZEBRA_LLT_FCPP, |
| 77 | ZEBRA_LLT_FCAL, |
| 78 | ZEBRA_LLT_FCPL, |
| 79 | ZEBRA_LLT_FCFABRIC, |
| 80 | ZEBRA_LLT_IEEE802_TR, |
| 81 | ZEBRA_LLT_IEEE80211, |
| 82 | ZEBRA_LLT_IEEE80211_RADIOTAP, |
| 83 | ZEBRA_LLT_IEEE802154, |
| 84 | ZEBRA_LLT_IEEE802154_PHY, |
| 85 | }; |
| 86 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 87 | /* |
| 88 | Interface name length. |
| 89 | |
| 90 | Linux define value in /usr/include/linux/if.h. |
| 91 | #define IFNAMSIZ 16 |
| 92 | |
| 93 | FreeBSD define value in /usr/include/net/if.h. |
| 94 | #define IFNAMSIZ 16 |
| 95 | */ |
| 96 | |
| 97 | #define INTERFACE_NAMSIZ 20 |
| 98 | #define INTERFACE_HWADDR_MAX 20 |
| 99 | |
Paul Jakma | 9099f9b | 2016-01-18 10:12:10 +0000 | [diff] [blame] | 100 | typedef signed int ifindex_t; |
| 101 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 102 | #ifdef HAVE_PROC_NET_DEV |
| 103 | struct if_stats |
| 104 | { |
| 105 | unsigned long rx_packets; /* total packets received */ |
| 106 | unsigned long tx_packets; /* total packets transmitted */ |
| 107 | unsigned long rx_bytes; /* total bytes received */ |
| 108 | unsigned long tx_bytes; /* total bytes transmitted */ |
| 109 | unsigned long rx_errors; /* bad packets received */ |
| 110 | unsigned long tx_errors; /* packet transmit problems */ |
| 111 | unsigned long rx_dropped; /* no space in linux buffers */ |
| 112 | unsigned long tx_dropped; /* no space available in linux */ |
| 113 | unsigned long rx_multicast; /* multicast packets received */ |
| 114 | unsigned long rx_compressed; |
| 115 | unsigned long tx_compressed; |
| 116 | unsigned long collisions; |
| 117 | |
| 118 | /* detailed rx_errors: */ |
| 119 | unsigned long rx_length_errors; |
| 120 | unsigned long rx_over_errors; /* receiver ring buff overflow */ |
| 121 | unsigned long rx_crc_errors; /* recved pkt with crc error */ |
| 122 | unsigned long rx_frame_errors; /* recv'd frame alignment error */ |
| 123 | unsigned long rx_fifo_errors; /* recv'r fifo overrun */ |
| 124 | unsigned long rx_missed_errors; /* receiver missed packet */ |
| 125 | /* detailed tx_errors */ |
| 126 | unsigned long tx_aborted_errors; |
| 127 | unsigned long tx_carrier_errors; |
| 128 | unsigned long tx_fifo_errors; |
| 129 | unsigned long tx_heartbeat_errors; |
| 130 | unsigned long tx_window_errors; |
| 131 | }; |
| 132 | #endif /* HAVE_PROC_NET_DEV */ |
| 133 | |
| 134 | /* Interface structure */ |
| 135 | struct interface |
| 136 | { |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 137 | /* Interface name. This should probably never be changed after the |
| 138 | interface is created, because the configuration info for this interface |
| 139 | is associated with this structure. For that reason, the interface |
| 140 | should also never be deleted (to avoid losing configuration info). |
| 141 | To delete, just set ifindex to IFINDEX_INTERNAL to indicate that the |
| 142 | interface does not exist in the kernel. |
| 143 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 144 | char name[INTERFACE_NAMSIZ + 1]; |
| 145 | |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 146 | /* Interface index (should be IFINDEX_INTERNAL for non-kernel or |
| 147 | deleted interfaces). */ |
Paul Jakma | 9099f9b | 2016-01-18 10:12:10 +0000 | [diff] [blame] | 148 | ifindex_t ifindex; |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 149 | #define IFINDEX_INTERNAL 0 |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 150 | |
| 151 | /* Zebra internal interface status */ |
| 152 | u_char status; |
| 153 | #define ZEBRA_INTERFACE_ACTIVE (1 << 0) |
| 154 | #define ZEBRA_INTERFACE_SUB (1 << 1) |
paul | 2e3b2e4 | 2002-12-13 21:03:13 +0000 | [diff] [blame] | 155 | #define ZEBRA_INTERFACE_LINKDETECTION (1 << 2) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 156 | |
| 157 | /* Interface flags. */ |
paul | c77d454 | 2006-01-11 01:59:04 +0000 | [diff] [blame] | 158 | uint64_t flags; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 159 | |
| 160 | /* Interface metric */ |
| 161 | int metric; |
| 162 | |
| 163 | /* Interface MTU. */ |
paul | c9eca01 | 2004-10-11 11:28:44 +0000 | [diff] [blame] | 164 | unsigned int mtu; /* IPv4 MTU */ |
| 165 | unsigned int mtu6; /* IPv6 MTU - probably, but not neccessarily same as mtu */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 166 | |
Timo Teräs | 954c7d6 | 2016-01-15 17:36:33 +0200 | [diff] [blame] | 167 | /* Link-layer information and hardware address */ |
| 168 | enum zebra_link_type ll_type; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 169 | u_char hw_addr[INTERFACE_HWADDR_MAX]; |
| 170 | int hw_addr_len; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 171 | |
| 172 | /* interface bandwidth, kbits */ |
| 173 | unsigned int bandwidth; |
| 174 | |
| 175 | /* description of the interface. */ |
| 176 | char *desc; |
| 177 | |
| 178 | /* Distribute list. */ |
| 179 | void *distribute_in; |
| 180 | void *distribute_out; |
| 181 | |
| 182 | /* Connected address list. */ |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 183 | struct list *connected; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 184 | |
| 185 | /* Daemon specific interface data pointer. */ |
| 186 | void *info; |
| 187 | |
| 188 | /* Statistics fileds. */ |
| 189 | #ifdef HAVE_PROC_NET_DEV |
| 190 | struct if_stats stats; |
| 191 | #endif /* HAVE_PROC_NET_DEV */ |
| 192 | #ifdef HAVE_NET_RT_IFLIST |
| 193 | struct if_data stats; |
| 194 | #endif /* HAVE_NET_RT_IFLIST */ |
Feng Lu | 2fc97f6 | 2015-05-22 11:39:57 +0200 | [diff] [blame] | 195 | |
| 196 | vrf_id_t vrf_id; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 197 | }; |
| 198 | |
| 199 | /* Connected address structure. */ |
| 200 | struct connected |
| 201 | { |
| 202 | /* Attached interface. */ |
| 203 | struct interface *ifp; |
| 204 | |
| 205 | /* Flags for configuration. */ |
| 206 | u_char conf; |
| 207 | #define ZEBRA_IFC_REAL (1 << 0) |
| 208 | #define ZEBRA_IFC_CONFIGURED (1 << 1) |
Christian Franke | f7f740f | 2013-01-24 14:04:48 +0000 | [diff] [blame] | 209 | #define ZEBRA_IFC_QUEUED (1 << 2) |
Andrew J. Schorr | 9c37851 | 2006-05-21 04:04:49 +0000 | [diff] [blame] | 210 | /* |
| 211 | The ZEBRA_IFC_REAL flag should be set if and only if this address |
Christian Franke | f7f740f | 2013-01-24 14:04:48 +0000 | [diff] [blame] | 212 | exists in the kernel and is actually usable. (A case where it exists but |
| 213 | is not yet usable would be IPv6 with DAD) |
Andrew J. Schorr | 9c37851 | 2006-05-21 04:04:49 +0000 | [diff] [blame] | 214 | The ZEBRA_IFC_CONFIGURED flag should be set if and only if this address |
| 215 | was configured by the user from inside quagga. |
Christian Franke | f7f740f | 2013-01-24 14:04:48 +0000 | [diff] [blame] | 216 | The ZEBRA_IFC_QUEUED flag should be set if and only if the address exists |
| 217 | in the kernel. It may and should be set although the address might not be |
| 218 | usable yet. (compare with ZEBRA_IFC_REAL) |
Andrew J. Schorr | 9c37851 | 2006-05-21 04:04:49 +0000 | [diff] [blame] | 219 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 220 | |
| 221 | /* Flags for connected address. */ |
| 222 | u_char flags; |
Andrew J. Schorr | e452963 | 2006-12-12 19:18:21 +0000 | [diff] [blame] | 223 | #define ZEBRA_IFA_SECONDARY (1 << 0) |
| 224 | #define ZEBRA_IFA_PEER (1 << 1) |
| 225 | /* N.B. the ZEBRA_IFA_PEER flag should be set if and only if |
| 226 | a peer address has been configured. If this flag is set, |
| 227 | the destination field must contain the peer address. |
| 228 | Otherwise, if this flag is not set, the destination address |
| 229 | will either contain a broadcast address or be NULL. |
| 230 | */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 231 | |
| 232 | /* Address of connected network. */ |
| 233 | struct prefix *address; |
Andrew J. Schorr | e452963 | 2006-12-12 19:18:21 +0000 | [diff] [blame] | 234 | |
| 235 | /* Peer or Broadcast address, depending on whether ZEBRA_IFA_PEER is set. |
| 236 | Note: destination may be NULL if ZEBRA_IFA_PEER is not set. */ |
| 237 | struct prefix *destination; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 238 | |
| 239 | /* Label for Linux 2.2.X and upper. */ |
| 240 | char *label; |
| 241 | }; |
| 242 | |
Andrew J. Schorr | e452963 | 2006-12-12 19:18:21 +0000 | [diff] [blame] | 243 | /* Does the destination field contain a peer address? */ |
| 244 | #define CONNECTED_PEER(C) CHECK_FLAG((C)->flags, ZEBRA_IFA_PEER) |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 245 | |
Andrew J. Schorr | e452963 | 2006-12-12 19:18:21 +0000 | [diff] [blame] | 246 | /* Prefix to insert into the RIB */ |
| 247 | #define CONNECTED_PREFIX(C) \ |
| 248 | (CONNECTED_PEER(C) ? (C)->destination : (C)->address) |
| 249 | |
| 250 | /* Identifying address. We guess that if there's a peer address, but the |
| 251 | local address is in the same prefix, then the local address may be unique. */ |
| 252 | #define CONNECTED_ID(C) \ |
| 253 | ((CONNECTED_PEER(C) && !prefix_match((C)->destination, (C)->address)) ?\ |
| 254 | (C)->destination : (C)->address) |
hasso | 3fb9cd6 | 2004-10-19 19:44:43 +0000 | [diff] [blame] | 255 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 256 | /* Interface hook sort. */ |
| 257 | #define IF_NEW_HOOK 0 |
| 258 | #define IF_DELETE_HOOK 1 |
| 259 | |
| 260 | /* There are some interface flags which are only supported by some |
| 261 | operating system. */ |
| 262 | |
| 263 | #ifndef IFF_NOTRAILERS |
| 264 | #define IFF_NOTRAILERS 0x0 |
| 265 | #endif /* IFF_NOTRAILERS */ |
| 266 | #ifndef IFF_OACTIVE |
| 267 | #define IFF_OACTIVE 0x0 |
| 268 | #endif /* IFF_OACTIVE */ |
| 269 | #ifndef IFF_SIMPLEX |
| 270 | #define IFF_SIMPLEX 0x0 |
| 271 | #endif /* IFF_SIMPLEX */ |
| 272 | #ifndef IFF_LINK0 |
| 273 | #define IFF_LINK0 0x0 |
| 274 | #endif /* IFF_LINK0 */ |
| 275 | #ifndef IFF_LINK1 |
| 276 | #define IFF_LINK1 0x0 |
| 277 | #endif /* IFF_LINK1 */ |
| 278 | #ifndef IFF_LINK2 |
| 279 | #define IFF_LINK2 0x0 |
| 280 | #endif /* IFF_LINK2 */ |
paul | 4ba9b92 | 2004-12-21 22:34:58 +0000 | [diff] [blame] | 281 | #ifndef IFF_NOXMIT |
| 282 | #define IFF_NOXMIT 0x0 |
| 283 | #endif /* IFF_NOXMIT */ |
| 284 | #ifndef IFF_NORTEXCH |
| 285 | #define IFF_NORTEXCH 0x0 |
| 286 | #endif /* IFF_NORTEXCH */ |
| 287 | #ifndef IFF_IPV4 |
| 288 | #define IFF_IPV4 0x0 |
| 289 | #endif /* IFF_IPV4 */ |
| 290 | #ifndef IFF_IPV6 |
| 291 | #define IFF_IPV6 0x0 |
| 292 | #endif /* IFF_IPV6 */ |
| 293 | #ifndef IFF_VIRTUAL |
| 294 | #define IFF_VIRTUAL 0x0 |
| 295 | #endif /* IFF_VIRTUAL */ |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 296 | |
| 297 | /* Prototypes. */ |
paul | 8cc4198 | 2005-05-06 21:25:49 +0000 | [diff] [blame] | 298 | extern int if_cmp_func (struct interface *, struct interface *); |
| 299 | extern struct interface *if_create (const char *name, int namelen); |
Paul Jakma | 9099f9b | 2016-01-18 10:12:10 +0000 | [diff] [blame] | 300 | extern struct interface *if_lookup_by_index (ifindex_t); |
paul | 8cc4198 | 2005-05-06 21:25:49 +0000 | [diff] [blame] | 301 | extern struct interface *if_lookup_exact_address (struct in_addr); |
| 302 | extern struct interface *if_lookup_address (struct in_addr); |
Dinesh Dutt | b81e97a | 2013-08-24 07:55:50 +0000 | [diff] [blame] | 303 | extern struct interface *if_lookup_prefix (struct prefix *prefix); |
ajs | a349198 | 2005-04-02 22:50:38 +0000 | [diff] [blame] | 304 | |
Feng Lu | 5a5702f | 2015-05-22 11:39:59 +0200 | [diff] [blame] | 305 | extern struct interface *if_create_vrf (const char *name, int namelen, |
| 306 | vrf_id_t vrf_id); |
Paul Jakma | 9099f9b | 2016-01-18 10:12:10 +0000 | [diff] [blame] | 307 | extern struct interface *if_lookup_by_index_vrf (ifindex_t, vrf_id_t vrf_id); |
Feng Lu | 5a5702f | 2015-05-22 11:39:59 +0200 | [diff] [blame] | 308 | extern struct interface *if_lookup_exact_address_vrf (struct in_addr, |
| 309 | vrf_id_t vrf_id); |
| 310 | extern struct interface *if_lookup_address_vrf (struct in_addr, |
| 311 | vrf_id_t vrf_id); |
| 312 | extern struct interface *if_lookup_prefix_vrf (struct prefix *prefix, |
| 313 | vrf_id_t vrf_id); |
| 314 | |
ajs | 08dbfb6 | 2005-04-03 03:40:52 +0000 | [diff] [blame] | 315 | /* These 2 functions are to be used when the ifname argument is terminated |
| 316 | by a '\0' character: */ |
paul | 8cc4198 | 2005-05-06 21:25:49 +0000 | [diff] [blame] | 317 | extern struct interface *if_lookup_by_name (const char *ifname); |
| 318 | extern struct interface *if_get_by_name (const char *ifname); |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 319 | |
Feng Lu | 5a5702f | 2015-05-22 11:39:59 +0200 | [diff] [blame] | 320 | extern struct interface *if_lookup_by_name_vrf (const char *ifname, |
| 321 | vrf_id_t vrf_id); |
| 322 | extern struct interface *if_get_by_name_vrf (const char *ifname, |
| 323 | vrf_id_t vrf_id); |
| 324 | |
ajs | 08dbfb6 | 2005-04-03 03:40:52 +0000 | [diff] [blame] | 325 | /* For these 2 functions, the namelen argument should be the precise length |
| 326 | of the ifname string (not counting any optional trailing '\0' character). |
| 327 | In most cases, strnlen should be used to calculate the namelen value. */ |
| 328 | extern struct interface *if_lookup_by_name_len(const char *ifname, |
Feng Lu | 5a5702f | 2015-05-22 11:39:59 +0200 | [diff] [blame] | 329 | size_t namelen); |
| 330 | extern struct interface *if_get_by_name_len(const char *ifname,size_t namelen); |
| 331 | |
| 332 | extern struct interface *if_lookup_by_name_len_vrf(const char *ifname, |
| 333 | size_t namelen, vrf_id_t vrf_id); |
| 334 | extern struct interface *if_get_by_name_len_vrf(const char *ifname, |
| 335 | size_t namelen, vrf_id_t vrf_id); |
ajs | a349198 | 2005-04-02 22:50:38 +0000 | [diff] [blame] | 336 | |
| 337 | |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 338 | /* Delete the interface, but do not free the structure, and leave it in the |
| 339 | interface list. It is often advisable to leave the pseudo interface |
| 340 | structure because there may be configuration information attached. */ |
| 341 | extern void if_delete_retain (struct interface *); |
| 342 | |
| 343 | /* Delete and free the interface structure: calls if_delete_retain and then |
| 344 | deletes it from the interface list and frees the structure. */ |
| 345 | extern void if_delete (struct interface *); |
| 346 | |
paul | 8cc4198 | 2005-05-06 21:25:49 +0000 | [diff] [blame] | 347 | extern int if_is_up (struct interface *); |
| 348 | extern int if_is_running (struct interface *); |
| 349 | extern int if_is_operative (struct interface *); |
| 350 | extern int if_is_loopback (struct interface *); |
| 351 | extern int if_is_broadcast (struct interface *); |
| 352 | extern int if_is_pointopoint (struct interface *); |
| 353 | extern int if_is_multicast (struct interface *); |
| 354 | extern void if_add_hook (int, int (*)(struct interface *)); |
Feng Lu | 5a5702f | 2015-05-22 11:39:59 +0200 | [diff] [blame] | 355 | extern void if_init (vrf_id_t, struct list **); |
| 356 | extern void if_terminate (vrf_id_t, struct list **); |
paul | 8cc4198 | 2005-05-06 21:25:49 +0000 | [diff] [blame] | 357 | extern void if_dump_all (void); |
ajs | 847947f | 2005-02-02 18:38:48 +0000 | [diff] [blame] | 358 | extern const char *if_flag_dump(unsigned long); |
Timo Teräs | 954c7d6 | 2016-01-15 17:36:33 +0200 | [diff] [blame] | 359 | extern const char *if_link_type_str (enum zebra_link_type); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 360 | |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 361 | /* Please use ifindex2ifname instead of if_indextoname where possible; |
| 362 | ifindex2ifname uses internal interface info, whereas if_indextoname must |
| 363 | make a system call. */ |
Paul Jakma | 9099f9b | 2016-01-18 10:12:10 +0000 | [diff] [blame] | 364 | extern const char *ifindex2ifname (ifindex_t); |
| 365 | extern const char *ifindex2ifname_vrf (ifindex_t, vrf_id_t vrf_id); |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 366 | |
| 367 | /* Please use ifname2ifindex instead of if_nametoindex where possible; |
| 368 | ifname2ifindex uses internal interface info, whereas if_nametoindex must |
| 369 | make a system call. */ |
Paul Jakma | 9099f9b | 2016-01-18 10:12:10 +0000 | [diff] [blame] | 370 | extern ifindex_t ifname2ifindex(const char *ifname); |
| 371 | extern ifindex_t ifname2ifindex_vrf(const char *ifname, vrf_id_t vrf_id); |
ajs | d2fc889 | 2005-04-02 18:38:43 +0000 | [diff] [blame] | 372 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 373 | /* Connected address functions. */ |
paul | 8cc4198 | 2005-05-06 21:25:49 +0000 | [diff] [blame] | 374 | extern struct connected *connected_new (void); |
| 375 | extern void connected_free (struct connected *); |
| 376 | extern void connected_add (struct interface *, struct connected *); |
| 377 | extern struct connected *connected_add_by_prefix (struct interface *, |
paul | 4a7aac1 | 2004-05-08 05:00:31 +0000 | [diff] [blame] | 378 | struct prefix *, |
| 379 | struct prefix *); |
paul | 8cc4198 | 2005-05-06 21:25:49 +0000 | [diff] [blame] | 380 | extern struct connected *connected_delete_by_prefix (struct interface *, |
paul | 4a7aac1 | 2004-05-08 05:00:31 +0000 | [diff] [blame] | 381 | struct prefix *); |
paul | 8cc4198 | 2005-05-06 21:25:49 +0000 | [diff] [blame] | 382 | extern struct connected *connected_lookup_address (struct interface *, |
paul | 4a7aac1 | 2004-05-08 05:00:31 +0000 | [diff] [blame] | 383 | struct in_addr); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 384 | |
| 385 | #ifndef HAVE_IF_NAMETOINDEX |
Paul Jakma | 9099f9b | 2016-01-18 10:12:10 +0000 | [diff] [blame] | 386 | extern ifindex_t if_nametoindex (const char *); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 387 | #endif |
| 388 | #ifndef HAVE_IF_INDEXTONAME |
Paul Jakma | 9099f9b | 2016-01-18 10:12:10 +0000 | [diff] [blame] | 389 | extern char *if_indextoname (ifindex_t, char *); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 390 | #endif |
| 391 | |
| 392 | /* Exported variables. */ |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 393 | extern struct list *iflist; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 394 | extern struct cmd_element interface_desc_cmd; |
| 395 | extern struct cmd_element no_interface_desc_cmd; |
| 396 | extern struct cmd_element interface_cmd; |
paul | 32d2463 | 2003-05-23 09:25:20 +0000 | [diff] [blame] | 397 | extern struct cmd_element no_interface_cmd; |
Feng Lu | 471ea39 | 2015-05-22 11:40:00 +0200 | [diff] [blame] | 398 | extern struct cmd_element interface_vrf_cmd; |
| 399 | extern struct cmd_element no_interface_vrf_cmd; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 400 | extern struct cmd_element interface_pseudo_cmd; |
| 401 | extern struct cmd_element no_interface_pseudo_cmd; |
Paul Jakma | 478ccfd | 2006-03-06 18:18:37 +0000 | [diff] [blame] | 402 | extern struct cmd_element show_address_cmd; |
Feng Lu | 5a5702f | 2015-05-22 11:39:59 +0200 | [diff] [blame] | 403 | extern struct cmd_element show_address_vrf_cmd; |
| 404 | extern struct cmd_element show_address_vrf_all_cmd; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 405 | |
| 406 | #endif /* _ZEBRA_IF_H */ |