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