X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=udp_send.c;h=f8cce2b943d0f204a089cc9c06a6911f879a0541;hp=7585eaa962ecb4577ed16e41c88235ed6ccec60a;hb=bae94d3ba972bb91626e5f15e2d5ac44da6b041d;hpb=4a96cfc150f797745c054bd5516e80079bdf52a8;ds=sidebyside diff --git a/udp_send.c b/udp_send.c index 7585eaa9..f8cce2b9 100644 --- a/udp_send.c +++ b/udp_send.c @@ -7,9 +7,12 @@ /** \file udp_send.c Para_server's udp sender. */ +#include #include #include +#include #include +#include #include "server.cmdline.h" #include "para.h" @@ -178,7 +181,9 @@ static int udp_init_session(struct udp_target *ut) } add_close_on_fork_list(ut->fd); ut->cq = cq_new(UDP_CQ_BYTES); - PARA_NOTICE_LOG("sending to udp %s#%d\n", ut->host, ut->port); + PARA_NOTICE_LOG("sending to udp %s#%d using fec parms %d:%d:%d\n", + ut->host, ut->port , ut->fcp.max_slice_bytes, + ut->fcp.data_slices_per_group, ut->fcp.slices_per_group); return 1; } @@ -257,19 +262,18 @@ fail: return ret; } -static void udp_add_target(const char *host, int port) +static void udp_add_target(struct sender_command_data *scd) { struct udp_target *ut = para_calloc(sizeof(struct udp_target)); - strncpy(ut->host, host, sizeof(ut->host)); - ut->port = port > 0 ? port : conf.udp_default_port_arg; + strncpy(ut->host, scd->host, sizeof(ut->host)); + ut->port = scd->port > 0 ? scd->port : conf.udp_default_port_arg; ut->fd = -1; /* not yet connected */ - PARA_INFO_LOG("adding to target list (%s#%d)\n", - ut->host, ut->port); + PARA_INFO_LOG("adding to target list (%s#%d)\n", ut->host, ut->port); para_list_add(&ut->node, &targets); - ut->fcp.slices_per_group = 16; - ut->fcp.data_slices_per_group = 14; - ut->fcp.max_slice_bytes = 1400; + ut->fcp.slices_per_group = scd->slices_per_group; + ut->fcp.data_slices_per_group = scd->data_slices_per_group; + ut->fcp.max_slice_bytes = scd->max_slice_bytes; ut->fcp.send = udp_send_fec; ut->fcp.private_data = ut; vss_add_fec_client(&ut->fcp, &ut->fc); @@ -277,7 +281,7 @@ static void udp_add_target(const char *host, int port) static int udp_com_add(struct sender_command_data *scd) { - udp_add_target(scd->host, scd->port); + udp_add_target(scd); return 1; } @@ -288,9 +292,13 @@ static char *udp_info(void) list_for_each_entry(ut, &targets, node) { bool is_v6 = strchr(ut->host, ':') != NULL; - char *tmp = make_message("%s%s%s%s:%d ", tgts ? : "", - is_v6 ? "[" : "", ut->host, - is_v6 ? "]" : "", ut->port); + char *tmp = make_message("%s%s%s%s:%d/%u:%u:%u ", tgts ? : "", + is_v6 ? "[" : "", ut->host, + is_v6 ? "]" : "", ut->port, + ut->fcp.max_slice_bytes, + ut->fcp.data_slices_per_group, + ut->fcp.slices_per_group + ); free(tgts); tgts = tmp; } @@ -309,25 +317,29 @@ static char *udp_info(void) static void udp_init_target_list(void) { - char host[MAX_HOSTLEN]; - int port, i; + struct sender_command_data scd; + int i; INIT_LIST_HEAD(&targets); - for (i = 0; i < conf.udp_target_given; i++) - if (parse_url(conf.udp_target_arg[i], host, - sizeof(host), &port) == NULL) + for (i = 0; i < conf.udp_target_given; i++) { + if (parse_fec_url(conf.udp_target_arg[i], &scd) < 0) { PARA_CRIT_LOG("syntax error for udp target option " - "#%d, ignoring\n", i); - else - udp_add_target(host, port); + "#%d, ignoring\n", i); + continue; + } + udp_add_target(&scd); + } } static char *udp_help(void) { return make_message( "usage: {on|off}\n" - "usage: {add|delete} host[:port]\n" + "usage: {add|delete} host[:port][/packet_size:k:n]\n" "examples: add 224.0.1.38:1500 (IPv4 multicast)\n" + " add 224.0.1.38:1500/1400:14:16\n" + " (likewise, using 1400 byte packets, with 14\n" + " data slices per 16 slice FEC group)\n" " add 10.10.1.42 (using default port)\n" " add [FF05::42]:1500 (IPv6 multicast)\n" " add [::1] (IPv6 localhost/default port)\n" @@ -339,7 +351,7 @@ static char *udp_help(void) /** * The init function of para_server's udp sender. * - * \param s Pointer to the http sender struct. + * \param s Pointer to the udp sender struct. * * It initializes all function pointers of \a s and the list of udp targets. */