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