]> git.ipfire.org Git - thirdparty/strongswan.git/blame - src/conftest/hooks/log_ke.c
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / conftest / hooks / log_ke.c
CommitLineData
c6f2bac1
MW
1/*
2 * Copyright (C) 2010 Martin Willi
19ef2aec
TB
3 *
4 * Copyright (C) secunet Security Networks AG
c6f2bac1
MW
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 */
16
17#include "hook.h"
18
19#include <encoding/payloads/ke_payload.h>
20
21typedef struct private_log_ke_t private_log_ke_t;
22
23/**
24 * Private data of an log_ke_t object.
25 */
26struct private_log_ke_t {
27
28 /**
29 * Implements the hook_t interface.
30 */
31 hook_t hook;
32};
33
34METHOD(listener_t, message, bool,
35 private_log_ke_t *this, ike_sa_t *ike_sa, message_t *message,
47b8f6ef 36 bool incoming, bool plain)
c6f2bac1 37{
47b8f6ef 38 if (incoming && plain)
c6f2bac1 39 {
5d82b2d3 40 enumerator_t *enumerator;
c6f2bac1
MW
41 payload_t *payload;
42 ke_payload_t *ke;
43
44 enumerator = message->create_payload_enumerator(message);
45 while (enumerator->enumerate(enumerator, &payload))
46 {
3ecfc83c 47 if (payload->get_type(payload) == PLV2_KEY_EXCHANGE)
c6f2bac1
MW
48 {
49 ke = (ke_payload_t*)payload;
50 DBG1(DBG_CFG, "received DH group %N",
51 diffie_hellman_group_names, ke->get_dh_group_number(ke));
52 }
53 }
54 enumerator->destroy(enumerator);
55 }
56 return TRUE;
57}
58
59METHOD(hook_t, destroy, void,
60 private_log_ke_t *this)
61{
62 free(this);
63}
64
65/**
66 * Create the IKE_AUTH fill hook
67 */
68hook_t *log_ke_hook_create(char *name)
69{
70 private_log_ke_t *this;
71
72 INIT(this,
73 .hook = {
74 .listener = {
75 .message = _message,
76 },
77 .destroy = _destroy,
78 },
79 );
80
81 return &this->hook;
82}