Skip to content

Commit

Permalink
config nb_connections and sane default
Browse files Browse the repository at this point in the history
  • Loading branch information
huitema committed Apr 4, 2021
1 parent a02edc1 commit 181b65f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
17 changes: 15 additions & 2 deletions picoquic/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ static option_table_line_t option_table[] = {
{ picoquic_option_PROPOSED_VERSION, 'v', "proposed_version", 1, "", "Version proposed by client, e.g. -v ff000012" },
{ picoquic_option_OUTDIR, 'o', "outdir", 1, "folder", "Folder where client writes downloaded files, defaults to current directory." },
{ picoquic_option_WWWDIR, 'w', "wwwdir", 1, "folder", "Folder containing web pages served by server" },
{ picoquic_option_MAX_CONNECTIONS, 'x', "max_connections", 1, "number",
"Maximum number of concurrent connections, default 256" },
{ picoquic_option_DO_RETRY, 'r', "do_retry", 0, "", "Do Retry Request" },
{ picoquic_option_INITIAL_RANDOM, 'R', "initial_random", 0, "", "randomize initial packet number" },
{ picoquic_option_RESET_SEED, 's', "reset_seed", 2, "<64b 64b>", "Reset seed" },
Expand Down Expand Up @@ -327,6 +329,17 @@ static int config_set_option(option_table_line_t* option_desc, option_param_t* p
case picoquic_option_WWWDIR:
ret = config_set_string_param(&config->www_dir, params, nb_params, 0);
break;
case picoquic_option_MAX_CONNECTIONS: {
int v = config_atoi(params, nb_params, 0, &ret);
if (ret != 0 || v <= 0 ) {
fprintf(stderr, "Invalid max connections: %s\n", config_optval_param_string(opval_buffer, 256, params, nb_params, 0));
ret = (ret == 0) ? -1 : ret;
}
else {
config->nb_connections = (uint32_t)v;
}
break;
}
case picoquic_option_DO_RETRY:
config->do_retry = 1;
break;
Expand Down Expand Up @@ -680,8 +693,7 @@ picoquic_quic_t* picoquic_create_and_configure(picoquic_quic_config_t* config,
uint64_t * p_simulated_time)
{
/* Create context */
/* TODO: sane default for NB connections
* TODO: padding policy
/* TODO: padding policy
* TODO: mtu max accessor
* TODO: set supported CC without linking every option
* TODO: set logging option without linking every option
Expand Down Expand Up @@ -810,6 +822,7 @@ void picoquic_config_init(picoquic_quic_config_t* config)
{
memset(config, 0, sizeof(picoquic_quic_config_t));
config->cnx_id_length = -1;
config->nb_connections = 256;
}

void picoquic_config_clear(picoquic_quic_config_t* config)
Expand Down
1 change: 1 addition & 0 deletions picoquic/picoquic_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ typedef enum {
picoquic_option_PROPOSED_VERSION,
picoquic_option_OUTDIR,
picoquic_option_WWWDIR,
picoquic_option_MAX_CONNECTIONS,
picoquic_option_DO_RETRY,
picoquic_option_INITIAL_RANDOM,
picoquic_option_RESET_SEED,
Expand Down
7 changes: 4 additions & 3 deletions picoquictest/config_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include "picoquic_utils.h"
#include "picoquic_config.h"

static char* ref_option_text = "c:k:K:p:v:o:w:rRs:S:G:P:O:M:e:C:E:i:l:Lb:q:m:n:a:t:zI:DQT:N:B:F:h";
static char* ref_option_text = "c:k:K:p:v:o:w:x:rRs:S:G:P:O:M:e:C:E:i:l:Lb:q:m:n:a:t:zI:DQT:N:B:F:h";

int config_option_letters_test()
{
Expand All @@ -45,7 +45,7 @@ int config_option_letters_test()
}

static picoquic_quic_config_t param1 = {
0, /*uint32_t nb_connections; */
1024, /*uint32_t nb_connections; */
"/data/github/picoquic", /* char const* solution_dir; */
"/data/certs/cert.pem", /* char const* server_cert_file; */
"/data/certs/key.pem", /* char const* server_key_file; */
Expand Down Expand Up @@ -96,6 +96,7 @@ static char const* config_argv1[] = {
"-k", "/data/certs/key.pem",
"-K", "/data/certs/esni_key.pem",
"-E", "/data/certs/esni_rr.txt",
"-x", "1024",
"-l", "/data/log.txt",
"-b", "/data/log/",
"-q", "/data/qlog/",
Expand All @@ -117,7 +118,7 @@ static char const* config_argv1[] = {
};

static picoquic_quic_config_t param2 = {
0, /*uint32_t nb_connections; */
256, /*uint32_t nb_connections; */
NULL, /* char const* solution_dir; */
NULL, /* char const* server_cert_file; */
NULL, /* char const* server_key_file; */
Expand Down

0 comments on commit 181b65f

Please sign in to comment.