+ if (dss->listen_fd >= 0)
+ para_fd_set(dss->listen_fd, rfds, max_fileno);
+}
+
+/**
+ * Query the TX CCID used on the sender-client half connection.
+ * \param sockfd Server socket descriptor to query (after accept(2)).
+ * \return CCID number > 0, -1 on error/incompatibility.
+ *
+ * NB: This feature is only available on Linux > 2.6.30; on older kernels
+ * ENOPROTOOPT ("Protocol not available") will be returned.
+ */
+static int dccp_get_tx_ccid(int sockfd)
+{
+ int tx_ccid;
+ socklen_t len = sizeof(tx_ccid);
+
+ if (getsockopt(sockfd, SOL_DCCP,
+ DCCP_SOCKOPT_TX_CCID, &tx_ccid, &len) < 0) {
+ PARA_WARNING_LOG("DCCP_SOCKOPT_TX_CCID: %s\n", strerror(errno));
+ return -1;
+ }
+ return tx_ccid;
+}
+
+static void dccp_shutdown_client(struct sender_client *sc)
+{
+ struct dccp_fec_client *dfc = sc->private_data;
+
+ vss_del_fec_client(dfc->fc);
+ shutdown_client(sc, dss);
+}
+
+static void dccp_shutdown_clients(void)
+{
+ struct sender_client *sc, *tmp;
+
+ list_for_each_entry_safe(sc, tmp, &dss->client_list, node)
+ dccp_shutdown_client(sc);
+}
+
+/** * Obtain current MPS according to RFC 4340, sec. 14. */
+static int dccp_init_fec(struct sender_client *sc)
+{
+ int mps, ret;
+ socklen_t ml = sizeof(mps);
+ uint32_t mss; /* max slize size */
+
+ /* If call fails, return some sensible minimum value */
+ ret = getsockopt(sc->fd, SOL_DCCP, DCCP_SOCKOPT_GET_CUR_MPS, &mps, &ml);
+ if (ret < 0) {
+ PARA_NOTICE_LOG("can not determine MPS: %s\n", strerror(errno));
+ mps = generic_max_transport_msg_size(sc->fd) - DCCP_MAX_HEADER;
+ }
+ PARA_INFO_LOG("current MPS = %d bytes\n", mps);
+ assert(mps > 0);
+ mss = OPT_UINT32_VAL(DCCP_MAX_SLICE_SIZE);
+ if (mss > 0 && mss <= INT_MAX)
+ mps = PARA_MIN(mps, (int)mss);
+ return mps;
+}
+
+static void dccp_send_fec(struct sender_client *sc, char *buf, size_t len)
+{
+ int ret = xwrite(sc->fd, buf, len);
+
+ if (ret < 0)
+ dccp_shutdown_client(sc);