Kernel/LibC: Implement basic ioctl for network addresses
This commit is contained in:
@@ -17,6 +17,7 @@ set(LIBC_SOURCES
|
||||
stdlib.cpp
|
||||
string.cpp
|
||||
strings.cpp
|
||||
stropts.cpp
|
||||
sys/banan-os.cpp
|
||||
sys/mman.cpp
|
||||
sys/socket.cpp
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
#define IF_NAMESIZE 16
|
||||
|
||||
__BEGIN_DECLS
|
||||
@@ -15,6 +17,22 @@ struct if_nameindex
|
||||
char* if_name; /* Null-terminated name of the interface. */
|
||||
};
|
||||
|
||||
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 */
|
||||
|
||||
void if_freenameindex(struct if_nameindex* ptr);
|
||||
char* if_indextoname(unsigned ifindex, char* ifname);
|
||||
struct if_nameindex* if_nameindex(void);
|
||||
|
||||
@@ -11,8 +11,8 @@ __BEGIN_DECLS
|
||||
#define __need_gid_t
|
||||
#include <sys/types.h>
|
||||
|
||||
typedef uint32_t t_uscalar_t;
|
||||
typedef int32_t t_scalar_t;
|
||||
typedef __UINT32_TYPE__ t_uscalar_t;
|
||||
typedef __INT32_TYPE__ t_scalar_t;
|
||||
|
||||
struct bandinfo
|
||||
{
|
||||
|
||||
@@ -67,6 +67,7 @@ __BEGIN_DECLS
|
||||
#define SYS_BIND 66
|
||||
#define SYS_SENDTO 67
|
||||
#define SYS_RECVFROM 68
|
||||
#define SYS_IOCTL 69
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
||||
14
libc/stropts.cpp
Normal file
14
libc/stropts.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <stdarg.h>
|
||||
#include <stropts.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int ioctl(int fildes, int request, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, request);
|
||||
void* extra = va_arg(args, void*);
|
||||
va_end(args);
|
||||
|
||||
return syscall(SYS_IOCTL, fildes, request, extra);
|
||||
}
|
||||
Reference in New Issue
Block a user