2006-08-08 16:33:33 +04:00
|
|
|
/*
|
2012-07-19 22:11:40 +04:00
|
|
|
* Copyright 2006-2012 Haiku, Inc. All Rights Reserved.
|
2006-08-08 16:33:33 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
2002-07-09 16:24:59 +04:00
|
|
|
*/
|
2002-07-12 13:37:43 +04:00
|
|
|
#ifndef _NET_IF_H
|
|
|
|
#define _NET_IF_H
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2003-12-01 16:15:03 +03:00
|
|
|
|
2002-07-12 13:37:43 +04:00
|
|
|
#include <net/route.h>
|
2006-08-08 16:33:33 +04:00
|
|
|
#include <sys/socket.h>
|
2002-07-12 13:37:43 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2006-08-08 16:33:33 +04:00
|
|
|
#define IF_NAMESIZE 32
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2006-08-08 16:33:33 +04:00
|
|
|
/* BSD specific/proprietary part */
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2006-08-08 16:33:33 +04:00
|
|
|
#define IFNAMSIZ IF_NAMESIZE
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2006-08-08 16:33:33 +04:00
|
|
|
struct ifreq_stream_stats {
|
|
|
|
uint32_t packets;
|
|
|
|
uint32_t errors;
|
|
|
|
uint64_t bytes;
|
|
|
|
uint32_t multicast_packets;
|
|
|
|
uint32_t dropped;
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
2006-08-08 16:33:33 +04:00
|
|
|
struct ifreq_stats {
|
|
|
|
struct ifreq_stream_stats receive;
|
|
|
|
struct ifreq_stream_stats send;
|
|
|
|
uint32_t collisions;
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ifreq {
|
2010-07-29 13:43:08 +04:00
|
|
|
char ifr_name[IF_NAMESIZE];
|
2002-07-09 16:24:59 +04:00
|
|
|
union {
|
2006-08-08 16:33:33 +04:00
|
|
|
struct sockaddr ifr_addr;
|
|
|
|
struct sockaddr ifr_dstaddr;
|
|
|
|
struct sockaddr ifr_broadaddr;
|
|
|
|
struct sockaddr ifr_mask;
|
|
|
|
struct ifreq_stats ifr_stats;
|
|
|
|
struct route_entry ifr_route;
|
2010-07-29 13:43:08 +04:00
|
|
|
int ifr_flags;
|
|
|
|
int ifr_index;
|
|
|
|
int ifr_metric;
|
|
|
|
int ifr_mtu;
|
|
|
|
int ifr_media;
|
|
|
|
int ifr_type;
|
|
|
|
int ifr_reqcap;
|
|
|
|
int ifr_count;
|
|
|
|
uint8_t* ifr_data;
|
2006-08-08 16:33:33 +04:00
|
|
|
};
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
2006-08-08 16:33:33 +04:00
|
|
|
|
2010-07-29 13:43:08 +04:00
|
|
|
/* used with SIOC_IF_ALIAS_ADD, SIOC_IF_ALIAS_GET, SIOC_ALIAS_SET */
|
* Reworked the complete stack to allow more than one address per network
interface - this caused quite a number of changes.
* Network interfaces, and its addresses are now reference counted (not yet
complete, though, InterfaceAddresses need to hold references to their
interface as well).
* There are two known regressions of this commit that I will fix later:
- you cannot remove interfaces anymore
- IPv4 multicast was broken anyway, but now it's disabled, too.
* Moved a device_interfaces.cpp|h out of interfaces.cpp.
* The datalink layer chain is now instantiated per domain per interface,
not just per interface anymore.
* When a buffer reaches the network layer, it has no known interface yet, ie.
the ipv4|6|whatever modules need to set this manually.
* Added more debug output, and some new debugger commands, the control option
is now printed in clear text.
* Added hash_address() function to the address modules. Added "const" to
set_to_defaults() where needed.
* Fixed net_buffer's restore header functions offset use as reported by Atis.
* Improved buffer dump output, use the domain module to print the address if
available.
* Moved net_buffer::type into the union, as it's not needed by the upper layers
anymore.
* Moved IPv6 specific code from {add|remove}_default_route() to where it
belongs, but disabled it for the time being.
* Completely discarded useless ipv4_datagram module.
* Added ping6 to the build.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37794 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-28 21:38:23 +04:00
|
|
|
struct ifaliasreq {
|
2010-07-29 13:43:08 +04:00
|
|
|
char ifra_name[IF_NAMESIZE];
|
|
|
|
int ifra_index;
|
* Reworked the complete stack to allow more than one address per network
interface - this caused quite a number of changes.
* Network interfaces, and its addresses are now reference counted (not yet
complete, though, InterfaceAddresses need to hold references to their
interface as well).
* There are two known regressions of this commit that I will fix later:
- you cannot remove interfaces anymore
- IPv4 multicast was broken anyway, but now it's disabled, too.
* Moved a device_interfaces.cpp|h out of interfaces.cpp.
* The datalink layer chain is now instantiated per domain per interface,
not just per interface anymore.
* When a buffer reaches the network layer, it has no known interface yet, ie.
the ipv4|6|whatever modules need to set this manually.
* Added more debug output, and some new debugger commands, the control option
is now printed in clear text.
* Added hash_address() function to the address modules. Added "const" to
set_to_defaults() where needed.
* Fixed net_buffer's restore header functions offset use as reported by Atis.
* Improved buffer dump output, use the domain module to print the address if
available.
* Moved net_buffer::type into the union, as it's not needed by the upper layers
anymore.
* Moved IPv6 specific code from {add|remove}_default_route() to where it
belongs, but disabled it for the time being.
* Completely discarded useless ipv4_datagram module.
* Added ping6 to the build.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37794 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-28 21:38:23 +04:00
|
|
|
struct sockaddr_storage ifra_addr;
|
2010-07-29 13:43:08 +04:00
|
|
|
union {
|
|
|
|
struct sockaddr_storage ifra_broadaddr;
|
|
|
|
struct sockaddr_storage ifra_destination;
|
|
|
|
};
|
* Reworked the complete stack to allow more than one address per network
interface - this caused quite a number of changes.
* Network interfaces, and its addresses are now reference counted (not yet
complete, though, InterfaceAddresses need to hold references to their
interface as well).
* There are two known regressions of this commit that I will fix later:
- you cannot remove interfaces anymore
- IPv4 multicast was broken anyway, but now it's disabled, too.
* Moved a device_interfaces.cpp|h out of interfaces.cpp.
* The datalink layer chain is now instantiated per domain per interface,
not just per interface anymore.
* When a buffer reaches the network layer, it has no known interface yet, ie.
the ipv4|6|whatever modules need to set this manually.
* Added more debug output, and some new debugger commands, the control option
is now printed in clear text.
* Added hash_address() function to the address modules. Added "const" to
set_to_defaults() where needed.
* Fixed net_buffer's restore header functions offset use as reported by Atis.
* Improved buffer dump output, use the domain module to print the address if
available.
* Moved net_buffer::type into the union, as it's not needed by the upper layers
anymore.
* Moved IPv6 specific code from {add|remove}_default_route() to where it
belongs, but disabled it for the time being.
* Completely discarded useless ipv4_datagram module.
* Added ping6 to the build.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37794 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-28 21:38:23 +04:00
|
|
|
struct sockaddr_storage ifra_mask;
|
2010-08-03 19:51:54 +04:00
|
|
|
uint32_t ifra_flags;
|
* Reworked the complete stack to allow more than one address per network
interface - this caused quite a number of changes.
* Network interfaces, and its addresses are now reference counted (not yet
complete, though, InterfaceAddresses need to hold references to their
interface as well).
* There are two known regressions of this commit that I will fix later:
- you cannot remove interfaces anymore
- IPv4 multicast was broken anyway, but now it's disabled, too.
* Moved a device_interfaces.cpp|h out of interfaces.cpp.
* The datalink layer chain is now instantiated per domain per interface,
not just per interface anymore.
* When a buffer reaches the network layer, it has no known interface yet, ie.
the ipv4|6|whatever modules need to set this manually.
* Added more debug output, and some new debugger commands, the control option
is now printed in clear text.
* Added hash_address() function to the address modules. Added "const" to
set_to_defaults() where needed.
* Fixed net_buffer's restore header functions offset use as reported by Atis.
* Improved buffer dump output, use the domain module to print the address if
available.
* Moved net_buffer::type into the union, as it's not needed by the upper layers
anymore.
* Moved IPv6 specific code from {add|remove}_default_route() to where it
belongs, but disabled it for the time being.
* Completely discarded useless ipv4_datagram module.
* Added ping6 to the build.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37794 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-07-28 21:38:23 +04:00
|
|
|
};
|
|
|
|
|
2010-11-11 00:44:26 +03:00
|
|
|
|
2006-08-08 16:33:33 +04:00
|
|
|
/* interface flags */
|
2007-04-03 18:42:07 +04:00
|
|
|
#define IFF_UP 0x0001
|
|
|
|
#define IFF_BROADCAST 0x0002 /* valid broadcast address */
|
|
|
|
#define IFF_LOOPBACK 0x0008
|
|
|
|
#define IFF_POINTOPOINT 0x0010 /* point-to-point link */
|
|
|
|
#define IFF_NOARP 0x0040 /* no address resolution */
|
|
|
|
#define IFF_AUTOUP 0x0080 /* auto dial */
|
|
|
|
#define IFF_PROMISC 0x0100 /* receive all packets */
|
|
|
|
#define IFF_ALLMULTI 0x0200 /* receive all multicast packets */
|
|
|
|
#define IFF_SIMPLEX 0x0800 /* doesn't receive own transmissions */
|
|
|
|
#define IFF_LINK 0x1000 /* has link */
|
2010-08-03 19:51:54 +04:00
|
|
|
#define IFF_AUTO_CONFIGURED 0x2000
|
|
|
|
#define IFF_CONFIGURING 0x4000
|
2007-04-03 18:42:07 +04:00
|
|
|
#define IFF_MULTICAST 0x8000 /* supports multicast */
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2010-08-03 19:51:54 +04:00
|
|
|
/* interface alias flags */
|
|
|
|
#define IFAF_AUTO_CONFIGURED 0x0001 /* has been automatically configured */
|
|
|
|
#define IFAF_CONFIGURING 0x0002 /* auto configuration in progress */
|
|
|
|
|
|
|
|
|
2010-07-29 13:43:08 +04:00
|
|
|
/* used with SIOCGIFCOUNT, and SIOCGIFCONF */
|
2002-07-09 16:24:59 +04:00
|
|
|
struct ifconf {
|
2010-07-29 13:43:08 +04:00
|
|
|
int ifc_len; /* size of buffer */
|
2002-07-09 16:24:59 +04:00
|
|
|
union {
|
2010-07-29 13:43:08 +04:00
|
|
|
void* ifc_buf;
|
|
|
|
struct ifreq* ifc_req;
|
|
|
|
int ifc_value;
|
2006-08-08 16:33:33 +04:00
|
|
|
};
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
2010-08-06 16:58:02 +04:00
|
|
|
/* Macro that returns the size of a single address within a SIOCGIFCONF buffer;
|
|
|
|
it looks like this because of compatibility with other platforms. */
|
2010-02-04 23:40:35 +03:00
|
|
|
#define _SIZEOF_ADDR_IFREQ(request) \
|
2010-12-06 14:33:00 +03:00
|
|
|
(IF_NAMESIZE + (request).ifr_addr.sa_len > (int)sizeof(struct ifreq) \
|
|
|
|
? IF_NAMESIZE + (request).ifr_addr.sa_len : sizeof(struct ifreq))
|
2010-02-04 23:40:35 +03:00
|
|
|
|
|
|
|
|
2006-08-08 16:33:33 +04:00
|
|
|
/* POSIX definitions follow */
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2006-08-08 16:33:33 +04:00
|
|
|
struct if_nameindex {
|
2010-07-29 13:43:08 +04:00
|
|
|
unsigned if_index; /* positive interface index */
|
|
|
|
char* if_name; /* interface name, ie. "loopback" */
|
2002-07-09 16:24:59 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-08-08 16:33:33 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2010-07-29 13:43:08 +04:00
|
|
|
unsigned if_nametoindex(const char* name);
|
2010-09-21 10:30:21 +04:00
|
|
|
char* if_indextoname(unsigned interfaceIndex, char* nameBuffer);
|
2010-07-29 13:43:08 +04:00
|
|
|
struct if_nameindex* if_nameindex(void);
|
|
|
|
void if_freenameindex(struct if_nameindex* interfaceArray);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-10-25 19:13:00 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-07-29 13:43:08 +04:00
|
|
|
|
2006-08-08 16:33:33 +04:00
|
|
|
#endif /* _NET_IF_H */
|