mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-29 16:52:28 +00:00
Introduce getifaddrs()
This function was invented by the BSDs (it's not in POSIX.1). It provides a high-level interface into ioctl(SIOCGIFCONF) which is comparatively clumsy to use. We already made the ioctls portable across our entire support vector back in 2021, so this interface is portable too. See o//tool/viz/getifaddrs.com for our demo app
This commit is contained in:
parent
6ca5ab4680
commit
024be3b009
5 changed files with 260 additions and 1 deletions
25
libc/sock/ifaddrs.h
Normal file
25
libc/sock/ifaddrs.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_SOCK_IFADDRS_H_
|
||||
#define COSMOPOLITAN_LIBC_SOCK_IFADDRS_H_
|
||||
#include "libc/sock/struct/sockaddr.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct ifaddrs {
|
||||
struct ifaddrs *ifa_next;
|
||||
char *ifa_name;
|
||||
unsigned ifa_flags;
|
||||
struct sockaddr *ifa_addr;
|
||||
struct sockaddr *ifa_netmask;
|
||||
union {
|
||||
struct sockaddr *ifa_broadaddr;
|
||||
struct sockaddr *ifa_dstaddr;
|
||||
};
|
||||
void *ifa_data;
|
||||
};
|
||||
|
||||
void freeifaddrs(struct ifaddrs *);
|
||||
int getifaddrs(struct ifaddrs **);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_SOCK_IFADDRS_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue