Initial message_bridge client and server

These will forward data, and track what made it across and what didn't
when configured correctly.  This should be off if nothing is requested
to be logged remotely.

It implements ttl, reconnects, and has a basic smoke test.

We still need to handle forwarding data for logging.

Change-Id: I7daebe8cef54029a5733b7f81ee6b68367c80d82
diff --git a/aos/network/sctp_lib.h b/aos/network/sctp_lib.h
new file mode 100644
index 0000000..0f90f87
--- /dev/null
+++ b/aos/network/sctp_lib.h
@@ -0,0 +1,78 @@
+#ifndef AOS_NETWORK_SCTP_LIB_H_
+#define AOS_NETWORK_SCTP_LIB_H_
+
+#include <arpa/inet.h>
+#include <netinet/sctp.h>
+
+#include <memory>
+#include <string>
+#include <string_view>
+
+#include "aos/unique_malloc_ptr.h"
+#include "gflags/gflags.h"
+#include "glog/logging.h"
+
+namespace aos {
+namespace message_bridge {
+
+// Resolves a socket and returns the address.  This can be either an ipv4 or
+// ipv6 address.
+struct sockaddr_storage ResolveSocket(std::string_view host, int port);
+
+// Returns a formatted version of the address.
+std::string Address(const struct sockaddr_storage &sockaddr);
+// Returns a formatted version of the address family.
+std::string_view Family(const struct sockaddr_storage &sockaddr);
+
+// Message received.
+// This message is malloced bigger than needed and the extra space after it is
+// the data.
+struct Message {
+  // Struct to let us force data to be well aligned.
+  struct OveralignedChar {
+    uint8_t data alignas(32);
+  };
+
+  // Headers.
+  struct {
+    struct sctp_rcvinfo rcvinfo;
+  } header;
+
+  // Address of the sender.
+  struct sockaddr_storage sin;
+
+  // Data type. Is it a block of data, or is it a struct sctp_notification?
+  enum MessageType { kMessage, kNotification } message_type;
+
+  size_t size = 0u;
+  uint8_t *mutable_data() {
+    return reinterpret_cast<uint8_t *>(&actual_data[0].data);
+  }
+  const uint8_t *data() const {
+    return reinterpret_cast<const uint8_t *>(&actual_data[0].data);
+  }
+
+  // Returns a human readable peer IP address.
+  std::string PeerAddress() const;
+
+  // Prints out the RcvInfo structure.
+  void LogRcvInfo() const;
+
+  // The start of the data.
+  OveralignedChar actual_data[];
+};
+
+void PrintNotification(const Message *msg);
+
+std::string GetHostname();
+
+// Gets and logs the contents of the sctp_status message.
+void LogSctpStatus(int fd, sctp_assoc_t assoc_id);
+
+// Read and allocate a message.
+aos::unique_c_ptr<Message> ReadSctpMessage(int fd, int max_size);
+
+}  // namespace message_bridge
+}  // namespace aos
+
+#endif  // AOS_NETWORK_SCTP_LIB_H_