diff --git a/src/libs/compat/freebsd11_network/compat.c b/src/libs/compat/freebsd11_network/compat.c index 3383226d98..73ff57795d 100644 --- a/src/libs/compat/freebsd11_network/compat.c +++ b/src/libs/compat/freebsd11_network/compat.c @@ -621,6 +621,18 @@ resource_int_value(const char *name, int unit, const char *resname, } +int +resource_disabled(const char *name, int unit) +{ + int error, value; + + error = resource_int_value(name, unit, "disabled", &value); + if (error) + return (0); + return (value); +} + + void * _kernel_malloc(size_t size, int flags) { diff --git a/src/libs/compat/freebsd11_network/compat/dev/led/led.h b/src/libs/compat/freebsd11_network/compat/dev/led/led.h new file mode 100644 index 0000000000..bad1a2c426 --- /dev/null +++ b/src/libs/compat/freebsd11_network/compat/dev/led/led.h @@ -0,0 +1,35 @@ +/* + * Copyright 2018, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT license. + */ +#ifndef _FBSD_COMPAT_DEV_LED_LED_H_ +#define _FBSD_COMPAT_DEV_LED_LED_H_ + + +typedef void led_t(void*, int); + + +struct cdev* led_create_state(led_t* func, void* priv, char const* name, int state) +{ + return NULL; +} + + +struct cdev* led_create(led_t* func, void* priv, char const* name) +{ + return NULL; +} + + +void led_destroy(struct cdev* dev) +{ +} + + +int led_set(char const* name, char const* cmd) +{ + return -1; +} + + +#endif /* _FBSD_COMPAT_DEV_LED_LED_H_ */ diff --git a/src/libs/compat/freebsd11_network/compat/machine/smp.h b/src/libs/compat/freebsd11_network/compat/machine/smp.h new file mode 100644 index 0000000000..3285153d39 --- /dev/null +++ b/src/libs/compat/freebsd11_network/compat/machine/smp.h @@ -0,0 +1,12 @@ +/* + * Copyright 2018, Haiku, Inc. All rights reserved. + * Distributed under the terms of the MIT license. + */ +#ifndef _FBSD_COMPAT_MACHINE_SMP_H_ +#define _FBSD_COMPAT_MACHINE_SMP_H_ + + +#include + + +#endif /* _FBSD_COMPAT_MACHINE_SMP_H_ */ diff --git a/src/libs/compat/freebsd11_network/compat/net/if.h b/src/libs/compat/freebsd11_network/compat/net/if.h index efa6d4554f..fde4ef522c 100644 --- a/src/libs/compat/freebsd11_network/compat/net/if.h +++ b/src/libs/compat/freebsd11_network/compat/net/if.h @@ -18,29 +18,41 @@ #define IF_Gbps(x) (IF_Mbps((x) * 1000)) /* Capabilities that interfaces can advertise. */ -#define IFCAP_RXCSUM 0x00001 /* can offload checksum on RX */ -#define IFCAP_TXCSUM 0x00002 /* can offload checksum on TX */ -#define IFCAP_NETCONS 0x00004 /* can be a network console */ -#define IFCAP_VLAN_MTU 0x00008 /* VLAN-compatible MTU */ +#define IFCAP_RXCSUM 0x00001 /* can offload checksum on RX */ +#define IFCAP_TXCSUM 0x00002 /* can offload checksum on TX */ +#define IFCAP_NETCONS 0x00004 /* can be a network console */ +#define IFCAP_VLAN_MTU 0x00008 /* VLAN-compatible MTU */ #define IFCAP_VLAN_HWTAGGING 0x00010 /* hardware VLAN tag support */ -#define IFCAP_JUMBO_MTU 0x00020 /* 9000 byte MTU supported */ -#define IFCAP_POLLING 0x00040 /* driver supports polling */ -#define IFCAP_VLAN_HWCSUM 0x00080 -#define IFCAP_TSO4 0x00100 /* supports TCP segmentation offload */ -#define IFCAP_TSO6 0x00200 /* can do TCP6 Segmentation Offload */ -#define IFCAP_WOL_UCAST 0x00800 /* wake on any unicast frame */ -#define IFCAP_WOL_MCAST 0x01000 /* wake on any multicast frame */ -#define IFCAP_WOL_MAGIC 0x02000 /* wake on any Magic Packet */ -#define IFCAP_VLAN_HWFILTER 0x10000 /* interface hw can filter vlan tag */ -#define IFCAP_POLLING_NOCOUNT 0x20000 -#define IFCAP_VLAN_HWTSO 0x40000 -#define IFCAP_LINKSTATE 0x80000 +#define IFCAP_JUMBO_MTU 0x00020 /* 9000 byte MTU supported */ +#define IFCAP_POLLING 0x00040 /* driver supports polling */ +#define IFCAP_VLAN_HWCSUM 0x00080 /* can do IFCAP_HWCSUM on VLANs */ +#define IFCAP_TSO4 0x00100 /* can do TCP Segmentation Offload */ +#define IFCAP_TSO6 0x00200 /* can do TCP6 Segmentation Offload */ +#define IFCAP_LRO 0x00400 /* can do Large Receive Offload */ +#define IFCAP_WOL_UCAST 0x00800 /* wake on any unicast frame */ +#define IFCAP_WOL_MCAST 0x01000 /* wake on any multicast frame */ +#define IFCAP_WOL_MAGIC 0x02000 /* wake on any Magic Packet */ +#define IFCAP_TOE4 0x04000 /* interface can offload TCP */ +#define IFCAP_TOE6 0x08000 /* interface can offload TCP6 */ +#define IFCAP_VLAN_HWFILTER 0x10000 /* interface hw can filter vlan tag */ +#define IFCAP_POLLING_NOCOUNT 0x20000 /* polling ticks cannot be fragmented */ +#define IFCAP_VLAN_HWTSO 0x40000 /* can do IFCAP_TSO on VLANs */ +#define IFCAP_LINKSTATE 0x80000 /* the runtime link state is dynamic */ +#define IFCAP_NETMAP 0x100000 /* netmap mode supported/enabled */ +#define IFCAP_RXCSUM_IPV6 0x200000 /* can offload checksum on IPv6 RX */ +#define IFCAP_TXCSUM_IPV6 0x400000 /* can offload checksum on IPv6 TX */ +#define IFCAP_HWSTATS 0x800000 /* manages counters internally */ + +#define IFCAP_HWCSUM_IPV6 (IFCAP_RXCSUM_IPV6 | IFCAP_TXCSUM_IPV6) #define IFCAP_HWCSUM (IFCAP_RXCSUM | IFCAP_TXCSUM) -#define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) -#define IFCAP_WOL (IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC) +#define IFCAP_TSO (IFCAP_TSO4 | IFCAP_TSO6) +#define IFCAP_WOL (IFCAP_WOL_UCAST | IFCAP_WOL_MCAST | IFCAP_WOL_MAGIC) +#define IFCAP_TOE (IFCAP_TOE4 | IFCAP_TOE6) +#define IFCAP_CANTCHANGE (IFCAP_NETMAP) +/* Interface flags */ #define IFF_DRV_RUNNING 0x00010000 #define IFF_DRV_OACTIVE 0x00020000 #define IFF_LINK0 0x00040000 /* per link layer defined bit */ diff --git a/src/libs/compat/freebsd11_network/compat/sys/bus.h b/src/libs/compat/freebsd11_network/compat/sys/bus.h index a4ad385a04..a4d6637905 100644 --- a/src/libs/compat/freebsd11_network/compat/sys/bus.h +++ b/src/libs/compat/freebsd11_network/compat/sys/bus.h @@ -84,6 +84,7 @@ typedef void driver_intr_t(void *); int resource_int_value(const char *name, int unit, const char *resname, int *result); +int resource_disabled(const char *name, int unit); struct resource *bus_alloc_resource(device_t dev, int type, int *rid, unsigned long start, unsigned long end, unsigned long count, uint32 flags); diff --git a/src/libs/compat/freebsd11_network/compat/sys/libkern.h b/src/libs/compat/freebsd11_network/compat/sys/libkern.h index a564410646..784f3abede 100644 --- a/src/libs/compat/freebsd11_network/compat/sys/libkern.h +++ b/src/libs/compat/freebsd11_network/compat/sys/libkern.h @@ -11,8 +11,9 @@ extern int random(void); -uint32_t arc4random(void); u_int read_random(void *, u_int); +void arc4rand(void *ptr, u_int len, int reseed); +uint32_t arc4random(void); static __inline int imax(int a, int b) { return (a > b ? a : b); } static __inline int imin(int a, int b) { return (a < b ? a : b); } diff --git a/src/libs/compat/freebsd11_network/compat/sys/mbuf.h b/src/libs/compat/freebsd11_network/compat/sys/mbuf.h index fd1d8dc814..054c9b01e4 100644 --- a/src/libs/compat/freebsd11_network/compat/sys/mbuf.h +++ b/src/libs/compat/freebsd11_network/compat/sys/mbuf.h @@ -148,15 +148,47 @@ #define EXT_FLAG_EMBREF 0x000001 /* embedded ext_count */ #define EXT_FLAG_EXTREF 0x000002 /* external ext_cnt, notyet */ -#define CSUM_IP 0x0001 -#define CSUM_TCP 0x0002 -#define CSUM_UDP 0x0004 -#define CSUM_TSO 0x0020 -#define CSUM_IP_CHECKED 0x0100 -#define CSUM_IP_VALID 0x0200 -#define CSUM_DATA_VALID 0x0400 -#define CSUM_PSEUDO_HDR 0x0800 -#define CSUM_DELAY_DATA (CSUM_TCP | CSUM_UDP) +/* Flags indicating checksum, segmentation and other offload work */ +#define CSUM_IP 0x00000001 /* IP header checksum offload */ +#define CSUM_IP_UDP 0x00000002 /* UDP checksum offload */ +#define CSUM_IP_TCP 0x00000004 /* TCP checksum offload */ +#define CSUM_IP_SCTP 0x00000008 /* SCTP checksum offload */ +#define CSUM_IP_TSO 0x00000010 /* TCP segmentation offload */ +#define CSUM_IP_ISCSI 0x00000020 /* iSCSI checksum offload */ + +#define CSUM_IP6_UDP 0x00000200 /* UDP checksum offload */ +#define CSUM_IP6_TCP 0x00000400 /* TCP checksum offload */ +#define CSUM_IP6_SCTP 0x00000800 /* SCTP checksum offload */ +#define CSUM_IP6_TSO 0x00001000 /* TCP segmentation offload */ +#define CSUM_IP6_ISCSI 0x00002000 /* iSCSI checksum offload */ + +/* Inbound checksum support where the checksum was verified by hardware. */ +#define CSUM_L3_CALC 0x01000000 /* calculated layer 3 csum */ +#define CSUM_L3_VALID 0x02000000 /* checksum is correct */ +#define CSUM_L4_CALC 0x04000000 /* calculated layer 4 csum */ +#define CSUM_L4_VALID 0x08000000 /* checksum is correct */ +#define CSUM_L5_CALC 0x10000000 /* calculated layer 5 csum */ +#define CSUM_L5_VALID 0x20000000 /* checksum is correct */ +#define CSUM_COALESCED 0x40000000 /* contains merged segments */ + +/* CSUM flags compatibility mappings. */ +#define CSUM_IP_CHECKED CSUM_L3_CALC +#define CSUM_IP_VALID CSUM_L3_VALID +#define CSUM_DATA_VALID CSUM_L4_VALID +#define CSUM_PSEUDO_HDR CSUM_L4_CALC +#define CSUM_SCTP_VALID CSUM_L4_VALID +#define CSUM_DELAY_DATA (CSUM_TCP|CSUM_UDP) +#define CSUM_DELAY_IP CSUM_IP /* Only v4, no v6 IP hdr csum */ +#define CSUM_DELAY_DATA_IPV6 (CSUM_TCP_IPV6|CSUM_UDP_IPV6) +#define CSUM_DATA_VALID_IPV6 CSUM_DATA_VALID +#define CSUM_TCP CSUM_IP_TCP +#define CSUM_UDP CSUM_IP_UDP +#define CSUM_SCTP CSUM_IP_SCTP +#define CSUM_TSO (CSUM_IP_TSO|CSUM_IP6_TSO) +#define CSUM_UDP_IPV6 CSUM_IP6_UDP +#define CSUM_TCP_IPV6 CSUM_IP6_TCP +#define CSUM_SCTP_IPV6 CSUM_IP6_SCTP + #define MEXTADD(m, buf, size, free, arg1, arg2, flags, type) \ m_extadd((m), (caddr_t)(buf), (size), (free),(arg1),(arg2),(flags), (type)) diff --git a/src/libs/compat/freebsd11_network/libkern.cpp b/src/libs/compat/freebsd11_network/libkern.cpp index 791fa88e63..adeb122a05 100644 --- a/src/libs/compat/freebsd11_network/libkern.cpp +++ b/src/libs/compat/freebsd11_network/libkern.cpp @@ -21,9 +21,18 @@ read_random(void* buf, u_int len) } +void +arc4rand(void *ptr, u_int len, int reseed) +{ + read_random(ptr, len); +} + + uint32_t arc4random(void) { - return random(); -} + uint32_t ret; + arc4rand(&ret, sizeof ret, 0); + return ret; +}