Added not-yet used sa_payload parameters used in IKEv1
This commit is contained in:
@@ -341,6 +341,31 @@ METHOD(sa_payload_t, create_substructure_enumerator, enumerator_t*,
|
||||
return this->proposals->create_enumerator(this->proposals);
|
||||
}
|
||||
|
||||
METHOD(sa_payload_t, get_lifetime, u_int32_t,
|
||||
private_sa_payload_t *this)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
METHOD(sa_payload_t, get_lifebytes, u_int64_t,
|
||||
private_sa_payload_t *this)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
METHOD(sa_payload_t, get_auth_method, auth_method_t,
|
||||
private_sa_payload_t *this)
|
||||
{
|
||||
return AUTH_NONE;
|
||||
}
|
||||
|
||||
METHOD(sa_payload_t, get_encap_mode, ipsec_mode_t,
|
||||
private_sa_payload_t *this, bool *udp)
|
||||
{
|
||||
*udp = FALSE;
|
||||
return MODE_NONE;
|
||||
}
|
||||
|
||||
METHOD2(payload_t, sa_payload_t, destroy, void,
|
||||
private_sa_payload_t *this)
|
||||
{
|
||||
@@ -370,6 +395,10 @@ sa_payload_t *sa_payload_create(payload_type_t type)
|
||||
},
|
||||
.get_proposals = _get_proposals,
|
||||
.create_substructure_enumerator = _create_substructure_enumerator,
|
||||
.get_lifetime = _get_lifetime,
|
||||
.get_lifebytes = _get_lifebytes,
|
||||
.get_auth_method = _get_auth_method,
|
||||
.get_encap_mode = _get_encap_mode,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
.next_payload = NO_PAYLOAD,
|
||||
@@ -431,3 +460,80 @@ sa_payload_t *sa_payload_create_from_proposal(payload_type_t type,
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header.
|
||||
*/
|
||||
sa_payload_t *sa_payload_create_from_proposals_v2(linked_list_t *proposals)
|
||||
{
|
||||
private_sa_payload_t *this;
|
||||
enumerator_t *enumerator;
|
||||
proposal_t *proposal;
|
||||
|
||||
this = (private_sa_payload_t*)sa_payload_create(SECURITY_ASSOCIATION);
|
||||
enumerator = proposals->create_enumerator(proposals);
|
||||
while (enumerator->enumerate(enumerator, &proposal))
|
||||
{
|
||||
add_proposal(this, proposal);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header.
|
||||
*/
|
||||
sa_payload_t *sa_payload_create_from_proposal_v2(proposal_t *proposal)
|
||||
{
|
||||
private_sa_payload_t *this;
|
||||
|
||||
this = (private_sa_payload_t*)sa_payload_create(SECURITY_ASSOCIATION);
|
||||
add_proposal(this, proposal);
|
||||
|
||||
return &this->public;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header.
|
||||
*/
|
||||
sa_payload_t *sa_payload_create_from_proposals_v1(linked_list_t *proposals,
|
||||
u_int32_t lifetime, u_int64_t lifebytes,
|
||||
auth_method_t auth, ipsec_mode_t mode, bool udp)
|
||||
{
|
||||
proposal_substructure_t *substruct;
|
||||
private_sa_payload_t *this;
|
||||
|
||||
this = (private_sa_payload_t*)sa_payload_create(SECURITY_ASSOCIATION);
|
||||
|
||||
/* IKEv1 encodes multiple proposals in a single substructure
|
||||
* TODO-IKEv1: Encode ESP+AH proposals in two different substructs */
|
||||
substruct = proposal_substructure_create_from_proposals(proposals);
|
||||
substruct->set_is_last_proposal(substruct, TRUE);
|
||||
this->proposals->insert_last(this->proposals, substruct);
|
||||
compute_length(this);
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header.
|
||||
*/
|
||||
sa_payload_t *sa_payload_create_from_proposal_v1(proposal_t *proposal,
|
||||
u_int32_t lifetime, u_int64_t lifebytes,
|
||||
auth_method_t auth, ipsec_mode_t mode, bool udp)
|
||||
{
|
||||
proposal_substructure_t *substruct;
|
||||
private_sa_payload_t *this;
|
||||
|
||||
this = (private_sa_payload_t*)sa_payload_create(SECURITY_ASSOCIATION_V1);
|
||||
|
||||
substruct = proposal_substructure_create_from_proposal(
|
||||
PROPOSAL_SUBSTRUCTURE_V1, proposal);
|
||||
substruct->set_is_last_proposal(substruct, TRUE);
|
||||
this->proposals->insert_last(this->proposals, substruct);
|
||||
compute_length(this);
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ typedef struct sa_payload_t sa_payload_t;
|
||||
#include <encoding/payloads/payload.h>
|
||||
#include <encoding/payloads/proposal_substructure.h>
|
||||
#include <utils/linked_list.h>
|
||||
#include <kernel/kernel_ipsec.h>
|
||||
#include <sa/authenticators/authenticator.h>
|
||||
|
||||
/**
|
||||
* Class representing an IKEv1 or IKEv2 SA Payload.
|
||||
@@ -48,6 +50,35 @@ struct sa_payload_t {
|
||||
*/
|
||||
linked_list_t *(*get_proposals) (sa_payload_t *this);
|
||||
|
||||
/**
|
||||
* Get the (shortest) lifetime of a proposal (IKEv1 only).
|
||||
*
|
||||
* @return lifetime, in seconds
|
||||
*/
|
||||
u_int32_t (*get_lifetime)(sa_payload_t *this);
|
||||
|
||||
/**
|
||||
* Get the (shortest) life duration of a proposal (IKEv1 only).
|
||||
*
|
||||
* @return life duration, in bytes
|
||||
*/
|
||||
u_int64_t (*get_lifebytes)(sa_payload_t *this);
|
||||
|
||||
/**
|
||||
* Get the first authentication method from the proposal (IKEv1 only).
|
||||
*
|
||||
* @return auth method, or AUTH_NONE
|
||||
*/
|
||||
auth_method_t (*get_auth_method)(sa_payload_t *this);
|
||||
|
||||
/**
|
||||
* Get the (first) encapsulation mode from a proposal (IKEv1 only).
|
||||
*
|
||||
* @param udp set to TRUE if UDP encapsulation used
|
||||
* @return ipsec encapsulation mode
|
||||
*/
|
||||
ipsec_mode_t (*get_encap_mode)(sa_payload_t *this, bool *udp);
|
||||
|
||||
/**
|
||||
* Create an enumerator over all proposal substructures.
|
||||
*
|
||||
@@ -70,26 +101,49 @@ struct sa_payload_t {
|
||||
sa_payload_t *sa_payload_create(payload_type_t type);
|
||||
|
||||
/**
|
||||
* Creates a sa_payload_t object from a list of proposals.
|
||||
* Creates an IKEv2 sa_payload_t object from a list of proposals.
|
||||
*
|
||||
* @param type SECURITY_ASSOCIATION or SECURITY_ASSOCIATION_V1
|
||||
* @param proposals list of proposals to build the payload from
|
||||
* @return sa_payload_t object
|
||||
*/
|
||||
sa_payload_t *sa_payload_create_from_proposal_list(payload_type_t type,
|
||||
linked_list_t *proposals);
|
||||
sa_payload_t *sa_payload_create_from_proposals_v2(linked_list_t *proposals);
|
||||
|
||||
/**
|
||||
* Creates a sa_payload_t object from a single proposal.
|
||||
* Creates an IKEv2 sa_payload_t object from a single proposal.
|
||||
*
|
||||
* This is only for convenience. Use sa_payload_create_from_proposal_list
|
||||
* if you want to add more than one proposal.
|
||||
*
|
||||
* @param type SECURITY_ASSOCIATION or SECURITY_ASSOCIATION_V1
|
||||
* @param proposal proposal from which the payload should be built.
|
||||
* @return sa_payload_t object
|
||||
*/
|
||||
sa_payload_t *sa_payload_create_from_proposal(payload_type_t type,
|
||||
proposal_t *proposal);
|
||||
sa_payload_t *sa_payload_create_from_proposal_v2(proposal_t *proposal);
|
||||
|
||||
/**
|
||||
* Creates an IKEv1 sa_payload_t object from a list of proposals.
|
||||
*
|
||||
* @param proposals list of proposals to build the payload from
|
||||
* @param lifetime lifetime in seconds
|
||||
* @param lifebytes lifebytes, in bytes
|
||||
* @param auth authentication method to use, or AUTH_NONE
|
||||
* @param mode IPsec encapsulation mode, TRANSPORT or TUNNEL
|
||||
* @param udp TRUE to use UDP encapsulation
|
||||
* @return sa_payload_t object
|
||||
*/
|
||||
sa_payload_t *sa_payload_create_from_proposals_v1(linked_list_t *proposals,
|
||||
u_int32_t lifetime, u_int64_t lifebytes,
|
||||
auth_method_t auth, ipsec_mode_t mode, bool udp);
|
||||
|
||||
/**
|
||||
* Creates an IKEv1 sa_payload_t object from a single proposal.
|
||||
*
|
||||
* @param proposal proposal from which the payload should be built.
|
||||
* @param lifetime lifetime in seconds
|
||||
* @param lifebytes lifebytes, in bytes
|
||||
* @param auth authentication method to use, or AUTH_NONE
|
||||
* @param mode IPsec encapsulation mode, TRANSPORT or TUNNEL
|
||||
* @param udp TRUE to use UDP encapsulation
|
||||
* @return sa_payload_t object
|
||||
*/
|
||||
sa_payload_t *sa_payload_create_from_proposal_v1(proposal_t *proposal,
|
||||
u_int32_t lifetime, u_int64_t lifebytes,
|
||||
auth_method_t auth, ipsec_mode_t mode, bool udp);
|
||||
|
||||
#endif /** SA_PAYLOAD_H_ @}*/
|
||||
|
||||
Reference in New Issue
Block a user