X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=net.c;h=b83ab8c61d34c3a52f8e0f35dfa63d05c3584f21;hp=6ab96215df880dc04eea0f6f90c48fd385720816;hb=e9e826f4fb415c4225ff5934fe42572ffa3b5ebc;hpb=7964fd8324c24679ca2ec85b6e9589f24079e089 diff --git a/net.c b/net.c index 6ab96215..b83ab8c6 100644 --- a/net.c +++ b/net.c @@ -661,6 +661,33 @@ int para_accept(int fd, void *addr, socklen_t size) 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. *