user: implement mlibc as the libc, finally.
It's finally done.. Signed-off-by: kaguya <vpshinomiya@protonmail.com>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
#ifndef _NET_ETHERNET_H
|
||||
#define _NET_ETHERNET_H
|
||||
|
||||
#include <bits/ether_addr.h>
|
||||
#include <stdint.h>
|
||||
#include <mlibc-config.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if __MLIBC_LINUX_OPTION
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wvariadic-macros"
|
||||
#pragma GCC diagnostic ignored "-Wpedantic"
|
||||
# include <linux/if_ether.h>
|
||||
#pragma GCC diagnostic pop
|
||||
#endif /* __MLIBC_LINUX_OPTION */
|
||||
|
||||
#define ETHERTYPE_PUP 0x0200
|
||||
#define ETHERTYPE_SPRITE 0x0500
|
||||
#define ETHERTYPE_IP 0x0800
|
||||
#define ETHERTYPE_ARP 0x0806
|
||||
#define ETHERTYPE_REVARP 0x8035
|
||||
#define ETHERTYPE_AT 0x809B
|
||||
#define ETHERTYPE_AARP 0x80F3
|
||||
#define ETHERTYPE_VLAN 0x8100
|
||||
#define ETHERTYPE_IPX 0x8137
|
||||
#define ETHERTYPE_IPV6 0x86dd
|
||||
#define ETHERTYPE_LOOPBACK 0x9000
|
||||
|
||||
struct ether_header {
|
||||
uint8_t ether_dhost[6];
|
||||
uint8_t ether_shost[6];
|
||||
uint16_t ether_type;
|
||||
};
|
||||
|
||||
#define ETHER_ADDR_LEN 6
|
||||
|
||||
#define ETHERTYPE_IP 0x0800
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,128 @@
|
||||
|
||||
#ifndef _NET_IF_H
|
||||
#define _NET_IF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <mlibc-config.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#define IF_NAMESIZE 16
|
||||
#define IFNAMSIZ IF_NAMESIZE
|
||||
#define ALTIFNAMSIZ 128
|
||||
#define IFALIASZ 256
|
||||
|
||||
struct if_nameindex {
|
||||
unsigned int if_index;
|
||||
char *if_name;
|
||||
};
|
||||
|
||||
struct ifmap {
|
||||
unsigned long mem_start;
|
||||
unsigned long mem_end;
|
||||
unsigned short base_addr;
|
||||
unsigned char irq;
|
||||
unsigned char dma;
|
||||
unsigned char port;
|
||||
};
|
||||
|
||||
struct ifreq {
|
||||
union {
|
||||
char ifrn_name[IFNAMSIZ];
|
||||
} ifr_ifrn;
|
||||
|
||||
union {
|
||||
struct sockaddr ifru_addr;
|
||||
struct sockaddr ifru_dstaddr;
|
||||
struct sockaddr ifru_broadaddr;
|
||||
struct sockaddr ifru_netmask;
|
||||
struct sockaddr ifru_hwaddr;
|
||||
short int ifru_flags;
|
||||
int ifru_ivalue;
|
||||
int ifru_mtu;
|
||||
struct ifmap ifru_map;
|
||||
char ifru_slave[IFNAMSIZ];
|
||||
char ifru_newname[IFNAMSIZ];
|
||||
char *ifru_data;
|
||||
} ifr_ifru;
|
||||
};
|
||||
|
||||
#define ifr_name ifr_ifrn.ifrn_name
|
||||
#define ifr_hwaddr ifr_ifru.ifru_hwaddr
|
||||
#define ifr_addr ifr_ifru.ifru_addr
|
||||
#define ifr_dstaddr ifr_ifru.ifru_dstaddr
|
||||
#define ifr_broadaddr ifr_ifru.ifru_broadaddr
|
||||
#define ifr_netmask ifr_ifru.ifru_netmask
|
||||
#define ifr_flags ifr_ifru.ifru_flags
|
||||
#define ifr_metric ifr_ifru.ifru_ivalue
|
||||
#define ifr_mtu ifr_ifru.ifru_mtu
|
||||
#define ifr_map ifr_ifru.ifru_map
|
||||
#define ifr_slave ifr_ifru.ifru_slave
|
||||
#define ifr_data ifr_ifru.ifru_data
|
||||
#define ifr_ifindex ifr_ifru.ifru_ivalue
|
||||
#define ifr_bandwidth ifr_ifru.ifru_ivalue
|
||||
#define ifr_qlen ifr_ifru.ifru_ivalue
|
||||
#define ifr_newname ifr_ifru.ifru_newname
|
||||
|
||||
struct ifconf {
|
||||
int ifc_len;
|
||||
union {
|
||||
char *ifcu_buf;
|
||||
struct ifreq *ifcu_req;
|
||||
} ifc_ifcu;
|
||||
};
|
||||
|
||||
#define ifc_buf ifc_ifcu.ifcu_buf
|
||||
#define ifc_req ifc_ifcu.ifcu_req
|
||||
|
||||
#ifndef __MLIBC_ABI_ONLY
|
||||
|
||||
void if_freenameindex(struct if_nameindex *__index);
|
||||
char *if_indextoname(unsigned int __index, char *__name);
|
||||
struct if_nameindex *if_nameindex(void);
|
||||
unsigned int if_nametoindex(const char *__name);
|
||||
|
||||
#endif /* !__MLIBC_ABI_ONLY */
|
||||
|
||||
#define IFHWADDRLEN 6
|
||||
|
||||
#define IFF_UP 0x1
|
||||
#define IFF_BROADCAST 0x2
|
||||
#define IFF_DEBUG 0x4
|
||||
#define IFF_LOOPBACK 0x8
|
||||
#define IFF_POINTOPOINT 0x10
|
||||
#define IFF_NOTRAILERS 0x20
|
||||
#define IFF_RUNNING 0x40
|
||||
#define IFF_NOARP 0x80
|
||||
#define IFF_PROMISC 0x100
|
||||
#define IFF_ALLMULTI 0x200
|
||||
#define IFF_MASTER 0x400
|
||||
#define IFF_SLAVE 0x800
|
||||
#define IFF_MULTICAST 0x1000
|
||||
#define IFF_PORTSEL 0x2000
|
||||
#define IFF_AUTOMEDIA 0x4000
|
||||
#define IFF_DYNAMIC 0x8000
|
||||
#define IFF_LOWER_UP 0x10000
|
||||
#define IFF_DORMANT 0x20000
|
||||
#define IFF_ECHO 0x40000
|
||||
|
||||
#if __MLIBC_LINUX_OPTION
|
||||
|
||||
#define __UAPI_DEF_IF_IFCONF 0
|
||||
#define __UAPI_DEF_IF_IFMAP 0
|
||||
#define __UAPI_DEF_IF_IFNAMSIZ 0
|
||||
#define __UAPI_DEF_IF_IFREQ 0
|
||||
#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 0
|
||||
#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 0
|
||||
|
||||
#endif /* __MLIBC_LINUX_OPTION */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _NET_IF_H */
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
#ifndef _NET_IF_ARP_H
|
||||
#define _NET_IF_ARP_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define MAX_ADDR_LEN 7
|
||||
|
||||
#define ARPOP_REQUEST 1
|
||||
#define ARPOP_REPLY 2
|
||||
#define ARPOP_RREQUEST 3
|
||||
#define ARPOP_RREPLY 4
|
||||
#define ARPOP_InREQUEST 8
|
||||
#define ARPOP_InREPLY 9
|
||||
#define ARPOP_NAK 10
|
||||
|
||||
#define ARPHRD_NETROM 0
|
||||
#define ARPHRD_ETHER 1
|
||||
#define ARPHRD_EETHER 2
|
||||
#define ARPHRD_AX25 3
|
||||
#define ARPHRD_PRONET 4
|
||||
#define ARPHRD_CHAOS 5
|
||||
#define ARPHRD_IEEE802 6
|
||||
#define ARPHRD_ARCNET 7
|
||||
#define ARPHRD_APPLETLK 8
|
||||
#define ARPHRD_DLCI 15
|
||||
#define ARPHRD_ATM 19
|
||||
#define ARPHRD_METRICOM 23
|
||||
#define ARPHRD_IEEE1394 24
|
||||
#define ARPHRD_EUI64 27
|
||||
#define ARPHRD_INFINIBAND 32
|
||||
#define ARPHRD_SLIP 256
|
||||
#define ARPHRD_CSLIP 257
|
||||
#define ARPHRD_SLIP6 258
|
||||
#define ARPHRD_CSLIP6 259
|
||||
#define ARPHRD_RSRVD 260
|
||||
#define ARPHRD_ADAPT 264
|
||||
#define ARPHRD_ROSE 270
|
||||
#define ARPHRD_X25 271
|
||||
#define ARPHRD_HWX25 272
|
||||
#define ARPHRD_CAN 280
|
||||
#define ARPHRD_PPP 512
|
||||
#define ARPHRD_CISCO 513
|
||||
#define ARPHRD_HDLC ARPHRD_CISCO
|
||||
#define ARPHRD_LAPB 516
|
||||
#define ARPHRD_DDCMP 517
|
||||
#define ARPHRD_RAWHDLC 518
|
||||
#define ARPHRD_RAWIP 519
|
||||
|
||||
#define ARPHRD_TUNNEL 768
|
||||
#define ARPHRD_TUNNEL6 769
|
||||
#define ARPHRD_FRAD 770
|
||||
#define ARPHRD_SKIP 771
|
||||
#define ARPHRD_LOOPBACK 772
|
||||
#define ARPHRD_LOCALTLK 773
|
||||
#define ARPHRD_FDDI 774
|
||||
#define ARPHRD_BIF 775
|
||||
#define ARPHRD_SIT 776
|
||||
#define ARPHRD_IPDDP 777
|
||||
#define ARPHRD_IPGRE 778
|
||||
#define ARPHRD_PIMREG 779
|
||||
#define ARPHRD_HIPPI 780
|
||||
#define ARPHRD_ASH 781
|
||||
#define ARPHRD_ECONET 782
|
||||
#define ARPHRD_IRDA 783
|
||||
#define ARPHRD_FCPP 784
|
||||
#define ARPHRD_FCAL 785
|
||||
#define ARPHRD_FCPL 786
|
||||
#define ARPHRD_FCFABRIC 787
|
||||
#define ARPHRD_IEEE802_TR 800
|
||||
#define ARPHRD_IEEE80211 801
|
||||
#define ARPHRD_IEEE80211_PRISM 802
|
||||
#define ARPHRD_IEEE80211_RADIOTAP 803
|
||||
#define ARPHRD_IEEE802154 804
|
||||
#define ARPHRD_IEEE802154_MONITOR 805
|
||||
#define ARPHRD_PHONET 820
|
||||
#define ARPHRD_PHONET_PIPE 821
|
||||
#define ARPHRD_CAIF 822
|
||||
#define ARPHRD_IP6GRE 823
|
||||
#define ARPHRD_NETLINK 824
|
||||
#define ARPHRD_6LOWPAN 825
|
||||
#define ARPHRD_VSOCKMON 826
|
||||
|
||||
#define ARPHRD_VOID 0xFFFF
|
||||
#define ARPHRD_NONE 0xFFFE
|
||||
|
||||
struct arphdr {
|
||||
uint16_t ar_hrd;
|
||||
uint16_t ar_pro;
|
||||
uint8_t ar_hln;
|
||||
uint8_t ar_pln;
|
||||
uint16_t ar_op;
|
||||
};
|
||||
|
||||
struct arpreq {
|
||||
struct sockaddr arp_pa;
|
||||
struct sockaddr arp_ha;
|
||||
int arp_flags;
|
||||
struct sockaddr arp_netmask;
|
||||
char arp_dev[16];
|
||||
};
|
||||
|
||||
#endif /* _NET_IF_ARP_H */
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef _NET_IF_PPP_H
|
||||
#define _NET_IF_PPP_H
|
||||
|
||||
#include <mlibc-config.h>
|
||||
|
||||
#if __MLIBC_LINUX_OPTION
|
||||
#include <asm/ioctl.h>
|
||||
#include <linux/ppp_defs.h>
|
||||
|
||||
#define PPPIOCGFLAGS _IOR('t', 90, int)
|
||||
#define PPPIOCSFLAGS _IOW('t', 89, int)
|
||||
#define PPPIOCGASYNCMAP _IOR('t', 88, int)
|
||||
#define PPPIOCSASYNCMAP _IOW('t', 87, int)
|
||||
#define PPPIOCGUNIT _IOR('t', 86, int)
|
||||
#define PPPIOCSMRU _IOW('t', 82, int)
|
||||
#define PPPIOCSMAXCID _IOW('t', 81, int)
|
||||
#define PPPIOCGXASYNCMAP _IOR('t', 80, ext_accm)
|
||||
#define PPPIOCSXASYNCMAP _IOW('t', 79, ext_accm)
|
||||
#define PPPIOCGDEBUG _IOR('t', 65, int)
|
||||
#define PPPIOCSDEBUG _IOW('t', 64, int)
|
||||
#endif
|
||||
|
||||
#endif /* _NET_IF_PPP_H */
|
||||
@@ -0,0 +1,35 @@
|
||||
#ifndef _NET_ROUTE_H
|
||||
#define _NET_ROUTE_H
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define RTF_HOST 0x0004
|
||||
#define RTF_REJECT 0x0200
|
||||
|
||||
struct rtentry {
|
||||
unsigned long int rt_pad1;
|
||||
struct sockaddr rt_dst;
|
||||
struct sockaddr rt_gateway;
|
||||
struct sockaddr rt_genmask;
|
||||
unsigned short int rt_flags;
|
||||
short int rt_pad2;
|
||||
unsigned long int rt_pad3;
|
||||
unsigned char rt_tos;
|
||||
unsigned char rt_class;
|
||||
short int rt_pad4[3];
|
||||
short int rt_metric;
|
||||
char *rt_dev;
|
||||
unsigned long int rt_mtu;
|
||||
unsigned long int rt_window;
|
||||
unsigned short int rt_irtt;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _NET_ROUTE_H */
|
||||
Reference in New Issue
Block a user