2006-08-08 16:33:33 +04:00
|
|
|
/*
|
2007-04-03 18:42:07 +04:00
|
|
|
* Copyright 2006-2007, 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_parameter {
|
|
|
|
char base_name[IF_NAMESIZE];
|
|
|
|
char device[128];
|
|
|
|
uint8_t sub_type;
|
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 {
|
2006-08-08 16:33:33 +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_parameter ifr_parameter;
|
|
|
|
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;
|
2007-05-02 04:10:00 +04:00
|
|
|
int ifr_reqcap;
|
2006-08-08 16:33:33 +04:00
|
|
|
};
|
2002-07-09 16:24:59 +04: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 */
|
|
|
|
#define IFF_AUTO_CONFIGURED 0x2000 /* has been automatically configured */
|
|
|
|
#define IFF_CONFIGURING 0x4000 /* auto configuration in progress */
|
|
|
|
#define IFF_MULTICAST 0x8000 /* supports multicast */
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
struct ifconf {
|
2006-08-08 16:33:33 +04:00
|
|
|
int ifc_len; /* size of buffer */
|
2002-07-09 16:24:59 +04:00
|
|
|
union {
|
2006-08-08 16:33:33 +04:00
|
|
|
void *ifc_buf;
|
|
|
|
struct ifreq *ifc_req;
|
|
|
|
int ifc_value;
|
|
|
|
};
|
2002-07-09 16:24:59 +04: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 {
|
|
|
|
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
|
|
|
|
2006-08-08 16:33:33 +04:00
|
|
|
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);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-10-25 19:13:00 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-08-08 16:33:33 +04:00
|
|
|
#endif /* _NET_IF_H */
|