WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
-
+
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
* @author Christian Grothoff
*
* @file
- * Standard TCP/IP network structs and IP checksum calculations for TUN interaction
+ * 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
+ * Standard TCP/IP network structs and IP checksum calculations for TUN
+ * interaction
* @{
*/
#ifndef GNUNET_TUN_LIB_H
struct GNUNET_TUN_IPv4Header
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned int header_length:4 GNUNET_PACKED;
- unsigned int version:4 GNUNET_PACKED;
+ unsigned int header_length : 4 GNUNET_PACKED;
+ unsigned int version : 4 GNUNET_PACKED;
#elif __BYTE_ORDER == __BIG_ENDIAN
- unsigned int version:4 GNUNET_PACKED;
- unsigned int header_length:4 GNUNET_PACKED;
+ unsigned int version : 4 GNUNET_PACKED;
+ unsigned int header_length : 4 GNUNET_PACKED;
#else
- #error byteorder undefined
+#error byteorder undefined
#endif
uint8_t diff_serv;
*/
uint16_t identification GNUNET_PACKED;
- unsigned int flags:3 GNUNET_PACKED;
+ unsigned int flags : 3 GNUNET_PACKED;
- unsigned int fragmentation_offset:13 GNUNET_PACKED;
+ unsigned int fragmentation_offset : 13 GNUNET_PACKED;
/**
* How many more hops can this packet be forwarded?
/**
* Origin of the packet.
*/
- struct in_addr source_address GNUNET_PACKED;
+ struct in_addr source_address;
/**
* Destination of the packet.
*/
- struct in_addr destination_address GNUNET_PACKED;
+ struct in_addr destination_address;
} GNUNET_GCC_STRUCT_LAYOUT;
struct GNUNET_TUN_IPv6Header
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned int traffic_class_h:4 GNUNET_PACKED;
- unsigned int version:4 GNUNET_PACKED;
- unsigned int traffic_class_l:4 GNUNET_PACKED;
- unsigned int flow_label:20 GNUNET_PACKED;
+ unsigned int traffic_class_h : 4 GNUNET_PACKED;
+ unsigned int version : 4 GNUNET_PACKED;
+ unsigned int traffic_class_l : 4 GNUNET_PACKED;
+ unsigned int flow_label : 20 GNUNET_PACKED;
#elif __BYTE_ORDER == __BIG_ENDIAN
- unsigned int version:4 GNUNET_PACKED;
- unsigned int traffic_class:8 GNUNET_PACKED;
- unsigned int flow_label:20 GNUNET_PACKED;
+ unsigned int version : 4 GNUNET_PACKED;
+ unsigned int traffic_class : 8 GNUNET_PACKED;
+ unsigned int flow_label : 20 GNUNET_PACKED;
#else
- #error byteorder undefined
+#error byteorder undefined
#endif
/**
* Length of the payload, excluding this header.
*/
unsigned int reserved : 4 GNUNET_PACKED;
#else
- #error byteorder undefined
+#error byteorder undefined
#endif
/**
};
-
/**
* A few common DNS classes (ok, only one is common, but I list a
* couple more to make it clear what we're talking about here).
/**
* Set to 1 if recursion is desired (client -> server)
*/
- unsigned int recursion_desired : 1 GNUNET_PACKED;
+ unsigned int recursion_desired : 1 GNUNET_PACKED;
/**
* Set to 1 if message is truncated
*/
- unsigned int message_truncated : 1 GNUNET_PACKED;
+ unsigned int message_truncated : 1 GNUNET_PACKED;
/**
* Set to 1 if this is an authoritative answer
/**
* See GNUNET_TUN_DNS_OPCODE_ defines.
*/
- unsigned int opcode : 4 GNUNET_PACKED;
+ unsigned int opcode : 4 GNUNET_PACKED;
/**
* query:0, response:1
*/
- unsigned int query_or_response : 1 GNUNET_PACKED;
+ unsigned int query_or_response : 1 GNUNET_PACKED;
/**
* See GNUNET_TUN_DNS_RETURN_CODE_ defines.
*/
- unsigned int return_code : 4 GNUNET_PACKED;
+ unsigned int return_code : 4 GNUNET_PACKED;
/**
* See RFC 4035.
*/
- unsigned int checking_disabled : 1 GNUNET_PACKED;
+ unsigned int checking_disabled : 1 GNUNET_PACKED;
/**
* Response has been cryptographically verified, RFC 4035.
*/
- unsigned int authenticated_data : 1 GNUNET_PACKED;
+ unsigned int authenticated_data : 1 GNUNET_PACKED;
/**
* Always zero.
*/
- unsigned int zero : 1 GNUNET_PACKED;
+ unsigned int zero : 1 GNUNET_PACKED;
/**
* Set to 1 if recursion is available (server -> client)
*/
- unsigned int recursion_available : 1 GNUNET_PACKED;
+ unsigned int recursion_available : 1 GNUNET_PACKED;
#elif __BYTE_ORDER == __BIG_ENDIAN
/**
* query:0, response:1
*/
- unsigned int query_or_response : 1 GNUNET_PACKED;
+ unsigned int query_or_response : 1 GNUNET_PACKED;
/**
* See GNUNET_TUN_DNS_OPCODE_ defines.
*/
- unsigned int opcode : 4 GNUNET_PACKED;
+ unsigned int opcode : 4 GNUNET_PACKED;
/**
* Set to 1 if this is an authoritative answer
/**
* Set to 1 if message is truncated
*/
- unsigned int message_truncated : 1 GNUNET_PACKED;
+ unsigned int message_truncated : 1 GNUNET_PACKED;
/**
* Set to 1 if recursion is desired (client -> server)
*/
- unsigned int recursion_desired : 1 GNUNET_PACKED;
+ unsigned int recursion_desired : 1 GNUNET_PACKED;
/**
* Set to 1 if recursion is available (server -> client)
*/
- unsigned int recursion_available : 1 GNUNET_PACKED;
+ unsigned int recursion_available : 1 GNUNET_PACKED;
/**
* Always zero.
*/
- unsigned int zero : 1 GNUNET_PACKED;
+ unsigned int zero : 1 GNUNET_PACKED;
/**
* Response has been cryptographically verified, RFC 4035.
*/
- unsigned int authenticated_data : 1 GNUNET_PACKED;
+ unsigned int authenticated_data : 1 GNUNET_PACKED;
/**
* See RFC 4035.
*/
- unsigned int checking_disabled : 1 GNUNET_PACKED;
+ unsigned int checking_disabled : 1 GNUNET_PACKED;
/**
* See GNUNET_TUN_DNS_RETURN_CODE_ defines.
*/
- unsigned int return_code : 4 GNUNET_PACKED;
+ unsigned int return_code : 4 GNUNET_PACKED;
#else
- #error byteorder undefined
+#error byteorder undefined
#endif
} GNUNET_GCC_STRUCT_LAYOUT;
-
/**
* DNS header.
*/
};
-#define GNUNET_TUN_ICMPTYPE_ECHO_REPLY 0
-#define GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE 3
-#define GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH 4
-#define GNUNET_TUN_ICMPTYPE_REDIRECT_MESSAGE 5
-#define GNUNET_TUN_ICMPTYPE_ECHO_REQUEST 8
-#define GNUNET_TUN_ICMPTYPE_ROUTER_ADVERTISEMENT 9
-#define GNUNET_TUN_ICMPTYPE_ROUTER_SOLICITATION 10
-#define GNUNET_TUN_ICMPTYPE_TIME_EXCEEDED 11
+#define GNUNET_TUN_ICMPTYPE_ECHO_REPLY 0
+#define GNUNET_TUN_ICMPTYPE_DESTINATION_UNREACHABLE 3
+#define GNUNET_TUN_ICMPTYPE_SOURCE_QUENCH 4
+#define GNUNET_TUN_ICMPTYPE_REDIRECT_MESSAGE 5
+#define GNUNET_TUN_ICMPTYPE_ECHO_REQUEST 8
+#define GNUNET_TUN_ICMPTYPE_ROUTER_ADVERTISEMENT 9
+#define GNUNET_TUN_ICMPTYPE_ROUTER_SOLICITATION 10
+#define GNUNET_TUN_ICMPTYPE_TIME_EXCEEDED 11
-#define GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE 1
-#define GNUNET_TUN_ICMPTYPE6_PACKET_TOO_BIG 2
-#define GNUNET_TUN_ICMPTYPE6_TIME_EXCEEDED 3
-#define GNUNET_TUN_ICMPTYPE6_PARAMETER_PROBLEM 4
-#define GNUNET_TUN_ICMPTYPE6_ECHO_REQUEST 128
-#define GNUNET_TUN_ICMPTYPE6_ECHO_REPLY 129
+#define GNUNET_TUN_ICMPTYPE6_DESTINATION_UNREACHABLE 1
+#define GNUNET_TUN_ICMPTYPE6_PACKET_TOO_BIG 2
+#define GNUNET_TUN_ICMPTYPE6_TIME_EXCEEDED 3
+#define GNUNET_TUN_ICMPTYPE6_PARAMETER_PROBLEM 4
+#define GNUNET_TUN_ICMPTYPE6_ECHO_REQUEST 128
+#define GNUNET_TUN_ICMPTYPE6_ECHO_REPLY 129
/**
*/
struct
{
- uint16_t identifier GNUNET_PACKED;
- uint16_t sequence_number GNUNET_PACKED;
+ uint16_t identifier GNUNET_PACKED;
+ uint16_t sequence_number GNUNET_PACKED;
} echo;
/**
{
uint16_t empty GNUNET_PACKED;
uint16_t next_hop_mtu GNUNET_PACKED;
- /* followed by original IP header + first 8 bytes of original IP datagram */
+ /* followed by original IP header + first 8 bytes of original IP datagram
+ */
} destination_unreachable;
/**
* ICMP Redirect
*/
- struct in_addr redirect_gateway_address GNUNET_PACKED;
+ struct in_addr redirect_gateway_address;
/**
* MTU for packets that are too big (IPv6).
uint32_t packet_too_big_mtu GNUNET_PACKED;
} quench;
-
};
*
* @param ip header to initialize
* @param protocol protocol to use (i.e. IPPROTO_UDP)
- * @param payload_length number of bytes of payload that follow (excluding IPv4 header)
+ * @param payload_length number of bytes of payload that follow (excluding IPv4
+ * header)
* @param src source IP address to use
* @param dst destination IP address to use
*/
void
GNUNET_TUN_initialize_ipv4_header (struct GNUNET_TUN_IPv4Header *ip,
- uint8_t protocol,
- uint16_t payload_length,
- const struct in_addr *src,
- const struct in_addr *dst);
+ uint8_t protocol,
+ uint16_t payload_length,
+ const struct in_addr *src,
+ const struct in_addr *dst);
/**
*
* @param ip header to initialize
* @param protocol protocol to use (i.e. IPPROTO_UDP)
- * @param payload_length number of bytes of payload that follow (excluding IPv4 header)
+ * @param payload_length number of bytes of payload that follow (excluding IPv4
+ * header)
* @param src source IP address to use
* @param dst destination IP address to use
*/
void
GNUNET_TUN_initialize_ipv6_header (struct GNUNET_TUN_IPv6Header *ip,
- uint8_t protocol,
- uint16_t payload_length,
- const struct in6_addr *src,
- const struct in6_addr *dst);
+ uint8_t protocol,
+ uint16_t payload_length,
+ const struct in6_addr *src,
+ const struct in6_addr *dst);
/**
* Calculate IPv4 TCP checksum.
*/
void
GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip,
- struct GNUNET_TUN_TcpHeader *tcp,
- const void *payload,
- uint16_t payload_length);
+ struct GNUNET_TUN_TcpHeader *tcp,
+ const void *payload,
+ uint16_t payload_length);
/**
* Calculate IPv6 TCP checksum.
*/
void
GNUNET_TUN_calculate_tcp6_checksum (const struct GNUNET_TUN_IPv6Header *ip,
- struct GNUNET_TUN_TcpHeader *tcp,
- const void *payload,
- uint16_t payload_length);
+ struct GNUNET_TUN_TcpHeader *tcp,
+ const void *payload,
+ uint16_t payload_length);
/**
* Calculate IPv4 UDP checksum.
*/
void
GNUNET_TUN_calculate_udp4_checksum (const struct GNUNET_TUN_IPv4Header *ip,
- struct GNUNET_TUN_UdpHeader *udp,
- const void *payload,
- uint16_t payload_length);
+ struct GNUNET_TUN_UdpHeader *udp,
+ const void *payload,
+ uint16_t payload_length);
/**
*/
void
GNUNET_TUN_calculate_udp6_checksum (const struct GNUNET_TUN_IPv6Header *ip,
- struct GNUNET_TUN_UdpHeader *udp,
- const void *payload,
- uint16_t payload_length);
+ struct GNUNET_TUN_UdpHeader *udp,
+ const void *payload,
+ uint16_t payload_length);
/**
*/
void
GNUNET_TUN_calculate_icmp_checksum (struct GNUNET_TUN_IcmpHeader *icmp,
- const void *payload,
- uint16_t payload_length);
+ const void *payload,
+ uint16_t payload_length);
/**
#endif
-/** @} */ /* end of group */
+/** @} */ /* end of group */