-/* $OpenBSD: iked.h,v 1.197 2021/11/24 21:06:21 tobhe Exp $ */
+/* $OpenBSD: iked.h,v 1.198 2021/11/26 16:22:44 patrick Exp $ */
/*
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
struct ibuf *msg_ke; /* dh key exchange */
struct iked_id msg_auth; /* AUTH payload */
struct iked_id msg_id;
+ struct iked_id msg_localid;
struct iked_id msg_cert;
struct ibuf *msg_cookie;
uint16_t msg_group;
-/* $OpenBSD: ikev2_msg.c,v 1.80 2021/09/07 14:06:23 tobhe Exp $ */
+/* $OpenBSD: ikev2_msg.c,v 1.81 2021/11/26 16:22:44 patrick Exp $ */
/*
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
ibuf_release(msg->msg_ke);
ibuf_release(msg->msg_auth.id_buf);
ibuf_release(msg->msg_id.id_buf);
+ ibuf_release(msg->msg_localid.id_buf);
ibuf_release(msg->msg_cert.id_buf);
ibuf_release(msg->msg_cookie);
ibuf_release(msg->msg_cookie2);
msg->msg_ke = NULL;
msg->msg_auth.id_buf = NULL;
msg->msg_id.id_buf = NULL;
+ msg->msg_localid.id_buf = NULL;
msg->msg_cert.id_buf = NULL;
msg->msg_cookie = NULL;
msg->msg_cookie2 = NULL;
-/* $OpenBSD: ikev2_pld.c,v 1.119 2021/11/12 14:18:54 tobhe Exp $ */
+/* $OpenBSD: ikev2_pld.c,v 1.120 2021/11/26 16:22:44 patrick Exp $ */
/*
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
return (0);
}
- if (!((sa->sa_hdr.sh_initiator && payload == IKEV2_PAYLOAD_IDr) ||
- (!sa->sa_hdr.sh_initiator && payload == IKEV2_PAYLOAD_IDi))) {
+ if (((sa->sa_hdr.sh_initiator && payload == IKEV2_PAYLOAD_IDr) ||
+ (!sa->sa_hdr.sh_initiator && payload == IKEV2_PAYLOAD_IDi)))
+ idp = &msg->msg_parent->msg_id;
+ else if (!sa->sa_hdr.sh_initiator && payload == IKEV2_PAYLOAD_IDr)
+ idp = &msg->msg_parent->msg_localid;
+ else {
ibuf_release(idb.id_buf);
log_debug("%s: unexpected id payload", __func__);
return (0);
}
- idp = &msg->msg_parent->msg_id;
if (idp->id_type) {
ibuf_release(idb.id_buf);
log_debug("%s: duplicate id payload", __func__);
-/* $OpenBSD: policy.c,v 1.86 2021/11/24 20:48:00 tobhe Exp $ */
+/* $OpenBSD: policy.c,v 1.87 2021/11/26 16:22:44 patrick Exp $ */
/*
* Copyright (c) 2020-2021 Tobias Heider <tobhe@openbsd.org>
sizeof(pol.pol_peerid.id_data));
log_debug("%s: peerid '%s'", __func__, s+1);
}
+ if (msg->msg_localid.id_type &&
+ ikev2_print_id(&msg->msg_localid, idstr, IKED_ID_SIZE) == 0 &&
+ (s = strchr(idstr, '/')) != NULL) {
+ pol.pol_localid.id_type = msg->msg_localid.id_type;
+ pol.pol_localid.id_length = strlen(s+1);
+ strlcpy(pol.pol_localid.id_data, s+1,
+ sizeof(pol.pol_localid.id_data));
+ log_debug("%s: localid '%s'", __func__, s+1);
+ }
/* Try to find a matching policy for this message */
if ((msg->msg_policy = policy_test(env, &pol)) != NULL) {