2023-05-26 22:21:07 +03:00
|
|
|
#ifndef _NET_IF_H
|
|
|
|
#define _NET_IF_H 1
|
|
|
|
|
|
|
|
// https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/net_if.h.html
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
2024-02-03 01:24:55 +02:00
|
|
|
#include <sys/socket.h>
|
|
|
|
|
2023-05-26 22:21:07 +03:00
|
|
|
#define IF_NAMESIZE 16
|
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
|
|
|
struct if_nameindex
|
|
|
|
{
|
|
|
|
unsigned if_index; /* Numeric index of the interface. */
|
|
|
|
char* if_name; /* Null-terminated name of the interface. */
|
|
|
|
};
|
|
|
|
|
2024-02-03 01:24:55 +02:00
|
|
|
struct ifreq
|
|
|
|
{
|
|
|
|
union {
|
|
|
|
struct sockaddr ifru_addr;
|
|
|
|
struct sockaddr ifru_netmask;
|
|
|
|
struct sockaddr ifru_hwaddr;
|
|
|
|
unsigned char __min_storage[sizeof(sockaddr) + 6];
|
|
|
|
} ifr_ifru;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SIOCGIFADDR 1 /* Get interface address */
|
|
|
|
#define SIOCSIFADDR 2 /* Set interface address */
|
|
|
|
#define SIOCGIFNETMASK 3 /* Get network mask */
|
|
|
|
#define SIOCSIFNETMASK 4 /* Set network mask */
|
|
|
|
#define SIOCGIFHWADDR 5 /* Get hardware address */
|
|
|
|
|
2023-05-26 22:21:07 +03:00
|
|
|
void if_freenameindex(struct if_nameindex* ptr);
|
|
|
|
char* if_indextoname(unsigned ifindex, char* ifname);
|
|
|
|
struct if_nameindex* if_nameindex(void);
|
|
|
|
unsigned if_nametoindex(const char* ifname);
|
|
|
|
|
|
|
|
__END_DECLS
|
|
|
|
|
|
|
|
#endif
|