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