mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 12:05:00 +00:00
Kernel+LibC: Share definitions for net/{if,if_arp,route}.h
This commit is contained in:
parent
ff50122dc5
commit
661bd992b0
8 changed files with 133 additions and 121 deletions
61
Kernel/API/POSIX/net/if.h
Normal file
61
Kernel/API/POSIX/net/if.h
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <Kernel/API/POSIX/sys/socket.h>
|
||||
#include <Kernel/API/POSIX/sys/types.h>
|
||||
|
||||
struct ifconf {
|
||||
int ifc_len;
|
||||
union {
|
||||
void* ifc_buf;
|
||||
struct ifreq* ifc_req;
|
||||
};
|
||||
};
|
||||
|
||||
struct ifreq {
|
||||
#define IFNAMSIZ 16
|
||||
char ifr_name[IFNAMSIZ];
|
||||
union {
|
||||
struct sockaddr ifru_addr;
|
||||
struct sockaddr ifru_dstaddr;
|
||||
struct sockaddr ifru_broadaddr;
|
||||
struct sockaddr ifru_netmask;
|
||||
struct sockaddr ifru_hwaddr;
|
||||
short ifru_flags;
|
||||
int ifru_metric;
|
||||
int64_t ifru_vnetid;
|
||||
uint64_t ifru_media;
|
||||
void* ifru_data;
|
||||
unsigned int ifru_index;
|
||||
} ifr_ifru;
|
||||
|
||||
#define ifr_addr ifr_ifru.ifru_addr // address
|
||||
#define ifr_dstaddr ifr_ifru.ifru_dstaddr // other end of p-to-p link
|
||||
#define ifr_broadaddr ifr_ifru.ifru_broadaddr // broadcast address
|
||||
#define ifr_netmask ifr_ifru.ifru_netmask // network mask
|
||||
#define ifr_flags ifr_ifru.ifru_flags // flags
|
||||
#define ifr_metric ifr_ifru.ifru_metric // metric
|
||||
#define ifr_mtu ifr_ifru.ifru_metric // mtu (overload)
|
||||
#define ifr_hardmtu ifr_ifru.ifru_metric // hardmtu (overload)
|
||||
#define ifr_media ifr_ifru.ifru_media // media options
|
||||
#define ifr_rdomainid ifr_ifru.ifru_metric // VRF instance (overload)
|
||||
#define ifr_vnetid ifr_ifru.ifru_vnetid // Virtual Net Id
|
||||
#define ifr_ttl ifr_ifru.ifru_metric // tunnel TTL (overload)
|
||||
#define ifr_data ifr_ifru.ifru_data // for use by interface
|
||||
#define ifr_index ifr_ifru.ifru_index // interface index
|
||||
#define ifr_llprio ifr_ifru.ifru_metric // link layer priority
|
||||
#define ifr_hwaddr ifr_ifru.ifru_hwaddr // MAC address
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
26
Kernel/API/POSIX/net/if_arp.h
Normal file
26
Kernel/API/POSIX/net/if_arp.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <Kernel/API/POSIX/sys/socket.h>
|
||||
#include <Kernel/API/POSIX/sys/types.h>
|
||||
|
||||
struct arpreq {
|
||||
struct sockaddr arp_pa; /* protocol address */
|
||||
struct sockaddr arp_ha; /* hardware address */
|
||||
struct sockaddr arp_netmask; /* netmask of protocol address */
|
||||
int arp_flags; /* flags */
|
||||
char arp_dev[16];
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
29
Kernel/API/POSIX/net/route.h
Normal file
29
Kernel/API/POSIX/net/route.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Marios Prokopakis <mariosprokopakis@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Kernel/API/POSIX/sys/socket.h>
|
||||
#include <Kernel/API/POSIX/sys/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct rtentry {
|
||||
struct sockaddr rt_gateway; /* the gateway address */
|
||||
struct sockaddr rt_genmask; /* the target network mask */
|
||||
unsigned short int rt_flags;
|
||||
char* rt_dev;
|
||||
/* FIXME: complete the struct */
|
||||
};
|
||||
|
||||
#define RTF_UP 0x1 /* do not delete the route */
|
||||
#define RTF_GATEWAY 0x2 /* the route is a gateway and not an end host */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -10,6 +10,9 @@
|
|||
#include <AK/Types.h>
|
||||
#include <Kernel/API/POSIX/fcntl.h>
|
||||
#include <Kernel/API/POSIX/futex.h>
|
||||
#include <Kernel/API/POSIX/net/if.h>
|
||||
#include <Kernel/API/POSIX/net/if_arp.h>
|
||||
#include <Kernel/API/POSIX/net/route.h>
|
||||
#include <Kernel/API/POSIX/netinet/in.h>
|
||||
#include <Kernel/API/POSIX/signal.h>
|
||||
#include <Kernel/API/POSIX/sys/mman.h>
|
||||
|
@ -163,63 +166,9 @@ struct sched_param {
|
|||
int sched_priority;
|
||||
};
|
||||
|
||||
struct ifreq {
|
||||
#define IFNAMSIZ 16
|
||||
char ifr_name[IFNAMSIZ];
|
||||
union {
|
||||
struct sockaddr ifru_addr;
|
||||
struct sockaddr ifru_dstaddr;
|
||||
struct sockaddr ifru_broadaddr;
|
||||
struct sockaddr ifru_netmask;
|
||||
struct sockaddr ifru_hwaddr;
|
||||
short ifru_flags;
|
||||
int ifru_metric;
|
||||
int64_t ifru_vnetid;
|
||||
uint64_t ifru_media;
|
||||
void* ifru_data;
|
||||
unsigned int ifru_index;
|
||||
} ifr_ifru;
|
||||
|
||||
#define ifr_addr ifr_ifru.ifru_addr // address
|
||||
#define ifr_dstaddr ifr_ifru.ifru_dstaddr // other end of p-to-p link
|
||||
#define ifr_broadaddr ifr_ifru.ifru_broadaddr // broadcast address
|
||||
#define ifr_netmask ifr_ifru.ifru_netmask // network mask
|
||||
#define ifr_flags ifr_ifru.ifru_flags // flags
|
||||
#define ifr_metric ifr_ifru.ifru_metric // metric
|
||||
#define ifr_mtu ifr_ifru.ifru_metric // mtu (overload)
|
||||
#define ifr_hardmtu ifr_ifru.ifru_metric // hardmtu (overload)
|
||||
#define ifr_media ifr_ifru.ifru_media // media options
|
||||
#define ifr_rdomainid ifr_ifru.ifru_metric // VRF instance (overload)
|
||||
#define ifr_vnetid ifr_ifru.ifru_vnetid // Virtual Net Id
|
||||
#define ifr_ttl ifr_ifru.ifru_metric // tunnel TTL (overload)
|
||||
#define ifr_data ifr_ifru.ifru_data // for use by interface
|
||||
#define ifr_index ifr_ifru.ifru_index // interface index
|
||||
#define ifr_llprio ifr_ifru.ifru_metric // link layer priority
|
||||
#define ifr_hwaddr ifr_ifru.ifru_hwaddr // MAC address
|
||||
};
|
||||
|
||||
struct rtentry {
|
||||
struct sockaddr rt_gateway; /* the gateway address */
|
||||
struct sockaddr rt_genmask; /* the target network mask */
|
||||
unsigned short int rt_flags;
|
||||
char* rt_dev;
|
||||
/* FIXME: complete the struct */
|
||||
};
|
||||
|
||||
#define RTF_UP 0x1 /* do not delete the route */
|
||||
#define RTF_GATEWAY 0x2 /* the route is a gateway and not an end host */
|
||||
|
||||
#define AT_FDCWD -100
|
||||
#define AT_SYMLINK_NOFOLLOW 0x100
|
||||
|
||||
struct arpreq {
|
||||
struct sockaddr arp_pa; /* protocol address */
|
||||
struct sockaddr arp_ha; /* hardware address */
|
||||
struct sockaddr arp_netmask; /* netmask of protocol address */
|
||||
int arp_flags; /* flags */
|
||||
char arp_dev[16];
|
||||
};
|
||||
|
||||
#define PURGE_ALL_VOLATILE 0x1
|
||||
#define PURGE_ALL_CLEAN_INODE 0x2
|
||||
|
||||
|
|
|
@ -1,60 +1,16 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/socket.h>
|
||||
#include <Kernel/API/POSIX/net/if.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct ifreq {
|
||||
#define IFNAMSIZ 16
|
||||
char ifr_name[IFNAMSIZ];
|
||||
union {
|
||||
struct sockaddr ifru_addr;
|
||||
struct sockaddr ifru_dstaddr;
|
||||
struct sockaddr ifru_broadaddr;
|
||||
struct sockaddr ifru_netmask;
|
||||
struct sockaddr ifru_hwaddr;
|
||||
short ifru_flags;
|
||||
int ifru_metric;
|
||||
int64_t ifru_vnetid;
|
||||
uint64_t ifru_media;
|
||||
void* ifru_data;
|
||||
unsigned int ifru_index;
|
||||
} ifr_ifru;
|
||||
|
||||
#define ifr_addr ifr_ifru.ifru_addr // address
|
||||
#define ifr_dstaddr ifr_ifru.ifru_dstaddr // other end of p-to-p link
|
||||
#define ifr_broadaddr ifr_ifru.ifru_broadaddr // broadcast address
|
||||
#define ifr_netmask ifr_ifru.ifru_netmask // network mask
|
||||
#define ifr_flags ifr_ifru.ifru_flags // flags
|
||||
#define ifr_metric ifr_ifru.ifru_metric // metric
|
||||
#define ifr_mtu ifr_ifru.ifru_metric // mtu (overload)
|
||||
#define ifr_hardmtu ifr_ifru.ifru_metric // hardmtu (overload)
|
||||
#define ifr_media ifr_ifru.ifru_media // media options
|
||||
#define ifr_rdomainid ifr_ifru.ifru_metric // VRF instance (overload)
|
||||
#define ifr_vnetid ifr_ifru.ifru_vnetid // Virtual Net Id
|
||||
#define ifr_ttl ifr_ifru.ifru_metric // tunnel TTL (overload)
|
||||
#define ifr_data ifr_ifru.ifru_data // for use by interface
|
||||
#define ifr_index ifr_ifru.ifru_index // interface index
|
||||
#define ifr_llprio ifr_ifru.ifru_metric // link layer priority
|
||||
#define ifr_hwaddr ifr_ifru.ifru_hwaddr // MAC address
|
||||
};
|
||||
|
||||
struct ifconf {
|
||||
int ifc_len;
|
||||
union {
|
||||
void* ifc_buf;
|
||||
struct ifreq* ifc_req;
|
||||
};
|
||||
};
|
||||
|
||||
unsigned int if_nametoindex(const char* ifname);
|
||||
unsigned int if_nametoindex(char const* ifname);
|
||||
char* if_indextoname(unsigned int ifindex, char* ifname);
|
||||
|
||||
__END_DECLS
|
||||
|
|
9
Userland/Libraries/LibC/net/if_arp.h
Normal file
9
Userland/Libraries/LibC/net/if_arp.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Kernel/API/POSIX/net/if_arp.h>
|
|
@ -6,23 +6,4 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
struct rtentry {
|
||||
struct sockaddr rt_gateway; /* the gateway address */
|
||||
struct sockaddr rt_genmask; /* the target network mask */
|
||||
unsigned short int rt_flags;
|
||||
char* rt_dev;
|
||||
/* FIXME: complete the struct */
|
||||
};
|
||||
|
||||
#define RTF_UP 0x1 /* do not delete the route */
|
||||
#define RTF_GATEWAY 0x2 /* the route is a gateway and not an end host */
|
||||
|
||||
struct arpreq {
|
||||
struct sockaddr arp_pa; /* protocol address */
|
||||
struct sockaddr arp_ha; /* hardware address */
|
||||
struct sockaddr arp_netmask; /* netmask of protocol address */
|
||||
int arp_flags; /* flags */
|
||||
char arp_dev[16];
|
||||
};
|
||||
#include <Kernel/API/POSIX/net/route.h>
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <AK/Types.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <net/if_arp.h>
|
||||
#include <net/route.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue