29 #define ikev2_set_state(sa, v) do { \ 31 clib_warning("sa state changed to " #v); \ 47 s =
format (s,
"ikev2: sw_if_index %d, next index %d",
54 #define foreach_ikev2_error \ 55 _(PROCESSED, "IKEv2 packets processed") \ 56 _(IKE_SA_INIT_RETRANSMIT, "IKE_SA_INIT retransmit ") \ 57 _(IKE_SA_INIT_IGNORE, "IKE_SA_INIT ignore (IKE SA already auth)") \ 58 _(IKE_REQ_RETRANSMIT, "IKE request retransmit") \ 59 _(IKE_REQ_IGNORE, "IKE request ignore (old msgid)") \ 60 _(NOT_IKEV2, "Non IKEv2 packets received") 64 #define _(sym,str) IKEV2_ERROR_##sym, 71 #define _(sym,string) string, 97 if (td->
type == IKEV2_TRANSFORM_TYPE_ENCR)
100 || t->
attrs[1] != 14)
118 u8 mandatory_bitmap, optional_bitmap;
122 mandatory_bitmap = (1 << IKEV2_TRANSFORM_TYPE_ENCR) |
123 (1 << IKEV2_TRANSFORM_TYPE_PRF) |
124 (1 << IKEV2_TRANSFORM_TYPE_INTEG) | (1 << IKEV2_TRANSFORM_TYPE_DH);
125 optional_bitmap = mandatory_bitmap;
129 mandatory_bitmap = (1 << IKEV2_TRANSFORM_TYPE_ENCR) |
130 (1 << IKEV2_TRANSFORM_TYPE_ESN);
131 optional_bitmap = mandatory_bitmap |
132 (1 << IKEV2_TRANSFORM_TYPE_INTEG) | (1 << IKEV2_TRANSFORM_TYPE_DH);
136 mandatory_bitmap = (1 << IKEV2_TRANSFORM_TYPE_INTEG) |
137 (1 << IKEV2_TRANSFORM_TYPE_ESN);
138 optional_bitmap = mandatory_bitmap | (1 << IKEV2_TRANSFORM_TYPE_DH);
153 if ((1 << transform->
type) & bitmap)
158 bitmap |= 1 << transform->
type;
165 clib_warning (
"bitmap is %x mandatory is %x optional is %x",
166 bitmap, mandatory_bitmap, optional_bitmap);
168 if ((bitmap & mandatory_bitmap) == mandatory_bitmap &&
169 (bitmap & ~optional_bitmap) == 0)
173 RAND_bytes ((
u8 *) & rv->
spi, sizeof (rv->
spi));
321 if (sa->
dh_group == IKEV2_TRANSFORM_DH_TYPE_NONE)
329 if (t2->type == IKEV2_TRANSFORM_TYPE_DH && sa->
dh_group == t2->dh_type)
340 sa->
dh_group = IKEV2_TRANSFORM_DH_TYPE_NONE;
345 RAND_bytes ((
u8 *) & sa->
rspi, 8);
376 vec_add2 (s, tmp, 2 *
sizeof (*spi));
378 spi[0] = clib_host_to_net_u64 (sa->
ispi);
379 spi[1] = clib_host_to_net_u64 (sa->
rspi);
484 u32 len = clib_net_to_host_u32 (ike->length);
485 u8 payload = ike->nextpayload;
487 clib_warning (
"ispi %lx rspi %lx nextpayload %x version %x " 488 "exchange %x flags %x msgid %x length %u",
489 clib_net_to_host_u64 (ike->ispi),
490 clib_net_to_host_u64 (ike->rspi),
491 payload, ike->version,
492 ike->exchange, ike->flags,
493 clib_net_to_host_u32 (ike->msgid), len);
495 sa->
ispi = clib_net_to_host_u64 (ike->ispi);
503 ike_payload_header_t *ikep = (ike_payload_header_t *) & ike->payload[p];
504 u32 plen = clib_net_to_host_u16 (ikep->length);
506 if (plen <
sizeof (ike_payload_header_t))
516 ike_ke_payload_header_t *ke = (ike_ke_payload_header_t *) ikep;
517 sa->
dh_group = clib_net_to_host_u16 (ke->dh_group);
537 clib_warning (
"unknown payload %u flags %x length %u", payload,
547 payload = ikep->nextpayload;
560 u32 len = clib_net_to_host_u32 (ike->length);
561 ike_payload_header_t *ikep = 0;
570 ikep = (ike_payload_header_t *) & ike->payload[p];
571 plen = clib_net_to_host_u16 (ikep->length);
573 if (plen <
sizeof (*ikep))
578 clib_warning (
"received IKEv2 payload SK, len %u", plen - 4);
579 last_payload = *payload;
583 clib_warning (
"unknown payload %u flags %x length %u", payload,
592 *payload = ikep->nextpayload;
605 plen = plen -
sizeof (*ikep) - tr_integ->
key_trunc;
607 if (memcmp (hmac, &ikep->payload[plen], tr_integ->
key_trunc))
633 if (tmp->i_id.type != sa->i_id.type ||
634 vec_len(tmp->i_id.data) != vec_len(sa->i_id.data) ||
635 memcmp(sa->i_id.data, tmp->i_id.data, vec_len(sa->i_id.data)))
638 if (sa->rspi != tmp->rspi)
639 vec_add1(delete, tmp - km->per_thread_data[cpu_index].sas);
643 for (i = 0; i <
vec_len (
delete); i++)
660 u32 len = clib_net_to_host_u32 (ike->length);
661 u8 payload = ike->nextpayload;
664 ike_payload_header_t *ikep;
667 clib_warning (
"ispi %lx rspi %lx nextpayload %x version %x " 668 "exchange %x flags %x msgid %x length %u",
669 clib_net_to_host_u64 (ike->ispi),
670 clib_net_to_host_u64 (ike->rspi),
671 payload, ike->version,
672 ike->exchange, ike->flags,
673 clib_net_to_host_u32 (ike->msgid), len);
683 goto cleanup_and_exit;
695 ikep = (ike_payload_header_t *) & plaintext[p];
696 plen = clib_net_to_host_u16 (ikep->length);
698 if (plen <
sizeof (ike_payload_header_t))
699 goto cleanup_and_exit;
703 clib_warning (
"received payload SA, len %u", plen -
sizeof (*ikep));
709 ike_id_payload_header_t *
id = (ike_id_payload_header_t *) ikep;
715 clib_warning (
"received payload IDi, len %u id_type %u",
716 plen -
sizeof (*
id), id->id_type);
720 ike_auth_payload_header_t *
a = (ike_auth_payload_header_t *) ikep;
726 clib_warning (
"received payload AUTH, len %u auth_type %u",
727 plen -
sizeof (*a), a->auth_method);
732 if (n->
msg_type == IKEV2_NOTIFY_MSG_INITIAL_CONTACT)
745 plen -
sizeof (*ikep));
753 plen -
sizeof (*ikep));
760 clib_warning (
"unknown payload %u flags %x length %u data %u",
761 payload, ikep->flags, plen - 4,
772 payload = ikep->nextpayload;
785 u32 len = clib_net_to_host_u32 (ike->length);
786 u8 payload = ike->nextpayload;
789 ike_payload_header_t *ikep;
792 clib_warning (
"ispi %lx rspi %lx nextpayload %x version %x " 793 "exchange %x flags %x msgid %x length %u",
794 clib_net_to_host_u64 (ike->ispi),
795 clib_net_to_host_u64 (ike->rspi),
796 payload, ike->version,
797 ike->exchange, ike->flags,
798 clib_net_to_host_u32 (ike->msgid), len);
803 goto cleanup_and_exit;
809 ikep = (ike_payload_header_t *) & plaintext[p];
810 plen = clib_net_to_host_u16 (ikep->length);
812 if (plen <
sizeof (ike_payload_header_t))
813 goto cleanup_and_exit;
818 if (n->
msg_type == IKEV2_NOTIFY_MSG_AUTHENTICATION_FAILED)
832 clib_warning (
"unknown payload %u flags %x length %u data %u",
833 payload, ikep->flags, plen - 4,
843 payload = ikep->nextpayload;
856 u32 len = clib_net_to_host_u32 (ike->length);
857 u8 payload = ike->nextpayload;
862 ike_payload_header_t *ikep;
870 clib_warning (
"ispi %lx rspi %lx nextpayload %x version %x " 871 "exchange %x flags %x msgid %x length %u",
872 clib_net_to_host_u64 (ike->ispi),
873 clib_net_to_host_u64 (ike->rspi),
874 payload, ike->version,
875 ike->exchange, ike->flags,
876 clib_net_to_host_u32 (ike->msgid), len);
881 goto cleanup_and_exit;
887 ikep = (ike_payload_header_t *) & plaintext[p];
888 plen = clib_net_to_host_u16 (ikep->length);
890 if (plen <
sizeof (ike_payload_header_t))
891 goto cleanup_and_exit;
900 if (n->
msg_type == IKEV2_NOTIFY_MSG_REKEY_SA)
915 clib_memcpy (i_nonce, ikep->payload, plen - sizeof (*ikep));
927 clib_warning (
"unknown payload %u flags %x length %u data %u",
928 payload, ikep->flags, plen - 4,
938 payload = ikep->nextpayload;
949 goto cleanup_and_exit;
1039 if (p->rem_id.type != sa->i_id.type ||
1040 vec_len(p->rem_id.data) != vec_len(sa->i_id.data) ||
1041 memcmp(p->rem_id.data, sa->i_id.data, vec_len(p->rem_id.data)))
1044 vec_foreach(ts, sa->childs[0].tsi)
1046 if (ikev2_ts_cmp(&p->rem_ts, ts))
1055 if (ikev2_ts_cmp(&p->loc_ts, ts))
1070 sa->childs[0].tsi = tsi;
1071 sa->childs[0].tsr = tsr;
1086 u8 *authmsg, *key_pad, *psk = 0, *auth = 0;
1093 if (!(sa->
i_auth.
method == IKEV2_AUTH_METHOD_SHARED_KEY_MIC ||
1109 if (p->rem_id.type != sa->i_id.type ||
1110 vec_len(p->rem_id.data) != vec_len(sa->i_id.data) ||
1111 memcmp(p->rem_id.data, sa->i_id.data, vec_len(p->rem_id.data)))
1114 if (sa->i_auth.method == IKEV2_AUTH_METHOD_SHARED_KEY_MIC)
1116 if (!p->auth.data ||
1117 p->auth.method != IKEV2_AUTH_METHOD_SHARED_KEY_MIC)
1120 psk = ikev2_calc_prf(tr_prf, p->auth.data, key_pad);
1121 auth = ikev2_calc_prf(tr_prf, psk, authmsg);
1123 if (!memcmp(auth, sa->i_auth.data, vec_len(sa->i_auth.data)))
1125 ikev2_set_state(sa, IKEV2_STATE_AUTHENTICATED);
1132 else if (sa->
i_auth.
method == IKEV2_AUTH_METHOD_RSA_SIG)
1134 if (p->auth.method != IKEV2_AUTH_METHOD_RSA_SIG)
1137 if (ikev2_verify_sign(p->auth.key, sa->i_auth.data, authmsg) == 1)
1139 ikev2_set_state(sa, IKEV2_STATE_AUTHENTICATED);
1155 sa->r_id.data =
vec_dup (sel_p->loc_id.data);
1156 sa->r_id.type = sel_p->loc_id.type;
1160 if (sel_p->auth.method == IKEV2_AUTH_METHOD_SHARED_KEY_MIC)
1163 sa->r_auth.method = IKEV2_AUTH_METHOD_SHARED_KEY_MIC;
1165 else if (sel_p->auth.method == IKEV2_AUTH_METHOD_RSA_SIG)
1168 sa->r_auth.method = IKEV2_AUTH_METHOD_RSA_SIG;
1174 sa->childs[0].r_proposals =
1199 memset (&a, 0,
sizeof (a));
1223 encr_type = IPSEC_CRYPTO_ALG_AES_CBC_128;
1226 encr_type = IPSEC_CRYPTO_ALG_AES_CBC_192;
1229 encr_type = IPSEC_CRYPTO_ALG_AES_CBC_256;
1253 if (tr->
integ_type != IKEV2_TRANSFORM_INTEG_TYPE_AUTH_HMAC_SHA1_96)
1307 ike_payload_header_t *ph;
1325 IKEV2_NOTIFY_MSG_NO_PROPOSAL_CHOSEN, 0);
1328 else if (sa->
dh_group == IKEV2_TRANSFORM_DH_TYPE_NONE)
1334 IKEV2_TRANSFORM_TYPE_DH);
1337 data[0] = (tr_dh->
dh_type >> 8) & 0xff;
1338 data[1] = (tr_dh->
dh_type) & 0xff;
1341 IKEV2_NOTIFY_MSG_INVALID_KE_PAYLOAD,
1352 IKEV2_NOTIFY_MSG_UNSUPPORTED_CRITICAL_PAYLOAD,
1358 ike->rspi = clib_host_to_net_u64 (sa->
rspi);
1377 IKEV2_NOTIFY_MSG_AUTHENTICATION_FAILED,
1391 IKEV2_NOTIFY_MSG_NO_PROPOSAL_CHOSEN, 0);
1403 IKEV2_NOTIFY_MSG_UNSUPPORTED_CRITICAL_PAYLOAD,
1446 IKEV2_NOTIFY_MSG_UNSUPPORTED_CRITICAL_PAYLOAD,
1469 IKEV2_NOTIFY_MSG_UNSUPPORTED_CRITICAL_PAYLOAD,
1485 tlen =
sizeof (*ike);
1492 ike->length = clib_host_to_net_u32 (tlen);
1505 plen =
sizeof (*ph);
1506 ph = (ike_payload_header_t *) & ike->payload[0];
1517 ph->length = clib_host_to_net_u16 (plen);
1518 ike->length = clib_host_to_net_u32 (tlen);
1548 if (sa->ispi == clib_net_to_host_u64(ike->ispi) &&
1549 sa->iaddr.as_u32 == iaddr.as_u32 &&
1550 sa->raddr.as_u32 == raddr.as_u32)
1553 u32 len = clib_net_to_host_u32(ike->length);
1554 u8 payload = ike->nextpayload;
1556 while (p < len && payload!= IKEV2_PAYLOAD_NONE) {
1557 ike_payload_header_t * ikep = (ike_payload_header_t *) &ike->payload[p];
1558 u32 plen = clib_net_to_host_u16(ikep->length);
1560 if (plen < sizeof(ike_payload_header_t))
1563 if (payload == IKEV2_PAYLOAD_NONCE)
1565 if (!memcmp(sa->i_nonce, ikep->payload, plen - sizeof(*ikep)))
1568 if (sa->state == IKEV2_STATE_SA_INIT)
1571 tmp = (ike_header_t*)sa->last_sa_init_res_packet_data;
1572 ike->ispi = tmp->ispi;
1573 ike->rspi = tmp->rspi;
1574 ike->nextpayload = tmp->nextpayload;
1575 ike->version = tmp->version;
1576 ike->exchange = tmp->exchange;
1577 ike->flags = tmp->flags;
1578 ike->msgid = tmp->msgid;
1579 ike->length = tmp->length;
1580 clib_memcpy(ike->payload, tmp->payload,
1581 clib_net_to_host_u32(tmp->length) - sizeof(*ike));
1582 clib_warning(
"IKE_SA_INIT retransmit from %U to %U",
1583 format_ip4_address, &raddr,
1584 format_ip4_address, &iaddr);
1590 clib_warning(
"IKE_SA_INIT ignore from %U to %U",
1591 format_ip4_address, &raddr,
1592 format_ip4_address, &iaddr);
1597 payload = ikep->nextpayload;
1611 u32 msg_id = clib_net_to_host_u32 (ike->msgid);
1624 ike->ispi = tmp->ispi;
1625 ike->rspi = tmp->rspi;
1626 ike->nextpayload = tmp->nextpayload;
1627 ike->version = tmp->version;
1628 ike->exchange = tmp->exchange;
1629 ike->flags = tmp->flags;
1630 ike->msgid = tmp->msgid;
1631 ike->length = tmp->length;
1633 clib_net_to_host_u32 (tmp->length) -
sizeof (*ike));
1655 u32 n_left_from, *from, *to_next;
1664 while (n_left_from > 0)
1670 while (n_left_from > 0 && n_left_to_next > 0)
1690 n_left_to_next -= 1;
1702 IKEV2_ERROR_NOT_IKEV2, 1);
1709 memset (sa0, 0,
sizeof (*sa0));
1711 if (ike0->rspi == 0)
1720 IKEV2_ERROR_IKE_SA_INIT_RETRANSMIT,
1722 len = clib_net_to_host_u32 (ike0->length);
1728 IKEV2_ERROR_IKE_SA_INIT_IGNORE,
1769 clib_net_to_host_u64 (ike0->rspi));
1779 IKEV2_ERROR_IKE_REQ_RETRANSMIT,
1781 len = clib_net_to_host_u32 (ike0->length);
1787 IKEV2_ERROR_IKE_REQ_IGNORE,
1809 clib_net_to_host_u64 (ike0->rspi));
1819 IKEV2_ERROR_IKE_REQ_RETRANSMIT,
1821 len = clib_net_to_host_u32 (ike0->length);
1827 IKEV2_ERROR_IKE_REQ_IGNORE,
1864 clib_net_to_host_u64 (ike0->rspi));
1874 IKEV2_ERROR_IKE_REQ_RETRANSMIT,
1876 len = clib_net_to_host_u32 (ike0->length);
1882 IKEV2_ERROR_IKE_REQ_IGNORE,
1907 clib_warning (
"IKEv2 exchange %u packet received from %U to %U",
1950 n_left_to_next, bi0, next0);
1957 IKEV2_ERROR_PROCESSED, frame->
n_vectors);
1965 .vector_size =
sizeof (
u32),
2019 memset (p, 0,
sizeof (*p));
2039 u8 * auth_data,
u8 data_hex_format)
2054 p->
auth.
hex = data_hex_format;
2056 if (auth_method == IKEV2_AUTH_METHOD_RSA_SIG)
2076 if (id_type > IKEV2_ID_TYPE_ID_RFC822_ADDR
2077 && id_type < IKEV2_ID_TYPE_ID_KEY_ID)
2164 for (thread_id = 0; thread_id < tm->
n_vlib_mains - 1; thread_id++)
ikev2_main_per_thread_data_t * per_thread_data
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
static int ikev2_retransmit_sa_init(ike_header_t *ike, ip4_address_t iaddr, ip4_address_t raddr)
void ikev2_payload_add_nonce(ikev2_payload_chain_t *c, u8 *nonce)
static u8 * format_ikev2_trace(u8 *s, va_list *args)
#define hash_set(h, key, value)
sll srl srl sll sra u16x4 i
#define IKEV2_PAYLOAD_NONCE
void ikev2_payload_add_notify(ikev2_payload_chain_t *c, u16 msg_type, u8 *data)
static int ikev2_delete_tunnel_interface(vnet_main_t *vnm, ikev2_sa_t *sa, ikev2_child_sa_t *child)
#define hash_unset(h, key)
clib_error_t * ikev2_add_del_profile(vlib_main_t *vm, u8 *name, int is_add)
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
void ikev2_payload_add_sa(ikev2_payload_chain_t *c, ikev2_sa_proposal_t *proposals)
static void ikev2_calc_keys(ikev2_sa_t *sa)
ikev2_sa_proposal_t * ikev2_parse_sa_payload(ike_payload_header_t *ikep)
#define IKEV2_PAYLOAD_NONE
ikev2_profile_t * profiles
ikev2_ts_t * ikev2_parse_ts_payload(ike_payload_header_t *ikep)
uword mhash_unset(mhash_t *h, void *key, uword *old_value)
v8 * ikev2_calc_prf(ikev2_sa_transform_t *tr, v8 *key, v8 *data)
#define IKEV2_EXCHANGE_SA_INIT
#define IKEV2_PAYLOAD_VENDOR
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
u8 remote_crypto_key[128]
struct _vlib_node_registration vlib_node_registration_t
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static void mhash_init_vec_string(mhash_t *h, uword n_value_bytes)
void ikev2_payload_add_ke(ikev2_payload_chain_t *c, u16 dh_group, u8 *dh_data)
static void ikev2_generate_sa_init_data(ikev2_sa_t *sa)
#define IKEV2_PAYLOAD_TSR
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static void ikev2_delete_sa(ikev2_sa_t *sa)
u8 * last_sa_init_res_packet_data
ikev2_notify_t * ikev2_parse_notify_payload(ike_payload_header_t *ikep)
ikev2_sa_transform_t * ikev2_sa_get_td_for_type(ikev2_sa_proposal_t *p, ikev2_transform_type_t type)
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
int ikev2_encrypt_data(ikev2_sa_t *sa, v8 *src, u8 *dst)
vnet_main_t * vnet_get_main(void)
#define IKEV2_PAYLOAD_DELETE
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
ikev2_sa_proposal_t * r_proposals
void ikev2_generate_dh(ikev2_sa_t *sa, ikev2_sa_transform_t *t)
EVP_PKEY * ikev2_load_cert_file(u8 *file)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static ikev2_sa_transform_t * ikev2_find_transform_data(ikev2_sa_transform_t *t)
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
EVP_PKEY * ikev2_load_key_file(u8 *file)
clib_error_t * ikev2_set_profile_auth(vlib_main_t *vm, u8 *name, u8 auth_method, u8 *auth_data, u8 data_hex_format)
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
static void ikev2_sa_match_ts(ikev2_sa_t *sa)
#define clib_warning(format, args...)
ikev2_sa_proposal_t * i_proposals
static void ikev2_sa_auth(ikev2_sa_t *sa)
#define vlib_call_init_function(vm, x)
#define ikev2_set_state(sa, v)
#define ikev2_payload_destroy_chain(V)
ikev2_sa_transform_t * transforms
#define IKEV2_EXCHANGE_CREATE_CHILD_SA
static void ikev2_initial_contact_cleanup(ikev2_sa_t *sa)
static ikev2_profile_t * ikev2_profile_index_by_name(u8 *name)
clib_error_t * ikev2_set_profile_id(vlib_main_t *vm, u8 *name, u8 id_type, u8 *data, int is_local)
u8 * ikev2_calc_prfplus(ikev2_sa_transform_t *tr, u8 *key, u8 *seed, int len)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
u8 * last_sa_init_req_packet_data
u16 current_length
Nbytes between current data and the end of this buffer.
#define IKEV2_PAYLOAD_IDR
static int ikev2_create_tunnel_interface(vnet_main_t *vnm, ikev2_sa_t *sa, ikev2_child_sa_t *child)
uword mhash_set_mem(mhash_t *h, void *key, uword *new_value, uword *old_value)
ikev2_sa_proposal_t * i_proposals
uword os_get_cpu_number(void)
#define IKEV2_HDR_FLAG_RESPONSE
mhash_t profile_index_by_name
ikev2_sa_transform_t * supported_transforms
#define pool_put(P, E)
Free an object E in pool P.
#define vec_dup(V)
Return copy of vector (no header, no alignment)
#define vec_del1(v, i)
Delete the element at index I.
#define IKEV2_PAYLOAD_FLAG_CRITICAL
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
clib_error_t * ikev2_set_local_key(vlib_main_t *vm, u8 *file)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
clib_error_t * ikev2_set_profile_ts(vlib_main_t *vm, u8 *name, u8 protocol_id, u16 start_port, u16 end_port, ip4_address_t start_addr, ip4_address_t end_addr, int is_local)
#define IKEV2_EXCHANGE_INFORMATIONAL
void ikev2_payload_add_delete(ikev2_payload_chain_t *c, ikev2_delete_t *d)
ipsec_crypto_alg_t crypto_alg
static u32 ikev2_generate_resp(ikev2_sa_t *sa, ike_header_t *ike)
static u8 * ikev2_decrypt_sk_payload(ikev2_sa_t *sa, ike_header_t *ike, u8 *payload)
static void ikev2_sa_del_child_sa(ikev2_sa_t *sa, ikev2_child_sa_t *child)
ikev2_auth_method_t method
#define vec_free(V)
Free vector's memory (no header).
static vlib_thread_main_t * vlib_get_thread_main()
static void ikev2_process_auth_req(vlib_main_t *vm, ikev2_sa_t *sa, ike_header_t *ike)
static uword ikev2_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#define clib_memcpy(a, b, c)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
ikev2_child_sa_t * ikev2_sa_get_child(ikev2_sa_t *sa, u32 spi, ikev2_protocol_id_t prot_id)
ikev2_sa_proposal_t * r_proposals
static u8 * ikev2_sa_generate_authmsg(ikev2_sa_t *sa, int is_responder)
static void ikev2_calc_child_keys(ikev2_sa_t *sa, ikev2_child_sa_t *child)
#define hash_create(elts, value_bytes)
void ikev2_payload_add_auth(ikev2_payload_chain_t *c, ikev2_auth_t *auth)
ikev2_protocol_id_t protocol_id
static uword * mhash_get(mhash_t *h, const void *key)
static void ikev2_process_informational_req(vlib_main_t *vm, ikev2_sa_t *sa, ike_header_t *ike)
ipsec_integ_alg_t integ_alg
void ikev2_sa_free_proposal_vector(ikev2_sa_proposal_t **v)
#define IKEV2_PAYLOAD_AUTH
#define ikev2_payload_new_chain(V)
ikev2_sa_proposal_t * r_proposal
#define vec_append(v1, v2)
Append v2 after v1.
#define VLIB_NODE_FLAG_TRACE
static vlib_node_registration_t ikev2_node
(constructor) VLIB_REGISTER_NODE (ikev2_node)
ikev2_sa_proposal_t * i_proposal
#define VLIB_BUFFER_IS_TRACED
#define IKEV2_PAYLOAD_TSI
static int ikev2_retransmit_resp(ikev2_sa_t *sa, ike_header_t *ike)
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
u8 * last_res_packet_data
static char * ikev2_error_strings[]
static void ikev2_process_sa_init_req(vlib_main_t *vm, ikev2_sa_t *sa, ike_header_t *ike)
int ipsec_add_del_tunnel_if(ipsec_add_del_tunnel_args_t *args)
#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 IKEV2_PAYLOAD_IDI
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
static void ikev2_process_create_child_sa_req(vlib_main_t *vm, ikev2_sa_t *sa, ike_header_t *ike)
ikev2_child_sa_t * childs
#define IKEV2_EXCHANGE_IKE_AUTH
static int ikev2_ts_cmp(ikev2_ts_t *ts1, ikev2_ts_t *ts2)
clib_error_t * ikev2_init(vlib_main_t *vm)
#define VLIB_REGISTER_NODE(x,...)
clib_error_t * ikev2_cli_init(vlib_main_t *vm)
#define vec_foreach(var, vec)
Vector iterator.
static void ikev2_sa_free_all_child_sa(ikev2_child_sa_t **childs)
static ikev2_sa_proposal_t * ikev2_select_proposal(ikev2_sa_proposal_t *proposals, ikev2_protocol_id_t prot_id)
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
#define clib_error_return(e, args...)
void ikev2_crypto_init(ikev2_main_t *km)
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
void ikev2_payload_add_ts(ikev2_payload_chain_t *c, ikev2_ts_t *ts, u8 type)
v8 * ikev2_decrypt_data(ikev2_sa_t *sa, u8 *data, int len)
static void ikev2_sa_free_all_vec(ikev2_sa_t *sa)
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u16 ip4_header_checksum(ip4_header_t *i)
u8 * ikev2_calc_sign(EVP_PKEY *pkey, u8 *data)
v8 * ikev2_calc_integr(ikev2_sa_transform_t *tr, v8 *key, u8 *data, int len)
u8 * format_ikev2_id_type(u8 *s, va_list *args)
#define foreach_ikev2_error
ikev2_delete_t * ikev2_parse_delete_payload(ike_payload_header_t *ikep)