2005-11-15 15:58:03 +00:00
|
|
|
/*
|
2018-07-25 13:29:58 +00:00
|
|
|
* Copyright (C) 2006-2018 Tobias Brunner
|
2010-11-24 10:54:12 +00:00
|
|
|
* Copyright (C) 2005-2010 Martin Willi
|
|
|
|
* Copyright (C) 2010 revosec AG
|
2007-10-03 15:10:41 +00:00
|
|
|
* Copyright (C) 2006 Daniel Roethlisberger
|
2006-07-07 08:49:06 +00:00
|
|
|
* Copyright (C) 2005 Jan Hutter
|
2018-05-23 14:04:50 +00:00
|
|
|
* HSR Hochschule fuer Technik Rapperswil
|
2005-11-15 15:58:03 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
2006-04-10 08:07:38 +00:00
|
|
|
|
2005-11-15 15:58:03 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
#include "notify_payload.h"
|
|
|
|
|
2006-03-23 15:25:43 +00:00
|
|
|
#include <daemon.h>
|
2005-11-23 09:57:18 +00:00
|
|
|
#include <encoding/payloads/encodings.h>
|
2006-10-18 11:46:13 +00:00
|
|
|
#include <crypto/hashers/hasher.h>
|
|
|
|
|
|
|
|
ENUM_BEGIN(notify_type_names, UNSUPPORTED_CRITICAL_PAYLOAD, UNSUPPORTED_CRITICAL_PAYLOAD,
|
|
|
|
"UNSUPPORTED_CRITICAL_PAYLOAD");
|
|
|
|
ENUM_NEXT(notify_type_names, INVALID_IKE_SPI, INVALID_MAJOR_VERSION, UNSUPPORTED_CRITICAL_PAYLOAD,
|
|
|
|
"INVALID_IKE_SPI",
|
|
|
|
"INVALID_MAJOR_VERSION");
|
|
|
|
ENUM_NEXT(notify_type_names, INVALID_SYNTAX, INVALID_SYNTAX, INVALID_MAJOR_VERSION,
|
|
|
|
"INVALID_SYNTAX");
|
|
|
|
ENUM_NEXT(notify_type_names, INVALID_MESSAGE_ID, INVALID_MESSAGE_ID, INVALID_SYNTAX,
|
|
|
|
"INVALID_MESSAGE_ID");
|
|
|
|
ENUM_NEXT(notify_type_names, INVALID_SPI, INVALID_SPI, INVALID_MESSAGE_ID,
|
|
|
|
"INVALID_SPI");
|
2011-12-21 12:46:47 +00:00
|
|
|
ENUM_NEXT(notify_type_names, ATTRIBUTES_NOT_SUPPORTED, NO_PROPOSAL_CHOSEN, INVALID_SPI,
|
|
|
|
"ATTRIBUTES_NOT_SUPPORTED",
|
2006-10-18 11:46:13 +00:00
|
|
|
"NO_PROPOSAL_CHOSEN");
|
2011-12-15 16:04:29 +00:00
|
|
|
ENUM_NEXT(notify_type_names, PAYLOAD_MALFORMED, AUTHENTICATION_FAILED, NO_PROPOSAL_CHOSEN,
|
2011-11-17 17:01:41 +00:00
|
|
|
"PAYLOAD_MALFORMED",
|
2011-12-17 11:19:30 +00:00
|
|
|
"INVALID_KE_PAYLOAD",
|
2011-12-15 16:04:29 +00:00
|
|
|
"INVALID_ID_INFORMATION",
|
|
|
|
"INVALID_CERT_ENCODING",
|
|
|
|
"INVALID_CERTIFICATE",
|
|
|
|
"CERT_TYPE_UNSUPPORTED",
|
|
|
|
"INVALID_CERT_AUTHORITY",
|
2011-12-17 11:19:30 +00:00
|
|
|
"INVALID_HASH_INFORMATION",
|
2006-10-18 11:46:13 +00:00
|
|
|
"AUTHENTICATION_FAILED");
|
2010-09-15 10:48:58 +00:00
|
|
|
ENUM_NEXT(notify_type_names, SINGLE_PAIR_REQUIRED, CHILD_SA_NOT_FOUND, AUTHENTICATION_FAILED,
|
2006-10-18 11:46:13 +00:00
|
|
|
"SINGLE_PAIR_REQUIRED",
|
|
|
|
"NO_ADDITIONAL_SAS",
|
|
|
|
"INTERNAL_ADDRESS_FAILURE",
|
|
|
|
"FAILED_CP_REQUIRED",
|
|
|
|
"TS_UNACCEPTABLE",
|
2007-06-25 13:26:02 +00:00
|
|
|
"INVALID_SELECTORS",
|
|
|
|
"UNACCEPTABLE_ADDRESSES",
|
2009-11-24 08:21:00 +00:00
|
|
|
"UNEXPECTED_NAT_DETECTED",
|
2010-09-15 10:48:58 +00:00
|
|
|
"USE_ASSIGNED_HoA",
|
|
|
|
"TEMPORARY_FAILURE",
|
|
|
|
"CHILD_SA_NOT_FOUND");
|
|
|
|
ENUM_NEXT(notify_type_names, ME_CONNECT_FAILED, ME_CONNECT_FAILED, CHILD_SA_NOT_FOUND,
|
2008-03-26 18:40:19 +00:00
|
|
|
"ME_CONNECT_FAILED");
|
2011-08-01 09:27:01 +00:00
|
|
|
ENUM_NEXT(notify_type_names, MS_NOTIFY_STATUS, MS_NOTIFY_STATUS, ME_CONNECT_FAILED,
|
|
|
|
"MS_NOTIFY_STATUS");
|
2015-02-23 12:54:41 +00:00
|
|
|
ENUM_NEXT(notify_type_names, INITIAL_CONTACT, SIGNATURE_HASH_ALGORITHMS, MS_NOTIFY_STATUS,
|
2006-10-18 11:46:13 +00:00
|
|
|
"INITIAL_CONTACT",
|
|
|
|
"SET_WINDOW_SIZE",
|
|
|
|
"ADDITIONAL_TS_POSSIBLE",
|
|
|
|
"IPCOMP_SUPPORTED",
|
|
|
|
"NAT_DETECTION_SOURCE_IP",
|
|
|
|
"NAT_DETECTION_DESTINATION_IP",
|
|
|
|
"COOKIE",
|
|
|
|
"USE_TRANSPORT_MODE",
|
|
|
|
"HTTP_CERT_LOOKUP_SUPPORTED",
|
|
|
|
"REKEY_SA",
|
|
|
|
"ESP_TFC_PADDING_NOT_SUPPORTED",
|
|
|
|
"NON_FIRST_FRAGMENTS_ALSO",
|
|
|
|
"MOBIKE_SUPPORTED",
|
|
|
|
"ADDITIONAL_IP4_ADDRESS",
|
|
|
|
"ADDITIONAL_IP6_ADDRESS",
|
|
|
|
"NO_ADDITIONAL_ADDRESSES",
|
|
|
|
"UPDATE_SA_ADDRESSES",
|
|
|
|
"COOKIE2",
|
|
|
|
"NO_NATS_ALLOWED",
|
2009-01-19 12:32:42 +00:00
|
|
|
"AUTH_LIFETIME",
|
|
|
|
"MULTIPLE_AUTH_SUPPORTED",
|
2009-11-24 08:21:00 +00:00
|
|
|
"ANOTHER_AUTH_FOLLOWS",
|
|
|
|
"REDIRECT_SUPPORTED",
|
|
|
|
"REDIRECT",
|
|
|
|
"REDIRECTED_FROM",
|
|
|
|
"TICKET_LT_OPAQUE",
|
|
|
|
"TICKET_REQUEST",
|
|
|
|
"TICKET_ACK",
|
|
|
|
"TICKET_NACK",
|
|
|
|
"TICKET_OPAQUE",
|
2010-08-04 08:02:09 +00:00
|
|
|
"LINK_ID",
|
|
|
|
"USE_WESP_MODE",
|
|
|
|
"ROHC_SUPPORTED",
|
2011-07-14 08:51:24 +00:00
|
|
|
"EAP_ONLY_AUTHENTICATION",
|
|
|
|
"CHILDLESS_IKEV2_SUPPORTED",
|
|
|
|
"QUICK_CRASH_DETECTION",
|
|
|
|
"IKEV2_MESSAGE_ID_SYNC_SUPPORTED",
|
2011-07-14 08:53:37 +00:00
|
|
|
"IKEV2_REPLAY_COUNTER_SYNC_SUPPORTED",
|
2011-07-14 08:51:24 +00:00
|
|
|
"IKEV2_MESSAGE_ID_SYNC",
|
2012-04-03 10:48:48 +00:00
|
|
|
"IPSEC_REPLAY_COUNTER_SYNC",
|
|
|
|
"SECURE PASSWORD_METHOD",
|
|
|
|
"PSK_PERSIST",
|
2013-03-02 16:18:37 +00:00
|
|
|
"PSK_CONFIRM",
|
2013-11-01 13:07:11 +00:00
|
|
|
"ERX_SUPPORTED",
|
2014-06-06 13:12:16 +00:00
|
|
|
"IFOM_CAPABILITY",
|
|
|
|
"SENDER_REQUEST_ID",
|
2015-02-23 12:54:41 +00:00
|
|
|
"FRAGMENTATION_SUPPORTED",
|
|
|
|
"SIGNATURE_HASH_ALGORITHMS");
|
2018-07-25 13:29:58 +00:00
|
|
|
ENUM_NEXT(notify_type_names, USE_PPK, NO_PPK_AUTH, SIGNATURE_HASH_ALGORITHMS,
|
|
|
|
"USE_PPK",
|
|
|
|
"PPK_IDENTITY",
|
|
|
|
"NO_PPK_AUTH");
|
|
|
|
ENUM_NEXT(notify_type_names, INITIAL_CONTACT_IKEV1, INITIAL_CONTACT_IKEV1, NO_PPK_AUTH,
|
2011-11-17 17:01:41 +00:00
|
|
|
"INITIAL_CONTACT");
|
2012-01-10 13:31:51 +00:00
|
|
|
ENUM_NEXT(notify_type_names, DPD_R_U_THERE, DPD_R_U_THERE_ACK, INITIAL_CONTACT_IKEV1,
|
|
|
|
"DPD_R_U_THERE",
|
|
|
|
"DPD_R_U_THERE_ACK");
|
2012-02-03 11:58:11 +00:00
|
|
|
ENUM_NEXT(notify_type_names, UNITY_LOAD_BALANCE, UNITY_LOAD_BALANCE, DPD_R_U_THERE_ACK,
|
|
|
|
"UNITY_LOAD_BALANCE");
|
|
|
|
ENUM_NEXT(notify_type_names, USE_BEET_MODE, USE_BEET_MODE, UNITY_LOAD_BALANCE,
|
2007-10-03 15:10:41 +00:00
|
|
|
"USE_BEET_MODE");
|
2012-02-24 12:37:00 +00:00
|
|
|
ENUM_NEXT(notify_type_names, ME_MEDIATION, RADIUS_ATTRIBUTE, USE_BEET_MODE,
|
2008-03-26 18:40:19 +00:00
|
|
|
"ME_MEDIATION",
|
|
|
|
"ME_ENDPOINT",
|
|
|
|
"ME_CALLBACK",
|
|
|
|
"ME_CONNECTID",
|
|
|
|
"ME_CONNECTKEY",
|
2008-03-27 09:54:09 +00:00
|
|
|
"ME_CONNECTAUTH",
|
2012-02-24 12:37:00 +00:00
|
|
|
"ME_RESPONSE",
|
2014-06-06 13:12:16 +00:00
|
|
|
"RADIUS_ATTRIBUTE");
|
2012-02-24 12:37:00 +00:00
|
|
|
ENUM_END(notify_type_names, RADIUS_ATTRIBUTE);
|
2005-11-24 09:17:51 +00:00
|
|
|
|
2007-07-03 08:50:14 +00:00
|
|
|
|
|
|
|
ENUM_BEGIN(notify_type_short_names, UNSUPPORTED_CRITICAL_PAYLOAD, UNSUPPORTED_CRITICAL_PAYLOAD,
|
|
|
|
"CRIT");
|
|
|
|
ENUM_NEXT(notify_type_short_names, INVALID_IKE_SPI, INVALID_MAJOR_VERSION, UNSUPPORTED_CRITICAL_PAYLOAD,
|
|
|
|
"INVAL_IKE_SPI",
|
|
|
|
"INVAL_MAJOR");
|
|
|
|
ENUM_NEXT(notify_type_short_names, INVALID_SYNTAX, INVALID_SYNTAX, INVALID_MAJOR_VERSION,
|
|
|
|
"INVAL_SYN");
|
|
|
|
ENUM_NEXT(notify_type_short_names, INVALID_MESSAGE_ID, INVALID_MESSAGE_ID, INVALID_SYNTAX,
|
|
|
|
"INVAL_MID");
|
|
|
|
ENUM_NEXT(notify_type_short_names, INVALID_SPI, INVALID_SPI, INVALID_MESSAGE_ID,
|
|
|
|
"INVAL_SPI");
|
2011-12-21 12:46:47 +00:00
|
|
|
ENUM_NEXT(notify_type_short_names, ATTRIBUTES_NOT_SUPPORTED, NO_PROPOSAL_CHOSEN, INVALID_SPI,
|
|
|
|
"ATTR_UNSUP",
|
2007-07-03 08:50:14 +00:00
|
|
|
"NO_PROP");
|
2011-12-15 16:04:29 +00:00
|
|
|
ENUM_NEXT(notify_type_short_names, PAYLOAD_MALFORMED, AUTHENTICATION_FAILED, NO_PROPOSAL_CHOSEN,
|
2011-11-17 17:01:41 +00:00
|
|
|
"PLD_MAL",
|
2011-12-15 16:04:29 +00:00
|
|
|
"INVAL_KE",
|
|
|
|
"INVAL_ID",
|
|
|
|
"INVAL_CERTEN",
|
|
|
|
"INVAL_CERT",
|
|
|
|
"CERT_UNSUP",
|
|
|
|
"INVAL_CA",
|
2011-12-17 11:19:30 +00:00
|
|
|
"INVAL_HASH",
|
2007-07-03 08:50:14 +00:00
|
|
|
"AUTH_FAILED");
|
2010-09-15 10:48:58 +00:00
|
|
|
ENUM_NEXT(notify_type_short_names, SINGLE_PAIR_REQUIRED, CHILD_SA_NOT_FOUND, AUTHENTICATION_FAILED,
|
2007-07-03 08:50:14 +00:00
|
|
|
"SINGLE_PAIR",
|
|
|
|
"NO_ADD_SAS",
|
|
|
|
"INT_ADDR_FAIL",
|
|
|
|
"FAIL_CP_REQ",
|
|
|
|
"TS_UNACCEPT",
|
|
|
|
"INVAL_SEL",
|
|
|
|
"UNACCEPT_ADDR",
|
2009-11-24 08:21:00 +00:00
|
|
|
"UNEXPECT_NAT",
|
2010-09-15 10:48:58 +00:00
|
|
|
"ASSIGNED_HoA",
|
|
|
|
"TEMP_FAIL",
|
|
|
|
"NO_CHILD_SA");
|
|
|
|
ENUM_NEXT(notify_type_short_names, ME_CONNECT_FAILED, ME_CONNECT_FAILED, CHILD_SA_NOT_FOUND,
|
2008-03-26 18:40:19 +00:00
|
|
|
"ME_CONN_FAIL");
|
2011-08-01 09:27:01 +00:00
|
|
|
ENUM_NEXT(notify_type_short_names, MS_NOTIFY_STATUS, MS_NOTIFY_STATUS, ME_CONNECT_FAILED,
|
|
|
|
"MS_STATUS");
|
2015-02-23 12:54:41 +00:00
|
|
|
ENUM_NEXT(notify_type_short_names, INITIAL_CONTACT, SIGNATURE_HASH_ALGORITHMS, MS_NOTIFY_STATUS,
|
2007-07-03 08:50:14 +00:00
|
|
|
"INIT_CONTACT",
|
|
|
|
"SET_WINSIZE",
|
|
|
|
"ADD_TS_POSS",
|
2011-07-14 08:51:24 +00:00
|
|
|
"IPCOMP_SUP",
|
2007-07-03 08:50:14 +00:00
|
|
|
"NATD_S_IP",
|
|
|
|
"NATD_D_IP",
|
|
|
|
"COOKIE",
|
|
|
|
"USE_TRANSP",
|
|
|
|
"HTTP_CERT_LOOK",
|
|
|
|
"REKEY_SA",
|
|
|
|
"ESP_TFC_PAD_N",
|
|
|
|
"NON_FIRST_FRAG",
|
|
|
|
"MOBIKE_SUP",
|
|
|
|
"ADD_4_ADDR",
|
|
|
|
"ADD_6_ADDR",
|
|
|
|
"NO_ADD_ADDR",
|
|
|
|
"UPD_SA_ADDR",
|
|
|
|
"COOKIE2",
|
|
|
|
"NO_NATS",
|
2009-01-19 12:32:42 +00:00
|
|
|
"AUTH_LFT",
|
|
|
|
"MULT_AUTH",
|
2009-11-24 08:21:00 +00:00
|
|
|
"AUTH_FOLLOWS",
|
|
|
|
"REDIR_SUP",
|
|
|
|
"REDIR",
|
|
|
|
"REDIR_FROM",
|
|
|
|
"TKT_LT_OPAK",
|
|
|
|
"TKT_REQ",
|
|
|
|
"TKT_ACK",
|
|
|
|
"TKT_NACK",
|
|
|
|
"TKT_OPAK",
|
2010-08-04 08:02:09 +00:00
|
|
|
"LINK_ID",
|
|
|
|
"WESP_MODE",
|
|
|
|
"ROHC_SUP",
|
2011-07-14 08:51:24 +00:00
|
|
|
"EAP_ONLY",
|
|
|
|
"CHDLESS_SUP",
|
|
|
|
"CRASH_DET",
|
|
|
|
"MSG_ID_SYN_SUP",
|
|
|
|
"RPL_CTR_SYN_SUP",
|
|
|
|
"MSG_ID_SYN",
|
2012-04-03 10:48:48 +00:00
|
|
|
"RPL_CTR_SYN",
|
|
|
|
"SEC_PASSWD",
|
|
|
|
"PSK_PST",
|
2013-03-02 16:18:37 +00:00
|
|
|
"PSK_CFM",
|
2013-11-01 13:07:11 +00:00
|
|
|
"ERX_SUP",
|
2014-06-06 13:12:16 +00:00
|
|
|
"IFOM_CAP",
|
|
|
|
"SENDER_REQ_ID",
|
2015-02-23 12:54:41 +00:00
|
|
|
"FRAG_SUP",
|
|
|
|
"HASH_ALG");
|
2018-07-25 13:29:58 +00:00
|
|
|
ENUM_NEXT(notify_type_short_names, USE_PPK, NO_PPK_AUTH, SIGNATURE_HASH_ALGORITHMS,
|
|
|
|
"USE_PPK",
|
|
|
|
"PPK_ID",
|
|
|
|
"NO_PPK");
|
|
|
|
ENUM_NEXT(notify_type_short_names, INITIAL_CONTACT_IKEV1, INITIAL_CONTACT_IKEV1, NO_PPK_AUTH,
|
2011-11-17 17:01:41 +00:00
|
|
|
"INITIAL_CONTACT");
|
2012-01-10 16:10:22 +00:00
|
|
|
ENUM_NEXT(notify_type_short_names, DPD_R_U_THERE, DPD_R_U_THERE_ACK, INITIAL_CONTACT_IKEV1,
|
|
|
|
"DPD",
|
|
|
|
"DPD_ACK");
|
2012-02-03 11:58:11 +00:00
|
|
|
ENUM_NEXT(notify_type_short_names, UNITY_LOAD_BALANCE, UNITY_LOAD_BALANCE, DPD_R_U_THERE_ACK,
|
|
|
|
"UNITY_LB");
|
|
|
|
ENUM_NEXT(notify_type_short_names, USE_BEET_MODE, USE_BEET_MODE, UNITY_LOAD_BALANCE,
|
2007-10-03 15:10:41 +00:00
|
|
|
"BEET_MODE");
|
2012-02-24 12:37:00 +00:00
|
|
|
ENUM_NEXT(notify_type_short_names, ME_MEDIATION, RADIUS_ATTRIBUTE, USE_BEET_MODE,
|
2008-03-26 18:40:19 +00:00
|
|
|
"ME_MED",
|
|
|
|
"ME_EP",
|
|
|
|
"ME_CB",
|
|
|
|
"ME_CID",
|
|
|
|
"ME_CKEY",
|
2008-03-27 09:54:09 +00:00
|
|
|
"ME_CAUTH",
|
2012-02-24 12:37:00 +00:00
|
|
|
"ME_R",
|
|
|
|
"RADIUS");
|
|
|
|
ENUM_END(notify_type_short_names, RADIUS_ATTRIBUTE);
|
2007-07-03 08:50:14 +00:00
|
|
|
|
|
|
|
|
2005-11-24 09:17:51 +00:00
|
|
|
typedef struct private_notify_payload_t private_notify_payload_t;
|
|
|
|
|
2005-11-15 15:58:03 +00:00
|
|
|
/**
|
2005-11-28 18:24:10 +00:00
|
|
|
* Private data of an notify_payload_t object.
|
2005-11-15 15:58:03 +00:00
|
|
|
*/
|
2005-11-24 09:17:51 +00:00
|
|
|
struct private_notify_payload_t {
|
2010-11-24 10:54:12 +00:00
|
|
|
|
2005-11-15 15:58:03 +00:00
|
|
|
/**
|
2005-11-28 18:24:10 +00:00
|
|
|
* Public notify_payload_t interface.
|
2005-11-15 15:58:03 +00:00
|
|
|
*/
|
|
|
|
notify_payload_t public;
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2005-11-15 15:58:03 +00:00
|
|
|
/**
|
2005-11-28 18:24:10 +00:00
|
|
|
* Next payload type.
|
2005-11-15 15:58:03 +00:00
|
|
|
*/
|
2016-03-22 12:22:01 +00:00
|
|
|
uint8_t next_payload;
|
2005-11-15 15:58:03 +00:00
|
|
|
|
|
|
|
/**
|
2005-11-28 18:24:10 +00:00
|
|
|
* Critical flag.
|
2005-11-15 15:58:03 +00:00
|
|
|
*/
|
|
|
|
bool critical;
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2010-11-24 15:34:16 +00:00
|
|
|
/**
|
|
|
|
* reserved bits
|
|
|
|
*/
|
2011-11-17 17:01:41 +00:00
|
|
|
bool reserved[8];
|
2010-11-24 15:34:16 +00:00
|
|
|
|
2005-11-15 15:58:03 +00:00
|
|
|
/**
|
2005-11-28 18:24:10 +00:00
|
|
|
* Length of this payload.
|
2005-11-15 15:58:03 +00:00
|
|
|
*/
|
2016-03-22 12:22:01 +00:00
|
|
|
uint16_t payload_length;
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2011-11-17 17:01:41 +00:00
|
|
|
/**
|
|
|
|
* Domain of interpretation, IKEv1 only.
|
|
|
|
*/
|
2016-03-22 12:22:01 +00:00
|
|
|
uint32_t doi;
|
2011-11-17 17:01:41 +00:00
|
|
|
|
2005-11-15 15:58:03 +00:00
|
|
|
/**
|
2005-11-28 18:24:10 +00:00
|
|
|
* Protocol id.
|
2005-11-15 15:58:03 +00:00
|
|
|
*/
|
2016-03-22 12:22:01 +00:00
|
|
|
uint8_t protocol_id;
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2005-11-15 15:58:03 +00:00
|
|
|
/**
|
2005-11-28 18:24:10 +00:00
|
|
|
* Spi size.
|
2005-11-15 15:58:03 +00:00
|
|
|
*/
|
2016-03-22 12:22:01 +00:00
|
|
|
uint8_t spi_size;
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2005-11-15 15:58:03 +00:00
|
|
|
/**
|
2005-11-28 18:24:10 +00:00
|
|
|
* Notify message type.
|
2005-11-15 15:58:03 +00:00
|
|
|
*/
|
2016-03-22 12:22:01 +00:00
|
|
|
uint16_t notify_type;
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2005-11-15 15:58:03 +00:00
|
|
|
/**
|
2005-11-28 18:24:10 +00:00
|
|
|
* Security parameter index (spi).
|
2005-11-15 15:58:03 +00:00
|
|
|
*/
|
|
|
|
chunk_t spi;
|
|
|
|
|
|
|
|
/**
|
2005-11-28 18:24:10 +00:00
|
|
|
* Notification data.
|
2005-11-15 15:58:03 +00:00
|
|
|
*/
|
2011-11-17 17:01:41 +00:00
|
|
|
chunk_t notify_data;
|
|
|
|
|
|
|
|
/**
|
2013-10-29 09:09:39 +00:00
|
|
|
* Type of payload, PLV2_NOTIFY or PLV1_NOTIFY
|
2011-11-17 17:01:41 +00:00
|
|
|
*/
|
|
|
|
payload_type_t type;
|
2005-11-15 15:58:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2011-11-17 17:01:41 +00:00
|
|
|
* Encoding rules for an IKEv2 notification payload
|
2005-11-15 15:58:03 +00:00
|
|
|
*/
|
2011-11-17 17:01:41 +00:00
|
|
|
static encoding_rule_t encodings_v2[] = {
|
2009-09-04 13:02:11 +00:00
|
|
|
/* 1 Byte next payload type, stored in the field next_payload */
|
2011-11-17 17:01:41 +00:00
|
|
|
{ U_INT_8, offsetof(private_notify_payload_t, next_payload) },
|
2005-11-15 15:58:03 +00:00
|
|
|
/* the critical bit */
|
2011-11-17 17:01:41 +00:00
|
|
|
{ FLAG, offsetof(private_notify_payload_t, critical) },
|
2009-09-04 13:02:11 +00:00
|
|
|
/* 7 Bit reserved bits, nowhere stored */
|
2011-11-17 17:01:41 +00:00
|
|
|
{ RESERVED_BIT, offsetof(private_notify_payload_t, reserved[0]) },
|
|
|
|
{ RESERVED_BIT, offsetof(private_notify_payload_t, reserved[1]) },
|
|
|
|
{ RESERVED_BIT, offsetof(private_notify_payload_t, reserved[2]) },
|
|
|
|
{ RESERVED_BIT, offsetof(private_notify_payload_t, reserved[3]) },
|
|
|
|
{ RESERVED_BIT, offsetof(private_notify_payload_t, reserved[4]) },
|
|
|
|
{ RESERVED_BIT, offsetof(private_notify_payload_t, reserved[5]) },
|
|
|
|
{ RESERVED_BIT, offsetof(private_notify_payload_t, reserved[6]) },
|
2005-11-15 15:58:03 +00:00
|
|
|
/* Length of the whole payload*/
|
2011-11-17 17:01:41 +00:00
|
|
|
{ PAYLOAD_LENGTH, offsetof(private_notify_payload_t, payload_length) },
|
2005-11-15 15:58:03 +00:00
|
|
|
/* Protocol ID as 8 bit field*/
|
2011-11-17 17:01:41 +00:00
|
|
|
{ U_INT_8, offsetof(private_notify_payload_t, protocol_id) },
|
2005-11-15 15:58:03 +00:00
|
|
|
/* SPI Size as 8 bit field*/
|
2011-11-17 17:01:41 +00:00
|
|
|
{ SPI_SIZE, offsetof(private_notify_payload_t, spi_size) },
|
2005-11-15 15:58:03 +00:00
|
|
|
/* Notify message type as 16 bit field*/
|
2011-11-17 17:01:41 +00:00
|
|
|
{ U_INT_16, offsetof(private_notify_payload_t, notify_type) },
|
2005-11-15 15:58:03 +00:00
|
|
|
/* SPI as variable length field*/
|
2011-11-17 17:01:41 +00:00
|
|
|
{ SPI, offsetof(private_notify_payload_t, spi) },
|
2005-11-15 15:58:03 +00:00
|
|
|
/* Key Exchange Data is from variable size */
|
2011-11-17 17:01:41 +00:00
|
|
|
{ CHUNK_DATA, offsetof(private_notify_payload_t, notify_data) },
|
2005-11-15 15:58:03 +00:00
|
|
|
};
|
|
|
|
|
2005-11-17 12:49:35 +00:00
|
|
|
/*
|
|
|
|
1 2 3
|
|
|
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
! Next Payload !C! RESERVED ! Payload Length !
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
! Protocol ID ! SPI Size ! Notify Message Type !
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
! !
|
|
|
|
~ Security Parameter Index (SPI) ~
|
|
|
|
! !
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
! !
|
|
|
|
~ Notification Data ~
|
|
|
|
! !
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
2011-11-17 17:01:41 +00:00
|
|
|
/**
|
|
|
|
* Encoding rules for an IKEv1 notification payload
|
|
|
|
*/
|
|
|
|
static encoding_rule_t encodings_v1[] = {
|
|
|
|
/* 1 Byte next payload type, stored in the field next_payload */
|
|
|
|
{ U_INT_8, offsetof(private_notify_payload_t, next_payload) },
|
|
|
|
/* 8 reserved bits */
|
|
|
|
{ RESERVED_BIT, offsetof(private_notify_payload_t, reserved[0]) },
|
|
|
|
{ RESERVED_BIT, offsetof(private_notify_payload_t, reserved[1]) },
|
|
|
|
{ RESERVED_BIT, offsetof(private_notify_payload_t, reserved[2]) },
|
|
|
|
{ RESERVED_BIT, offsetof(private_notify_payload_t, reserved[3]) },
|
|
|
|
{ RESERVED_BIT, offsetof(private_notify_payload_t, reserved[4]) },
|
|
|
|
{ RESERVED_BIT, offsetof(private_notify_payload_t, reserved[5]) },
|
|
|
|
{ RESERVED_BIT, offsetof(private_notify_payload_t, reserved[6]) },
|
|
|
|
{ RESERVED_BIT, offsetof(private_notify_payload_t, reserved[7]) },
|
|
|
|
/* Length of the whole payload*/
|
|
|
|
{ PAYLOAD_LENGTH, offsetof(private_notify_payload_t, payload_length) },
|
|
|
|
/* DOI as 32 bit field*/
|
|
|
|
{ U_INT_32, offsetof(private_notify_payload_t, doi) },
|
|
|
|
/* Protocol ID as 8 bit field*/
|
|
|
|
{ U_INT_8, offsetof(private_notify_payload_t, protocol_id) },
|
|
|
|
/* SPI Size as 8 bit field*/
|
|
|
|
{ SPI_SIZE, offsetof(private_notify_payload_t, spi_size) },
|
|
|
|
/* Notify message type as 16 bit field*/
|
|
|
|
{ U_INT_16, offsetof(private_notify_payload_t, notify_type) },
|
|
|
|
/* SPI as variable length field*/
|
|
|
|
{ SPI, offsetof(private_notify_payload_t, spi) },
|
|
|
|
/* Key Exchange Data is from variable size */
|
|
|
|
{ CHUNK_DATA, offsetof(private_notify_payload_t, notify_data) },
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
1 2 3
|
|
|
|
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
! Next Payload ! RESERVED ! Payload Length !
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
! DOI !
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
! Protocol ID ! SPI Size ! Notify Message Type !
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
! !
|
|
|
|
~ Security Parameter Index (SPI) ~
|
|
|
|
! !
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
! !
|
|
|
|
~ Notification Data ~
|
|
|
|
! !
|
|
|
|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
|
|
|
*/
|
|
|
|
|
2005-11-17 12:49:35 +00:00
|
|
|
|
2010-11-24 10:54:12 +00:00
|
|
|
METHOD(payload_t, verify, status_t,
|
|
|
|
private_notify_payload_t *this)
|
2005-11-17 12:49:35 +00:00
|
|
|
{
|
2007-06-21 15:25:28 +00:00
|
|
|
bool bad_length = FALSE;
|
|
|
|
|
2006-06-07 13:26:23 +00:00
|
|
|
switch (this->protocol_id)
|
2005-11-17 12:49:35 +00:00
|
|
|
{
|
2006-06-15 11:09:11 +00:00
|
|
|
case PROTO_NONE:
|
2006-06-07 13:26:23 +00:00
|
|
|
case PROTO_IKE:
|
|
|
|
case PROTO_AH:
|
|
|
|
case PROTO_ESP:
|
|
|
|
break;
|
|
|
|
default:
|
2006-10-26 09:46:56 +00:00
|
|
|
DBG1(DBG_ENC, "Unknown protocol (%d)", this->protocol_id);
|
2006-06-07 13:26:23 +00:00
|
|
|
return FAILED;
|
2005-11-17 12:49:35 +00:00
|
|
|
}
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2006-07-05 10:53:20 +00:00
|
|
|
switch (this->notify_type)
|
2006-02-14 14:52:00 +00:00
|
|
|
{
|
2006-07-05 10:53:20 +00:00
|
|
|
case INVALID_KE_PAYLOAD:
|
2006-02-14 14:52:00 +00:00
|
|
|
{
|
2013-10-29 09:09:39 +00:00
|
|
|
if (this->type == PLV2_NOTIFY && this->notify_data.len != 2)
|
2006-07-05 10:53:20 +00:00
|
|
|
{
|
2007-06-21 15:25:28 +00:00
|
|
|
bad_length = TRUE;
|
2006-07-05 10:53:20 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-02-14 14:52:00 +00:00
|
|
|
}
|
2006-07-05 10:53:20 +00:00
|
|
|
case NAT_DETECTION_SOURCE_IP:
|
|
|
|
case NAT_DETECTION_DESTINATION_IP:
|
2008-03-27 09:54:09 +00:00
|
|
|
case ME_CONNECTAUTH:
|
2006-02-14 14:52:00 +00:00
|
|
|
{
|
2011-11-17 17:01:41 +00:00
|
|
|
if (this->notify_data.len != HASH_SIZE_SHA1)
|
2006-07-05 10:53:20 +00:00
|
|
|
{
|
2007-06-21 15:25:28 +00:00
|
|
|
bad_length = TRUE;
|
2006-07-05 10:53:20 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case INVALID_SYNTAX:
|
|
|
|
case INVALID_MAJOR_VERSION:
|
|
|
|
case NO_PROPOSAL_CHOSEN:
|
|
|
|
{
|
2013-10-29 09:09:39 +00:00
|
|
|
if (this->type == PLV2_NOTIFY && this->notify_data.len != 0)
|
2006-07-05 10:53:20 +00:00
|
|
|
{
|
2007-06-21 15:25:28 +00:00
|
|
|
bad_length = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2019-08-27 16:32:32 +00:00
|
|
|
case COOKIE:
|
|
|
|
{
|
|
|
|
if (this->notify_data.len < 1 || this->notify_data.len > 64)
|
|
|
|
{
|
|
|
|
bad_length = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2007-06-21 15:25:28 +00:00
|
|
|
case ADDITIONAL_IP4_ADDRESS:
|
|
|
|
{
|
2011-11-17 17:01:41 +00:00
|
|
|
if (this->notify_data.len != 4)
|
2007-06-21 15:25:28 +00:00
|
|
|
{
|
|
|
|
bad_length = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ADDITIONAL_IP6_ADDRESS:
|
|
|
|
{
|
2011-11-17 17:01:41 +00:00
|
|
|
if (this->notify_data.len != 16)
|
2007-06-21 15:25:28 +00:00
|
|
|
{
|
|
|
|
bad_length = TRUE;
|
2006-07-05 10:53:20 +00:00
|
|
|
}
|
|
|
|
break;
|
2006-02-14 14:52:00 +00:00
|
|
|
}
|
2015-02-23 12:54:41 +00:00
|
|
|
case SIGNATURE_HASH_ALGORITHMS:
|
|
|
|
{
|
|
|
|
if (this->notify_data.len % 2)
|
|
|
|
{
|
|
|
|
bad_length = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2007-11-20 12:06:40 +00:00
|
|
|
case AUTH_LIFETIME:
|
|
|
|
{
|
2011-11-17 17:01:41 +00:00
|
|
|
if (this->notify_data.len != 4)
|
2007-11-20 12:06:40 +00:00
|
|
|
{
|
|
|
|
bad_length = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-05-08 16:19:11 +00:00
|
|
|
case IPCOMP_SUPPORTED:
|
|
|
|
{
|
2011-11-17 17:01:41 +00:00
|
|
|
if (this->notify_data.len != 3)
|
2008-05-08 16:19:11 +00:00
|
|
|
{
|
|
|
|
bad_length = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-03-27 10:17:29 +00:00
|
|
|
case ME_ENDPOINT:
|
2011-11-17 17:01:41 +00:00
|
|
|
if (this->notify_data.len != 8 &&
|
|
|
|
this->notify_data.len != 12 &&
|
|
|
|
this->notify_data.len != 24)
|
2008-03-27 10:17:29 +00:00
|
|
|
{
|
|
|
|
bad_length = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ME_CONNECTID:
|
2011-11-17 17:01:41 +00:00
|
|
|
if (this->notify_data.len < 4 ||
|
|
|
|
this->notify_data.len > 16)
|
2008-03-27 10:17:29 +00:00
|
|
|
{
|
|
|
|
bad_length = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ME_CONNECTKEY:
|
2011-11-17 17:01:41 +00:00
|
|
|
if (this->notify_data.len < 16 ||
|
|
|
|
this->notify_data.len > 32)
|
2008-03-27 10:17:29 +00:00
|
|
|
{
|
|
|
|
bad_length = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2012-01-10 13:31:51 +00:00
|
|
|
case DPD_R_U_THERE:
|
|
|
|
case DPD_R_U_THERE_ACK:
|
|
|
|
if (this->notify_data.len != 4)
|
2008-03-27 10:17:29 +00:00
|
|
|
{
|
|
|
|
bad_length = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2006-07-05 10:53:20 +00:00
|
|
|
default:
|
|
|
|
/* TODO: verify */
|
|
|
|
break;
|
2006-02-14 14:52:00 +00:00
|
|
|
}
|
2007-06-21 15:25:28 +00:00
|
|
|
if (bad_length)
|
|
|
|
{
|
|
|
|
DBG1(DBG_ENC, "invalid notify data length for %N (%d)",
|
|
|
|
notify_type_names, this->notify_type,
|
2011-11-17 17:01:41 +00:00
|
|
|
this->notify_data.len);
|
2007-06-21 15:25:28 +00:00
|
|
|
return FAILED;
|
|
|
|
}
|
2005-11-17 12:49:35 +00:00
|
|
|
return SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-11-17 10:27:55 +00:00
|
|
|
METHOD(payload_t, get_encoding_rules, int,
|
|
|
|
private_notify_payload_t *this, encoding_rule_t **rules)
|
2005-11-15 15:58:03 +00:00
|
|
|
{
|
2013-10-29 09:09:39 +00:00
|
|
|
if (this->type == PLV2_NOTIFY)
|
2011-11-17 17:01:41 +00:00
|
|
|
{
|
|
|
|
*rules = encodings_v2;
|
|
|
|
return countof(encodings_v2);
|
|
|
|
}
|
|
|
|
*rules = encodings_v1;
|
|
|
|
return countof(encodings_v1);
|
2005-11-15 15:58:03 +00:00
|
|
|
}
|
|
|
|
|
2011-11-17 11:27:46 +00:00
|
|
|
METHOD(payload_t, get_header_length, int,
|
|
|
|
private_notify_payload_t *this)
|
2005-11-15 15:58:03 +00:00
|
|
|
{
|
2013-10-29 09:09:39 +00:00
|
|
|
if (this->type == PLV2_NOTIFY)
|
2011-11-17 17:01:41 +00:00
|
|
|
{
|
|
|
|
return 8 + this->spi_size;
|
|
|
|
}
|
|
|
|
return 12 + this->spi_size;
|
2005-11-15 15:58:03 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 10:54:12 +00:00
|
|
|
METHOD(payload_t, get_type, payload_type_t,
|
|
|
|
private_notify_payload_t *this)
|
2005-11-15 15:58:03 +00:00
|
|
|
{
|
2011-11-17 17:01:41 +00:00
|
|
|
return this->type;
|
2005-11-15 15:58:03 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 10:54:12 +00:00
|
|
|
METHOD(payload_t, get_next_type, payload_type_t,
|
|
|
|
private_notify_payload_t *this)
|
2005-11-15 15:58:03 +00:00
|
|
|
{
|
2010-11-24 10:54:12 +00:00
|
|
|
return this->next_payload;
|
2005-11-15 15:58:03 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 10:54:12 +00:00
|
|
|
METHOD(payload_t, set_next_type, void,
|
|
|
|
private_notify_payload_t *this, payload_type_t type)
|
2005-11-15 15:58:03 +00:00
|
|
|
{
|
|
|
|
this->next_payload = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2006-10-18 11:46:13 +00:00
|
|
|
* recompute the payloads length.
|
2005-11-15 15:58:03 +00:00
|
|
|
*/
|
2011-11-17 11:27:46 +00:00
|
|
|
static void compute_length(private_notify_payload_t *this)
|
2005-11-15 15:58:03 +00:00
|
|
|
{
|
2011-11-17 17:01:41 +00:00
|
|
|
this->payload_length = get_header_length(this) + this->notify_data.len;
|
2005-11-28 18:24:10 +00:00
|
|
|
}
|
2005-11-15 15:58:03 +00:00
|
|
|
|
2010-11-24 10:54:12 +00:00
|
|
|
METHOD(payload_t, get_length, size_t,
|
|
|
|
private_notify_payload_t *this)
|
2006-10-18 11:46:13 +00:00
|
|
|
{
|
|
|
|
return this->payload_length;
|
|
|
|
}
|
|
|
|
|
2016-03-22 12:22:01 +00:00
|
|
|
METHOD(notify_payload_t, get_protocol_id, uint8_t,
|
2010-11-24 10:54:12 +00:00
|
|
|
private_notify_payload_t *this)
|
2005-11-15 15:58:03 +00:00
|
|
|
{
|
|
|
|
return this->protocol_id;
|
|
|
|
}
|
|
|
|
|
2010-11-24 10:54:12 +00:00
|
|
|
METHOD(notify_payload_t, set_protocol_id, void,
|
2016-03-22 12:22:01 +00:00
|
|
|
private_notify_payload_t *this, uint8_t protocol_id)
|
2005-11-15 15:58:03 +00:00
|
|
|
{
|
|
|
|
this->protocol_id = protocol_id;
|
|
|
|
}
|
|
|
|
|
2010-11-24 10:54:12 +00:00
|
|
|
METHOD(notify_payload_t, get_notify_type, notify_type_t,
|
|
|
|
private_notify_payload_t *this)
|
2005-11-15 15:58:03 +00:00
|
|
|
{
|
2006-07-05 10:53:20 +00:00
|
|
|
return this->notify_type;
|
2005-11-15 15:58:03 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 10:54:12 +00:00
|
|
|
METHOD(notify_payload_t, set_notify_type, void,
|
|
|
|
private_notify_payload_t *this, notify_type_t notify_type)
|
2005-11-15 15:58:03 +00:00
|
|
|
{
|
2006-07-05 10:53:20 +00:00
|
|
|
this->notify_type = notify_type;
|
2005-11-15 15:58:03 +00:00
|
|
|
}
|
|
|
|
|
2016-03-22 12:22:01 +00:00
|
|
|
METHOD(notify_payload_t, get_spi, uint32_t,
|
2010-11-24 10:54:12 +00:00
|
|
|
private_notify_payload_t *this)
|
2005-11-15 15:58:03 +00:00
|
|
|
{
|
2006-06-07 13:26:23 +00:00
|
|
|
switch (this->protocol_id)
|
|
|
|
{
|
|
|
|
case PROTO_AH:
|
|
|
|
case PROTO_ESP:
|
2007-02-08 13:53:41 +00:00
|
|
|
if (this->spi.len == 4)
|
|
|
|
{
|
2016-03-22 12:22:01 +00:00
|
|
|
return *((uint32_t*)this->spi.ptr);
|
2007-02-08 13:53:41 +00:00
|
|
|
}
|
2006-06-07 13:26:23 +00:00
|
|
|
default:
|
2007-02-08 13:53:41 +00:00
|
|
|
break;
|
2006-06-07 13:26:23 +00:00
|
|
|
}
|
2007-02-08 13:53:41 +00:00
|
|
|
return 0;
|
2005-11-15 15:58:03 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 10:54:12 +00:00
|
|
|
METHOD(notify_payload_t, set_spi, void,
|
2016-03-22 12:22:01 +00:00
|
|
|
private_notify_payload_t *this, uint32_t spi)
|
2005-11-15 15:58:03 +00:00
|
|
|
{
|
2006-06-07 13:26:23 +00:00
|
|
|
chunk_free(&this->spi);
|
|
|
|
switch (this->protocol_id)
|
2005-11-15 15:58:03 +00:00
|
|
|
{
|
2006-06-07 13:26:23 +00:00
|
|
|
case PROTO_AH:
|
|
|
|
case PROTO_ESP:
|
|
|
|
this->spi = chunk_alloc(4);
|
2016-03-22 12:22:01 +00:00
|
|
|
*((uint32_t*)this->spi.ptr) = spi;
|
2006-06-07 13:26:23 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2005-11-15 15:58:03 +00:00
|
|
|
}
|
2006-06-07 13:26:23 +00:00
|
|
|
this->spi_size = this->spi.len;
|
2006-10-18 11:46:13 +00:00
|
|
|
compute_length(this);
|
2005-11-28 18:24:10 +00:00
|
|
|
}
|
2005-11-15 15:58:03 +00:00
|
|
|
|
2011-12-09 14:43:36 +00:00
|
|
|
METHOD(notify_payload_t, get_spi_data, chunk_t,
|
|
|
|
private_notify_payload_t *this)
|
|
|
|
{
|
|
|
|
switch (this->protocol_id)
|
|
|
|
{
|
|
|
|
case PROTO_IKE:
|
|
|
|
if (this->spi.len == 16)
|
|
|
|
{
|
|
|
|
return this->spi;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return chunk_empty;
|
|
|
|
}
|
|
|
|
|
|
|
|
METHOD(notify_payload_t, set_spi_data, void,
|
|
|
|
private_notify_payload_t *this, chunk_t spi)
|
|
|
|
{
|
|
|
|
chunk_free(&this->spi);
|
|
|
|
switch (this->protocol_id)
|
|
|
|
{
|
|
|
|
case PROTO_IKE:
|
|
|
|
this->spi = chunk_clone(spi);
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
this->spi_size = this->spi.len;
|
|
|
|
compute_length(this);
|
|
|
|
}
|
|
|
|
|
2010-11-24 10:54:12 +00:00
|
|
|
METHOD(notify_payload_t, get_notification_data, chunk_t,
|
|
|
|
private_notify_payload_t *this)
|
2005-11-15 15:58:03 +00:00
|
|
|
{
|
2011-11-17 17:01:41 +00:00
|
|
|
return this->notify_data;
|
2005-11-15 15:58:03 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 10:54:12 +00:00
|
|
|
METHOD(notify_payload_t, set_notification_data, void,
|
|
|
|
private_notify_payload_t *this, chunk_t data)
|
2005-11-15 15:58:03 +00:00
|
|
|
{
|
2011-11-17 17:01:41 +00:00
|
|
|
free(this->notify_data.ptr);
|
|
|
|
this->notify_data = chunk_clone(data);
|
2006-10-18 11:46:13 +00:00
|
|
|
compute_length(this);
|
2005-11-15 15:58:03 +00:00
|
|
|
}
|
|
|
|
|
2010-11-24 10:54:12 +00:00
|
|
|
METHOD2(payload_t, notify_payload_t, destroy, void,
|
|
|
|
private_notify_payload_t *this)
|
2005-11-22 11:54:58 +00:00
|
|
|
{
|
2011-11-17 17:01:41 +00:00
|
|
|
free(this->notify_data.ptr);
|
2010-11-24 10:54:12 +00:00
|
|
|
free(this->spi.ptr);
|
2006-04-10 08:07:38 +00:00
|
|
|
free(this);
|
2005-11-22 11:54:58 +00:00
|
|
|
}
|
|
|
|
|
2005-11-15 15:58:03 +00:00
|
|
|
/*
|
|
|
|
* Described in header
|
|
|
|
*/
|
2011-11-17 17:01:41 +00:00
|
|
|
notify_payload_t *notify_payload_create(payload_type_t type)
|
2005-11-15 15:58:03 +00:00
|
|
|
{
|
2010-11-24 10:54:12 +00:00
|
|
|
private_notify_payload_t *this;
|
|
|
|
|
|
|
|
INIT(this,
|
|
|
|
.public = {
|
|
|
|
.payload_interface = {
|
|
|
|
.verify = _verify,
|
|
|
|
.get_encoding_rules = _get_encoding_rules,
|
2011-11-17 11:27:46 +00:00
|
|
|
.get_header_length = _get_header_length,
|
2010-11-24 10:54:12 +00:00
|
|
|
.get_length = _get_length,
|
|
|
|
.get_next_type = _get_next_type,
|
|
|
|
.set_next_type = _set_next_type,
|
|
|
|
.get_type = _get_type,
|
|
|
|
.destroy = _destroy,
|
|
|
|
},
|
|
|
|
.get_protocol_id = _get_protocol_id,
|
|
|
|
.set_protocol_id = _set_protocol_id,
|
|
|
|
.get_notify_type = _get_notify_type,
|
|
|
|
.set_notify_type = _set_notify_type,
|
|
|
|
.get_spi = _get_spi,
|
|
|
|
.set_spi = _set_spi,
|
2011-12-09 14:43:36 +00:00
|
|
|
.get_spi_data = _get_spi_data,
|
|
|
|
.set_spi_data = _set_spi_data,
|
2010-11-24 10:54:12 +00:00
|
|
|
.get_notification_data = _get_notification_data,
|
|
|
|
.set_notification_data = _set_notification_data,
|
|
|
|
.destroy = _destroy,
|
|
|
|
},
|
2011-11-17 17:01:41 +00:00
|
|
|
.doi = IKEV1_DOI_IPSEC,
|
2013-10-29 09:09:39 +00:00
|
|
|
.next_payload = PL_NONE,
|
2011-11-17 17:01:41 +00:00
|
|
|
.type = type,
|
2010-11-24 10:54:12 +00:00
|
|
|
);
|
2011-11-17 11:27:46 +00:00
|
|
|
compute_length(this);
|
2006-07-05 10:53:20 +00:00
|
|
|
return &this->public;
|
2005-11-15 15:58:03 +00:00
|
|
|
}
|
|
|
|
|
2005-12-02 11:38:56 +00:00
|
|
|
/*
|
|
|
|
* Described in header.
|
|
|
|
*/
|
2010-11-24 10:54:12 +00:00
|
|
|
notify_payload_t *notify_payload_create_from_protocol_and_type(
|
2011-11-17 17:01:41 +00:00
|
|
|
payload_type_t type, protocol_id_t protocol, notify_type_t notify)
|
2005-12-02 11:38:56 +00:00
|
|
|
{
|
2011-11-17 17:01:41 +00:00
|
|
|
notify_payload_t *this = notify_payload_create(type);
|
2005-12-02 11:38:56 +00:00
|
|
|
|
2011-11-17 17:01:41 +00:00
|
|
|
this->set_notify_type(this, notify);
|
|
|
|
this->set_protocol_id(this, protocol);
|
2009-09-04 11:46:09 +00:00
|
|
|
|
2011-11-17 17:01:41 +00:00
|
|
|
return this;
|
2005-12-02 11:38:56 +00:00
|
|
|
}
|