diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/charon/encodings/encodings.c | 74 | ||||
-rw-r--r-- | Source/charon/encodings/encodings.h | 331 | ||||
-rw-r--r-- | Source/charon/encodings/ike_header.c | 73 | ||||
-rw-r--r-- | Source/charon/encodings/ike_header.h | 96 |
4 files changed, 0 insertions, 574 deletions
diff --git a/Source/charon/encodings/encodings.c b/Source/charon/encodings/encodings.c deleted file mode 100644 index 5f2c62f64..000000000 --- a/Source/charon/encodings/encodings.c +++ /dev/null @@ -1,74 +0,0 @@ -/** - * @file encodings.c - * - * @brief Type definitions for parser and generator, - * also payload types are defined here. - * - * Header is parsed like a payload and gets its one payload_id - * from PRIVATE USE space. Also the substructures - * of specific payload types get their own payload_id - * from PRIVATE_USE space. See RFC for mor informations. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#include <stdlib.h> - -#include "../types.h" -#include "encodings.h" -#include "ike_header.h" - -extern payload_info_t ike_header_info; - -/* - * build the mappings for payload_type_t - */ -mapping_t payload_type_t_mappings[] = { - {NO_PAYLOAD, "NO_PAYLOAD"}, - {SECURITY_ASSOCIATION, "SECURITY_ASSOCIATION"}, - {KEY_EXCHANGE, "KEY_EXCHANGE"}, - {ID_INITIATOR, "ID_INITIATOR"}, - {ID_RESPONDER, "ID_RESPONDER"}, - {CERTIFICATE, "CERTIFICATE"}, - {CERTIFICATE_REQUEST, "CERTIFICATE_REQUEST"}, - {AUTHENTICATION, "AUTHENTICATION"}, - {NONCE, "NONCE"}, - {NOTIFY, "NOTIFY"}, - {DELETE, "DELETE"}, - {VENDOR_ID, "VENDOR_ID"}, - {TRAFFIC_SELECTOR_INITIATOR, "TRAFFIC_SELECTOR_INITIATOR"}, - {TRAFFIC_SELECTOR_RESPONDER, "TRAFFIC_SELECTOR_RESPONDER"}, - {ENCRYPTED, "ENCRYPTED"}, - {CONFIGURATION, "CONFIGURATION"}, - {EXTENSIBLE_AUTHENTICATION, "EXTENSIBLE_AUTHENTICATION"}, - {HEADER, "HEADER"}, - {MAPPING_END, NULL} -}; - - -/** - * List containing all payload informations - * supported by parser and generator. - * - * @warning This list must be NULL terminated. - */ -payload_info_t *payload_infos[] = { - &ike_header_info, - NULL -}; - - diff --git a/Source/charon/encodings/encodings.h b/Source/charon/encodings/encodings.h deleted file mode 100644 index 14fb73ff6..000000000 --- a/Source/charon/encodings/encodings.h +++ /dev/null @@ -1,331 +0,0 @@ -/** - * @file encodings.h - * - * @brief Type definitions for parser and generator, - * also payload types are defined here. - * - * Header is parsed like a payload and gets its one payload_id - * from PRIVATE USE space. Also the substructures - * of specific payload types get their own payload_id - * from PRIVATE_USE space. See RFC for mor informations. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef ENCODINGS_H_ -#define ENCODINGS_H_ - -#include "../types.h" -#include "../definitions.h" - - -/** - * @brief All different kinds of encoding types. - * - * Each field of an IKEv2-Message (in header or payload) - * which has to be parsed or generated differently has its own - * type defined here. - */ -typedef enum encoding_type_e encoding_type_t; - -enum encoding_type_e{ - /** - * Representing a 4 Bit unsigned int value - * - * - * When generating it must be changed from host to network order. - * The value is read from the associated data struct. - * The current write position is moved 4 bit forward afterwards. - * - * When parsing it must be changed from network to host order. - * The value is written to the associated data struct. - * The current read pointer is moved 4 bit forward afterwards. - */ - U_INT_4, - /** - * Representing a 8 Bit unsigned int value - * - * - * When generating it must be changed from host to network order. - * The value is read from the associated data struct. - * The current write position is moved 8 bit forward afterwards. - * - * When parsing it must be changed from network to host order. - * The value is written to the associated data struct. - * The current read pointer is moved 8 bit forward afterwards. - */ - U_INT_8, - /** - * Representing a 16 Bit unsigned int value - * - * - * When generating it must be changed from host to network order. - * The value is read from the associated data struct. - * The current write position is moved 16 bit forward afterwards. - * - * When parsing it must be changed from network to host order. - * The value is written to the associated data struct. - * The current read pointer is moved 16 bit forward afterwards. - */ - U_INT_16, - /** - * Representing a 32 Bit unsigned int value - * - * When generating it must be changed from host to network order. - * The value is read from the associated data struct. - * The current write position is moved 32 bit forward afterwards. - * - * When parsing it must be changed from network to host order. - * The value is written to the associated data struct. - * The current read pointer is moved 32 bit forward afterwards. - */ - - U_INT_32, - /** - * Representing a 64 Bit unsigned int value - * - * When generating it must be changed from host to network order. - * The value is read from the associated data struct. - * The current write position is moved 64 bit forward afterwards. - * - * When parsing it must be changed from network to host order. - * The value is written to the associated data struct. - * The current read pointer is moved 64 bit forward afterwards. - */ - U_INT_64, - /** - * @brief represents a RESERVED_BIT used in FLAG-Bytes - * - * When generating, the next bit is set to zero and the current write - * position is moved one bit forward. - * No value is read from the associated data struct. - * The current write position is moved 1 bit forward afterwards. - * - * When parsing, the current read pointer is moved one bit forward. - * No value is written to the associated data struct. - * The current read pointer is moved 1 bit forward afterwards. - */ - RESERVED_BIT, - /** - * @brief represents a RESERVED_BYTE - * - * When generating, the next byte is set to zero and the current write - * position is moved one byte forward. - * No value is read from the associated data struct. - * The current write position is moved 1 byte forward afterwards. - * - * When parsing, the current read pointer is moved one byte forward. - * No value is written to the associated data struct. - * The current read pointer is moved 1 byte forward afterwards. - */ - RESERVED_BYTE, - /** - * Representing a 1 Bit flag. - * - * When generation, the next bit is set to 1 if the associated value - * in the data struct is TRUE, 0 otherwise. The current write position - * is moved 1 bit forward afterwards. - * - * When parsing, the next bit is read and stored in the associated data - * struct. 0 means FALSE, 1 means TRUE, The current read pointer - * is moved 1 bit forward afterwards - */ - FLAG, - /** - * Representating a length field - * - * When generating it must be changed from host to network order. - * The value is read from the associated data struct. - * The current write position is moved 32 bit forward afterwards. - * - * When parsing it must be changed from network to host order. - * The value is written to the associated data struct. - * The current read pointer is moved 32 bit forward afterwards. - */ - LENGTH, - /** - * Representating a spi size field - * - * When generating it must be changed from host to network order. - * The value is read from the associated data struct. - * The current write position is moved 32 bit forward afterwards. - * - * When parsing it must be changed from network to host order. - * The value is written to the associated data struct. - * The current read pointer is moved 32 bit forward afterwards. - */ - SPI_SIZE -}; - -/** - * An encoding rule is a mapping of a specific encoding type to - * a location in the data struct where the current field is stored to - * or read from. - * - * For examples see directory encodings/. - * - * This rules are used by parser and generator. - */ -typedef struct encoding_rule_s encoding_rule_t; - -struct encoding_rule_s{ - /** - * Encoding type - */ - encoding_type_t type; - /** - * Offset in the data struct - * - * When parsing, data are written to this offset of the - * data struct. - * - * When generating, data are read from this offset in the - * data struct. - */ - u_int32_t offset; -}; - - -/** - * Payload-Types of a IKEv2-Message - * - * - * Header and substructures are also defined as - * payload types with values from PRIVATE USE space. - */ -typedef enum payload_type_e payload_type_t; - -enum payload_type_e{ - - /** - * NO_PAYLOAD - */ - NO_PAYLOAD = 0, - - /** - * SA - */ - SECURITY_ASSOCIATION = 33, - /** - * KE - */ - KEY_EXCHANGE = 34, - /** - * IDi - */ - ID_INITIATOR = 35, - /** - * IDr - */ - ID_RESPONDER = 36, - /** - * CERT - */ - CERTIFICATE = 37, - /** - * CERTREQ - */ - CERTIFICATE_REQUEST = 38, - /** - * AUTH - */ - AUTHENTICATION = 39, - /** - * Ni, Nr - */ - NONCE = 40, - /** - * N - */ - NOTIFY = 41, - /** - * D - */ - DELETE = 42, - /** - * V - */ - VENDOR_ID = 43, - /** - * TSi - */ - TRAFFIC_SELECTOR_INITIATOR = 44, - /** - * TSr - */ - TRAFFIC_SELECTOR_RESPONDER = 45, - /** - * E - */ - ENCRYPTED = 46, - /** - * CP - */ - CONFIGURATION = 47, - /** - * EAP - */ - EXTENSIBLE_AUTHENTICATION = 48, - - /** - * Header has value 140 of PRIVATE USE space - * - * This payload type is not send over wire and just - * used internally to handle IKEv2-Header like a payload. - */ - HEADER = 140 -}; - - -/* - * build string mapping array for payload_type_t - */ -extern mapping_t payload_type_t_mappings[]; - -/** - * Information of a specific payload are stored in this struct - * - * The following informations are needed for each payload - * - payload type - * - length of its associated data struct in bytes - * - encoding rules array - * - encoding rules count - */ -typedef struct payload_info_s payload_info_t; - -struct payload_info_s{ - /** - * Type of payload - */ - payload_type_t payload_type; - /** - * Length of associated data struct in bytes - */ - size_t data_struct_length; - - /** - * Pointer to the encoding rules array - */ - encoding_rule_t *ecoding_rules; - - /** - * Number of encoding rules for the specific payload_type - */ - size_t encoding_rules_count; -}; - -#endif /*ENCODINGS_H_*/ diff --git a/Source/charon/encodings/ike_header.c b/Source/charon/encodings/ike_header.c deleted file mode 100644 index 39bc23fd6..000000000 --- a/Source/charon/encodings/ike_header.c +++ /dev/null @@ -1,73 +0,0 @@ -/** - * @file ike_header.c - * - * @brief Definition of the encoding rules used when parsing or generating - * an IKEv2-Header - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -/* offsetof macro */ -#include <stddef.h> - - #include "encodings.h" - #include "ike_header.h" - -/** - * Encoding rules to parse or generate a IKEv2-Header - * - * The defined offsets are the positions in a struct of type - * ike_header_t. - * - */ -encoding_rule_t ike_header_encodings[] = { - /* 8 Byte SPI, stored in the field initiator_spi */ - { U_INT_64, offsetof(ike_header_t, initiator_spi) }, - /* 8 Byte SPI, stored in the field responder_spi */ - { U_INT_64, offsetof(ike_header_t, responder_spi) }, - /* 1 Byte next payload type, stored in the field next_payload */ - { U_INT_8, offsetof(ike_header_t, next_payload) }, - /* 4 Bit major version, stored in the field maj_version */ - { U_INT_4, offsetof(ike_header_t, maj_version) }, - /* 4 Bit minor version, stored in the field min_version */ - { U_INT_4, offsetof(ike_header_t, min_version) }, - /* 8 Bit for the exchange type */ - { U_INT_8, offsetof(ike_header_t, exchange_type) }, - /* 2 Bit reserved bits, nowhere stored */ - { RESERVED_BIT, 0 }, - { RESERVED_BIT, 0 }, - /* 3 Bit flags, stored in the fields response, version and initiator */ - { FLAG, offsetof(ike_header_t, flags.response) }, - { FLAG, offsetof(ike_header_t, flags.version) }, - { FLAG, offsetof(ike_header_t, flags.initiator) }, - /* 3 Bit reserved bits, nowhere stored */ - { RESERVED_BIT, 0 }, - { RESERVED_BIT, 0 }, - { RESERVED_BIT, 0 }, - /* 4 Byte message id, stored in the field message_id */ - { U_INT_32, offsetof(ike_header_t, message_id) }, - /* 4 Byte length fied, stored in the field length */ - { LENGTH, offsetof(ike_header_t, length) } -}; - -/** - * This informations are needed for autmatic parsing of header content - */ -payload_info_t ike_header_info = {HEADER, - sizeof(ike_header_t), - ike_header_encodings, - (sizeof(ike_header_encodings)/sizeof(encoding_rule_t))}; diff --git a/Source/charon/encodings/ike_header.h b/Source/charon/encodings/ike_header.h deleted file mode 100644 index 6ca431a70..000000000 --- a/Source/charon/encodings/ike_header.h +++ /dev/null @@ -1,96 +0,0 @@ -/** - * @file ike_header.h - * - * @brief Declaration of the data struct ike_header_t. - * - * The data of a parsed header are stored in a struct of this type. - * - */ - -/* - * Copyright (C) 2005 Jan Hutter, Martin Willi - * Hochschule fuer Technik Rapperswil - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2 of the License, or (at your - * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - */ - -#ifndef IKE_HEADER_H_ -#define IKE_HEADER_H_ - -#include "../types.h" - -/** - * Data structure to hold the data of an IKEv2-Header - * - * The header format of an IKEv2-Message is compatible to the - * ISAKMP-Header format to allow implementations supporting - * both versions of the IKE-protocol. - * - */ -typedef struct ike_header_s ike_header_t; - -struct ike_header_s{ - /** - * SPI of the initiator - */ - u_int64_t initiator_spi; - /** - * SPI of the responder - */ - u_int64_t responder_spi; - /** - * next payload type - */ - u_int8_t next_payload; - /** - * IKE major version - */ - u_int8_t maj_version; - - /** - * IKE minor version - */ - u_int8_t min_version; - - /** - * Exchange type - */ - u_int8_t exchange_type; - - /** - * Flags of the Message - * - */ - struct { - /** - * Sender is initiator of the associated IKE_SA_INIT-Exchange - */ - bool initiator; - /** - * is protocol supporting higher version? - */ - bool version; - /** - * TRUE, if this is a response, FALSE if its a Request - */ - bool response; - } flags; - /** - * Associated Message-ID - */ - u_int32_t message_id; - /** - * Length of the whole IKEv2-Message (header and all payloads) - */ - u_int32_t length; -}; - -#endif /*IKE_HEADER_H_*/ |