2b1c0755dd
global name space, and have ugly identifiers for nothing :-) * Added a flags field to struct ifaliasreq. Added flags to mark an alias that is currently being configured, or has been automatically configured. Those flags aren't used yet, but they will replace IFF_CONFIGURING and friends. * Implemented deleting addresses only from interfaces via ifconfig. * Added more command aliases for delete to ifconfig ("del", and "delete", for more consistency with route). * Fixed control_routes() to only release a reference to an address if it actually got one before. * If an interface address is deleted, its routes are now removed as well. * InterfaceAddress now holds a reference to its interface as planned. * Implemented removing interfaces. Works quite nicely. * When downing an interface, all of its routes are now removed. When upping it again, at least the default routes are added. * datalink.cpp's get_interface_name_or_index() leaked a reference to the interface found. * SIOCAIFADDR would also leak a reference when new addresses were added. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37872 a95241bf-73f2-0310-859d-f6bbb57e9c96
124 lines
2.8 KiB
C
124 lines
2.8 KiB
C
/*
|
|
* Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _NET_IF_H
|
|
#define _NET_IF_H
|
|
|
|
|
|
#include <net/route.h>
|
|
#include <sys/socket.h>
|
|
|
|
|
|
#define IF_NAMESIZE 32
|
|
|
|
/* BSD specific/proprietary part */
|
|
|
|
#define IFNAMSIZ IF_NAMESIZE
|
|
|
|
struct ifreq_stream_stats {
|
|
uint32_t packets;
|
|
uint32_t errors;
|
|
uint64_t bytes;
|
|
uint32_t multicast_packets;
|
|
uint32_t dropped;
|
|
};
|
|
|
|
struct ifreq_stats {
|
|
struct ifreq_stream_stats receive;
|
|
struct ifreq_stream_stats send;
|
|
uint32_t collisions;
|
|
};
|
|
|
|
struct ifreq {
|
|
char ifr_name[IF_NAMESIZE];
|
|
union {
|
|
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;
|
|
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;
|
|
};
|
|
};
|
|
|
|
/* used with SIOC_IF_ALIAS_ADD, SIOC_IF_ALIAS_GET, SIOC_ALIAS_SET */
|
|
struct ifaliasreq {
|
|
char ifra_name[IF_NAMESIZE];
|
|
int ifra_index;
|
|
struct sockaddr_storage ifra_addr;
|
|
union {
|
|
struct sockaddr_storage ifra_broadaddr;
|
|
struct sockaddr_storage ifra_destination;
|
|
};
|
|
struct sockaddr_storage ifra_mask;
|
|
uint32_t ifra_flags;
|
|
};
|
|
|
|
/* interface flags */
|
|
#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 */
|
|
#define IFF_AUTO_CONFIGURED 0x2000
|
|
#define IFF_CONFIGURING 0x4000
|
|
#define IFF_MULTICAST 0x8000 /* supports multicast */
|
|
|
|
/* interface alias flags */
|
|
#define IFAF_AUTO_CONFIGURED 0x0001 /* has been automatically configured */
|
|
#define IFAF_CONFIGURING 0x0002 /* auto configuration in progress */
|
|
|
|
|
|
/* used with SIOCGIFCOUNT, and SIOCGIFCONF */
|
|
struct ifconf {
|
|
int ifc_len; /* size of buffer */
|
|
union {
|
|
void* ifc_buf;
|
|
struct ifreq* ifc_req;
|
|
int ifc_value;
|
|
};
|
|
};
|
|
|
|
#define _SIZEOF_ADDR_IFREQ(request) \
|
|
(sizeof((request).ifr_name) + (request).ifr_addr.sa_len)
|
|
|
|
|
|
/* POSIX definitions follow */
|
|
|
|
struct if_nameindex {
|
|
unsigned if_index; /* positive interface index */
|
|
char* if_name; /* interface name, ie. "loopback" */
|
|
};
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
unsigned if_nametoindex(const char* name);
|
|
char* if_indextoname(unsigned index, char* nameBuffer);
|
|
struct if_nameindex* if_nameindex(void);
|
|
void if_freenameindex(struct if_nameindex* interfaceArray);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
|
|
#endif /* _NET_IF_H */
|