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;
}
/**
return new_fd < 0? -ERRNO_TO_PARA_ERROR(errno) : new_fd;
}
+/**
+ * Probe the list of DCCP CCIDs supported locally by the host.
+ * \param ccids Array to be filled in.
+ * \param nccids Length of \a ccids.
+ * \return Pointer to \a ccids, NULL on failure.
+ *
+ * NB: This feature is only available on Linux > 2.6.30; on older kernels
+ * ENOPROTOOPT ("Protocol not available") will be returned.
+ */
+const uint8_t *dccp_available_ccids(uint8_t *ccids, uint8_t *nccids)
+{
+ int fd = makesock(AF_UNSPEC, IPPROTO_DCCP, 0, NULL, 0);
+
+ if (fd < 0)
+ return NULL;
+
+ if (getsockopt(fd, SOL_DCCP, DCCP_SOCKOPT_AVAILABLE_CCIDS,
+ ccids, (socklen_t *)nccids) < 0) {
+ PARA_ERROR_LOG("No DCCP_SOCKOPT_AVAILABLE_CCIDS: %s\n",
+ strerror(errno));
+ *nccids = 0;
+ }
+ close(fd);
+
+ return *nccids ? ccids : NULL;
+}
+
/**
* Prepare a structure for \p AF_UNIX socket addresses.
*
int recv_cred_buffer(int, char *, size_t);
ssize_t send_cred_buffer(int, char*);
int recv_pattern(int fd, const char *pattern, size_t bufsize);
+
+/**
+ * Functions and definitions to support \p IPPROTO_DCCP
+ */
+/** Hardcoded maximum number of separate CCID modules compiled into a host */
+#define DCCP_MAX_HOST_CCIDS 20
+extern const uint8_t *dccp_available_ccids(uint8_t *ccids, uint8_t *nccids);