X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=dccp_recv.c;h=c22fa84d461ed48a7a35c980ad32b8c8129b65c8;hb=a31d410d3dbc0f0c866a11a5a46b58054625f4ba;hp=0a7b3c069271329152f131afa1f1334416473d10;hpb=a5927501e41fa3fca2975452617474e78ffecc48;p=paraslash.git diff --git a/dccp_recv.c b/dccp_recv.c index 0a7b3c06..c22fa84d 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,38 @@ 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; + int i, j, nccids; + + nccids = dccp_available_ccids(&ccids); + if (nccids <= 0) + 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;