]>
Commit | Line | Data |
---|---|---|
718e3744 | 1 | /* Interface related header. |
896014f4 DL |
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 along | |
17 | * with this program; see the file COPYING; if not, write to the Free Software | |
18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | */ | |
718e3744 | 20 | |
21 | #ifndef _ZEBRA_IF_H | |
22 | #define _ZEBRA_IF_H | |
23 | ||
b892f1dd | 24 | #include "zebra.h" |
718e3744 | 25 | #include "linklist.h" |
4a1ab8e4 | 26 | #include "memory.h" |
e80e7cce | 27 | #include "qobj.h" |
ce19a04a | 28 | #include "hook.h" |
4a1ab8e4 DL |
29 | |
30 | DECLARE_MTYPE(IF) | |
31 | DECLARE_MTYPE(CONNECTED_LABEL) | |
718e3744 | 32 | |
8ccc7e80 TT |
33 | /* Interface link-layer type, if known. Derived from: |
34 | * | |
35 | * net/if_arp.h on various platforms - Linux especially. | |
36 | * http://www.iana.org/assignments/arp-parameters/arp-parameters.xhtml | |
37 | * | |
38 | * Some of the more obviously defunct technologies left out. | |
39 | */ | |
40 | enum zebra_link_type { | |
d62a17ae | 41 | ZEBRA_LLT_UNKNOWN = 0, |
42 | ZEBRA_LLT_ETHER, | |
43 | ZEBRA_LLT_EETHER, | |
44 | ZEBRA_LLT_AX25, | |
45 | ZEBRA_LLT_PRONET, | |
46 | ZEBRA_LLT_IEEE802, | |
47 | ZEBRA_LLT_ARCNET, | |
48 | ZEBRA_LLT_APPLETLK, | |
49 | ZEBRA_LLT_DLCI, | |
50 | ZEBRA_LLT_ATM, | |
51 | ZEBRA_LLT_METRICOM, | |
52 | ZEBRA_LLT_IEEE1394, | |
53 | ZEBRA_LLT_EUI64, | |
54 | ZEBRA_LLT_INFINIBAND, | |
55 | ZEBRA_LLT_SLIP, | |
56 | ZEBRA_LLT_CSLIP, | |
57 | ZEBRA_LLT_SLIP6, | |
58 | ZEBRA_LLT_CSLIP6, | |
59 | ZEBRA_LLT_RSRVD, | |
60 | ZEBRA_LLT_ADAPT, | |
61 | ZEBRA_LLT_ROSE, | |
62 | ZEBRA_LLT_X25, | |
63 | ZEBRA_LLT_PPP, | |
64 | ZEBRA_LLT_CHDLC, | |
65 | ZEBRA_LLT_LAPB, | |
66 | ZEBRA_LLT_RAWHDLC, | |
67 | ZEBRA_LLT_IPIP, | |
68 | ZEBRA_LLT_IPIP6, | |
69 | ZEBRA_LLT_FRAD, | |
70 | ZEBRA_LLT_SKIP, | |
71 | ZEBRA_LLT_LOOPBACK, | |
72 | ZEBRA_LLT_LOCALTLK, | |
73 | ZEBRA_LLT_FDDI, | |
74 | ZEBRA_LLT_SIT, | |
75 | ZEBRA_LLT_IPDDP, | |
76 | ZEBRA_LLT_IPGRE, | |
77 | ZEBRA_LLT_IP6GRE, | |
78 | ZEBRA_LLT_PIMREG, | |
79 | ZEBRA_LLT_HIPPI, | |
80 | ZEBRA_LLT_ECONET, | |
81 | ZEBRA_LLT_IRDA, | |
82 | ZEBRA_LLT_FCPP, | |
83 | ZEBRA_LLT_FCAL, | |
84 | ZEBRA_LLT_FCPL, | |
85 | ZEBRA_LLT_FCFABRIC, | |
86 | ZEBRA_LLT_IEEE802_TR, | |
87 | ZEBRA_LLT_IEEE80211, | |
88 | ZEBRA_LLT_IEEE80211_RADIOTAP, | |
89 | ZEBRA_LLT_IEEE802154, | |
90 | ZEBRA_LLT_IEEE802154_PHY, | |
8ccc7e80 TT |
91 | }; |
92 | ||
718e3744 | 93 | /* |
94 | Interface name length. | |
95 | ||
96 | Linux define value in /usr/include/linux/if.h. | |
97 | #define IFNAMSIZ 16 | |
98 | ||
99 | FreeBSD define value in /usr/include/net/if.h. | |
100 | #define IFNAMSIZ 16 | |
101 | */ | |
102 | ||
103 | #define INTERFACE_NAMSIZ 20 | |
104 | #define INTERFACE_HWADDR_MAX 20 | |
105 | ||
b892f1dd PJ |
106 | typedef signed int ifindex_t; |
107 | ||
718e3744 | 108 | #ifdef HAVE_PROC_NET_DEV |
d62a17ae | 109 | struct if_stats { |
110 | unsigned long rx_packets; /* total packets received */ | |
111 | unsigned long tx_packets; /* total packets transmitted */ | |
112 | unsigned long rx_bytes; /* total bytes received */ | |
113 | unsigned long tx_bytes; /* total bytes transmitted */ | |
114 | unsigned long rx_errors; /* bad packets received */ | |
115 | unsigned long tx_errors; /* packet transmit problems */ | |
116 | unsigned long rx_dropped; /* no space in linux buffers */ | |
117 | unsigned long tx_dropped; /* no space available in linux */ | |
118 | unsigned long rx_multicast; /* multicast packets received */ | |
119 | unsigned long rx_compressed; | |
120 | unsigned long tx_compressed; | |
121 | unsigned long collisions; | |
122 | ||
123 | /* detailed rx_errors: */ | |
124 | unsigned long rx_length_errors; | |
125 | unsigned long rx_over_errors; /* receiver ring buff overflow */ | |
126 | unsigned long rx_crc_errors; /* recved pkt with crc error */ | |
127 | unsigned long rx_frame_errors; /* recv'd frame alignment error */ | |
128 | unsigned long rx_fifo_errors; /* recv'r fifo overrun */ | |
129 | unsigned long rx_missed_errors; /* receiver missed packet */ | |
130 | /* detailed tx_errors */ | |
131 | unsigned long tx_aborted_errors; | |
132 | unsigned long tx_carrier_errors; | |
133 | unsigned long tx_fifo_errors; | |
134 | unsigned long tx_heartbeat_errors; | |
135 | unsigned long tx_window_errors; | |
718e3744 | 136 | }; |
137 | #endif /* HAVE_PROC_NET_DEV */ | |
138 | ||
16f1b9ee OD |
139 | /* Here are "non-official" architectural constants. */ |
140 | #define TE_EXT_MASK 0x0FFFFFFF | |
141 | #define TE_EXT_ANORMAL 0x80000000 | |
142 | #define LOSS_PRECISION 0.000003 | |
143 | #define TE_KILO_BIT 1000 | |
144 | #define TE_BYTE 8 | |
145 | #define DEFAULT_BANDWIDTH 10000 | |
146 | #define MAX_CLASS_TYPE 8 | |
147 | #define MAX_PKT_LOSS 50.331642 | |
148 | ||
daf0a4d2 OD |
149 | /* |
150 | * Link Parameters Status: | |
151 | * equal to 0: unset | |
152 | * different from 0: set | |
153 | */ | |
16f1b9ee | 154 | #define LP_UNSET 0x0000 |
daf0a4d2 | 155 | #define LP_TE_METRIC 0x0001 |
16f1b9ee OD |
156 | #define LP_MAX_BW 0x0002 |
157 | #define LP_MAX_RSV_BW 0x0004 | |
158 | #define LP_UNRSV_BW 0x0008 | |
159 | #define LP_ADM_GRP 0x0010 | |
160 | #define LP_RMT_AS 0x0020 | |
161 | #define LP_DELAY 0x0040 | |
162 | #define LP_MM_DELAY 0x0080 | |
163 | #define LP_DELAY_VAR 0x0100 | |
164 | #define LP_PKT_LOSS 0x0200 | |
165 | #define LP_RES_BW 0x0400 | |
166 | #define LP_AVA_BW 0x0800 | |
167 | #define LP_USE_BW 0x1000 | |
168 | ||
169 | #define IS_PARAM_UNSET(lp, st) !(lp->lp_status & st) | |
170 | #define IS_PARAM_SET(lp, st) (lp->lp_status & st) | |
171 | #define IS_LINK_PARAMS_SET(lp) (lp->lp_status != LP_UNSET) | |
172 | ||
173 | #define SET_PARAM(lp, st) (lp->lp_status) |= (st) | |
174 | #define UNSET_PARAM(lp, st) (lp->lp_status) &= ~(st) | |
175 | #define RESET_LINK_PARAM(lp) (lp->lp_status = LP_UNSET) | |
176 | ||
177 | /* Link Parameters for Traffic Engineering */ | |
178 | struct if_link_params { | |
d7c0a89a QY |
179 | uint32_t lp_status; /* Status of Link Parameters: */ |
180 | uint32_t te_metric; /* Traffic Engineering metric */ | |
d62a17ae | 181 | float default_bw; |
182 | float max_bw; /* Maximum Bandwidth */ | |
183 | float max_rsv_bw; /* Maximum Reservable Bandwidth */ | |
184 | float unrsv_bw[MAX_CLASS_TYPE]; /* Unreserved Bandwidth per Class Type | |
185 | (8) */ | |
d7c0a89a QY |
186 | uint32_t admin_grp; /* Administrative group */ |
187 | uint32_t rmt_as; /* Remote AS number */ | |
d62a17ae | 188 | struct in_addr rmt_ip; /* Remote IP address */ |
d7c0a89a QY |
189 | uint32_t av_delay; /* Link Average Delay */ |
190 | uint32_t min_delay; /* Link Min Delay */ | |
191 | uint32_t max_delay; /* Link Max Delay */ | |
192 | uint32_t delay_var; /* Link Delay Variation */ | |
d62a17ae | 193 | float pkt_loss; /* Link Packet Loss */ |
194 | float res_bw; /* Residual Bandwidth */ | |
195 | float ava_bw; /* Available Bandwidth */ | |
196 | float use_bw; /* Utilized Bandwidth */ | |
16f1b9ee OD |
197 | }; |
198 | ||
199 | #define INTERFACE_LINK_PARAMS_SIZE sizeof(struct if_link_params) | |
200 | #define HAS_LINK_PARAMS(ifp) ((ifp)->link_params != NULL) | |
201 | ||
718e3744 | 202 | /* Interface structure */ |
d62a17ae | 203 | struct interface { |
ff880b78 | 204 | RB_ENTRY(interface) name_entry, index_entry; |
f4e14fdb | 205 | |
d62a17ae | 206 | /* Interface name. This should probably never be changed after the |
207 | interface is created, because the configuration info for this | |
208 | interface | |
209 | is associated with this structure. For that reason, the interface | |
210 | should also never be deleted (to avoid losing configuration info). | |
211 | To delete, just set ifindex to IFINDEX_INTERNAL to indicate that the | |
212 | interface does not exist in the kernel. | |
213 | */ | |
bcc24579 | 214 | char name[INTERFACE_NAMSIZ]; |
d62a17ae | 215 | |
216 | /* Interface index (should be IFINDEX_INTERNAL for non-kernel or | |
ff880b78 RW |
217 | deleted interfaces). |
218 | WARNING: the ifindex needs to be changed using the if_set_index() | |
219 | function. Failure to respect this will cause corruption in the data | |
220 | structure used to store the interfaces and if_lookup_by_index() will | |
221 | not work as expected. | |
222 | */ | |
d62a17ae | 223 | ifindex_t ifindex; |
d2fc8896 | 224 | #define IFINDEX_INTERNAL 0 |
718e3744 | 225 | |
d62a17ae | 226 | /* Zebra internal interface status */ |
d7c0a89a | 227 | uint8_t status; |
718e3744 | 228 | #define ZEBRA_INTERFACE_ACTIVE (1 << 0) |
229 | #define ZEBRA_INTERFACE_SUB (1 << 1) | |
2e3b2e47 | 230 | #define ZEBRA_INTERFACE_LINKDETECTION (1 << 2) |
c23af4d3 | 231 | #define ZEBRA_INTERFACE_VRF_LOOPBACK (1 << 3) |
525c1839 | 232 | |
d62a17ae | 233 | /* Interface flags. */ |
234 | uint64_t flags; | |
718e3744 | 235 | |
d62a17ae | 236 | /* Interface metric */ |
237 | uint32_t metric; | |
718e3744 | 238 | |
d62a17ae | 239 | /* Interface Speed in Mb/s */ |
240 | uint32_t speed; | |
2d7f0d76 | 241 | |
d62a17ae | 242 | /* Interface MTU. */ |
243 | unsigned int mtu; /* IPv4 MTU */ | |
244 | unsigned int | |
245 | mtu6; /* IPv6 MTU - probably, but not neccessarily same as mtu | |
9d303b37 | 246 | */ |
718e3744 | 247 | |
d62a17ae | 248 | /* Link-layer information and hardware address */ |
249 | enum zebra_link_type ll_type; | |
d7c0a89a | 250 | uint8_t hw_addr[INTERFACE_HWADDR_MAX]; |
d62a17ae | 251 | int hw_addr_len; |
718e3744 | 252 | |
d62a17ae | 253 | /* interface bandwidth, kbits */ |
254 | unsigned int bandwidth; | |
16f1b9ee | 255 | |
d62a17ae | 256 | /* Link parameters for Traffic Engineering */ |
257 | struct if_link_params *link_params; | |
718e3744 | 258 | |
d62a17ae | 259 | /* description of the interface. */ |
260 | char *desc; | |
718e3744 | 261 | |
d62a17ae | 262 | /* Distribute list. */ |
263 | void *distribute_in; | |
264 | void *distribute_out; | |
718e3744 | 265 | |
d62a17ae | 266 | /* Connected address list. */ |
267 | struct list *connected; | |
a80beece | 268 | |
d62a17ae | 269 | /* Neighbor connected address list. */ |
270 | struct list *nbr_connected; | |
718e3744 | 271 | |
d62a17ae | 272 | /* Daemon specific interface data pointer. */ |
273 | void *info; | |
244c1cdc | 274 | |
d62a17ae | 275 | char ptm_enable; /* Should we look at ptm_status ? */ |
276 | char ptm_status; | |
277 | ||
278 | /* Statistics fileds. */ | |
718e3744 | 279 | #ifdef HAVE_PROC_NET_DEV |
d62a17ae | 280 | struct if_stats stats; |
281 | #endif /* HAVE_PROC_NET_DEV */ | |
718e3744 | 282 | #ifdef HAVE_NET_RT_IFLIST |
d62a17ae | 283 | struct if_data stats; |
718e3744 | 284 | #endif /* HAVE_NET_RT_IFLIST */ |
3968dbf8 | 285 | |
d62a17ae | 286 | struct route_node *node; |
287 | vrf_id_t vrf_id; | |
e80e7cce | 288 | |
d62a17ae | 289 | QOBJ_FIELDS |
718e3744 | 290 | }; |
0c74bbe0 | 291 | |
f4e14fdb RW |
292 | RB_HEAD(if_name_head, interface); |
293 | RB_PROTOTYPE(if_name_head, interface, name_entry, if_cmp_func); | |
ff880b78 RW |
294 | RB_HEAD(if_index_head, interface); |
295 | RB_PROTOTYPE(if_index_head, interface, index_entry, if_cmp_func); | |
e80e7cce | 296 | DECLARE_QOBJ_TYPE(interface) |
718e3744 | 297 | |
ff880b78 RW |
298 | #define IFNAME_RB_INSERT(vrf, ifp) \ |
299 | if (RB_INSERT(if_name_head, &vrf->ifaces_by_name, (ifp))) \ | |
300 | zlog_err( \ | |
301 | "%s(%s): corruption detected -- interface with this " \ | |
302 | "name exists already in VRF %u!", \ | |
303 | __func__, (ifp)->name, (ifp)->vrf_id); | |
304 | ||
305 | #define IFNAME_RB_REMOVE(vrf, ifp) \ | |
306 | if (RB_REMOVE(if_name_head, &vrf->ifaces_by_name, (ifp)) == NULL) \ | |
307 | zlog_err( \ | |
308 | "%s(%s): corruption detected -- interface with this " \ | |
309 | "name doesn't exist in VRF %u!", \ | |
310 | __func__, (ifp)->name, (ifp)->vrf_id); | |
311 | ||
312 | #define IFINDEX_RB_INSERT(vrf, ifp) \ | |
313 | if (RB_INSERT(if_index_head, &vrf->ifaces_by_index, (ifp))) \ | |
314 | zlog_err( \ | |
315 | "%s(%u): corruption detected -- interface with this " \ | |
316 | "ifindex exists already in VRF %u!", \ | |
317 | __func__, (ifp)->ifindex, (ifp)->vrf_id); | |
318 | ||
319 | #define IFINDEX_RB_REMOVE(vrf, ifp) \ | |
320 | if (RB_REMOVE(if_index_head, &vrf->ifaces_by_index, (ifp)) == NULL) \ | |
321 | zlog_err( \ | |
322 | "%s(%u): corruption detected -- interface with this " \ | |
323 | "ifindex doesn't exist in VRF %u!", \ | |
324 | __func__, (ifp)->ifindex, (ifp)->vrf_id); | |
325 | ||
451fda4f RW |
326 | #define FOR_ALL_INTERFACES(vrf, ifp) \ |
327 | if (vrf) \ | |
328 | RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) | |
329 | ||
330 | #define FOR_ALL_INTERFACES_ADDRESSES(ifp, connected, node) \ | |
331 | for (ALL_LIST_ELEMENTS_RO(ifp->connected, node, connected)) | |
332 | ||
ce19a04a DL |
333 | /* called from the library code whenever interfaces are created/deleted |
334 | * note: interfaces may not be fully realized at that point; also they | |
335 | * may not exist in the system (ifindex = IFINDEX_INTERNAL) | |
336 | * | |
337 | * priority values are important here, daemons should be at 0 while modules | |
338 | * can use 1000+ so they run after the daemon has initialised daemon-specific | |
339 | * interface data | |
340 | */ | |
996c9314 LB |
341 | DECLARE_HOOK(if_add, (struct interface * ifp), (ifp)) |
342 | DECLARE_KOOH(if_del, (struct interface * ifp), (ifp)) | |
ce19a04a | 343 | |
718e3744 | 344 | /* Connected address structure. */ |
d62a17ae | 345 | struct connected { |
346 | /* Attached interface. */ | |
347 | struct interface *ifp; | |
718e3744 | 348 | |
d62a17ae | 349 | /* Flags for configuration. */ |
d7c0a89a | 350 | uint8_t conf; |
718e3744 | 351 | #define ZEBRA_IFC_REAL (1 << 0) |
352 | #define ZEBRA_IFC_CONFIGURED (1 << 1) | |
f7f740fe | 353 | #define ZEBRA_IFC_QUEUED (1 << 2) |
d62a17ae | 354 | /* |
355 | The ZEBRA_IFC_REAL flag should be set if and only if this address | |
356 | exists in the kernel and is actually usable. (A case where it exists | |
357 | but | |
358 | is not yet usable would be IPv6 with DAD) | |
359 | The ZEBRA_IFC_CONFIGURED flag should be set if and only if this | |
360 | address | |
361 | was configured by the user from inside quagga. | |
362 | The ZEBRA_IFC_QUEUED flag should be set if and only if the address | |
363 | exists | |
364 | in the kernel. It may and should be set although the address might | |
365 | not be | |
366 | usable yet. (compare with ZEBRA_IFC_REAL) | |
367 | */ | |
368 | ||
369 | /* Flags for connected address. */ | |
d7c0a89a | 370 | uint8_t flags; |
e4529636 AS |
371 | #define ZEBRA_IFA_SECONDARY (1 << 0) |
372 | #define ZEBRA_IFA_PEER (1 << 1) | |
525c1839 | 373 | #define ZEBRA_IFA_UNNUMBERED (1 << 2) |
d62a17ae | 374 | /* N.B. the ZEBRA_IFA_PEER flag should be set if and only if |
375 | a peer address has been configured. If this flag is set, | |
376 | the destination field must contain the peer address. | |
377 | Otherwise, if this flag is not set, the destination address | |
378 | will either contain a broadcast address or be NULL. | |
379 | */ | |
380 | ||
381 | /* Address of connected network. */ | |
382 | struct prefix *address; | |
383 | ||
384 | /* Peer or Broadcast address, depending on whether ZEBRA_IFA_PEER is | |
385 | set. | |
386 | Note: destination may be NULL if ZEBRA_IFA_PEER is not set. */ | |
387 | struct prefix *destination; | |
388 | ||
389 | /* Label for Linux 2.2.X and upper. */ | |
390 | char *label; | |
718e3744 | 391 | }; |
392 | ||
a80beece | 393 | /* Nbr Connected address structure. */ |
d62a17ae | 394 | struct nbr_connected { |
395 | /* Attached interface. */ | |
396 | struct interface *ifp; | |
a80beece | 397 | |
d62a17ae | 398 | /* Address of connected network. */ |
399 | struct prefix *address; | |
a80beece DS |
400 | }; |
401 | ||
e4529636 AS |
402 | /* Does the destination field contain a peer address? */ |
403 | #define CONNECTED_PEER(C) CHECK_FLAG((C)->flags, ZEBRA_IFA_PEER) | |
404 | ||
405 | /* Prefix to insert into the RIB */ | |
d62a17ae | 406 | #define CONNECTED_PREFIX(C) \ |
e4529636 | 407 | (CONNECTED_PEER(C) ? (C)->destination : (C)->address) |
3fb9cd6e | 408 | |
e4529636 AS |
409 | /* Identifying address. We guess that if there's a peer address, but the |
410 | local address is in the same prefix, then the local address may be unique. */ | |
d62a17ae | 411 | #define CONNECTED_ID(C) \ |
412 | ((CONNECTED_PEER(C) && !prefix_match((C)->destination, (C)->address)) \ | |
413 | ? (C)->destination \ | |
414 | : (C)->address) | |
3fb9cd6e | 415 | |
718e3744 | 416 | /* There are some interface flags which are only supported by some |
417 | operating system. */ | |
418 | ||
419 | #ifndef IFF_NOTRAILERS | |
420 | #define IFF_NOTRAILERS 0x0 | |
421 | #endif /* IFF_NOTRAILERS */ | |
422 | #ifndef IFF_OACTIVE | |
423 | #define IFF_OACTIVE 0x0 | |
424 | #endif /* IFF_OACTIVE */ | |
425 | #ifndef IFF_SIMPLEX | |
426 | #define IFF_SIMPLEX 0x0 | |
427 | #endif /* IFF_SIMPLEX */ | |
428 | #ifndef IFF_LINK0 | |
429 | #define IFF_LINK0 0x0 | |
430 | #endif /* IFF_LINK0 */ | |
431 | #ifndef IFF_LINK1 | |
432 | #define IFF_LINK1 0x0 | |
433 | #endif /* IFF_LINK1 */ | |
434 | #ifndef IFF_LINK2 | |
435 | #define IFF_LINK2 0x0 | |
436 | #endif /* IFF_LINK2 */ | |
4ba9b924 | 437 | #ifndef IFF_NOXMIT |
438 | #define IFF_NOXMIT 0x0 | |
439 | #endif /* IFF_NOXMIT */ | |
440 | #ifndef IFF_NORTEXCH | |
441 | #define IFF_NORTEXCH 0x0 | |
442 | #endif /* IFF_NORTEXCH */ | |
443 | #ifndef IFF_IPV4 | |
444 | #define IFF_IPV4 0x0 | |
445 | #endif /* IFF_IPV4 */ | |
446 | #ifndef IFF_IPV6 | |
447 | #define IFF_IPV6 0x0 | |
448 | #endif /* IFF_IPV6 */ | |
449 | #ifndef IFF_VIRTUAL | |
450 | #define IFF_VIRTUAL 0x0 | |
451 | #endif /* IFF_VIRTUAL */ | |
718e3744 | 452 | |
453 | /* Prototypes. */ | |
d62a17ae | 454 | extern int if_cmp_name_func(char *, char *); |
455 | ||
14fcc65c DS |
456 | /* |
457 | * Passing in VRF_UNKNOWN is a valid thing to do, unless we | |
458 | * are creating a new interface. | |
459 | * | |
460 | * This is useful for vrf route-leaking. So more than anything | |
461 | * else think before you use VRF_UNKNOWN | |
462 | */ | |
d62a17ae | 463 | extern void if_update_to_new_vrf(struct interface *, vrf_id_t vrf_id); |
996c9314 | 464 | extern struct interface *if_create(const char *name, vrf_id_t vrf_id); |
d62a17ae | 465 | extern struct interface *if_lookup_by_index(ifindex_t, vrf_id_t vrf_id); |
466 | extern struct interface *if_lookup_exact_address(void *matchaddr, int family, | |
467 | vrf_id_t vrf_id); | |
468 | extern struct connected *if_lookup_address(void *matchaddr, int family, | |
469 | vrf_id_t vrf_id); | |
470 | extern struct interface *if_lookup_prefix(struct prefix *prefix, | |
471 | vrf_id_t vrf_id); | |
8736158a | 472 | |
92a57eb2 | 473 | /* These 3 functions are to be used when the ifname argument is terminated |
08dbfb69 | 474 | by a '\0' character: */ |
d62a17ae | 475 | extern struct interface *if_lookup_by_name_all_vrf(const char *ifname); |
476 | extern struct interface *if_lookup_by_name(const char *ifname, vrf_id_t vrf_id); | |
bcc24579 RW |
477 | extern struct interface *if_get_by_name(const char *ifname, vrf_id_t vrf_id, |
478 | int vty); | |
ff880b78 | 479 | extern void if_set_index(struct interface *ifp, ifindex_t ifindex); |
a349198f | 480 | |
d2fc8896 | 481 | /* Delete the interface, but do not free the structure, and leave it in the |
d62a17ae | 482 | interface list. It is often advisable to leave the pseudo interface |
d2fc8896 | 483 | structure because there may be configuration information attached. */ |
d62a17ae | 484 | extern void if_delete_retain(struct interface *); |
d2fc8896 | 485 | |
486 | /* Delete and free the interface structure: calls if_delete_retain and then | |
487 | deletes it from the interface list and frees the structure. */ | |
d62a17ae | 488 | extern void if_delete(struct interface *); |
489 | ||
490 | extern int if_is_up(struct interface *); | |
491 | extern int if_is_running(struct interface *); | |
492 | extern int if_is_operative(struct interface *); | |
493 | extern int if_is_no_ptm_operative(struct interface *); | |
494 | extern int if_is_loopback(struct interface *); | |
0c74bbe0 | 495 | extern int if_is_vrf(struct interface *ifp); |
d62a17ae | 496 | extern int if_is_broadcast(struct interface *); |
497 | extern int if_is_pointopoint(struct interface *); | |
498 | extern int if_is_multicast(struct interface *); | |
d62a17ae | 499 | extern void if_cmd_init(void); |
f4e14fdb RW |
500 | struct vrf; |
501 | extern void if_terminate(struct vrf *vrf); | |
d62a17ae | 502 | extern void if_dump_all(void); |
847947f2 | 503 | extern const char *if_flag_dump(unsigned long); |
d62a17ae | 504 | extern const char *if_link_type_str(enum zebra_link_type); |
718e3744 | 505 | |
d2fc8896 | 506 | /* Please use ifindex2ifname instead of if_indextoname where possible; |
507 | ifindex2ifname uses internal interface info, whereas if_indextoname must | |
508 | make a system call. */ | |
d62a17ae | 509 | extern const char *ifindex2ifname(ifindex_t, vrf_id_t vrf_id); |
d2fc8896 | 510 | |
511 | /* Please use ifname2ifindex instead of if_nametoindex where possible; | |
512 | ifname2ifindex uses internal interface info, whereas if_nametoindex must | |
513 | make a system call. */ | |
128c2be2 | 514 | extern ifindex_t ifname2ifindex(const char *ifname, vrf_id_t vrf_id); |
d2fc8896 | 515 | |
718e3744 | 516 | /* Connected address functions. */ |
d62a17ae | 517 | extern struct connected *connected_new(void); |
518 | extern void connected_free(struct connected *); | |
519 | extern void connected_add(struct interface *, struct connected *); | |
520 | extern struct connected * | |
521 | connected_add_by_prefix(struct interface *, struct prefix *, struct prefix *); | |
522 | extern struct connected *connected_delete_by_prefix(struct interface *, | |
523 | struct prefix *); | |
524 | extern struct connected *connected_lookup_prefix(struct interface *, | |
525 | struct prefix *); | |
526 | extern struct connected *connected_lookup_prefix_exact(struct interface *, | |
527 | struct prefix *); | |
528 | extern struct nbr_connected *nbr_connected_new(void); | |
529 | extern void nbr_connected_free(struct nbr_connected *); | |
530 | struct nbr_connected *nbr_connected_check(struct interface *, struct prefix *); | |
718e3744 | 531 | |
16f1b9ee | 532 | /* link parameters */ |
d62a17ae | 533 | struct if_link_params *if_link_params_get(struct interface *); |
534 | void if_link_params_free(struct interface *); | |
16f1b9ee | 535 | |
718e3744 | 536 | #endif /* _ZEBRA_IF_H */ |