Remove old unused code

Change-Id: Icfa4cd429df4330b60dc2752af0e8124981ad579
diff --git a/aos/BUILD b/aos/BUILD
index 617b91c..86aa433 100644
--- a/aos/BUILD
+++ b/aos/BUILD
@@ -47,15 +47,6 @@
     visibility = ["//visibility:public"],
 )
 
-cc_library(
-    name = "byteorder",
-    hdrs = [
-        "byteorder.h",
-    ],
-    target_compatible_with = ["@platforms//os:linux"],
-    visibility = ["//visibility:public"],
-)
-
 py_library(
     name = "python_init",
     srcs = ["__init__.py"],
@@ -81,15 +72,6 @@
 )
 
 cc_library(
-    name = "network_port",
-    hdrs = [
-        "network_port.h",
-    ],
-    target_compatible_with = ["@platforms//os:linux"],
-    visibility = ["//visibility:public"],
-)
-
-cc_library(
     name = "unique_malloc_ptr",
     hdrs = [
         "unique_malloc_ptr.h",
diff --git a/aos/byteorder.h b/aos/byteorder.h
deleted file mode 100644
index 4a0fd8c..0000000
--- a/aos/byteorder.h
+++ /dev/null
@@ -1,201 +0,0 @@
-#ifndef AOS_BYTEORDER_H_
-#define AOS_BYTEORDER_H_
-
-#ifndef __VXWORKS__
-#include <endian.h> // endian(3)
-#endif
-#include <string.h>
-#include <stdint.h>
-
-// Contains functions for converting between host and network byte order for
-// things other than 16/32 bit integers (those are provided by byteorder(3)).
-// Also gives a nice templated interface to these functions.
-
-namespace aos {
-namespace {
-
-template <typename int_type, int_type (*function)(int_type)>
-static inline void copier(const void *in, void *out) {
-  // Have confirmed by looking at the assembly code that this generates the same
-  // code as the (undefined by the c++ standard) way of using a union to do it.
-  // (which is pretty efficient)
-  int_type temp;
-  memcpy(&temp, in, sizeof(int_type));
-  temp = function(temp);
-  memcpy(out, &temp, sizeof(int_type));
-}
-template <typename int_type, typename T, int_type (*function)(int_type)>
-static inline T memcpier(T in) {
-  copier<int_type, function>(&in, &in);
-  return in;
-}
-
-// Needed because be64toh etc are macros (not that the manpage says
-// anything...).
-// These are used instead of ntohs etc because gcc didn't inline those.
-#ifdef __clang__
-// Apparently the macros use "register", and clang doesn't like that.
-#define register
-#endif
-static inline uint64_t _be64toh(uint64_t in) { return be64toh(in); }
-static inline uint64_t _htobe64(uint64_t in) { return htobe64(in); }
-static inline uint32_t _be32toh(uint32_t in) { return be32toh(in); }
-static inline uint32_t _htobe32(uint32_t in) { return htobe32(in); }
-static inline uint16_t _be16toh(uint16_t in) { return be16toh(in); }
-static inline uint16_t _htobe16(uint16_t in) { return htobe16(in); }
-#ifdef __clang__
-#undef register
-#endif
-
-template<int bytes, typename T> class do_ntoh {
- public:
-  static inline T apply(T net);
-  static inline void copy(const char *in, T &net);
-};
-template<typename T> class do_ntoh<1, T> {
- public:
-  static inline T apply(T net) { return net; }
-  static inline void copy(const char *in, T *host) { host[0] = in[0]; }
-};
-template<typename T> class do_ntoh<2, T> {
- public:
-  static inline T apply(T net) { return memcpier<uint16_t, T, _be16toh>(net); }
-  static inline void copy(const char *in, T *host) {
-    copier<uint16_t, _be16toh>(in, host);
-  }
-};
-template<typename T> class do_ntoh<4, T> {
- public:
-  static inline T apply(T net) { return memcpier<uint32_t, T, _be32toh>(net); }
-  static inline void copy(const char *in, T *host) {
-    copier<uint32_t, _be32toh>(in, host);
-  }
-};
-template<typename T> class do_ntoh<8, T> {
- public:
-  static inline T apply(T net) { return memcpier<uint64_t, T, _be64toh>(net); }
-  static inline void copy(const char *in, T *host) {
-    copier<uint64_t, _be64toh>(in, host);
-  }
-};
-
-template <size_t Size>
-struct do_ntoh_int {
-  static inline void copy(const char *in, char *host);
-};
-template <>
-struct do_ntoh_int<1> {
-  static inline void copy(const char *in, char *host) { host[0] = in[0]; }
-};
-template <>
-struct do_ntoh_int<2> {
-  static inline void copy(const char *in, char *host) {
-    copier<uint16_t, _be16toh>(in, host);
-  }
-};
-template <>
-struct do_ntoh_int<4> {
-  static inline void copy(const char *in, char *host) {
-    copier<uint32_t, _be32toh>(in, host);
-  }
-};
-template <>
-struct do_ntoh_int<8> {
-  static inline void copy(const char *in, char *host) {
-    copier<uint64_t, _be64toh>(in, host);
-  }
-};
-
-template<int bytes, typename T> class do_hton {
- public:
-  static inline T apply(T host);
-  static inline void copy(const T *host, char *out);
-};
-template<typename T> class do_hton<1, T> {
- public:
-  static inline T apply(T host) { return host; }
-  static inline void copy(const T *host, char *out) { out[0] = host[0]; }
-};
-template<typename T> class do_hton<2, T> {
- public:
-  static inline T apply(T host) { return memcpier<uint16_t, T, _htobe16>(host); }
-  static inline void copy(const T *host, char *out) {
-    copier<uint16_t, _htobe16>(host, out);
-  }
-};
-template<typename T> class do_hton<4, T> {
- public:
-  static inline T apply(T host) { return memcpier<uint32_t, T, _htobe32>(host); }
-  static inline void copy(const T *host, char *out) {
-    copier<uint32_t, _htobe32>(host, out);
-  }
-};
-template<typename T> class do_hton<8, T> {
- public:
-  static inline T apply(T host) { return memcpier<uint64_t, T, _htobe64>(host); }
-  static inline void copy(const T *host, char *out) {
-    copier<uint64_t, _htobe64>(host, out);
-  }
-};
-
-template <size_t Size>
-struct do_hton_int {
-  static inline void copy(const char *host, char *out);
-};
-template <>
-struct do_hton_int<1> {
-  static inline void copy(const char *host, char *out) { out[0] = host[0]; }
-};
-template <>
-struct do_hton_int<2> {
-  static inline void copy(const char *host, char *out) {
-    copier<uint16_t, _htobe16>(host, out);
-  }
-};
-template <>
-struct do_hton_int<4> {
-  static inline void copy(const char *host, char *out) {
-    copier<uint32_t, _htobe32>(host, out);
-  }
-};
-template <>
-struct do_hton_int<8> {
-  static inline void copy(const char *host, char *out) {
-    copier<uint64_t, _htobe64>(host, out);
-  }
-};
-
-}  // namespace
-
-// Converts T from network to host byte order.
-template <typename T>
-static inline T ntoh(T net) {
-  return do_ntoh<sizeof(net), T>::apply(net);
-}
-// Converts T from host to network byte order.
-template <typename T>
-static inline T hton(T host) {
-  return do_hton<sizeof(host), T>::apply(host);
-}
-
-template <typename T>
-static inline void to_host(const char *input, T *host) {
-  do_ntoh<sizeof(*host), T>::copy(input, host);
-}
-template <typename T>
-static inline void to_network(const T *host, char *output) {
-  do_hton<sizeof(*host), T>::copy(host, output);
-}
-
-template <size_t Size>
-static inline void to_host(const char *input, char *host) {
-  do_ntoh_int<Size>::copy(input, host);
-}
-template <size_t Size>
-static inline void to_network(const char *host, char *output) {
-  do_hton_int<Size>::copy(host, output);
-}
-
-} // namespace aos
-
-#endif
diff --git a/aos/network_port.h b/aos/network_port.h
deleted file mode 100644
index 0c84b5e..0000000
--- a/aos/network_port.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef AOS_NETWORK_PORT_H_
-#define AOS_NETWORK_PORT_H_
-
-#include <stdint.h>
-
-namespace aos {
-
-// Constants representing the various ports used for communications and some
-// documentation about what each is used for.
-enum class NetworkPort : uint16_t {
-  // UDP socket sending motor values from the prime to the crio.
-  kMotors = 9710,
-  // UDP socket forwarding drivers station packets from the crio to the prime.
-  kDS = 9711,
-  // UDP socket sending sensor values from the crio to the prime.
-  kSensors = 9712,
-  // HTTP server that sends out camera feeds in mjpg format.
-  // Should not be changed because this number shows up elsewhere too.
-  kCameraStreamer = 9714,
-};
-
-// Constants representing the various devices that talk on the network and the
-// last segment of their IP addresses.
-enum class NetworkAddress : uint8_t {
-  // The computer that the cRIO talks to.
-  kPrime = 179,
-  kCRIO = 2,
-};
-
-}  // namespace aos
-
-#endif  // AOS_NETWORK_PORT_H_
diff --git a/aos/util/BUILD b/aos/util/BUILD
index f0a65d9..7c5052c 100644
--- a/aos/util/BUILD
+++ b/aos/util/BUILD
@@ -92,21 +92,6 @@
 )
 
 cc_library(
-    name = "inet_addr",
-    srcs = [
-        "inet_addr.cc",
-    ],
-    hdrs = [
-        "inet_addr.h",
-    ],
-    target_compatible_with = ["@platforms//os:linux"],
-    deps = [
-        "//aos:byteorder",
-        "//aos:network_port",
-    ],
-)
-
-cc_library(
     name = "phased_loop",
     srcs = [
         "phased_loop.cc",
diff --git a/aos/util/inet_addr.cc b/aos/util/inet_addr.cc
deleted file mode 100644
index edb7dbb..0000000
--- a/aos/util/inet_addr.cc
+++ /dev/null
@@ -1,41 +0,0 @@
-#include "aos/util/inet_addr.h"
-
-#include <stdlib.h>
-#ifndef __VXWORKS__
-#include <string.h>
-
-#include "aos/byteorder.h"
-#else
-
-template<typename T>
-T hton(T);
-
-template<uint32_t>
-uint32_t hton(uint32_t v) { return v; }
-
-#endif
-
-namespace aos {
-namespace util {
-
-const char *MakeIPAddress(const in_addr &base_address,
-                          ::aos::NetworkAddress last_segment) {
-  in_addr address = base_address;
-  SetLastSegment(&address, last_segment);
-
-#ifdef __VXWORKS__
-  char *r = static_cast<char *>(malloc(INET_ADDR_LEN));
-  inet_ntoa_b(address, r);
-  return r;
-#else
-  return strdup(inet_ntoa(address));
-#endif
-}
-
-void SetLastSegment(in_addr *address, ::aos::NetworkAddress last_segment) {
-  address->s_addr &= ~(hton<uint32_t>(0xFF));
-  address->s_addr |= hton<uint32_t>(static_cast<uint8_t>(last_segment));
-}
-
-}  // namespace util
-}  // namespace aos
diff --git a/aos/util/inet_addr.h b/aos/util/inet_addr.h
deleted file mode 100644
index dc2d613..0000000
--- a/aos/util/inet_addr.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef AOS_UTIL_INET_ADDR_H_
-#define AOS_UTIL_INET_ADDR_H_
-
-#ifdef __VXWORKS__
-#include <inetLib.h>
-#else
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#endif
-
-#include "aos/network_port.h"
-
-namespace aos {
-namespace util {
-
-// Makes an IP address string from base_address with the last byte set to
-// last_segment.
-// Returns a malloc(3)ed string.
-const char *MakeIPAddress(const in_addr &base_address,
-                          ::aos::NetworkAddress last_segment);
-
-// Sets the last byte of *address to last_segment.
-void SetLastSegment(in_addr *address, ::aos::NetworkAddress last_segment);
-
-}  // namespace util
-}  // namespace aos
-
-#endif  // AOS_UTIL_INET_ADDR_H_
diff --git a/y2014/BUILD b/y2014/BUILD
index 4332a63..458c411 100644
--- a/y2014/BUILD
+++ b/y2014/BUILD
@@ -67,7 +67,6 @@
     ],
     target_compatible_with = ["@platforms//os:linux"],
     deps = [
-        "//aos:byteorder",
         "//aos:init",
         "//aos/events:shm_event_loop",
         "//aos/logging",
diff --git a/y2014/hot_goal_reader.cc b/y2014/hot_goal_reader.cc
index 68ee071..9f5dc87 100644
--- a/y2014/hot_goal_reader.cc
+++ b/y2014/hot_goal_reader.cc
@@ -6,7 +6,6 @@
 #include <arpa/inet.h>
 #include <unistd.h>
 
-#include "aos/byteorder.h"
 #include "aos/events/shm_event_loop.h"
 #include "aos/init.h"
 #include "aos/logging/logging.h"
@@ -37,7 +36,7 @@
         sockaddr_in address, *sockaddr_pointer;
         memset(&address, 0, sizeof(address));
         address.sin_family = AF_INET;
-        address.sin_port = ::aos::hton<uint16_t>(1180);
+        address.sin_port = htons(1180);
         sockaddr *address_pointer;
         sockaddr_pointer = &address;
         memcpy(&address_pointer, &sockaddr_pointer, sizeof(void *));