X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=dccp_recv.c;h=a0f8371efae6b0974a4f9c88ef1365b208a48eda;hp=0a7b3c069271329152f131afa1f1334416473d10;hb=081ea8699e6a309c44446884b8c3752529d96a25;hpb=a5927501e41fa3fca2975452617474e78ffecc48 diff --git a/dccp_recv.c b/dccp_recv.c index 0a7b3c06..a0f8371e 100644 --- a/dccp_recv.c +++ b/dccp_recv.c @@ -57,11 +57,25 @@ static int dccp_recv_open(struct receiver_node *rn) { struct private_dccp_recv_data *pdd; struct dccp_recv_args_info *conf = rn->conf; - int fd, ret = para_connect_simple(IPPROTO_DCCP, conf->host_arg, - conf->port_arg); - if (ret < 0) - return ret; - fd = ret; + struct flowopts *fo = NULL; + uint8_t *ccids = NULL; + int fd, ret, i; + + /* Copy CCID preference list (u8 array required) */ + if (conf->ccid_given) { + ccids = para_malloc(conf->ccid_given); + fo = flowopt_new(); + + for (i = 0; i < conf->ccid_given; i++) + ccids[i] = conf->ccid_arg[i]; + + OPT_ADD(fo, SOL_DCCP, DCCP_SOCKOPT_CCID, ccids, i); + } + + fd = makesock(IPPROTO_DCCP, 0, conf->host_arg, conf->port_arg, fo); + free(ccids); + if (fd < 0) + return fd; /* * Disable unused CCIDs: the receiver does not send any application * data to the server. By shutting down this unused path we reduce @@ -84,11 +98,37 @@ err: return ret; } +/** + * Check whether the host supports the requested 'ccid' arguments. + * \param conf DCCP receiver arguments. + * \return True if all CCIDs requested in \a conf are supported. + */ +static bool dccp_recv_ccid_support_check(struct dccp_recv_args_info *conf) +{ + uint8_t ccids[DCCP_MAX_HOST_CCIDS]; + uint8_t nccids = sizeof(ccids), i, j; + + if (dccp_available_ccids(ccids, &nccids) == NULL) + return false; + + for (i = 0; i < conf->ccid_given; i++) { + for (j = 0; j < nccids && ccids[j] != conf->ccid_arg[i]; j++) + ; + if (j == nccids) { + PARA_ERROR_LOG("'CCID-%d' not supported on this host.\n", + conf->ccid_arg[i]); + return false; + } + } + return true; +} + static void *dccp_recv_parse_config(int argc, char **argv) { - struct dccp_recv_args_info *tmp = para_calloc(sizeof(struct dccp_recv_args_info)); + struct dccp_recv_args_info *tmp = para_calloc(sizeof(*tmp)); - if (!dccp_recv_cmdline_parser(argc, argv, tmp)) + if (!dccp_recv_cmdline_parser(argc, argv, tmp) && + dccp_recv_ccid_support_check(tmp)) return tmp; free(tmp); return NULL;