15 #ifndef __included_ikev2_priv_h__ 16 #define __included_ikev2_priv_h__ 28 #include <openssl/rand.h> 29 #include <openssl/dh.h> 30 #include <openssl/hmac.h> 31 #include <openssl/evp.h> 33 #define foreach_ikev2_log_level \ 36 _(0x02, LOG_WARNING) \ 44 #define _(n,f) IKEV2_##f = n, 51 #define _ikev2_elog(_level, _msg) \ 53 ikev2_main_t *km = &ikev2_main; \ 54 if (PREDICT_FALSE (km->log_level >= _level)) \ 56 ELOG_TYPE_DECLARE (e) = \ 58 .format = "ikev2 " _msg, \ 61 ELOG_DATA (&vlib_global_main.elog_main, e); \ 65 #define ikev2_elog_sa_state(_format, _ispi) \ 67 ikev2_main_t *km = &ikev2_main; \ 68 if (PREDICT_FALSE (km->log_level >= IKEV2_LOG_DEBUG)) \ 70 ELOG_TYPE_DECLARE (e) = \ 72 .format = "ikev2: " _format, \ 73 .format_args = "i8", \ 79 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 84 #define ikev2_elog_exchange(_format, _ispi, _rspi, _addr) \ 86 ikev2_main_t *km = &ikev2_main; \ 87 if (PREDICT_FALSE (km->log_level >= IKEV2_LOG_DEBUG)) \ 89 ELOG_TYPE_DECLARE (e) = \ 91 .format = "ikev2: " _format, \ 92 .format_args = "i8i8i1i1i1i1", \ 103 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 106 ed->oct4 = (_addr) >> 24; \ 107 ed->oct3 = (_addr) >> 16; \ 108 ed->oct2 = (_addr) >> 8; \ 109 ed->oct1 = (_addr); \ 113 #define ikev2_elog_uint(_level, _format, _val) \ 115 ikev2_main_t *km = &ikev2_main; \ 116 if (PREDICT_FALSE (km->log_level >= _level)) \ 118 ELOG_TYPE_DECLARE (e) = \ 120 .format = "ikev2: " _format, \ 121 .format_args = "i8", \ 127 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 132 #define ikev2_elog_uint_peers(_level, _format, _val, _ip1, _ip2) \ 134 ikev2_main_t *km = &ikev2_main; \ 135 if (PREDICT_FALSE (km->log_level >= _level)) \ 137 ELOG_TYPE_DECLARE (e) = \ 139 .format = "ikev2: " _format, \ 140 .format_args = "i8i1i1i1i1i1i1i1i1", \ 142 CLIB_PACKED(struct { \ 144 u8 i11; u8 i12; u8 i13; u8 i14; \ 145 u8 i21; u8 i22; u8 i23; u8 i24; }) *ed; \ 146 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 148 ed->i14 = (_ip1) >> 24; \ 149 ed->i13 = (_ip1) >> 16; \ 150 ed->i12 = (_ip1) >> 8; \ 152 ed->i24 = (_ip2) >> 24; \ 153 ed->i23 = (_ip2) >> 16; \ 154 ed->i22 = (_ip2) >> 8; \ 159 #define ikev2_elog_peers(_level, _format, _ip1, _ip2) \ 161 ikev2_main_t *km = &ikev2_main; \ 162 if (PREDICT_FALSE (km->log_level >= _level)) \ 164 ELOG_TYPE_DECLARE (e) = \ 166 .format = "ikev2: " _format, \ 167 .format_args = "i1i1i1i1i1i1i1i1", \ 169 CLIB_PACKED(struct { \ 170 u8 i11; u8 i12; u8 i13; u8 i14; \ 171 u8 i21; u8 i22; u8 i23; u8 i24; }) *ed; \ 172 ed = ELOG_DATA (&vlib_global_main.elog_main, e); \ 173 ed->i14 = (_ip1) >> 24; \ 174 ed->i13 = (_ip1) >> 16; \ 175 ed->i12 = (_ip1) >> 8; \ 177 ed->i24 = (_ip2) >> 24; \ 178 ed->i23 = (_ip2) >> 16; \ 179 ed->i22 = (_ip2) >> 8; \ 184 #define ikev2_elog_error(_msg) \ 185 _ikev2_elog(IKEV2_LOG_ERROR, "[error] " _msg) 186 #define ikev2_elog_warning(_msg) \ 187 _ikev2_elog(IKEV2_LOG_WARNING, "[warning] " _msg) 188 #define ikev2_elog_debug(_msg) \ 189 _ikev2_elog(IKEV2_LOG_DEBUG, "[debug] " _msg) 190 #define ikev2_elog_detail(_msg) \ 191 _ikev2_elog(IKEV2_LOG_DETAIL, "[detail] " _msg) 194 #define ikev2_log_error(...) \ 195 vlib_log(VLIB_LOG_LEVEL_ERR, ikev2_main.log_class, __VA_ARGS__) 196 #define ikev2_log_warning(...) \ 197 vlib_log(VLIB_LOG_LEVEL_WARNING, ikev2_main.log_class, __VA_ARGS__) 198 #define ikev2_log_debug(...) \ 199 vlib_log(VLIB_LOG_LEVEL_DEBUG, ikev2_main.log_class, __VA_ARGS__) 531 #define ikev2_payload_new_chain(V) vec_validate (V, 0) 532 #define ikev2_payload_destroy_chain(V) do { \ 533 vec_free((V)->data); \ ikev2_main_per_thread_data_t * per_thread_data
void ikev2_payload_add_sa(ikev2_payload_chain_t *c, ikev2_sa_proposal_t *proposals)
#define CLIB_CACHE_LINE_ALIGN_MARK(mark)
ikev2_transforms_set ike_ts
void ikev2_payload_add_notify(ikev2_payload_chain_t *c, u16 msg_type, u8 *data)
ikev2_transform_integ_type_t
u8 * ikev2_calc_prfplus(ikev2_sa_transform_t *tr, u8 *key, u8 *seed, int len)
ikev2_sa_transform_t * ikev2_sa_get_td_for_type(ikev2_sa_proposal_t *p, ikev2_transform_type_t type)
ikev2_profile_t * profiles
u32 current_remote_id_mask
void ikev2_payload_add_id(ikev2_payload_chain_t *c, ikev2_id_t *id, u8 type)
u8 * last_sa_init_res_packet_data
u8 init_response_received
ikev2_ts_t * ikev2_parse_ts_payload(ike_payload_header_t *ikep)
ikev2_transform_dh_type_t
EVP_PKEY * ikev2_load_cert_file(u8 *file)
void ikev2_payload_add_ts(ikev2_payload_chain_t *c, ikev2_ts_t *ts, u8 type)
ikev2_sa_proposal_t * r_proposals
EVP_PKEY * ikev2_load_key_file(u8 *file)
ikev2_sa_proposal_t * i_proposals
int ikev2_verify_sign(EVP_PKEY *pkey, u8 *sigbuf, u8 *data)
ikev2_sa_transform_t * transforms
ikev2_responder_t responder
vl_api_fib_path_type_t type
u8 * last_sa_init_req_packet_data
int ikev2_set_log_level(ikev2_log_level_t log_level)
ikev2_sa_proposal_t * i_proposals
mhash_t profile_index_by_name
ikev2_sa_transform_t * supported_transforms
void ikev2_payload_chain_add_padding(ikev2_payload_chain_t *c, int bs)
u8 * ikev2_calc_sign(EVP_PKEY *pkey, u8 *data)
v8 * ikev2_calc_prf(ikev2_sa_transform_t *tr, v8 *key, v8 *data)
ikev2_delete_t * ikev2_parse_delete_payload(ike_payload_header_t *ikep)
The fine-grained event logger allows lightweight, thread-safe event logging at minimum cost...
ikev2_sa_proposal_t * ikev2_parse_sa_payload(ike_payload_header_t *ikep)
ikev2_auth_method_t method
ikev2_transform_encr_type_t
v8 * ikev2_decrypt_data(ikev2_sa_t *sa, u8 *data, int len)
void ikev2_payload_add_nonce(ikev2_payload_chain_t *c, u8 *nonce)
ikev2_sa_proposal_t * r_proposals
enum ikev2_log_level_t_ ikev2_log_level_t
ikev2_protocol_id_t protocol_id
ikev2_notify_t * ikev2_parse_notify_payload(ike_payload_header_t *ikep)
f64 liveness_period_check
void ikev2_complete_dh(ikev2_sa_t *sa, ikev2_sa_transform_t *t)
ikev2_transform_esn_type_t
ikev2_sa_proposal_t * r_proposal
v8 * ikev2_calc_integr(ikev2_sa_transform_t *tr, v8 *key, u8 *data, int len)
ikev2_log_level_t log_level
ikev2_sa_proposal_t * i_proposal
void ikev2_crypto_init(ikev2_main_t *km)
u8 * last_res_packet_data
void ikev2_payload_add_auth(ikev2_payload_chain_t *c, ikev2_auth_t *auth)
void ikev2_payload_add_ke(ikev2_payload_chain_t *c, u16 dh_group, u8 *dh_data)
void ikev2_payload_add_notify_2(ikev2_payload_chain_t *c, u16 msg_type, u8 *data, ikev2_notify_t *notify)
ikev2_child_sa_t * childs
vlib_log_class_t log_class
void ikev2_parse_vendor_payload(ike_payload_header_t *ikep)
int ikev2_encrypt_data(ikev2_sa_t *sa, v8 *src, u8 *dst)
void ikev2_payload_add_delete(ikev2_payload_chain_t *c, ikev2_delete_t *d)
ikev2_transform_prf_type_t
void ikev2_sa_free_proposal_vector(ikev2_sa_proposal_t **v)
#define foreach_ikev2_log_level
ikev2_transforms_set esp_ts
void ikev2_generate_dh(ikev2_sa_t *sa, ikev2_sa_transform_t *t)