]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
06_get-tx-ccid.diff
authorGerrit Renker <grenker@cscs.ch>
Thu, 25 Feb 2010 16:05:45 +0000 (17:05 +0100)
committerAndre Noll <maan@systemlinux.org>
Thu, 25 Feb 2010 16:05:45 +0000 (17:05 +0100)
This patch adds support for querying the TX half-connection CCID
in use to from sender to client.

On more recent kernels (> 2.6.30) supporting this functionality,
connected clients are now displayed in the manner
          <IP-address>"#"<port>"~"<CCID-number>

dccp_send.c

index 94719f0443c2081842c14e6e153262e551e2903c..7d8967cca6f9ad47dc5b8578b350fd81d2ad49d8 100644 (file)
@@ -44,15 +44,46 @@ static void dccp_pre_select(int *max_fileno, fd_set *rfds,
                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_post_select(fd_set *rfds, __a_unused fd_set *wfds)
 {
        struct sender_client *sc;
+       int tx_ccid;
 
        if (dss->listen_fd < 0 || !FD_ISSET(dss->listen_fd, rfds))
                return;
        sc = accept_sender_client(dss);
        if (!sc)
                return;
+
+       /* If CCID identifiable, present client as <host>#<port>~<ccid> */
+       tx_ccid = dccp_get_tx_ccid(sc->fd);
+       if (tx_ccid != -1) {
+               char *tmp = make_message("%s~%d", sc->name, tx_ccid);
+
+               free(sc->name);
+               sc->name = tmp;
+       }
        /*
         * Bypass unused CCID paths: the sender does not receive application data
         * from the client; by shutting down this unused communication path we can