Extended IKE header for IKEv1 support

This commit is contained in:
Martin Willi
2012-03-20 17:30:39 +01:00
parent ccdd3a4cee
commit 526b5afb45
4 changed files with 238 additions and 60 deletions
+97 -17
View File
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2007 Tobias Brunner
* Copyright (C) 2005-2006 Martin Willi
* Copyright (C) 2005-2011 Martin Willi
* Copyright (C) 2005 Jan Hutter
* Hochschule fuer Technik Rapperswil
*
@@ -30,19 +30,24 @@ typedef struct ike_header_t ike_header_t;
#include <encoding/payloads/payload.h>
/**
* Major Version of IKEv2.
* Major Version of IKEv1 we implement.
*/
#define IKE_MAJOR_VERSION 2
#define IKEV1_MAJOR_VERSION 1
/**
* Minor Version of IKEv2.
* Minor Version of IKEv2 we implement.
*/
#define IKE_MINOR_VERSION 0
#define IKEV1_MINOR_VERSION 0
/**
* Flag in IKEv2-Header. Always 0.
* Major Version of IKEv2 we implement.
*/
#define HIGHER_VERSION_SUPPORTED_FLAG 0
#define IKEV2_MAJOR_VERSION 2
/**
* Minor Version of IKEv2 we implement.
*/
#define IKEV2_MINOR_VERSION 0
/**
* Length of IKE Header in Bytes.
@@ -57,9 +62,34 @@ typedef struct ike_header_t ike_header_t;
enum exchange_type_t{
/**
* EXCHANGE_TYPE_UNDEFINED. In private space, since not a official message type.
* Identity Protection (Main mode).
*/
EXCHANGE_TYPE_UNDEFINED = 255,
ID_PROT = 2,
/**
* Authentication Only.
*/
AUTH_ONLY = 3,
/**
* Aggresive (Aggressive mode)
*/
AGGRESSIVE = 4,
/**
* Informational in IKEv1
*/
INFORMATIONAL_V1 = 5,
/**
* Quick Mode
*/
QUICK_MODE = 32,
/**
* New Group Mode
*/
NEW_GROUP_MODE = 33,
/**
* IKE_SA_INIT.
@@ -77,7 +107,7 @@ enum exchange_type_t{
CREATE_CHILD_SA = 36,
/**
* INFORMATIONAL.
* INFORMATIONAL in IKEv2.
*/
INFORMATIONAL = 37,
@@ -91,6 +121,11 @@ enum exchange_type_t{
*/
ME_CONNECT = 240
#endif /* ME */
/**
* Undefined exchange type, in private space.
*/
EXCHANGE_TYPE_UNDEFINED = 255,
};
/**
@@ -99,14 +134,10 @@ enum exchange_type_t{
extern enum_name_t *exchange_type_names;
/**
* An object of this type represents an IKEv2 header and is used to
* generate and parse IKEv2 headers.
*
* The header format of an IKEv2-Message is compatible to the
* ISAKMP-Header format to allow implementations supporting
* both versions of the IKE-protocol.
* An object of this type represents an IKE header of either IKEv1 or IKEv2.
*/
struct ike_header_t {
/**
* The payload_t interface.
*/
@@ -210,6 +241,48 @@ struct ike_header_t {
*/
void (*set_initiator_flag) (ike_header_t *this, bool initiator);
/**
* Get the encryption flag.
*
* @return encryption flag
*/
bool (*get_encryption_flag) (ike_header_t *this);
/**
* Set the encryption flag.
*
* @param encryption encryption flag
*/
void (*set_encryption_flag) (ike_header_t *this, bool encryption);
/**
* Get the commit flag.
*
* @return commit flag
*/
bool (*get_commit_flag) (ike_header_t *this);
/**
* Set the commit flag.
*
* @param commit commit flag
*/
void (*set_commit_flag) (ike_header_t *this, bool commit);
/**
* Get the authentication only flag.
*
* @return authonly flag
*/
bool (*get_authonly_flag) (ike_header_t *this);
/**
* Set the authentication only flag.
*
* @param authonly authonly flag
*/
void (*set_authonly_flag) (ike_header_t *this, bool authonly);
/**
* Get the exchange type.
*
@@ -245,10 +318,17 @@ struct ike_header_t {
};
/**
* Create an ike_header_t object
* Create an empty ike_header_t object.
*
* @return ike_header_t object
*/
ike_header_t *ike_header_create(void);
/**
* Create an ike_header_t object for a specific major/minor version
*
* @return ike_header_t object
*/
ike_header_t *ike_header_create_version(int major, int minor);
#endif /** IKE_HEADER_H_ @}*/