diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-08-25 12:51:21 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-08-25 12:51:21 +0000 |
commit | ccf6004e61a5379954aed85be6ed49ab7e886a7d (patch) | |
tree | 31b63266ea85235a126aa618126e2f836eb4eef2 /src/tun/regex.c | |
parent | 182fae1b29eafe14018d45beb9613725651a779c (diff) |
ensure binding multiple ports to the same service descriptor works (again) with the correct mapping of ports
Diffstat (limited to 'src/tun/regex.c')
-rw-r--r-- | src/tun/regex.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/tun/regex.c b/src/tun/regex.c index f1ebb85f47..d48fe1da81 100644 --- a/src/tun/regex.c +++ b/src/tun/regex.c @@ -810,4 +810,27 @@ GNUNET_TUN_service_name_to_hash (const char *service_name, } +/** + * Compute the CADET port given a service descriptor + * (returned from #GNUNET_TUN_service_name_to_hash) and + * a TCP/UDP port @a ip_port. + * + * @param desc service shared secret + * @param ip_port TCP/UDP port, use 0 for ICMP + * @param[out] cadet_port CADET port to use + */ +void +GNUNET_TUN_compute_service_cadet_port (const struct GNUNET_HashCode *desc, + uint16_t ip_port, + struct GNUNET_HashCode *cadet_port) +{ + uint16_t be_port = htons (ip_port); + + *cadet_port = *desc; + GNUNET_memcpy (cadet_port, + &be_port, + sizeof (uint16_t)); +} + + /* end of regex.c */ |