aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_strings_lib.h
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-26 12:36:51 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-26 12:36:51 +0000
commitaeb922926c639ffdd992f96cd125e47bb0e2c301 (patch)
tree85097e40305035ad337f0c0e8dc0f95343dbed3a /src/include/gnunet_strings_lib.h
parent7679eb4a51b8d0e9e4671dae00ca83c9f1b22de7 (diff)
downloadgnunet-aeb922926c639ffdd992f96cd125e47bb0e2c301.tar.gz
gnunet-aeb922926c639ffdd992f96cd125e47bb0e2c301.zip
-moving code to parse IPv4/IPv6 subnet specifications to strings and making it part of the public API
Diffstat (limited to 'src/include/gnunet_strings_lib.h')
-rw-r--r--src/include/gnunet_strings_lib.h68
1 files changed, 67 insertions, 1 deletions
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h
index 2e6f599d1..e0a299ac3 100644
--- a/src/include/gnunet_strings_lib.h
+++ b/src/include/gnunet_strings_lib.h
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2012 Christian Grothoff (and other contributing authors) 3 (C) 2001-2013 Christian Grothoff (and other contributing authors)
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -469,6 +469,72 @@ GNUNET_STRINGS_get_utf8_args (int argc,
469 char *const **u8argv); 469 char *const **u8argv);
470 470
471 471
472/* ***************** IPv4/IPv6 parsing ****************** */
473
474/**
475 * @brief IPV4 network in CIDR notation.
476 */
477struct GNUNET_STRINGS_IPv4NetworkPolicy
478{
479 /**
480 * IPv4 address.
481 */
482 struct in_addr network;
483
484 /**
485 * IPv4 netmask.
486 */
487 struct in_addr netmask;
488};
489
490/**
491
492 * @brief network in CIDR notation for IPV6.
493 */
494struct GNUNET_STRINGS_IPv6NetworkPolicy
495{
496 /**
497 * IPv6 address.
498 */
499 struct in6_addr network;
500
501 /**
502 * IPv6 netmask.
503 */
504 struct in6_addr netmask;
505};
506
507
508/**
509 * Parse an IPv4 network policy. The argument specifies a list of
510 * subnets. The format is <tt>[network/netmask;]*</tt> (no whitespace,
511 * must be terminated with a semicolon). The network must be given in
512 * dotted-decimal notation. The netmask can be given in CIDR notation
513 * (/16) or in dotted-decimal (/255.255.0.0).
514 *
515 * @param routeList a string specifying the IPv4 subnets
516 * @return the converted list, terminated with all zeros;
517 * NULL if the synatx is flawed
518 */
519struct GNUNET_STRINGS_IPv4NetworkPolicy *
520GNUNET_STRINGS_parse_ipv4_policy (const char *routeList);
521
522
523/**
524 * Parse an IPv6 network policy. The argument specifies a list of
525 * subnets. The format is <tt>[network/netmask;]*</tt> (no whitespace,
526 * must be terminated with a semicolon). The network must be given in
527 * colon-hex notation. The netmask must be given in CIDR notation
528 * (/16) or can be omitted to specify a single host.
529 *
530 * @param routeListX a string specifying the policy
531 * @return the converted list, 0-terminated, NULL if the synatx is flawed
532 */
533struct GNUNET_STRINGS_IPv6NetworkPolicy *
534GNUNET_STRINGS_parse_ipv6_policy (const char *routeListX);
535
536
537
472#if 0 /* keep Emacsens' auto-indent happy */ 538#if 0 /* keep Emacsens' auto-indent happy */
473{ 539{
474#endif 540#endif