33#define DOT "(0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F)"
56 addr = (
const uint32_t *)
ipv6;
59 "6-%04X-%08X%08X%08X%08X",
88 "(%X|%X|%X|%X|%X|%X|%X|%X)",
123 _ (
"Bad mask: %d\n"),
141 const uint8_t *v = (
const uint8_t *) &
value;
142 const uint8_t *
m = (
const uint8_t *) &mask;
185 for (off = 0; off < len; off++)
232 char beforep[36 + 2];
233 char middlehp[33 + 2];
234 char middlelp[33 + 2];
236 char dots[5 * strlen (
DOT)];
245 unsigned int start_port;
246 unsigned int end_port;
258 for (i =
start; i <=
end; i += step)
264 if (i / step < start_port / step)
265 strcat (before, buf);
266 else if (i / step > end_port / step)
268 else if (i / step == start_port / step)
269 strcat (middlel, buf);
270 else if (i / step == end_port / step)
271 strcat (middleh, buf);
273 if (strlen (before) > 0)
274 before[strlen (before) - 1] =
'\0';
275 if (strlen (middlel) > 0)
276 middlel[strlen (middlel) - 1] =
'\0';
277 if (strlen (middleh) > 0)
278 middleh[strlen (middleh) - 1] =
'\0';
279 if (strlen (after) > 0)
280 after[strlen (after) - 1] =
'\0';
287 strcpy (beforep, before);
294 strcpy (middlelp, middlel);
301 strcpy (middlehp, middleh);
308 strcpy (afterp, after);
310 for (xstep = step / 16; xstep > 0; xstep /= 16)
314 if (strlen (middlel) > 0)
316 (start_port / step) * step + step - 1,
321 if (strlen (middleh) > 0)
323 (end_port / step) * step + step - 1,
351 if ((strlen (middleh) > 0) &&
352 (strlen (rech) > 0) &&
353 (strlen (middlel) > 0) &&
363 else if ((strlen (middleh) > 0) &&
371 else if ((strlen (middlel) > 0) &&
383 if ((strlen (before) > 0) &&
384 (strlen (after) > 0))
386 if (strlen (dots) > 0)
388 if (strlen (middle) > 0)
403 if (strlen (middle) > 0)
421 else if (strlen (before) > 0)
423 if (strlen (dots) > 0)
425 if (strlen (middle) > 0)
437 if (strlen (middle) > 0)
448 else if (strlen (after) > 0)
450 if (strlen (dots) > 0)
452 if (strlen (middle) > 0)
464 if (strlen (middle) > 0)
475 else if (strlen (middle) > 0)
537 for (i = 1; i <= 0xFFFF; i++)
539 if ((i >= pp->
start_port) && (i <= pp->end_port))
580 const uint16_t *a = addr;
581 const uint16_t *
m = mask;
589 for (i = 0; i < len / 2; i++)
630 sizeof(
struct in_addr));
663 sizeof(
struct in6_addr));
694 for (i = 0; (0 == i) || (0 != np[i].
network.s_addr); i++)
727 struct in6_addr
zero;
738 memset (&
zero, 0,
sizeof(
struct in6_addr));
739 for (i = 0; (0 == i) || (0 != memcmp (&
zero, &np[i].
network,
sizeof(
struct
763 if (0 == memcmp (&
zero, &np[i].
network,
sizeof(
struct in6_addr)))
795 uint16_t be_port = htons (ip_port);
static mp_limb_t d[(((256)+GMP_NUMB_BITS - 1)/GMP_NUMB_BITS)]
static struct GNUNET_ARM_Operation * op
Current operation.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
static int start
Set if we are to start default services (including ARM).
static int ret
Final status code.
static int end
Set if we are to shutdown all services (including ARM).
static uint16_t port
Port number.
static char * line
Desired phone line (string to be converted to a hash).
static char * value
Value of the record to add/remove.
static struct GNUNET_CADET_Port * cadet_port
Listen port for incoming requests.
static const struct GNUNET_CRYPTO_PrivateKey zero
Public key of all zeros.
static char * service_name
Option -s: service name (hash to get service descriptor)
static int ipv6
Option -6: IPv6 requested.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
#define GNUNET_log(kind,...)
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_STRINGS_IPv6NetworkPolicy * GNUNET_STRINGS_parse_ipv6_policy(const char *routeListX)
Parse an IPv6 network policy.
struct GNUNET_STRINGS_IPv4NetworkPolicy * GNUNET_STRINGS_parse_ipv4_policy(const char *routeListX)
Parse an IPv4 network policy.
void GNUNET_TUN_ipv6toregexsearch(const struct in6_addr *ipv6, uint16_t port, char *rxstr)
Create a regex in rxstr from the given ipv6 and port.
#define GNUNET_TUN_IPV4_REGEXLEN
Maximum regex string length for use with GNUNET_TUN_ipv4toregexsearch.
#define GNUNET_TUN_IPV6_REGEXLEN
Maximum regex string length for use with GNUNET_TUN_ipv6toregexsearch.
char * GNUNET_TUN_ipv6policy2regex(const char *policy)
Convert an exit policy to a regular expression.
void GNUNET_TUN_compute_service_cadet_port(const struct GNUNET_HashCode *desc, uint16_t ip_port, struct GNUNET_HashCode *cadet_port)
Compute the CADET port given a service descriptor (returned from GNUNET_TUN_service_name_to_hash) and...
void GNUNET_TUN_service_name_to_hash(const char *service_name, struct GNUNET_HashCode *hc)
Hash the service name of a hosted service to the hash code that is used to identify the service on th...
void GNUNET_TUN_ipv4toregexsearch(const struct in_addr *ip, uint16_t port, char *rxstr)
Create a regex in rxstr from the given ip and port.
char * GNUNET_TUN_ipv4policy2regex(const char *policy)
Convert an exit policy to a regular expression.
static char * ipv4_to_regex(const struct GNUNET_STRINGS_IPv4NetworkPolicy *v4)
Convert a single line of an IPv4 policy to a regular expression.
static char * ipv6_to_regex(const struct GNUNET_STRINGS_IPv6NetworkPolicy *v6)
Convert a single line of an IPv4 policy to a regular expression.
static char * num_to_regex(uint16_t value, uint16_t mask)
Convert the given 16-bit number to a regex.
static int needs_parens(const char *arg)
Do we need to put parents around the given argument?
#define DOT
'wildcard', matches all possible values (for HEX encoding).
static char * nibble_to_regex(uint8_t value, uint8_t mask)
Convert the given 4-bit (!) number to a regex.
static char * address_to_regex(const void *addr, const void *mask, size_t len)
Convert an address (IPv4 or IPv6) to a regex.
static char * port_to_regex(const struct GNUNET_STRINGS_PortPolicy *pp)
Convert a port policy to a regular expression.
static char * compute_policy(unsigned int start, unsigned int end, unsigned int step, const struct GNUNET_STRINGS_PortPolicy *pp)
Compute port policy for the given range of port numbers.
IPV4 network in CIDR notation.
struct in_addr network
IPv4 address.
struct GNUNET_STRINGS_PortPolicy pp
Policy for port access.
struct in_addr netmask
IPv4 netmask.
network in CIDR notation for IPV6.
struct GNUNET_STRINGS_PortPolicy pp
Policy for port access.
struct in6_addr network
IPv6 address.
struct in6_addr netmask
IPv6 netmask.
uint16_t start_port
Starting port range (0 if none given).
int negate_portrange
GNUNET_YES if the port range should be negated ("!" in policy).
uint16_t end_port
End of port range (0 if none given).