X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Finclude%2Fgnunet_tun_lib.h;h=7bef0a6bebad64f4e15254013f493b1446cf5737;hb=360d7afad50d1af425a20e89419d2063a6a0e220;hp=efadc4d14789a5fa2bc9cb19673a81afb3c41a9b;hpb=0c9ca79b2eb820c3266e9117f3ba9179cbdc2ff1;p=oweals%2Fgnunet.git diff --git a/src/include/gnunet_tun_lib.h b/src/include/gnunet_tun_lib.h index efadc4d14..7bef0a6be 100644 --- a/src/include/gnunet_tun_lib.h +++ b/src/include/gnunet_tun_lib.h @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2010-2013 Christian Grothoff + Copyright (C) 2010-2013 Christian Grothoff GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -14,15 +14,20 @@ You should have received a copy of the GNU General Public License along with GNUnet; see the file COPYING. If not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. + Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /** - * @file include/gnunet_tun_lib.h - * @brief standard TCP/IP network structs and IP checksum calculations for TUN interaction * @author Philipp Toelke * @author Christian Grothoff + * + * @file + * Standard TCP/IP network structs and IP checksum calculations for TUN interaction + * + * @defgroup tun TUN library + * Standard TCP/IP network structs and IP checksum calculations for TUN interaction + * @{ */ #ifndef GNUNET_TUN_LIB_H #define GNUNET_TUN_LIB_H @@ -184,6 +189,18 @@ struct GNUNET_TUN_IPv6Header } GNUNET_GCC_STRUCT_LAYOUT; +/** + * TCP flags. + */ +#define GNUNET_TUN_TCP_FLAGS_FIN 1 +#define GNUNET_TUN_TCP_FLAGS_SYN 2 +#define GNUNET_TUN_TCP_FLAGS_RST 4 +#define GNUNET_TUN_TCP_FLAGS_PSH 8 +#define GNUNET_TUN_TCP_FLAGS_ACK 16 +#define GNUNET_TUN_TCP_FLAGS_URG 32 +#define GNUNET_TUN_TCP_FLAGS_ECE 64 +#define GNUNET_TUN_TCP_FLAGS_CWR 128 + /** * TCP packet header. */ @@ -529,6 +546,31 @@ struct GNUNET_TUN_DnsSrvRecord }; +/** + * Payload of DNS CERT record. + */ +struct GNUNET_TUN_DnsCertRecord +{ + + /** + * Certificate type + */ + uint16_t cert_type; + + /** + * Certificate KeyTag + */ + uint16_t cert_tag; + + /** + * Algorithm + */ + uint8_t algorithm; + + /* Followed by the certificate */ +}; + + /** * Payload of DNSSEC TLSA record. * http://datatracker.ietf.org/doc/draft-ietf-dane-protocol/ @@ -594,6 +636,7 @@ struct GNUNET_TUN_GnsVpnRecord /* followed by the servicename */ }; + /** * DNS query prefix. */ @@ -658,16 +701,19 @@ struct GNUNET_TUN_DnsRecordLine /** * ICMP header. */ -struct GNUNET_TUN_IcmpHeader { +struct GNUNET_TUN_IcmpHeader +{ uint8_t type; uint8_t code; uint16_t crc GNUNET_PACKED; - union { + union + { /** * ICMP Echo (request/reply) */ - struct { + struct + { uint16_t identifier GNUNET_PACKED; uint16_t sequence_number GNUNET_PACKED; } echo; @@ -675,7 +721,8 @@ struct GNUNET_TUN_IcmpHeader { /** * ICMP Destination Unreachable (RFC 1191) */ - struct ih_pmtu { + struct ih_pmtu + { uint16_t empty GNUNET_PACKED; uint16_t next_hop_mtu GNUNET_PACKED; /* followed by original IP header + first 8 bytes of original IP datagram */ @@ -857,4 +904,47 @@ char * GNUNET_TUN_ipv4policy2regex (const char *policy); +/** + * Hash the service name of a hosted service to the + * hash code that is used to identify the service on + * the network. + * + * @param service_name a string + * @param[out] hc corresponding hash + */ +void +GNUNET_TUN_service_name_to_hash (const char *service_name, + struct GNUNET_HashCode *hc); + + +/** + * Check if two sockaddrs are equal. + * + * @param sa one address + * @param sb another address + * @param include_port also check ports + * @return #GNUNET_YES if they are equal + */ +int +GNUNET_TUN_sockaddr_cmp (const struct sockaddr *sa, + const struct sockaddr *sb, + int include_port); + + +/** + * 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); + #endif + +/** @} */ /* end of group */