Add <netinet/in.h> for hton/ntoh macros

diff --git a/include/extern.h b/include/extern.h
deleted file mode 100644
index f3369ba..0000000
--- a/include/extern.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/*
- * extern.h
- */
-
-#ifndef _EXTERN_H
-#define _EXTERN_H
-
-#ifdef __cplusplus
-#define __extern extern "C"
-#else
-#define __extern extern
-#endif
-
-#endif /* _EXTERN_H */
diff --git a/include/netinet/in.h b/include/netinet/in.h
new file mode 100644
index 0000000..a4bcb7e
--- /dev/null
+++ b/include/netinet/in.h
@@ -0,0 +1,45 @@
+/*
+ * netinet/in.h
+ */
+
+#ifndef _NETINET_IN_H
+#define _NETINET_IN_H
+
+#include <stdint.h>
+#include <endian.h>
+
+#ifdef __BIG_ENDIAN
+
+#define htonl(x) ((uint32_t)(x))
+#define ntohl(x) ((uint32_t)(x))
+#define htons(x) ((uint16_t)(x))
+#define ntohs(x) ((uint16_t)(x))
+
+#elif defined(__LITTLE_ENDIAN)
+
+static __inline__
+uint32_t htonl(uint32_t __x)
+{
+#if defined(__i486__)||defined(__pentium__)||defined(__pentiumpro__)
+  asm("bswap %0" : "+rm" (__x));
+  return __x;
+#else
+  return (__x >> 24) + ((__x >> 8) & 0xff00) +
+    ((__x & 0xff00) << 8) + (__x << 24);
+#endif
+}
+
+static __inline__
+uint16_t htons(uint16_t __x)
+{
+  return (__x >> 8) + (__x << 8);
+}
+
+#define htonl(x) htonl(x)
+#define ntohl(x) htohl(x)
+#define htons(x) htons(x)
+#define ntohs(x) htons(x)
+
+#endif /* endian */
+
+#endif /* _NETINET_IN_H */
diff --git a/klibc/include/netinet/in.h b/klibc/include/netinet/in.h
new file mode 100644
index 0000000..a4bcb7e
--- /dev/null
+++ b/klibc/include/netinet/in.h
@@ -0,0 +1,45 @@
+/*
+ * netinet/in.h
+ */
+
+#ifndef _NETINET_IN_H
+#define _NETINET_IN_H
+
+#include <stdint.h>
+#include <endian.h>
+
+#ifdef __BIG_ENDIAN
+
+#define htonl(x) ((uint32_t)(x))
+#define ntohl(x) ((uint32_t)(x))
+#define htons(x) ((uint16_t)(x))
+#define ntohs(x) ((uint16_t)(x))
+
+#elif defined(__LITTLE_ENDIAN)
+
+static __inline__
+uint32_t htonl(uint32_t __x)
+{
+#if defined(__i486__)||defined(__pentium__)||defined(__pentiumpro__)
+  asm("bswap %0" : "+rm" (__x));
+  return __x;
+#else
+  return (__x >> 24) + ((__x >> 8) & 0xff00) +
+    ((__x & 0xff00) << 8) + (__x << 24);
+#endif
+}
+
+static __inline__
+uint16_t htons(uint16_t __x)
+{
+  return (__x >> 8) + (__x << 8);
+}
+
+#define htonl(x) htonl(x)
+#define ntohl(x) htohl(x)
+#define htons(x) htons(x)
+#define ntohs(x) htons(x)
+
+#endif /* endian */
+
+#endif /* _NETINET_IN_H */