Resend any reliable messages received before startup

We want to be able to publish (and receive) low frequency configuration
messages.  This lets us make those *not* periodic when we move them
across nodes, simplifying the system.

This takes some special tracking at startup.  We very much don't want to
re-send messages already sent.  That would result in 2 receive
timestamps for a single node for 1 send packet, probably breaking log
sorting.  I'm not interested in learning what would break...

Change-Id: I489460cd4919907516e504e6694d7cef544b0da6
diff --git a/aos/network/sctp_server.cc b/aos/network/sctp_server.cc
index c8563d5..e18d0d8 100644
--- a/aos/network/sctp_server.cc
+++ b/aos/network/sctp_server.cc
@@ -80,6 +80,44 @@
   return ReadSctpMessage(fd_, max_size_);
 }
 
+bool SctpServer::Abort(sctp_assoc_t snd_assoc_id) {
+  // Use the assoc_id for the destination instead of the msg_name.
+  struct msghdr outmsg;
+  outmsg.msg_namelen = 0;
+
+  outmsg.msg_iovlen = 0;
+
+  // Build up the sndinfo message.
+  char outcmsg[CMSG_SPACE(sizeof(struct sctp_sndrcvinfo))];
+  outmsg.msg_control = outcmsg;
+  outmsg.msg_controllen = CMSG_SPACE(sizeof(struct sctp_sndrcvinfo));
+  outmsg.msg_flags = 0;
+
+  struct cmsghdr *cmsg = CMSG_FIRSTHDR(&outmsg);
+  cmsg->cmsg_level = IPPROTO_SCTP;
+  cmsg->cmsg_type = SCTP_SNDRCV;
+  cmsg->cmsg_len = CMSG_LEN(sizeof(struct sctp_sndrcvinfo));
+
+  struct sctp_sndrcvinfo *sinfo = (struct sctp_sndrcvinfo *)CMSG_DATA(cmsg);
+  memset(sinfo, 0, sizeof(struct sctp_sndrcvinfo));
+  sinfo->sinfo_ppid = ++ppid_;
+  sinfo->sinfo_stream = 0;
+  sinfo->sinfo_flags = SCTP_ABORT;
+  sinfo->sinfo_assoc_id = snd_assoc_id;
+
+  // And send.
+  const ssize_t size = sendmsg(fd_, &outmsg, MSG_NOSIGNAL | MSG_DONTWAIT);
+  if (size == -1) {
+    if (errno == EPIPE || errno == EAGAIN || errno == ESHUTDOWN) {
+      return false;
+    }
+    return false;
+  } else {
+    CHECK_EQ(0, size);
+    return true;
+  }
+}
+
 bool SctpServer::Send(std::string_view data, sctp_assoc_t snd_assoc_id,
                       int stream, int timetolive) {
   struct iovec iov;