mirror of
https://github.com/strongswan/strongswan.git
synced 2025-11-22 00:01:45 -05:00
- fixed bad SVN issues, should all work again now
- does not compile, need rewrite of parser and generator
This commit is contained in:
parent
52f831011f
commit
c0211a292b
@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "tester.h"
|
#include "utils/tester.h"
|
||||||
#include "job_queue.h"
|
#include "queues/job_queue.h"
|
||||||
|
|
||||||
|
|
||||||
job_queue_t *job_queue;
|
job_queue_t *job_queue;
|
||||||
|
|||||||
@ -140,7 +140,7 @@ FILE_PATTERNS = *.c *.h
|
|||||||
|
|
||||||
RECURSIVE = YES
|
RECURSIVE = YES
|
||||||
|
|
||||||
EXCLUDE = tests
|
EXCLUDE = testcases
|
||||||
|
|
||||||
EXCLUDE_SYMLINKS = NO
|
EXCLUDE_SYMLINKS = NO
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "utils/allocator.h"
|
#include "utils/allocator.h"
|
||||||
|
#include "payloads/payload.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct private_generator_context_s private_generator_context_t;
|
typedef struct private_generator_context_s private_generator_context_t;
|
||||||
|
|||||||
@ -24,7 +24,8 @@
|
|||||||
#define GENERATOR_H_
|
#define GENERATOR_H_
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "encodings/encodings.h"
|
#include "payloads/encodings.h"
|
||||||
|
#include "payloads/payload.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generating is done in a data buffer.
|
* Generating is done in a data buffer.
|
||||||
@ -120,6 +121,6 @@ struct generator_s {
|
|||||||
* all the payload informations needed to
|
* all the payload informations needed to
|
||||||
* automatic generate a specific payload
|
* automatic generate a specific payload
|
||||||
*/
|
*/
|
||||||
generator_t * generator_create(payload_info_t ** payload_infos);
|
generator_t * generator_create();
|
||||||
|
|
||||||
#endif /*GENERATOR_H_*/
|
#endif /*GENERATOR_H_*/
|
||||||
|
|||||||
@ -28,7 +28,8 @@
|
|||||||
#include "ike_sa_id.h"
|
#include "ike_sa_id.h"
|
||||||
#include "utils/linked_list.h"
|
#include "utils/linked_list.h"
|
||||||
#include "utils/allocator.h"
|
#include "utils/allocator.h"
|
||||||
#include "encodings/encodings.h"
|
#include "payloads/encodings.h"
|
||||||
|
#include "payloads/payload.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry for a payload in the internal used linked list
|
* Entry for a payload in the internal used linked list
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "utils/allocator.h"
|
#include "utils/allocator.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
#include "payloads/payload.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private data stored in a context
|
* @private data stored in a context
|
||||||
|
|||||||
@ -24,7 +24,8 @@
|
|||||||
#define PARSER_H_
|
#define PARSER_H_
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "encodings/encodings.h"
|
#include "payloads/encodings.h"
|
||||||
|
#include "payloads/payload.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The parser context stores state information for a parsing session.
|
* @brief The parser context stores state information for a parsing session.
|
||||||
@ -101,6 +102,6 @@ struct parser_s {
|
|||||||
* @param payload_infos list of payload_info_t
|
* @param payload_infos list of payload_info_t
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
parser_t *parser_create(payload_info_t **payload_infos);
|
parser_t *parser_create();
|
||||||
|
|
||||||
#endif /*PARSER_H_*/
|
#endif /*PARSER_H_*/
|
||||||
|
|||||||
206
Source/charon/payloads/encodings.h
Normal file
206
Source/charon/payloads/encodings.h
Normal file
@ -0,0 +1,206 @@
|
|||||||
|
/**
|
||||||
|
* @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;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /*ENCODINGS_H_*/
|
||||||
67
Source/charon/payloads/ike_header.c
Normal file
67
Source/charon/payloads/ike_header.c
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/**
|
||||||
|
* @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) }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
111
Source/charon/payloads/ike_header.h
Normal file
111
Source/charon/payloads/ike_header.h
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
/**
|
||||||
|
* @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"
|
||||||
|
#include "payload.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 {
|
||||||
|
/**
|
||||||
|
* implements payload_t interface
|
||||||
|
*/
|
||||||
|
payload_t payload_interface;
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create an empty ike_header
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - created ike_header, or
|
||||||
|
* - NULL if failed
|
||||||
|
*/
|
||||||
|
|
||||||
|
ike_header_t *create_ike_header();
|
||||||
|
|
||||||
|
#endif /*IKE_HEADER_H_*/
|
||||||
63
Source/charon/payloads/payload.c
Normal file
63
Source/charon/payloads/payload.c
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
* @file payload.c
|
||||||
|
*
|
||||||
|
* @brief Generic payload interface
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 "payload.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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}
|
||||||
|
};
|
||||||
|
|
||||||
197
Source/charon/payloads/payload.h
Normal file
197
Source/charon/payloads/payload.h
Normal file
@ -0,0 +1,197 @@
|
|||||||
|
/**
|
||||||
|
* @file payload.h
|
||||||
|
*
|
||||||
|
* @brief Generic payload interface
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 PAYLOAD_H_
|
||||||
|
#define PAYLOAD_H_
|
||||||
|
|
||||||
|
#include "encodings.h"
|
||||||
|
#include "../types.h"
|
||||||
|
#include "../definitions.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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[];
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Generic interface for all payload types (inclusive
|
||||||
|
* header and substructures)
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
typedef struct payload_s payload_t;
|
||||||
|
|
||||||
|
struct payload_s {
|
||||||
|
/**
|
||||||
|
* @brief Destroys a payload and all included substructures.
|
||||||
|
*
|
||||||
|
* @param this payload to destroy
|
||||||
|
* @return
|
||||||
|
* SUCCESS in any case
|
||||||
|
*/
|
||||||
|
status_t (*destroy) (payload_t *this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get encoding rules for this payload
|
||||||
|
*
|
||||||
|
* @param this calling object
|
||||||
|
* @param[out] rules location to store pointer of first rule
|
||||||
|
* @param[out] rule_count location to store number of rules
|
||||||
|
* @return
|
||||||
|
* SUCCESS in any case
|
||||||
|
*/
|
||||||
|
status_t (*get_encoding_rules) (payload_t *this, encoding_rule_t **rules, size_t *rule_count);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief get type of payload
|
||||||
|
*
|
||||||
|
* @param this calling object
|
||||||
|
* @return type of this payload
|
||||||
|
*/
|
||||||
|
payload_type_t (*get_type) (payload_t *this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief get type of next payload or zero if this is the last one
|
||||||
|
*
|
||||||
|
* @param this calling object
|
||||||
|
* @return type of next payload
|
||||||
|
*/
|
||||||
|
payload_type_t (*get_next_type) (payload_t *this);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief get length of payload
|
||||||
|
*
|
||||||
|
* @param this calling object
|
||||||
|
* @return length of this payload
|
||||||
|
*/
|
||||||
|
payload_type_t (*get_length) (payload_t *this);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Create an empty payload.
|
||||||
|
*
|
||||||
|
* Useful for the parser, who wants a generic constructor for all payloads.
|
||||||
|
* It supports all payload_t methods.
|
||||||
|
*
|
||||||
|
* @param type type of the payload to create
|
||||||
|
* @return
|
||||||
|
* - created payload, or
|
||||||
|
* - NULL if failed
|
||||||
|
*/
|
||||||
|
|
||||||
|
payload_t *create_empty_payload(payload_type_t type);
|
||||||
|
|
||||||
|
#endif /*PAYLOAD_H_*/
|
||||||
@ -29,8 +29,8 @@
|
|||||||
#include "../utils/allocator.h"
|
#include "../utils/allocator.h"
|
||||||
#include "../utils/logger_manager.h"
|
#include "../utils/logger_manager.h"
|
||||||
#include "../utils/logger.h"
|
#include "../utils/logger.h"
|
||||||
#include "../encodings/encodings.h"
|
#include "../payloads/encodings.h"
|
||||||
#include "../encodings/ike_header.h"
|
#include "../payloads/ike_header.h"
|
||||||
|
|
||||||
extern payload_info_t *payload_infos[];
|
extern payload_info_t *payload_infos[];
|
||||||
|
|
||||||
|
|||||||
@ -27,8 +27,8 @@
|
|||||||
#include "../parser.h"
|
#include "../parser.h"
|
||||||
#include "../utils/allocator.h"
|
#include "../utils/allocator.h"
|
||||||
#include "../utils/logger_manager.h"
|
#include "../utils/logger_manager.h"
|
||||||
#include "../encodings/encodings.h"
|
#include "../payloads/encodings.h"
|
||||||
#include "../encodings/ike_header.h"
|
#include "../payloads/ike_header.h"
|
||||||
|
|
||||||
extern payload_info_t *payload_infos[];
|
extern payload_info_t *payload_infos[];
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
#include "../socket.h"
|
#include "../socket.h"
|
||||||
#include "../queues/send_queue.h"
|
#include "../queues/send_queue.h"
|
||||||
#include "../queues/job_queue.h"
|
#include "../queues/job_queue.h"
|
||||||
#include "../encodings/encodings.h"
|
#include "../payloads/encodings.h"
|
||||||
#include "../utils/allocator.h"
|
#include "../utils/allocator.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user