diff --git a/include/posix/netinet/in.h b/include/posix/netinet/in.h index 5f5ef04..e190c39 100644 --- a/include/posix/netinet/in.h +++ b/include/posix/netinet/in.h @@ -6,4 +6,57 @@ #include +#ifndef CONFIG_LWIP +/** + * Convert an u16_t from host- to network byte order. + * + * @param n u16_t in host byte order + * @return n in network byte order + */ +inline u16_t +htons(u16_t n) +{ + return ((n & 0xff) << 8) | ((n & 0xff00) >> 8); +} + +/** + * Convert an u16_t from network- to host byte order. + * + * @param n u16_t in network byte order + * @return n in host byte order + */ +inline u16_t +ntohs(u16_t n) +{ + return htons(n); +} + +/** + * Convert an u32_t from host- to network byte order. + * + * @param n u32_t in host byte order + * @return n in network byte order + */ +inline u32_t +htonl(u32_t n) +{ + return ((n & 0xff) << 24) | + ((n & 0xff00) << 8) | + ((n & 0xff0000UL) >> 8) | + ((n & 0xff000000UL) >> 24); +} + +/** + * Convert an u32_t from network- to host byte order. + * + * @param n u32_t in network byte order + * @return n in host byte order + */ +inline u32_t +ntohl(u32_t n) +{ + return htonl(n); +} +#endif + #endif /* _POSIX_SYS_IN_H_ */ diff --git a/stub.mk b/stub.mk index ae6ac01..b216007 100644 --- a/stub.mk +++ b/stub.mk @@ -129,7 +129,7 @@ CONFIG_CONSFRONT ?= n CONFIG_CONSFRONT_SYNC ?= n CONFIG_XENBUS ?= y CONFIG_XC ?= y -CONFIG_LWIP ?= y +CONFIG_LWIP ?= n CONFIG_SHUTDOWN ?= y CONFIG_PVH ?= y @@ -146,8 +146,6 @@ MINIOS_OBJS0-y := \ hypervisor.o \ kernel.o \ lock.o \ - lwip-arch.o \ - lwip-net.o \ main.o \ math.o \ mm.o \ @@ -159,6 +157,7 @@ MINIOS_OBJS0-y := \ sys.o \ xencons_ring.o \ xmalloc.o +MINIOS_OBJS0-$(CONFIG_LWIP) += lwip-arch.o lwip-net.o MINIOS_OBJS0-$(CONFIG_XENBUS) += xenbus.o MINIOS_OBJS0-$(CONFIG_XENBUS) += xs.o MINIOS_OBJS0-$(CONFIG_BLKFRONT) += blkfront.o @@ -169,6 +168,7 @@ MINIOS_OBJS0-$(CONFIG_FBFRONT) += fbfront.o MINIOS_OBJS0-$(CONFIG_PCIFRONT) += pcifront.o MINIOS_OBJS0-$(CONFIG_CONSFRONT) += xencons_bus.o MINIOS_OBJS0-$(CONFIG_NETFRONT) += netfront.o +MINIOS_OPT_FLAGS-$(CONFIG_LWIP) += -DCONFIG_LWIP MINIOS_OPT_FLAGS-$(CONFIG_START_NETWORK) += -DCONFIG_START_NETWORK MINIOS_OPT_FLAGS-$(CONFIG_SPARSE_BSS) += -DCONFIG_SPARSE_BSS MINIOS_OPT_FLAGS-$(CONFIG_QEMU_XS_ARGS) += -DCONFIG_QEMU_XS_ARGS @@ -387,6 +387,8 @@ distclean-lwip: else +CINCLUDES += -isystem $(LWIP_ROOT)/include/lwip +CINCLUDES += -isystem $(LWIP_ROOT)/include/lwip/ipv4 MINIOS_LWIP_LIB := MINIOS_LWIP_OBJS :=