36 }) ike_notify_payload_header_t;
59 }) ike_ts_payload_header_t;
83 }) ike_sa_transform_data_t;
98 static ike_payload_header_t *
101 ike_payload_header_t *hdr =
106 hdr->nextpayload = payload_type;
112 hdr = (ike_payload_header_t *) tmp;
115 hdr->length = clib_host_to_net_u16 (len);
124 ike_payload_header_t *hdr;
128 len = clib_net_to_host_u16 (hdr->length);
129 hdr->length = clib_host_to_net_u16 (len +
vec_len (data));
142 ike_notify_payload_header_t *n;
148 n->msg_type = clib_host_to_net_u16 (msg_type);
164 ike_payload_header_t *ph;
166 ike_sa_transform_data_t *tr;
181 prop->last_or_more = proposals - p + 1 <
vec_len (proposals) ? 2 : 0;
184 prop->spi_size = spi_size;
188 prop->spi[0] = clib_host_to_net_u32 (p->
spi);
193 tr = (ike_sa_transform_data_t *) tmp;
196 tr->transform_type = t->
type;
197 tr->transform_id = clib_host_to_net_u16 (t->
transform_id);
199 clib_host_to_net_u16 (
sizeof (*tr) +
vec_len (t->
attrs));
217 ike_ke_payload_header_t *ke;
221 ke->dh_group = clib_host_to_net_u16 (dh_group);
229 sizeof (ike_payload_header_t));
236 ike_id_payload_header_t *idp;
241 idp->id_type =
id->type;
264 dp->num_of_spi = clib_host_to_net_u16 (num_of_spi);
268 u32 spi = clib_host_to_net_u32 (d2->
spi);
279 ike_auth_payload_header_t *ap;
285 ap->auth_method = auth->
method;
292 ike_ts_payload_header_t *tsh;
305 vec_add2 (data, tmp,
sizeof (*entry));
309 entry->selector_len = clib_host_to_net_u16 (16);
310 entry->start_port = clib_host_to_net_u16 (ts2->
start_port);
311 entry->end_port = clib_host_to_net_u16 (ts2->
end_port);
323 u8 *tmp __attribute__ ((unused));
336 u32 plen = clib_net_to_host_u16 (ikep->length);
339 int proposal_ptr = 0;
355 transform_ptr = proposal_ptr +
sizeof (*sap) + sap->spi_size;
361 if (sap->spi_size == 4)
363 proposal->
spi = clib_net_to_host_u32 (sap->spi[0]);
366 for (
i = 0;
i < sap->num_transforms;
i++)
368 ike_sa_transform_data_t *tr =
369 (ike_sa_transform_data_t *) & ikep->payload[transform_ptr];
370 u16 tlen = clib_net_to_host_u16 (tr->transform_len);
372 if (tlen <
sizeof (*tr))
377 transform->
type = tr->transform_type;
378 transform->
transform_id = clib_net_to_host_u16 (tr->transform_id);
379 if (tlen >
sizeof (*tr))
380 vec_add (transform->
attrs, tr->attributes, tlen - sizeof (*tr));
381 transform_ptr += tlen;
384 proposal_ptr += clib_net_to_host_u16 (sap->proposal_len);
386 while (proposal_ptr < (plen -
sizeof (*ikep)) && sap->last_or_more == 2);
389 if (proposal_ptr != (plen -
sizeof (*ikep)) || sap->last_or_more)
403 ike_ts_payload_header_t *tsp = (ike_ts_payload_header_t *) ikep;
407 for (i = 0; i < tsp->num_ts; i++)
409 if (tsp->ts[i].ts_type != 7)
412 "unsupported TS type received (%u)", tsp->ts[i].ts_type);
417 ts->ts_type = tsp->ts[
i].ts_type;
418 ts->protocol_id = tsp->ts[
i].protocol_id;
419 ts->start_port = tsp->ts[
i].start_port;
420 ts->end_port = tsp->ts[
i].end_port;
421 ts->start_addr.as_u32 = tsp->ts[
i].start_addr.as_u32;
422 ts->end_addr.as_u32 = tsp->ts[
i].end_addr.as_u32;
430 ike_notify_payload_header_t *n = (ike_notify_payload_header_t *) ikep;
431 u32 plen = clib_net_to_host_u16 (ikep->length);
436 r->
msg_type = clib_net_to_host_u16 (n->msg_type);
439 if (n->spi_size == 4)
442 r->
spi = clib_net_to_host_u32 (spi);
444 else if (n->spi_size == 0)
453 if (plen > (
sizeof (*n) + n->spi_size))
456 plen - sizeof (*n) - n->spi_size);
465 u32 plen = clib_net_to_host_u16 (ikep->length);
466 ikev2_elog_uint (IKEV2_LOG_DEBUG,
"vendor payload skipped, len %d", plen);
474 u16 num_of_spi = clib_net_to_host_u16 (d->num_of_spi);
487 del->protocol_id = d->protocol_id;
488 del->spi = clib_net_to_host_u32 (d->spi[i++]);
void ikev2_payload_add_nonce(ikev2_payload_chain_t *c, u8 *nonce)
#define IKEV2_PAYLOAD_NONCE
void ikev2_payload_add_notify(ikev2_payload_chain_t *c, u16 msg_type, u8 *data)
void ikev2_payload_add_sa(ikev2_payload_chain_t *c, ikev2_sa_proposal_t *proposals)
ikev2_sa_proposal_t * ikev2_parse_sa_payload(ike_payload_header_t *ikep)
#define clib_memcpy_fast(a, b, c)
ikev2_ts_t * ikev2_parse_ts_payload(ike_payload_header_t *ikep)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
void ikev2_payload_add_ke(ikev2_payload_chain_t *c, u16 dh_group, u8 *dh_data)
ikev2_notify_t * ikev2_parse_notify_payload(ike_payload_header_t *ikep)
#define clib_memcpy(d, s, n)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
#define IKEV2_PAYLOAD_DELETE
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
void ikev2_parse_vendor_payload(ike_payload_header_t *ikep)
void ikev2_payload_add_id(ikev2_payload_chain_t *c, ikev2_id_t *id, u8 type)
#define IKEV2_PAYLOAD_NOTIFY
#define ikev2_elog_detail(_msg)
ikev2_sa_transform_t * transforms
vl_api_fib_path_type_t type
typedef CLIB_PACKED(struct { u8 nextpayload;u8 flags;u16 length;u8 protocol_id;u8 spi_size;u16 msg_type;u8 payload[0];})
void ikev2_payload_add_delete(ikev2_payload_chain_t *c, ikev2_delete_t *d)
#define ikev2_elog_uint(_level, _format, _val)
ikev2_auth_method_t method
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
#define clib_warning(format, args...)
static ike_payload_header_t * ikev2_payload_add_hdr(ikev2_payload_chain_t *c, u8 payload_type, int len)
void ikev2_payload_add_auth(ikev2_payload_chain_t *c, ikev2_auth_t *auth)
ikev2_protocol_id_t protocol_id
ike_delete_payload_header_t
void ikev2_sa_free_proposal_vector(ikev2_sa_proposal_t **v)
#define IKEV2_PAYLOAD_AUTH
#define vec_append(v1, v2)
Append v2 after v1.
static void ikev2_payload_add_data(ikev2_payload_chain_t *c, u8 *data)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void ikev2_payload_chain_add_padding(ikev2_payload_chain_t *c, int bs)
#define vec_foreach(var, vec)
Vector iterator.
void ikev2_payload_add_ts(ikev2_payload_chain_t *c, ikev2_ts_t *ts, u8 type)
void ikev2_payload_add_notify_2(ikev2_payload_chain_t *c, u16 msg_type, u8 *data, ikev2_notify_t *notify)
ikev2_delete_t * ikev2_parse_delete_payload(ike_payload_header_t *ikep)