moved typedefs to beginning of files to solve some include problems

splitted authenticator to have a separate implementation for each auth_method_t
using va_copy to clone va_lists, should fix proplems on AMD64
some other cleanups
This commit is contained in:
Martin Willi
2006-10-30 14:07:05 +00:00
parent 09cb5472bc
commit 382b481795
119 changed files with 1196 additions and 1120 deletions
+5 -5
View File
@@ -24,6 +24,8 @@
#ifndef GENERATOR_H_
#define GENERATOR_H_
typedef struct generator_t generator_t;
#include <types.h>
#include <encoding/payloads/encodings.h>
#include <encoding/payloads/payload.h>
@@ -31,24 +33,22 @@
/**
* Generating is done in a data buffer.
* This is thehe start size of this buffer in bytes.
*
*
* @ingroup enconding
*/
#define GENERATOR_DATA_BUFFER_SIZE 500
/**
* Number of bytes to increase the buffer, if it is to small.
*
*
* @ingroup enconding
*/
#define GENERATOR_DATA_BUFFER_INCREASE_VALUE 500
typedef struct generator_t generator_t;
/**
* @brief A generator_t class used to generate IKEv2 payloads.
*
*
* After creation, multiple payloads can be generated with the generate_payload
* method. The generated bytes are appended. After all payloads are added,
* the write_to_chunk method writes out all generated data since
+2 -3
View File
@@ -25,6 +25,8 @@
#ifndef MESSAGE_H_
#define MESSAGE_H_
typedef struct message_t message_t;
#include <types.h>
#include <sa/ike_sa_id.h>
#include <network/packet.h>
@@ -39,9 +41,6 @@
*/
#define MESSAGE_PRINTF_SPEC 'M'
typedef struct message_t message_t;
/**
* @brief This class is used to represent an IKEv2-Message.
*
+5 -6
View File
@@ -24,23 +24,22 @@
#ifndef PARSER_H_
#define PARSER_H_
typedef struct parser_t parser_t;
#include <types.h>
#include <encoding/payloads/encodings.h>
#include <encoding/payloads/payload.h>
typedef struct parser_t parser_t;
/**
* @brief A parser_t class to parse IKEv2 payloads.
*
*
* A parser is used for parsing one chunk of data. Multiple
* payloads can be parsed out of the chunk using parse_payload.
* The parser remains the state until destroyed.
*
*
* @b Constructors:
* - parser_create()
*
*
* @ingroup encoding
*/
struct parser_t {
+13 -14
View File
@@ -70,7 +70,6 @@ struct private_auth_payload_t {
*
* The defined offsets are the positions in a object of type
* private_auth_payload_t.
*
*/
encoding_rule_t auth_payload_encodings[] = {
/* 1 Byte next payload type, stored in the field next_payload */
@@ -78,23 +77,23 @@ encoding_rule_t auth_payload_encodings[] = {
/* the critical bit */
{ FLAG, offsetof(private_auth_payload_t, critical) },
/* 7 Bit reserved bits, nowhere stored */
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
{ RESERVED_BIT, 0 },
/* Length of the whole payload*/
{ PAYLOAD_LENGTH, offsetof(private_auth_payload_t, payload_length)},
/* 1 Byte AUTH type*/
{ U_INT_8, offsetof(private_auth_payload_t, auth_method) },
/* 3 reserved bytes */
{ RESERVED_BYTE, 0 },
{ RESERVED_BYTE, 0 },
{ RESERVED_BYTE, 0 },
{ RESERVED_BYTE, 0 },
{ RESERVED_BYTE, 0 },
{ RESERVED_BYTE, 0 },
/* some auth data bytes, length is defined in PAYLOAD_LENGTH */
{ AUTH_DATA, offsetof(private_auth_payload_t, auth_data) }
{ AUTH_DATA, offsetof(private_auth_payload_t, auth_data) }
};
/*
@@ -116,8 +115,8 @@ encoding_rule_t auth_payload_encodings[] = {
*/
static status_t verify(private_auth_payload_t *this)
{
if ((this->auth_method == 0) ||
((this->auth_method >= 4) && (this->auth_method <= 200)))
if (this->auth_method == 0 ||
(this->auth_method >= 4 && this->auth_method <= 200))
{
/* reserved IDs */
return FAILED;
+6 -8
View File
@@ -21,13 +21,14 @@
* for more details.
*/
#ifndef AUTH_PAYLOAD_H_
#define AUTH_PAYLOAD_H_
typedef struct auth_payload_t auth_payload_t;
#include <types.h>
#include <encoding/payloads/payload.h>
#include <config/policies/policy.h>
#include <sa/authenticators/authenticator.h>
/**
* Length of a auth payload without the auth data in bytes.
@@ -36,17 +37,14 @@
*/
#define AUTH_PAYLOAD_HEADER_LENGTH 8
typedef struct auth_payload_t auth_payload_t;
/**
* @brief Class representing an IKEv2 AUTH payload.
*
*
* The AUTH payload format is described in RFC section 3.8.
*
*
* @b Constructors:
* - auth_payload_create()
*
*
* @ingroup payloads
*/
struct auth_payload_t {
+7 -9
View File
@@ -24,6 +24,9 @@
#ifndef CERT_PAYLOAD_H_
#define CERT_PAYLOAD_H_
typedef enum cert_encoding_t cert_encoding_t;
typedef struct cert_payload_t cert_payload_t;
#include <types.h>
#include <crypto/x509.h>
#include <encoding/payloads/payload.h>
@@ -35,12 +38,9 @@
*/
#define CERT_PAYLOAD_HEADER_LENGTH 5
typedef enum cert_encoding_t cert_encoding_t;
/**
* @brief Certificate encoding, as described in IKEv2 RFC section 3.6
*
*
* @ingroup payloads
*/
enum cert_encoding_t {
@@ -66,11 +66,9 @@ enum cert_encoding_t {
*/
extern enum_name_t *cert_encoding_names;
typedef struct cert_payload_t cert_payload_t;
/**
* @brief Class representing an IKEv2 CERT payload.
*
*
* The CERT payload format is described in RFC section 3.6.
* This is just a dummy implementation to fullfill the standards
* requirements. A full implementation would offer setters/getters
@@ -78,9 +76,9 @@ typedef struct cert_payload_t cert_payload_t;
*
* @b Constructors:
* - cert_payload_create()
*
*
* @todo Implement setters/getters for the different certificate encodings.
*
*
* @ingroup payloads
*/
struct cert_payload_t {
@@ -24,6 +24,8 @@
#ifndef CERTREQ_PAYLOAD_H_
#define CERTREQ_PAYLOAD_H_
typedef struct certreq_payload_t certreq_payload_t;
#include <types.h>
#include <encoding/payloads/payload.h>
#include <encoding/payloads/cert_payload.h>
@@ -36,21 +38,19 @@
#define CERTREQ_PAYLOAD_HEADER_LENGTH 5
typedef struct certreq_payload_t certreq_payload_t;
/**
* @brief Class representing an IKEv2 CERTREQ payload.
*
*
* The CERTREQ payload format is described in RFC section 3.7.
* This is just a dummy implementation to fullfill the standards
* requirements. A full implementation would offer setters/getters
* for the different encoding types.
*
*
* @b Constructors:
* - certreq_payload_create()
*
*
* @todo Implement payload functionality.
*
*
* @ingroup payloads
*/
struct certreq_payload_t {
@@ -24,11 +24,13 @@
#ifndef CONFIGURATION_ATTRIBUTE_H_
#define CONFIGURATION_ATTRIBUTE_H_
typedef enum configuration_attribute_type_t configuration_attribute_type_t;
typedef struct configuration_attribute_t configuration_attribute_t;
#include <types.h>
#include <encoding/payloads/payload.h>
/**
* Configuration attribute header length in bytes.
*
@@ -36,9 +38,6 @@
*/
#define CONFIGURATION_ATTRIBUTE_HEADER_LENGTH 4
typedef enum configuration_attribute_type_t configuration_attribute_type_t;
/**
* Type of the attribute, as in IKEv2 RFC 3.15.1.
*
@@ -68,8 +67,6 @@ enum configuration_attribute_type_t {
*/
extern enum_name_t *configuration_attribute_type_names;
typedef struct configuration_attribute_t configuration_attribute_t;
/**
* @brief Class representing an IKEv2-CONFIGURATION Attribute.
*
+4 -7
View File
@@ -24,6 +24,9 @@
#ifndef CP_PAYLOAD_H_
#define CP_PAYLOAD_H_
typedef enum config_type_t config_type_t;
typedef struct cp_payload_t cp_payload_t;
#include <types.h>
#include <encoding/payloads/payload.h>
#include <encoding/payloads/configuration_attribute.h>
@@ -36,12 +39,9 @@
*/
#define CP_PAYLOAD_HEADER_LENGTH 8
typedef enum config_type_t config_type_t;
/**
* Config Type of an Configuration Payload.
*
*
* @ingroup payloads
*/
enum config_type_t {
@@ -58,9 +58,6 @@ enum config_type_t {
*/
extern enum_name_t *config_type_names;
typedef struct cp_payload_t cp_payload_t;
/**
* @brief Class representing an IKEv2-CP Payload.
*
@@ -24,31 +24,29 @@
#ifndef DELETE_PAYLOAD_H_
#define DELETE_PAYLOAD_H_
typedef struct delete_payload_t delete_payload_t;
#include <types.h>
#include <encoding/payloads/payload.h>
#include <encoding/payloads/proposal_substructure.h>
/**
* Length of a delete payload without the SPI in bytes.
*
*
* @ingroup payloads
*/
#define DELETE_PAYLOAD_HEADER_LENGTH 8
typedef struct delete_payload_t delete_payload_t;
/**
* @brief Class representing an IKEv2 DELETE payload.
*
*
* The DELETE payload format is described in RFC section 3.11.
*
*
* @b Constructors:
* - delete_payload_create()
*
*
* @todo Implement better setter/getters
*
*
* @ingroup payloads
*/
struct delete_payload_t {
+5 -6
View File
@@ -24,6 +24,8 @@
#ifndef EAP_PAYLOAD_H_
#define EAP_PAYLOAD_H_
typedef struct eap_payload_t eap_payload_t;
#include <types.h>
#include <encoding/payloads/payload.h>
@@ -34,19 +36,16 @@
*/
#define EAP_PAYLOAD_HEADER_LENGTH 4
typedef struct eap_payload_t eap_payload_t;
/**
* @brief Class representing an IKEv2 EAP payload.
*
*
* The EAP payload format is described in RFC section 3.16.
*
* @b Constructors:
* - eap_payload_create()
*
*
* @todo Implement functionality for this payload
*
*
* @ingroup payloads
*/
struct eap_payload_t {
+6 -8
View File
@@ -24,24 +24,25 @@
#ifndef ENCODINGS_H_
#define ENCODINGS_H_
typedef enum encoding_type_t encoding_type_t;
typedef struct encoding_rule_t encoding_rule_t;
#include <types.h>
#include <definitions.h>
typedef enum encoding_type_t encoding_type_t;
/**
* @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.
*
*
* 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 IKEv2-Draft for more informations.
*
*
* @ingroup payloads
*/
enum encoding_type_t {
@@ -505,9 +506,6 @@ enum encoding_type_t {
*/
extern enum_name_t *encoding_type_names;
typedef struct encoding_rule_t encoding_rule_t;
/**
* 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
@@ -23,6 +23,8 @@
#ifndef ENCRYPTION_PAYLOAD_H_
#define ENCRYPTION_PAYLOAD_H_
typedef struct encryption_payload_t encryption_payload_t;
#include <types.h>
#include <crypto/crypters/crypter.h>
#include <crypto/signers/signer.h>
@@ -37,11 +39,9 @@
#define ENCRYPTION_PAYLOAD_HEADER_LENGTH 4
typedef struct encryption_payload_t encryption_payload_t;
/**
/**
* @brief The encryption payload as described in RFC section 3.14.
*
*
* Before any crypt/decrypt/sign/verify operation can occur,
* the transforms must be set. After that, a parsed encryption payload
* can be decrypted, which also will parse the contained payloads.
@@ -51,10 +51,10 @@ typedef struct encryption_payload_t encryption_payload_t;
* must be builded after generation of all payloads and the encryption
* of the encryption payload.
* Signature verificatin is done before decryption.
*
*
* @b Constructors:
* - encryption_payload_create()
*
*
* @ingroup payloads
*/
struct encryption_payload_t {
+5 -6
View File
@@ -25,6 +25,8 @@
#ifndef ID_PAYLOAD_H_
#define ID_PAYLOAD_H_
typedef struct id_payload_t id_payload_t;
#include <types.h>
#include <utils/identification.h>
#include <encoding/payloads/payload.h>
@@ -36,18 +38,15 @@
*/
#define ID_PAYLOAD_HEADER_LENGTH 8
typedef struct id_payload_t id_payload_t;
/**
* Object representing an IKEv2 ID payload.
*
*
* The ID payload format is described in RFC section 3.5.
*
*
* @b Constructors:
* - id_payload_create_from_identification()
* - id_payload_create()
*
*
* @ingroup payloads
*/
struct id_payload_t {
+3 -5
View File
@@ -24,6 +24,9 @@
#ifndef IKE_HEADER_H_
#define IKE_HEADER_H_
typedef enum exchange_type_t exchange_type_t;
typedef struct ike_header_t ike_header_t;
#include <types.h>
#include <encoding/payloads/payload.h>
@@ -55,8 +58,6 @@
*/
#define IKE_HEADER_LENGTH 28
typedef enum exchange_type_t exchange_type_t;
/**
* @brief Different types of IKE-Exchanges.
*
@@ -99,9 +100,6 @@ enum exchange_type_t{
*/
extern enum_name_t *exchange_type_names;
typedef struct ike_header_t ike_header_t;
/**
* @brief An object of this type represents an IKEv2 header and is used to
* generate and parse IKEv2 headers.
+5 -6
View File
@@ -24,6 +24,8 @@
#ifndef KE_PAYLOAD_H_
#define KE_PAYLOAD_H_
typedef struct ke_payload_t ke_payload_t;
#include <types.h>
#include <encoding/payloads/payload.h>
#include <encoding/payloads/transform_substructure.h>
@@ -37,17 +39,14 @@
*/
#define KE_PAYLOAD_HEADER_LENGTH 8
typedef struct ke_payload_t ke_payload_t;
/**
* @brief Class representing an IKEv2-KE Payload.
*
*
* The KE Payload format is described in RFC section 3.4.
*
*
* @b Constructors:
* - ke_payload_create()
*
*
* @ingroup payloads
*/
struct ke_payload_t {
+2 -2
View File
@@ -24,6 +24,8 @@
#ifndef NONCE_PAYLOAD_H_
#define NONCE_PAYLOAD_H_
typedef struct nonce_payload_t nonce_payload_t;
#include <types.h>
#include <encoding/payloads/payload.h>
@@ -43,8 +45,6 @@
*/
#define NONCE_PAYLOAD_HEADER_LENGTH 4
typedef struct nonce_payload_t nonce_payload_t;
/**
* Object representing an IKEv2 Nonce payload.
*
@@ -26,6 +26,9 @@
#ifndef NOTIFY_PAYLOAD_H_
#define NOTIFY_PAYLOAD_H_
typedef enum notify_type_t notify_type_t;
typedef struct notify_payload_t notify_payload_t;
#include <types.h>
#include <encoding/payloads/payload.h>
#include <encoding/payloads/proposal_substructure.h>
@@ -38,14 +41,11 @@
*/
#define NOTIFY_PAYLOAD_HEADER_LENGTH 8
typedef enum notify_type_t notify_type_t;
/**
/**
* @brief Notify message types.
*
*
* See IKEv2 RFC 3.10.1.
*
*
* @ingroup payloads
*/
enum notify_type_t {
@@ -98,8 +98,6 @@ enum notify_type_t {
extern enum_name_t *notify_type_names;
typedef struct notify_payload_t notify_payload_t;
/**
* @brief Class representing an IKEv2-Notify Payload.
*
+5 -7
View File
@@ -24,19 +24,20 @@
#ifndef PAYLOAD_H_
#define PAYLOAD_H_
typedef enum payload_type_t payload_type_t;
typedef struct payload_t payload_t;
#include <types.h>
#include <definitions.h>
#include <encoding/payloads/encodings.h>
typedef enum payload_type_t payload_type_t;
/**
* @brief Payload-Types of a IKEv2-Message.
*
*
* Header and substructures are also defined as
* payload types with values from PRIVATE USE space.
*
*
* @ingroup payloads
*/
enum payload_type_t{
@@ -194,9 +195,6 @@ extern enum_name_t *payload_type_names;
*/
extern enum_name_t *payload_type_short_names;
typedef struct payload_t payload_t;
/**
* @brief Generic interface for all payload types (incl.header and substructures).
*
@@ -24,6 +24,8 @@
#ifndef PROPOSAL_SUBSTRUCTURE_H_
#define PROPOSAL_SUBSTRUCTURE_H_
typedef struct proposal_substructure_t proposal_substructure_t;
#include <types.h>
#include <encoding/payloads/payload.h>
#include <encoding/payloads/transform_substructure.h>
@@ -38,9 +40,6 @@
*/
#define PROPOSAL_SUBSTRUCTURE_HEADER_LENGTH 8
typedef struct proposal_substructure_t proposal_substructure_t;
/**
* @brief Class representing an IKEv2-PROPOSAL SUBSTRUCTURE.
*
+6 -6
View File
@@ -24,6 +24,8 @@
#ifndef SA_PAYLOAD_H_
#define SA_PAYLOAD_H_
typedef struct sa_payload_t sa_payload_t;
#include <types.h>
#include <encoding/payloads/payload.h>
#include <encoding/payloads/proposal_substructure.h>
@@ -36,20 +38,18 @@
*/
#define SA_PAYLOAD_HEADER_LENGTH 4
typedef struct sa_payload_t sa_payload_t;
/**
* @brief Class representing an IKEv2-SA Payload.
*
*
* The SA Payload format is described in RFC section 3.3.
*
*
* @b Constructors:
* - sa_payload_create()
* - sa_payload_create_from_ike_proposals()
* - sa_payload_create_from_proposal()
*
*
* @todo Add support of algorithms without specified keylength in get_proposals and get_ike_proposals.
*
*
* @ingroup payloads
*/
struct sa_payload_t {
@@ -25,6 +25,8 @@
#ifndef TRAFFIC_SELECTOR_SUBSTRUCTURE_H_
#define TRAFFIC_SELECTOR_SUBSTRUCTURE_H_
typedef struct traffic_selector_substructure_t traffic_selector_substructure_t;
#include <types.h>
#include <encoding/payloads/payload.h>
#include <utils/host.h>
@@ -37,8 +39,6 @@
*/
#define TRAFFIC_SELECTOR_HEADER_LENGTH 8
typedef struct traffic_selector_substructure_t traffic_selector_substructure_t;
/**
* @brief Class representing an IKEv2 TRAFFIC SELECTOR.
*
@@ -24,12 +24,13 @@
#ifndef TRANSFORM_ATTRIBUTE_H_
#define TRANSFORM_ATTRIBUTE_H_
typedef enum transform_attribute_type_t transform_attribute_type_t;
typedef struct transform_attribute_t transform_attribute_t;
#include <types.h>
#include <encoding/payloads/payload.h>
typedef enum transform_attribute_type_t transform_attribute_type_t;
/**
* Type of the attribute, as in IKEv2 RFC 3.3.5.
*
@@ -47,8 +48,6 @@ enum transform_attribute_type_t {
*/
extern enum_name_t *transform_attribute_type_names;
typedef struct transform_attribute_t transform_attribute_t;
/**
* @brief Class representing an IKEv2- TRANSFORM Attribute.
*
@@ -24,6 +24,8 @@
#ifndef TRANSFORM_SUBSTRUCTURE_H_
#define TRANSFORM_SUBSTRUCTURE_H_
typedef struct transform_substructure_t transform_substructure_t;
#include <types.h>
#include <definitions.h>
#include <encoding/payloads/payload.h>
@@ -51,8 +53,6 @@
#define TRANSFORM_SUBSTRUCTURE_HEADER_LENGTH 8
typedef struct transform_substructure_t transform_substructure_t;
/**
* @brief Class representing an IKEv2- TRANSFORM SUBSTRUCTURE.
*
+5 -5
View File
@@ -25,6 +25,8 @@
#ifndef TS_PAYLOAD_H_
#define TS_PAYLOAD_H_
typedef struct ts_payload_t ts_payload_t;
#include <types.h>
#include <utils/linked_list.h>
#include <config/traffic_selector.h>
@@ -39,17 +41,15 @@
#define TS_PAYLOAD_HEADER_LENGTH 8
typedef struct ts_payload_t ts_payload_t;
/**
* @brief Class representing an IKEv2 TS payload.
*
*
* The TS payload format is described in RFC section 3.13.
*
*
* @b Constructors:
* - ts_payload_create()
* - ts_payload_create_from_traffic_selectors()
*
*
* @ingroup payloads
*/
struct ts_payload_t {
@@ -24,6 +24,8 @@
#ifndef UNKNOWN_PAYLOAD_H_
#define UNKNOWN_PAYLOAD_H_
typedef struct unknown_payload_t unknown_payload_t;
#include <types.h>
#include <encoding/payloads/payload.h>
@@ -34,19 +36,16 @@
*/
#define UNKNOWN_PAYLOAD_HEADER_LENGTH 4
typedef struct unknown_payload_t unknown_payload_t;
/**
* @brief Payload which can't be processed further.
*
*
* When the parser finds an unknown payload, he builds an instance of
* this class. This allows further processing of this payload, such as
* a check for the critical bit in the header.
*
*
* @b Constructors:
* - unknown_payload_create()
*
*
* @ingroup payloads
*/
struct unknown_payload_t {
@@ -24,6 +24,8 @@
#ifndef VENDOR_ID_PAYLOAD_H_
#define VENDOR_ID_PAYLOAD_H_
typedef struct vendor_id_payload_t vendor_id_payload_t;
#include <types.h>
#include <encoding/payloads/payload.h>
@@ -35,16 +37,14 @@
#define VENDOR_ID_PAYLOAD_HEADER_LENGTH 4
typedef struct vendor_id_payload_t vendor_id_payload_t;
/**
* @brief Class representing an IKEv2 VENDOR ID payload.
*
*
* The VENDOR ID payload format is described in RFC section 3.12.
*
*
* @b Constructors:
* - vendor_id_payload_create()
*
*
* @ingroup payloads
*/
struct vendor_id_payload_t {