diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2010-06-14 08:10:33 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2010-06-14 08:10:33 +0000 |
commit | e834fcd4ecac4135ad6e8ed7ea7be646efaea5cd (patch) | |
tree | b1e904ba3cd6d6a0811d72756affe0b53d9562fb /sbin/iked/ikev2_msg.c | |
parent | e1944808d62d45bb05963968faa0fde7ab36feed (diff) |
More code for initiator mode (not finished yet)
Diffstat (limited to 'sbin/iked/ikev2_msg.c')
-rw-r--r-- | sbin/iked/ikev2_msg.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/sbin/iked/ikev2_msg.c b/sbin/iked/ikev2_msg.c index 85d82138539..115f2a459d2 100644 --- a/sbin/iked/ikev2_msg.c +++ b/sbin/iked/ikev2_msg.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ikev2_msg.c,v 1.1 2010/06/10 08:29:47 reyk Exp $ */ +/* $OpenBSD: ikev2_msg.c,v 1.2 2010/06/14 08:10:32 reyk Exp $ */ /* $vantronix: ikev2.c,v 1.101 2010/06/03 07:57:33 reyk Exp $ */ /* @@ -786,3 +786,37 @@ ikev2_msg_authsign(struct iked *env, struct iked_sa *sa, return (ret); } + +int +ikev2_msg_frompeer(struct iked_message *msg) +{ + struct iked_sa *sa = msg->msg_sa; + struct ike_header *hdr; + + if (sa == NULL || + (hdr = ibuf_seek(msg->msg_data, 0, sizeof(*hdr))) == NULL) + return (0); + + if (!sa->sa_hdr.sh_initiator && + (hdr->ike_flags & IKEV2_FLAG_INITIATOR)) + return (1); + else if (sa->sa_hdr.sh_initiator && + (hdr->ike_flags & IKEV2_FLAG_INITIATOR) == 0) + return (1); + + return (0); +} + +struct iked_socket * +ikev2_msg_getsocket(struct iked *env, int af) +{ + switch (af) { + case AF_INET: + return (env->sc_sock4); + case AF_INET6: + return (env->sc_sock6); + } + + log_debug("%s: af socket %d not available", __func__, af); + return (NULL); +} |