{
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
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;
int
default="8000"
optional
+
+option "ccid" c
+"CCID preference(s) for this connection"
+int
+# restrict the maximum number of times this option can be passed
+optional multiple(-10)
+# currently known CCIDs:
+# - CCID-2 (RFC 4341),
+# - CCID-3 (RFC 4342),
+# - CCID-4 (RFC 5622),
+# - CCID-248 ... CCID-254 are experimental (RFC 4340, 19.5)
+values="2", "3", "4", "248", "249", "250", "251", "252", "253", "254"
+details="
+ Depends on the CCIDs available on the server; this information
+ can be seen in the display of 'para_client si'.
+
+ When present exactly once, this option mandates the CCID
+ to use for the sender-receiver connection.
+
+ If it is passed more than once, it sets a preference list
+ of CCIDs for this connection. The order of appearance here
+ signifies descending priority. For example,
+ --ccid 4 --c 2 --ccid 3
+ generates the preference list (CCID-4, CCID-2, CCID-3).
+
+ The request is reconciled with the CCIDs on the server via
+ the 'server-priority' mechanism of RFC 4340 6.3.1/10.
+"