summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <marcello.stanisci@inria.fr>2017-03-15 11:40:24 +0100
committerMarcello Stanisci <marcello.stanisci@inria.fr>2017-03-15 11:40:47 +0100
commit796d0e5aa54ed99dd00fae26982a0e99f9d99f8e (patch)
tree45b58e703374b2227ab606b2758467c3c4fa79c4
parentf51f3438fa3451ee758152e53fe823780fb1e261 (diff)
Porting 'nat'.
-rw-r--r--src/datastore/gnunet-datastore.c10
-rw-r--r--src/nat/gnunet-nat.c65
-rw-r--r--src/testing/gnunet-testing.c40
-rw-r--r--src/testing/list-keys.c15
4 files changed, 81 insertions, 49 deletions
diff --git a/src/datastore/gnunet-datastore.c b/src/datastore/gnunet-datastore.c
index b3d14c43c..509c7f8b1 100644
--- a/src/datastore/gnunet-datastore.c
+++ b/src/datastore/gnunet-datastore.c
@@ -239,10 +239,12 @@ run (void *cls, char *const *args, const char *cfgfile,
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- { 's', "sourcecfg", "FILENAME",
- gettext_noop ("specifies the configuration to use to access an alternative datastore; will merge that datastore into our current datastore"),
- 1, &GNUNET_GETOPT_set_filename, &alternative_cfg },
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_FILENAME ('s',
+ "sourcecfg",
+ "FILENAME",
+ gettext_noop ("specifies the configuration to use to access an alternative datastore; will merge that datastore into our current datastore"),
+ &alternative_cfg),
GNUNET_GETOPT_OPTION_END
};
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
diff --git a/src/nat/gnunet-nat.c b/src/nat/gnunet-nat.c
index 04bde5111..50e0dff0f 100644
--- a/src/nat/gnunet-nat.c
+++ b/src/nat/gnunet-nat.c
@@ -72,7 +72,7 @@ static char *remote_addr;
/**
* Should we actually bind to #bind_addr and receive and process STUN requests?
*/
-static unsigned int do_stun;
+static int do_stun;
/**
* Handle to NAT operation.
@@ -417,29 +417,46 @@ int
main (int argc,
char *const argv[])
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'i', "in", "ADDRESS",
- gettext_noop ("which IP and port are we locally using to bind/listen to"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &local_addr },
- {'r', "remote", "ADDRESS",
- gettext_noop ("which remote IP and port should be asked for connection reversal"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &remote_addr },
- {'S', "section", NULL,
- gettext_noop ("name of configuration section to find additional options, such as manual host punching data"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &section_name },
- {'s', "stun", NULL,
- gettext_noop ("enable STUN processing"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &do_stun },
- {'t', "tcp", NULL,
- gettext_noop ("use TCP"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &use_tcp },
- {'u', "udp", NULL,
- gettext_noop ("use UDP"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &use_udp },
- {'W', "watch", NULL,
- gettext_noop ("watch for connection reversal requests"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &listen_reversal },
- GNUNET_GETOPT_OPTION_END
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+
+ GNUNET_GETOPT_OPTION_STRING ('i',
+ "in",
+ "ADDRESS",
+ gettext_noop ("which IP and port are we locally using to bind/listen to"),
+ &local_addr),
+
+ GNUNET_GETOPT_OPTION_STRING ('r',
+ "remote",
+ "ADDRESS",
+ gettext_noop ("which remote IP and port should be asked for connection reversal"),
+ &remote_addr),
+
+ GNUNET_GETOPT_OPTION_STRING ('S',
+ "section",
+ NULL,
+ gettext_noop ("name of configuration section to find additional options, such as manual host punching data"),
+ &section_name),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('s',
+ "stun",
+ gettext_noop ("enable STUN processing"),
+ &do_stun),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('t',
+ "tcp",
+ gettext_noop ("use TCP"),
+ &use_tcp),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('u',
+ "udp",
+ gettext_noop ("use UDP"),
+ &use_udp),
+
+ GNUNET_GETOPT_OPTION_SET_ONE ('W',
+ "watch",
+ gettext_noop ("watch for connection reversal requests"),
+ &listen_reversal),
+ GNUNET_GETOPT_OPTION_END
};
if (GNUNET_OK !=
diff --git a/src/testing/gnunet-testing.c b/src/testing/gnunet-testing.c
index 07f1560cb..686b38192 100644
--- a/src/testing/gnunet-testing.c
+++ b/src/testing/gnunet-testing.c
@@ -348,17 +348,35 @@ run_no_scheduler (void *cls, char *const *args, const char *cfgfile,
int
main (int argc, char *const *argv)
{
- static const struct GNUNET_GETOPT_CommandLineOption options[] = {
- {'C', "cfg", NULL, gettext_noop ("create unique configuration files"),
- GNUNET_NO, &GNUNET_GETOPT_set_one, &create_cfg},
- {'k', "key", "FILENAME", gettext_noop ("extract hostkey file from pre-computed hostkey list"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &create_hostkey},
- {'n', "number", "NUMBER", gettext_noop ("number of unique configuration files to create, or number of the hostkey to extract"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &create_no},
- {'t', "template", "FILENAME", gettext_noop ("configuration template"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &create_cfg_template},
- {'r', "run", "SERVICE", gettext_noop ("run the given service, wait on stdin for 'r' (restart) or 'q' (quit)"),
- GNUNET_YES, &GNUNET_GETOPT_set_string, &run_service_name},
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_SET_ONE ('C',
+ "cfg",
+ gettext_noop ("create unique configuration files"),
+ &create_cfg),
+ GNUNET_GETOPT_OPTION_STRING ('k',
+ "key",
+ "FILENAME",
+ gettext_noop ("extract hostkey file from pre-computed hostkey list"),
+ &create_hostkey),
+
+ GNUNET_GETOPT_OPTION_SET_UINT ('n',
+ "number",
+ "NUMBER",
+ gettext_noop ("number of unique configuration files to create, or number of the hostkey to extract"),
+ &create_no),
+
+
+ GNUNET_GETOPT_OPTION_STRING ('t',
+ "template",
+ "FILENAME",
+ gettext_noop ("configuration template"),
+ &create_cfg_template),
+
+ GNUNET_GETOPT_OPTION_STRING ('r',
+ "run",
+ "SERVICE",
+ gettext_noop ("run the given service, wait on stdin for 'r' (restart) or 'q' (quit)"),
+ &run_service_name),
GNUNET_GETOPT_OPTION_END
};
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
diff --git a/src/testing/list-keys.c b/src/testing/list-keys.c
index 1fd46ebf2..cfb49460a 100644
--- a/src/testing/list-keys.c
+++ b/src/testing/list-keys.c
@@ -6,10 +6,6 @@ static unsigned int nkeys;
static unsigned int nskip;
static int result;
-
-
-
-
/**
* Main run function.
*
@@ -87,12 +83,11 @@ run (void *cls, char *const *args, const char *cfgfile,
int main (int argc, char *argv[])
{
struct GNUNET_GETOPT_CommandLineOption option[] = {
- {'n', "num-keys", "COUNT",
- gettext_noop ("list COUNT number of keys"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &nkeys},
- {'s', "skip", "COUNT",
- gettext_noop ("skip COUNT number of keys in the beginning"),
- GNUNET_YES, &GNUNET_GETOPT_set_uint, &nskip},
+ GNUNET_GETOPT_OPTION_SET_UINT ('n',
+ "num-keys",
+ "COUNT",
+ gettext_noop ("list COUNT number of keys"),
+ &nkeys),
GNUNET_GETOPT_OPTION_END
};
int ret;