1 /* Interface related header.
2 Copyright (C) 1997, 98, 99 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
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.
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.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
27 Interface name length.
29 Linux define value in /usr/include/linux/if.h.
32 FreeBSD define value in /usr/include/net/if.h.
36 #define INTERFACE_NAMSIZ 20
37 #define INTERFACE_HWADDR_MAX 20
39 /* Internal If indexes start at 0xFFFFFFFF and go down to 1 greater
41 #define IFINDEX_INTERNBASE 0x80000000
43 #ifdef HAVE_PROC_NET_DEV
46 unsigned long rx_packets; /* total packets received */
47 unsigned long tx_packets; /* total packets transmitted */
48 unsigned long rx_bytes; /* total bytes received */
49 unsigned long tx_bytes; /* total bytes transmitted */
50 unsigned long rx_errors; /* bad packets received */
51 unsigned long tx_errors; /* packet transmit problems */
52 unsigned long rx_dropped; /* no space in linux buffers */
53 unsigned long tx_dropped; /* no space available in linux */
54 unsigned long rx_multicast; /* multicast packets received */
55 unsigned long rx_compressed;
56 unsigned long tx_compressed;
57 unsigned long collisions;
59 /* detailed rx_errors: */
60 unsigned long rx_length_errors;
61 unsigned long rx_over_errors; /* receiver ring buff overflow */
62 unsigned long rx_crc_errors; /* recved pkt with crc error */
63 unsigned long rx_frame_errors; /* recv'd frame alignment error */
64 unsigned long rx_fifo_errors; /* recv'r fifo overrun */
65 unsigned long rx_missed_errors; /* receiver missed packet */
66 /* detailed tx_errors */
67 unsigned long tx_aborted_errors;
68 unsigned long tx_carrier_errors;
69 unsigned long tx_fifo_errors;
70 unsigned long tx_heartbeat_errors;
71 unsigned long tx_window_errors;
73 #endif /* HAVE_PROC_NET_DEV */
75 /* Interface structure */
79 char name[INTERFACE_NAMSIZ + 1];
81 /* Interface index. */
84 /* Zebra internal interface status */
86 #define ZEBRA_INTERFACE_ACTIVE (1 << 0)
87 #define ZEBRA_INTERFACE_SUB (1 << 1)
89 /* Interface flags. */
92 /* Interface metric */
98 /* Hardware address. */
99 #ifdef HAVE_SOCKADDR_DL
100 struct sockaddr_dl sdl;
102 unsigned short hw_type;
103 u_char hw_addr[INTERFACE_HWADDR_MAX];
105 #endif /* HAVE_SOCKADDR_DL */
107 /* interface bandwidth, kbits */
108 unsigned int bandwidth;
110 /* description of the interface. */
113 /* Distribute list. */
115 void *distribute_out;
117 /* Connected address list. */
120 /* Daemon specific interface data pointer. */
123 /* Statistics fileds. */
124 #ifdef HAVE_PROC_NET_DEV
125 struct if_stats stats;
126 #endif /* HAVE_PROC_NET_DEV */
127 #ifdef HAVE_NET_RT_IFLIST
128 struct if_data stats;
129 #endif /* HAVE_NET_RT_IFLIST */
132 /* Connected address structure. */
135 /* Attached interface. */
136 struct interface *ifp;
138 /* Flags for configuration. */
140 #define ZEBRA_IFC_REAL (1 << 0)
141 #define ZEBRA_IFC_CONFIGURED (1 << 1)
143 /* Flags for connected address. */
145 #define ZEBRA_IFA_SECONDARY (1 << 0)
147 /* Address of connected network. */
148 struct prefix *address;
149 struct prefix *destination;
151 /* Label for Linux 2.2.X and upper. */
155 /* Interface hook sort. */
156 #define IF_NEW_HOOK 0
157 #define IF_DELETE_HOOK 1
159 /* There are some interface flags which are only supported by some
162 #ifndef IFF_NOTRAILERS
163 #define IFF_NOTRAILERS 0x0
164 #endif /* IFF_NOTRAILERS */
166 #define IFF_OACTIVE 0x0
167 #endif /* IFF_OACTIVE */
169 #define IFF_SIMPLEX 0x0
170 #endif /* IFF_SIMPLEX */
172 #define IFF_LINK0 0x0
173 #endif /* IFF_LINK0 */
175 #define IFF_LINK1 0x0
176 #endif /* IFF_LINK1 */
178 #define IFF_LINK2 0x0
179 #endif /* IFF_LINK2 */
182 struct interface *if_new (void);
183 struct interface *if_create (void);
184 struct interface *if_lookup_by_index (unsigned int);
185 struct interface *if_lookup_by_name (char *);
186 struct interface *if_lookup_exact_address (struct in_addr);
187 struct interface *if_lookup_address (struct in_addr);
188 struct interface *if_get_by_name (char *);
189 void if_delete (struct interface *);
190 int if_is_up (struct interface *);
191 int if_is_loopback (struct interface *);
192 int if_is_broadcast (struct interface *);
193 int if_is_pointopoint (struct interface *);
194 int if_is_multicast (struct interface *);
195 void if_add_hook (int, int (*)(struct interface *));
198 char *ifindex2ifname (unsigned int);
200 /* Connected address functions. */
201 struct connected *connected_new ();
202 void connected_free (struct connected *);
203 void connected_add (struct interface *, struct connected *);
204 struct connected *connected_delete_by_prefix (struct interface *, struct prefix *);
205 int ifc_pointopoint (struct connected *);
207 #ifndef HAVE_IF_NAMETOINDEX
208 unsigned int if_nametoindex (const char *);
210 #ifndef HAVE_IF_INDEXTONAME
211 char *if_indextoname (unsigned int, char *);
214 /* Exported variables. */
216 extern struct cmd_element interface_desc_cmd;
217 extern struct cmd_element no_interface_desc_cmd;
218 extern struct cmd_element interface_cmd;
219 extern struct cmd_element interface_pseudo_cmd;
220 extern struct cmd_element no_interface_pseudo_cmd;
222 #endif /* _ZEBRA_IF_H */