ikev1: Support parsing of AH+IPComp proposals

This commit is contained in:
Martin Willi
2013-10-11 10:15:21 +02:00
parent 25f74be8f9
commit a1379e3210
+11 -9
View File
@@ -341,10 +341,10 @@ METHOD(sa_payload_t, get_ipcomp_proposals, linked_list_t*,
{ {
int current_proposal = -1, unsupported_proposal = -1; int current_proposal = -1, unsupported_proposal = -1;
enumerator_t *enumerator; enumerator_t *enumerator;
proposal_substructure_t *substruct, *esp = NULL, *ipcomp = NULL; proposal_substructure_t *substruct, *espah = NULL, *ipcomp = NULL;
linked_list_t *list; linked_list_t *list;
/* we currently only support the combination ESP+IPComp, find the first */ /* we currently only support the combination ESP|AH+IPComp, find the first */
enumerator = this->proposals->create_enumerator(this->proposals); enumerator = this->proposals->create_enumerator(this->proposals);
while (enumerator->enumerate(enumerator, &substruct)) while (enumerator->enumerate(enumerator, &substruct))
{ {
@@ -355,25 +355,27 @@ METHOD(sa_payload_t, get_ipcomp_proposals, linked_list_t*,
{ {
continue; continue;
} }
if (protocol_id != PROTO_ESP && protocol_id != PROTO_IPCOMP) if (protocol_id != PROTO_ESP && protocol_id != PROTO_AH &&
protocol_id != PROTO_IPCOMP)
{ /* unsupported combination */ { /* unsupported combination */
esp = ipcomp = NULL; espah = ipcomp = NULL;
unsupported_proposal = current_proposal; unsupported_proposal = current_proposal;
continue; continue;
} }
if (proposal_number != current_proposal) if (proposal_number != current_proposal)
{ /* start of a new proposal */ { /* start of a new proposal */
if (esp && ipcomp) if (espah && ipcomp)
{ /* previous proposal is valid */ { /* previous proposal is valid */
break; break;
} }
esp = ipcomp = NULL; espah = ipcomp = NULL;
current_proposal = proposal_number; current_proposal = proposal_number;
} }
switch (protocol_id) switch (protocol_id)
{ {
case PROTO_ESP: case PROTO_ESP:
esp = substruct; case PROTO_AH:
espah = substruct;
break; break;
case PROTO_IPCOMP: case PROTO_IPCOMP:
ipcomp = substruct; ipcomp = substruct;
@@ -383,9 +385,9 @@ METHOD(sa_payload_t, get_ipcomp_proposals, linked_list_t*,
enumerator->destroy(enumerator); enumerator->destroy(enumerator);
list = linked_list_create(); list = linked_list_create();
if (esp && ipcomp && ipcomp->get_cpi(ipcomp, cpi)) if (espah && ipcomp && ipcomp->get_cpi(ipcomp, cpi))
{ {
esp->get_proposals(esp, list); espah->get_proposals(espah, list);
} }
return list; return list;
} }