05_dccp-supported-ccid-lookup.diff
[paraslash.git] / dccp_send.c
index d2f81dd9168023df27a1fefdb883e3234382c1cc..94719f0443c2081842c14e6e153262e551e2903c 100644 (file)
@@ -104,9 +104,33 @@ static int dccp_com_allow(struct sender_command_data *scd)
        return 1;
 }
 
+/**
+ * Return list of available CCIDs or warning, in static buffer.
+ */
+static const char *dccp_list_available_ccids(void)
+{
+       uint8_t ccids[DCCP_MAX_HOST_CCIDS];
+       uint8_t nccids = sizeof(ccids), i, len;
+       /* Worst case length: n * 3 digits + n-1 spaces + '\0' */
+       static char list[DCCP_MAX_HOST_CCIDS * 4];
+
+       if (dccp_available_ccids(ccids, &nccids) == NULL) {
+               snprintf(list, sizeof(list), "Unable to query available CCIDs");
+       } else {
+               for (i = len = 0; i < nccids; i++)
+                       len += snprintf(list + len, sizeof(list) - len,
+                                       "%s%d", i ? " " : "", ccids[i]);
+       }
+       return list;
+}
+
 static char *dccp_info(void)
 {
-       return get_sender_info(dss, "dccp");
+       char *info = get_sender_info(dss, "dccp");
+       char *ret  = make_message("%s" "\tsupported ccids: %s\n",
+                                 info, dccp_list_available_ccids());
+       free(info);
+       return ret;
 }
 
 /**