[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT/LWIP PATCH 1/4] Import network headers from musl to support Ruby



Copied as is from the official musl git mirror
git://git.musl-libc.org/musl, commit 6fcb440d.

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
 musl-imported/include/ifaddrs.h          |  35 ++++++
 musl-imported/include/net/ethernet.h     |  55 +++++++++
 musl-imported/include/net/if_arp.h       | 142 ++++++++++++++++++++++
 musl-imported/include/netinet/if_ether.h | 145 +++++++++++++++++++++++
 musl-imported/include/netinet/in_systm.h |   9 ++
 musl-imported/include/netinet/udp.h      |  45 +++++++
 musl-imported/include/netpacket/packet.h |  62 ++++++++++
 7 files changed, 493 insertions(+)
 create mode 100644 musl-imported/include/ifaddrs.h
 create mode 100644 musl-imported/include/net/ethernet.h
 create mode 100644 musl-imported/include/net/if_arp.h
 create mode 100644 musl-imported/include/netinet/if_ether.h
 create mode 100644 musl-imported/include/netinet/in_systm.h
 create mode 100644 musl-imported/include/netinet/udp.h
 create mode 100644 musl-imported/include/netpacket/packet.h

diff --git a/musl-imported/include/ifaddrs.h b/musl-imported/include/ifaddrs.h
new file mode 100644
index 0000000..c0328a8
--- /dev/null
+++ b/musl-imported/include/ifaddrs.h
@@ -0,0 +1,35 @@
+#ifndef _IFADDRS_H
+#define _IFADDRS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+
+struct ifaddrs {
+       struct ifaddrs *ifa_next;
+       char *ifa_name;
+       unsigned ifa_flags;
+       struct sockaddr *ifa_addr;
+       struct sockaddr *ifa_netmask;
+       union {
+               struct sockaddr *ifu_broadaddr;
+               struct sockaddr *ifu_dstaddr;
+       } ifa_ifu;
+       void *ifa_data;
+};
+#define ifa_broadaddr ifa_ifu.ifu_broadaddr
+#define ifa_dstaddr ifa_ifu.ifu_dstaddr
+
+void freeifaddrs(struct ifaddrs *);
+int getifaddrs(struct ifaddrs **);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/musl-imported/include/net/ethernet.h 
b/musl-imported/include/net/ethernet.h
new file mode 100644
index 0000000..c8d4177
--- /dev/null
+++ b/musl-imported/include/net/ethernet.h
@@ -0,0 +1,55 @@
+#ifndef _NET_ETHERNET_H
+#define _NET_ETHERNET_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+#include <sys/types.h>
+#include <netinet/if_ether.h>
+
+struct ether_addr {
+       uint8_t ether_addr_octet[ETH_ALEN];
+};
+
+struct ether_header {
+       uint8_t  ether_dhost[ETH_ALEN];
+       uint8_t  ether_shost[ETH_ALEN];
+       uint16_t ether_type;
+};
+
+#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
+
+
+#define        ETHER_ADDR_LEN  ETH_ALEN
+#define        ETHER_TYPE_LEN  2
+#define        ETHER_CRC_LEN   4
+#define        ETHER_HDR_LEN   ETH_HLEN
+#define        ETHER_MIN_LEN   (ETH_ZLEN + ETHER_CRC_LEN)
+#define        ETHER_MAX_LEN   (ETH_FRAME_LEN + ETHER_CRC_LEN)
+
+#define        ETHER_IS_VALID_LEN(foo) \
+       ((foo) >= ETHER_MIN_LEN && (foo) <= ETHER_MAX_LEN)
+
+#define        ETHERTYPE_TRAIL         0x1000
+#define        ETHERTYPE_NTRAILER      16
+
+#define        ETHERMTU        ETH_DATA_LEN
+#define        ETHERMIN        (ETHER_MIN_LEN - ETHER_HDR_LEN - ETHER_CRC_LEN)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/musl-imported/include/net/if_arp.h 
b/musl-imported/include/net/if_arp.h
new file mode 100644
index 0000000..27becc8
--- /dev/null
+++ b/musl-imported/include/net/if_arp.h
@@ -0,0 +1,142 @@
+/* Nonstandard header */
+#ifndef _NET_IF_ARP_H
+#define _NET_IF_ARP_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <inttypes.h>
+#include <sys/types.h>
+#include <sys/socket.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
+
+struct arphdr {
+       uint16_t ar_hrd;
+       uint16_t ar_pro;
+       uint8_t ar_hln;
+       uint8_t ar_pln;
+       uint16_t ar_op;
+};
+
+
+#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 arpreq {
+       struct sockaddr arp_pa;
+       struct sockaddr arp_ha;
+       int arp_flags;
+       struct sockaddr arp_netmask;
+       char arp_dev[16];
+};
+
+struct arpreq_old {
+       struct sockaddr arp_pa;
+       struct sockaddr arp_ha;
+       int arp_flags;
+       struct sockaddr arp_netmask;
+};
+
+#define ATF_COM                0x02
+#define        ATF_PERM        0x04
+#define        ATF_PUBL        0x08
+#define        ATF_USETRAILERS 0x10
+#define ATF_NETMASK     0x20
+#define ATF_DONTPUB    0x40
+#define ATF_MAGIC      0x80
+
+#define ARPD_UPDATE    0x01
+#define ARPD_LOOKUP    0x02
+#define ARPD_FLUSH     0x03
+
+struct arpd_request {
+       unsigned short req;
+       uint32_t ip;
+       unsigned long dev;
+       unsigned long stamp;
+       unsigned long updated;
+       unsigned char ha[MAX_ADDR_LEN];
+};
+
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/musl-imported/include/netinet/if_ether.h 
b/musl-imported/include/netinet/if_ether.h
new file mode 100644
index 0000000..ecd6c73
--- /dev/null
+++ b/musl-imported/include/netinet/if_ether.h
@@ -0,0 +1,145 @@
+#ifndef _NETINET_IF_ETHER_H
+#define _NETINET_IF_ETHER_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#define ETH_ALEN       6
+#define ETH_TLEN       2
+#define ETH_HLEN       14
+#define ETH_ZLEN       60
+#define ETH_DATA_LEN   1500
+#define ETH_FRAME_LEN  1514
+#define ETH_FCS_LEN    4
+#define ETH_MIN_MTU    68
+#define ETH_MAX_MTU    0xFFFFU
+
+#define ETH_P_LOOP     0x0060
+#define ETH_P_PUP      0x0200
+#define ETH_P_PUPAT    0x0201
+#define ETH_P_TSN      0x22F0
+#define ETH_P_ERSPAN2  0x22EB
+#define ETH_P_IP       0x0800
+#define ETH_P_X25      0x0805
+#define ETH_P_ARP      0x0806
+#define        ETH_P_BPQ       0x08FF
+#define ETH_P_IEEEPUP  0x0a00
+#define ETH_P_IEEEPUPAT        0x0a01
+#define ETH_P_BATMAN   0x4305
+#define ETH_P_DEC       0x6000
+#define ETH_P_DNA_DL    0x6001
+#define ETH_P_DNA_RC    0x6002
+#define ETH_P_DNA_RT    0x6003
+#define ETH_P_LAT       0x6004
+#define ETH_P_DIAG      0x6005
+#define ETH_P_CUST      0x6006
+#define ETH_P_SCA       0x6007
+#define ETH_P_TEB      0x6558
+#define ETH_P_RARP      0x8035
+#define ETH_P_ATALK    0x809B
+#define ETH_P_AARP     0x80F3
+#define ETH_P_8021Q    0x8100
+#define ETH_P_IPX      0x8137
+#define ETH_P_IPV6     0x86DD
+#define ETH_P_PAUSE    0x8808
+#define ETH_P_SLOW     0x8809
+#define ETH_P_WCCP     0x883E
+#define ETH_P_MPLS_UC  0x8847
+#define ETH_P_MPLS_MC  0x8848
+#define ETH_P_ATMMPOA  0x884c
+#define ETH_P_PPP_DISC 0x8863
+#define ETH_P_PPP_SES  0x8864
+#define ETH_P_LINK_CTL 0x886c
+#define ETH_P_ATMFATE  0x8884
+#define ETH_P_PAE      0x888E
+#define ETH_P_AOE      0x88A2
+#define ETH_P_8021AD   0x88A8
+#define ETH_P_802_EX1  0x88B5
+#define ETH_P_ERSPAN   0x88BE
+#define ETH_P_PREAUTH  0x88C7
+#define ETH_P_TIPC     0x88CA
+#define ETH_P_MACSEC   0x88E5
+#define ETH_P_8021AH   0x88E7
+#define ETH_P_MVRP     0x88F5
+#define ETH_P_1588     0x88F7
+#define ETH_P_NCSI     0x88F8
+#define ETH_P_PRP      0x88FB
+#define ETH_P_FCOE     0x8906
+#define ETH_P_TDLS     0x890D
+#define ETH_P_FIP      0x8914
+#define ETH_P_IBOE     0x8915
+#define ETH_P_80221    0x8917
+#define ETH_P_HSR      0x892F
+#define ETH_P_NSH      0x894F
+#define ETH_P_LOOPBACK 0x9000
+#define ETH_P_QINQ1    0x9100
+#define ETH_P_QINQ2    0x9200
+#define ETH_P_QINQ3    0x9300
+#define ETH_P_EDSA     0xDADA
+#define ETH_P_IFE      0xED3E
+#define ETH_P_AF_IUCV  0xFBFB
+
+#define ETH_P_802_3_MIN        0x0600
+
+#define ETH_P_802_3    0x0001
+#define ETH_P_AX25     0x0002
+#define ETH_P_ALL      0x0003
+#define ETH_P_802_2    0x0004
+#define ETH_P_SNAP     0x0005
+#define ETH_P_DDCMP     0x0006
+#define ETH_P_WAN_PPP   0x0007
+#define ETH_P_PPP_MP    0x0008
+#define ETH_P_LOCALTALK 0x0009
+#define ETH_P_CAN      0x000C
+#define ETH_P_CANFD    0x000D
+#define ETH_P_PPPTALK  0x0010
+#define ETH_P_TR_802_2 0x0011
+#define ETH_P_MOBITEX  0x0015
+#define ETH_P_CONTROL  0x0016
+#define ETH_P_IRDA     0x0017
+#define ETH_P_ECONET   0x0018
+#define ETH_P_HDLC     0x0019
+#define ETH_P_ARCNET   0x001A
+#define ETH_P_DSA      0x001B
+#define ETH_P_TRAILER  0x001C
+#define ETH_P_PHONET   0x00F5
+#define ETH_P_IEEE802154 0x00F6
+#define ETH_P_CAIF     0x00F7
+#define ETH_P_XDSA     0x00F8
+#define ETH_P_MAP      0x00F9
+
+struct ethhdr {
+       uint8_t h_dest[ETH_ALEN];
+       uint8_t h_source[ETH_ALEN];
+       uint16_t h_proto;
+};
+
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+
+struct ether_arp {
+       struct  arphdr ea_hdr;
+       uint8_t arp_sha[ETH_ALEN];
+       uint8_t arp_spa[4];
+       uint8_t arp_tha[ETH_ALEN];
+       uint8_t arp_tpa[4];
+};
+#define        arp_hrd ea_hdr.ar_hrd
+#define        arp_pro ea_hdr.ar_pro
+#define        arp_hln ea_hdr.ar_hln
+#define        arp_pln ea_hdr.ar_pln
+#define        arp_op  ea_hdr.ar_op
+
+#define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \
+do { \
+       (enaddr)[0] = 0x01; \
+       (enaddr)[1] = 0x00; \
+       (enaddr)[2] = 0x5e; \
+       (enaddr)[3] = ((uint8_t *)ipaddr)[1] & 0x7f; \
+       (enaddr)[4] = ((uint8_t *)ipaddr)[2]; \
+       (enaddr)[5] = ((uint8_t *)ipaddr)[3]; \
+} while(0)
+
+#define __UAPI_DEF_ETHHDR       0
+
+#endif
diff --git a/musl-imported/include/netinet/in_systm.h 
b/musl-imported/include/netinet/in_systm.h
new file mode 100644
index 0000000..a7b4177
--- /dev/null
+++ b/musl-imported/include/netinet/in_systm.h
@@ -0,0 +1,9 @@
+#ifndef _NETINET_IN_SYSTM_H
+#define _NETINET_IN_SYSTM_H
+
+#include <stdint.h>
+
+typedef uint16_t n_short;
+typedef uint32_t n_long, n_time;
+
+#endif
diff --git a/musl-imported/include/netinet/udp.h 
b/musl-imported/include/netinet/udp.h
new file mode 100644
index 0000000..ffd8907
--- /dev/null
+++ b/musl-imported/include/netinet/udp.h
@@ -0,0 +1,45 @@
+#ifndef _NETINET_UDP_H
+#define _NETINET_UDP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <features.h>
+#include <stdint.h>
+
+#ifdef _GNU_SOURCE
+#define uh_sport source
+#define uh_dport dest
+#define uh_ulen len
+#define uh_sum check
+#endif
+
+struct udphdr {
+       uint16_t uh_sport;
+       uint16_t uh_dport;
+       uint16_t uh_ulen;
+       uint16_t uh_sum;
+};
+
+#define UDP_CORK       1
+#define UDP_ENCAP      100
+#define UDP_NO_CHECK6_TX 101
+#define UDP_NO_CHECK6_RX 102
+#define UDP_SEGMENT    103
+#define UDP_GRO                104
+
+#define UDP_ENCAP_ESPINUDP_NON_IKE 1
+#define UDP_ENCAP_ESPINUDP     2
+#define UDP_ENCAP_L2TPINUDP    3
+#define UDP_ENCAP_GTP0         4
+#define UDP_ENCAP_GTP1U                5
+#define UDP_ENCAP_RXRPC                6
+
+#define SOL_UDP            17
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/musl-imported/include/netpacket/packet.h 
b/musl-imported/include/netpacket/packet.h
new file mode 100644
index 0000000..b36e092
--- /dev/null
+++ b/musl-imported/include/netpacket/packet.h
@@ -0,0 +1,62 @@
+#ifndef _NETPACKET_PACKET_H
+#define _NETPACKET_PACKET_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct sockaddr_ll {
+       unsigned short sll_family, sll_protocol;
+       int sll_ifindex;
+       unsigned short sll_hatype;
+       unsigned char sll_pkttype, sll_halen;
+       unsigned char sll_addr[8];
+};
+
+struct packet_mreq {
+       int mr_ifindex;
+       unsigned short int mr_type,  mr_alen;
+       unsigned char mr_address[8];
+};
+
+#define PACKET_HOST            0
+#define PACKET_BROADCAST       1
+#define PACKET_MULTICAST       2
+#define PACKET_OTHERHOST       3
+#define PACKET_OUTGOING                4
+#define PACKET_LOOPBACK                5
+#define PACKET_FASTROUTE       6
+
+#define PACKET_ADD_MEMBERSHIP          1
+#define PACKET_DROP_MEMBERSHIP         2
+#define        PACKET_RECV_OUTPUT              3
+#define        PACKET_RX_RING                  5
+#define        PACKET_STATISTICS               6
+#define PACKET_COPY_THRESH             7
+#define PACKET_AUXDATA                 8
+#define PACKET_ORIGDEV                 9
+#define PACKET_VERSION                 10
+#define PACKET_HDRLEN                  11
+#define PACKET_RESERVE                 12
+#define PACKET_TX_RING                 13
+#define PACKET_LOSS                    14
+#define PACKET_VNET_HDR                        15
+#define PACKET_TX_TIMESTAMP            16
+#define PACKET_TIMESTAMP               17
+#define PACKET_FANOUT                  18
+#define PACKET_TX_HAS_OFF              19
+#define PACKET_QDISC_BYPASS            20
+#define PACKET_ROLLOVER_STATS          21
+#define PACKET_FANOUT_DATA             22
+#define PACKET_IGNORE_OUTGOING         23
+
+#define PACKET_MR_MULTICAST    0
+#define PACKET_MR_PROMISC      1
+#define PACKET_MR_ALLMULTI     2
+#define PACKET_MR_UNICAST      3
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
-- 
2.20.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.