version 1.1.1.2, 2013/07/21 23:54:39
|
version 1.1.1.3, 2016/11/02 10:09:10
|
Line 21 Boston, MA 02111-1307, USA. */
|
Line 21 Boston, MA 02111-1307, USA. */
|
#ifndef _ZEBRA_IF_H |
#ifndef _ZEBRA_IF_H |
#define _ZEBRA_IF_H |
#define _ZEBRA_IF_H |
|
|
|
#include "zebra.h" |
#include "linklist.h" |
#include "linklist.h" |
|
|
|
/* Interface link-layer type, if known. Derived from: |
|
* |
|
* net/if_arp.h on various platforms - Linux especially. |
|
* http://www.iana.org/assignments/arp-parameters/arp-parameters.xhtml |
|
* |
|
* Some of the more obviously defunct technologies left out. |
|
*/ |
|
enum zebra_link_type { |
|
ZEBRA_LLT_UNKNOWN = 0, |
|
ZEBRA_LLT_ETHER, |
|
ZEBRA_LLT_EETHER, |
|
ZEBRA_LLT_AX25, |
|
ZEBRA_LLT_PRONET, |
|
ZEBRA_LLT_IEEE802, |
|
ZEBRA_LLT_ARCNET, |
|
ZEBRA_LLT_APPLETLK, |
|
ZEBRA_LLT_DLCI, |
|
ZEBRA_LLT_ATM, |
|
ZEBRA_LLT_METRICOM, |
|
ZEBRA_LLT_IEEE1394, |
|
ZEBRA_LLT_EUI64, |
|
ZEBRA_LLT_INFINIBAND, |
|
ZEBRA_LLT_SLIP, |
|
ZEBRA_LLT_CSLIP, |
|
ZEBRA_LLT_SLIP6, |
|
ZEBRA_LLT_CSLIP6, |
|
ZEBRA_LLT_RSRVD, |
|
ZEBRA_LLT_ADAPT, |
|
ZEBRA_LLT_ROSE, |
|
ZEBRA_LLT_X25, |
|
ZEBRA_LLT_PPP, |
|
ZEBRA_LLT_CHDLC, |
|
ZEBRA_LLT_LAPB, |
|
ZEBRA_LLT_RAWHDLC, |
|
ZEBRA_LLT_IPIP, |
|
ZEBRA_LLT_IPIP6, |
|
ZEBRA_LLT_FRAD, |
|
ZEBRA_LLT_SKIP, |
|
ZEBRA_LLT_LOOPBACK, |
|
ZEBRA_LLT_LOCALTLK, |
|
ZEBRA_LLT_FDDI, |
|
ZEBRA_LLT_SIT, |
|
ZEBRA_LLT_IPDDP, |
|
ZEBRA_LLT_IPGRE, |
|
ZEBRA_LLT_IP6GRE, |
|
ZEBRA_LLT_PIMREG, |
|
ZEBRA_LLT_HIPPI, |
|
ZEBRA_LLT_ECONET, |
|
ZEBRA_LLT_IRDA, |
|
ZEBRA_LLT_FCPP, |
|
ZEBRA_LLT_FCAL, |
|
ZEBRA_LLT_FCPL, |
|
ZEBRA_LLT_FCFABRIC, |
|
ZEBRA_LLT_IEEE802_TR, |
|
ZEBRA_LLT_IEEE80211, |
|
ZEBRA_LLT_IEEE80211_RADIOTAP, |
|
ZEBRA_LLT_IEEE802154, |
|
ZEBRA_LLT_IEEE802154_PHY, |
|
}; |
|
|
/* |
/* |
Interface name length. |
Interface name length. |
|
|
Line 36 Boston, MA 02111-1307, USA. */
|
Line 97 Boston, MA 02111-1307, USA. */
|
#define INTERFACE_NAMSIZ 20 |
#define INTERFACE_NAMSIZ 20 |
#define INTERFACE_HWADDR_MAX 20 |
#define INTERFACE_HWADDR_MAX 20 |
|
|
|
typedef signed int ifindex_t; |
|
|
#ifdef HAVE_PROC_NET_DEV |
#ifdef HAVE_PROC_NET_DEV |
struct if_stats |
struct if_stats |
{ |
{ |
Line 82 struct interface
|
Line 145 struct interface
|
|
|
/* Interface index (should be IFINDEX_INTERNAL for non-kernel or |
/* Interface index (should be IFINDEX_INTERNAL for non-kernel or |
deleted interfaces). */ |
deleted interfaces). */ |
unsigned int ifindex; | ifindex_t ifindex; |
#define IFINDEX_INTERNAL 0 |
#define IFINDEX_INTERNAL 0 |
|
|
/* Zebra internal interface status */ |
/* Zebra internal interface status */ |
Line 101 struct interface
|
Line 164 struct interface
|
unsigned int mtu; /* IPv4 MTU */ |
unsigned int mtu; /* IPv4 MTU */ |
unsigned int mtu6; /* IPv6 MTU - probably, but not neccessarily same as mtu */ |
unsigned int mtu6; /* IPv6 MTU - probably, but not neccessarily same as mtu */ |
|
|
/* Hardware address. */ | /* Link-layer information and hardware address */ |
#ifdef HAVE_STRUCT_SOCKADDR_DL | enum zebra_link_type ll_type; |
union { | |
/* note that sdl_storage is never accessed, it only exists to make space. | |
* all actual uses refer to sdl - but use sizeof(sdl_storage)! this fits | |
* best with C aliasing rules. */ | |
struct sockaddr_dl sdl; | |
struct sockaddr_storage sdl_storage; | |
}; | |
#else | |
unsigned short hw_type; | |
u_char hw_addr[INTERFACE_HWADDR_MAX]; |
u_char hw_addr[INTERFACE_HWADDR_MAX]; |
int hw_addr_len; |
int hw_addr_len; |
#endif /* HAVE_STRUCT_SOCKADDR_DL */ |
|
|
|
/* interface bandwidth, kbits */ |
/* interface bandwidth, kbits */ |
unsigned int bandwidth; |
unsigned int bandwidth; |
Line 139 struct interface
|
Line 192 struct interface
|
#ifdef HAVE_NET_RT_IFLIST |
#ifdef HAVE_NET_RT_IFLIST |
struct if_data stats; |
struct if_data stats; |
#endif /* HAVE_NET_RT_IFLIST */ |
#endif /* HAVE_NET_RT_IFLIST */ |
|
|
|
vrf_id_t vrf_id; |
}; |
}; |
|
|
/* Connected address structure. */ |
/* Connected address structure. */ |
Line 151 struct connected
|
Line 206 struct connected
|
u_char conf; |
u_char conf; |
#define ZEBRA_IFC_REAL (1 << 0) |
#define ZEBRA_IFC_REAL (1 << 0) |
#define ZEBRA_IFC_CONFIGURED (1 << 1) |
#define ZEBRA_IFC_CONFIGURED (1 << 1) |
|
#define ZEBRA_IFC_QUEUED (1 << 2) |
/* |
/* |
The ZEBRA_IFC_REAL flag should be set if and only if this address |
The ZEBRA_IFC_REAL flag should be set if and only if this address |
exists in the kernel. | exists in the kernel and is actually usable. (A case where it exists but |
| is not yet usable would be IPv6 with DAD) |
The ZEBRA_IFC_CONFIGURED flag should be set if and only if this address |
The ZEBRA_IFC_CONFIGURED flag should be set if and only if this address |
was configured by the user from inside quagga. |
was configured by the user from inside quagga. |
|
The ZEBRA_IFC_QUEUED flag should be set if and only if the address exists |
|
in the kernel. It may and should be set although the address might not be |
|
usable yet. (compare with ZEBRA_IFC_REAL) |
*/ |
*/ |
|
|
/* Flags for connected address. */ |
/* Flags for connected address. */ |
Line 237 struct connected
|
Line 297 struct connected
|
/* Prototypes. */ |
/* Prototypes. */ |
extern int if_cmp_func (struct interface *, struct interface *); |
extern int if_cmp_func (struct interface *, struct interface *); |
extern struct interface *if_create (const char *name, int namelen); |
extern struct interface *if_create (const char *name, int namelen); |
extern struct interface *if_lookup_by_index (unsigned int); | extern struct interface *if_lookup_by_index (ifindex_t); |
extern struct interface *if_lookup_exact_address (struct in_addr); |
extern struct interface *if_lookup_exact_address (struct in_addr); |
extern struct interface *if_lookup_address (struct in_addr); |
extern struct interface *if_lookup_address (struct in_addr); |
|
extern struct interface *if_lookup_prefix (struct prefix *prefix); |
|
|
|
extern struct interface *if_create_vrf (const char *name, int namelen, |
|
vrf_id_t vrf_id); |
|
extern struct interface *if_lookup_by_index_vrf (ifindex_t, vrf_id_t vrf_id); |
|
extern struct interface *if_lookup_exact_address_vrf (struct in_addr, |
|
vrf_id_t vrf_id); |
|
extern struct interface *if_lookup_address_vrf (struct in_addr, |
|
vrf_id_t vrf_id); |
|
extern struct interface *if_lookup_prefix_vrf (struct prefix *prefix, |
|
vrf_id_t vrf_id); |
|
|
/* These 2 functions are to be used when the ifname argument is terminated |
/* These 2 functions are to be used when the ifname argument is terminated |
by a '\0' character: */ |
by a '\0' character: */ |
extern struct interface *if_lookup_by_name (const char *ifname); |
extern struct interface *if_lookup_by_name (const char *ifname); |
extern struct interface *if_get_by_name (const char *ifname); |
extern struct interface *if_get_by_name (const char *ifname); |
|
|
|
extern struct interface *if_lookup_by_name_vrf (const char *ifname, |
|
vrf_id_t vrf_id); |
|
extern struct interface *if_get_by_name_vrf (const char *ifname, |
|
vrf_id_t vrf_id); |
|
|
/* For these 2 functions, the namelen argument should be the precise length |
/* For these 2 functions, the namelen argument should be the precise length |
of the ifname string (not counting any optional trailing '\0' character). |
of the ifname string (not counting any optional trailing '\0' character). |
In most cases, strnlen should be used to calculate the namelen value. */ |
In most cases, strnlen should be used to calculate the namelen value. */ |
extern struct interface *if_lookup_by_name_len(const char *ifname, |
extern struct interface *if_lookup_by_name_len(const char *ifname, |
size_t namelen); | size_t namelen); |
extern struct interface *if_get_by_name_len(const char *ifname, size_t namelen); | extern struct interface *if_get_by_name_len(const char *ifname,size_t namelen); |
|
|
|
extern struct interface *if_lookup_by_name_len_vrf(const char *ifname, |
|
size_t namelen, vrf_id_t vrf_id); |
|
extern struct interface *if_get_by_name_len_vrf(const char *ifname, |
|
size_t namelen, vrf_id_t vrf_id); |
|
|
|
|
/* Delete the interface, but do not free the structure, and leave it in the |
/* Delete the interface, but do not free the structure, and leave it in the |
interface list. It is often advisable to leave the pseudo interface |
interface list. It is often advisable to leave the pseudo interface |
structure because there may be configuration information attached. */ |
structure because there may be configuration information attached. */ |
Line 271 extern int if_is_broadcast (struct interface *);
|
Line 352 extern int if_is_broadcast (struct interface *);
|
extern int if_is_pointopoint (struct interface *); |
extern int if_is_pointopoint (struct interface *); |
extern int if_is_multicast (struct interface *); |
extern int if_is_multicast (struct interface *); |
extern void if_add_hook (int, int (*)(struct interface *)); |
extern void if_add_hook (int, int (*)(struct interface *)); |
extern void if_init (void); | extern void if_init (vrf_id_t, struct list **); |
extern void if_terminate (void); | extern void if_terminate (vrf_id_t, struct list **); |
extern void if_dump_all (void); |
extern void if_dump_all (void); |
extern const char *if_flag_dump(unsigned long); |
extern const char *if_flag_dump(unsigned long); |
|
extern const char *if_link_type_str (enum zebra_link_type); |
|
|
/* Please use ifindex2ifname instead of if_indextoname where possible; |
/* Please use ifindex2ifname instead of if_indextoname where possible; |
ifindex2ifname uses internal interface info, whereas if_indextoname must |
ifindex2ifname uses internal interface info, whereas if_indextoname must |
make a system call. */ |
make a system call. */ |
extern const char *ifindex2ifname (unsigned int); | extern const char *ifindex2ifname (ifindex_t); |
| extern const char *ifindex2ifname_vrf (ifindex_t, vrf_id_t vrf_id); |
|
|
/* Please use ifname2ifindex instead of if_nametoindex where possible; |
/* Please use ifname2ifindex instead of if_nametoindex where possible; |
ifname2ifindex uses internal interface info, whereas if_nametoindex must |
ifname2ifindex uses internal interface info, whereas if_nametoindex must |
make a system call. */ |
make a system call. */ |
extern unsigned int ifname2ifindex(const char *ifname); | extern ifindex_t ifname2ifindex(const char *ifname); |
| extern ifindex_t ifname2ifindex_vrf(const char *ifname, vrf_id_t vrf_id); |
|
|
/* Connected address functions. */ |
/* Connected address functions. */ |
extern struct connected *connected_new (void); |
extern struct connected *connected_new (void); |
Line 299 extern struct connected *connected_lookup_address (st
|
Line 383 extern struct connected *connected_lookup_address (st
|
struct in_addr); |
struct in_addr); |
|
|
#ifndef HAVE_IF_NAMETOINDEX |
#ifndef HAVE_IF_NAMETOINDEX |
extern unsigned int if_nametoindex (const char *); | extern ifindex_t if_nametoindex (const char *); |
#endif |
#endif |
#ifndef HAVE_IF_INDEXTONAME |
#ifndef HAVE_IF_INDEXTONAME |
extern char *if_indextoname (unsigned int, char *); | extern char *if_indextoname (ifindex_t, char *); |
#endif |
#endif |
|
|
/* Exported variables. */ |
/* Exported variables. */ |
Line 311 extern struct cmd_element interface_desc_cmd;
|
Line 395 extern struct cmd_element interface_desc_cmd;
|
extern struct cmd_element no_interface_desc_cmd; |
extern struct cmd_element no_interface_desc_cmd; |
extern struct cmd_element interface_cmd; |
extern struct cmd_element interface_cmd; |
extern struct cmd_element no_interface_cmd; |
extern struct cmd_element no_interface_cmd; |
|
extern struct cmd_element interface_vrf_cmd; |
|
extern struct cmd_element no_interface_vrf_cmd; |
extern struct cmd_element interface_pseudo_cmd; |
extern struct cmd_element interface_pseudo_cmd; |
extern struct cmd_element no_interface_pseudo_cmd; |
extern struct cmd_element no_interface_pseudo_cmd; |
extern struct cmd_element show_address_cmd; |
extern struct cmd_element show_address_cmd; |
|
extern struct cmd_element show_address_vrf_cmd; |
|
extern struct cmd_element show_address_vrf_all_cmd; |
|
|
#endif /* _ZEBRA_IF_H */ |
#endif /* _ZEBRA_IF_H */ |