Annotation of embedaddon/strongswan/src/conftest/hooks/log_id.c, revision 1.1
1.1 ! misho 1: /*
! 2: * Copyright (C) 2010 Martin Willi
! 3: * Copyright (C) 2010 revosec AG
! 4: *
! 5: * This program is free software; you can redistribute it and/or modify it
! 6: * under the terms of the GNU General Public License as published by the
! 7: * Free Software Foundation; either version 2 of the License, or (at your
! 8: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
! 9: *
! 10: * This program is distributed in the hope that it will be useful, but
! 11: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
! 12: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
! 13: * for more details.
! 14: */
! 15:
! 16: #include "hook.h"
! 17:
! 18: #include <encoding/payloads/id_payload.h>
! 19:
! 20: typedef struct private_log_id_t private_log_id_t;
! 21:
! 22: /**
! 23: * Private data of an log_id_t object.
! 24: */
! 25: struct private_log_id_t {
! 26:
! 27: /**
! 28: * Implements the hook_t interface.
! 29: */
! 30: hook_t hook;
! 31: };
! 32:
! 33: METHOD(listener_t, message, bool,
! 34: private_log_id_t *this, ike_sa_t *ike_sa, message_t *message,
! 35: bool incoming, bool plain)
! 36: {
! 37: if (incoming && plain)
! 38: {
! 39: enumerator_t *enumerator;
! 40: payload_t *payload;
! 41: id_payload_t *id_payload;
! 42: identification_t *id;
! 43: chunk_t data;
! 44:
! 45: enumerator = message->create_payload_enumerator(message);
! 46: while (enumerator->enumerate(enumerator, &payload))
! 47: {
! 48: if (payload->get_type(payload) == PLV2_ID_INITIATOR ||
! 49: payload->get_type(payload) == PLV2_ID_RESPONDER)
! 50: {
! 51: id_payload = (id_payload_t*)payload;
! 52: id = id_payload->get_identification(id_payload);
! 53: data = id->get_encoding(id);
! 54:
! 55: DBG1(DBG_CFG, "%N: %N %B",
! 56: payload_type_short_names, payload->get_type(payload),
! 57: id_type_names, id->get_type(id), &data);
! 58: id->destroy(id);
! 59: }
! 60: }
! 61: enumerator->destroy(enumerator);
! 62: }
! 63: return TRUE;
! 64: }
! 65:
! 66: METHOD(hook_t, destroy, void,
! 67: private_log_id_t *this)
! 68: {
! 69: free(this);
! 70: }
! 71:
! 72: /**
! 73: * Create the IKE_AUTH fill hook
! 74: */
! 75: hook_t *log_id_hook_create(char *name)
! 76: {
! 77: private_log_id_t *this;
! 78:
! 79: INIT(this,
! 80: .hook = {
! 81: .listener = {
! 82: .message = _message,
! 83: },
! 84: .destroy = _destroy,
! 85: },
! 86: );
! 87:
! 88: return &this->hook;
! 89: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>