aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/sa/ikev2/tasks/child_create.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2013-06-20 16:12:14 +0200
committerMartin Willi <martin@revosec.ch>2013-10-11 10:15:21 +0200
commitcdab8630d975caa1d471faf24adea67540b376ab (patch)
treea0e9202731c3f495ace36c5105223f4e082b226f /src/libcharon/sa/ikev2/tasks/child_create.c
parentf0c59e1cf8abc1ca6cde344b558b85cbeac21271 (diff)
downloadstrongswan-cdab8630d975caa1d471faf24adea67540b376ab.tar.bz2
strongswan-cdab8630d975caa1d471faf24adea67540b376ab.tar.xz
ikev2: Allocate SPI with the protocol of the first/negotiated proposal
Diffstat (limited to 'src/libcharon/sa/ikev2/tasks/child_create.c')
-rw-r--r--src/libcharon/sa/ikev2/tasks/child_create.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/libcharon/sa/ikev2/tasks/child_create.c b/src/libcharon/sa/ikev2/tasks/child_create.c
index 8ae36af84..7cfa537a9 100644
--- a/src/libcharon/sa/ikev2/tasks/child_create.c
+++ b/src/libcharon/sa/ikev2/tasks/child_create.c
@@ -244,9 +244,23 @@ static bool allocate_spi(private_child_create_t *this)
{
enumerator_t *enumerator;
proposal_t *proposal;
+ protocol_id_t proto = PROTO_ESP;
- /* TODO: allocate additional SPI for AH if we have such proposals */
- this->my_spi = this->child_sa->alloc_spi(this->child_sa, PROTO_ESP);
+ if (this->initiator)
+ {
+ /* we just get a SPI for the first protocol. TODO: If we ever support
+ * proposal lists with mixed protocols, we'd need multiple SPIs */
+ if (this->proposals->get_first(this->proposals,
+ (void**)&proposal) == SUCCESS)
+ {
+ proto = proposal->get_protocol(proposal);
+ }
+ }
+ else
+ {
+ proto = this->proposal->get_protocol(this->proposal);
+ }
+ this->my_spi = this->child_sa->alloc_spi(this->child_sa, proto);
if (this->my_spi)
{
if (this->initiator)