Annotation of embedaddon/strongswan/src/libcharon/sa/ikev1/tasks/isakmp_dpd.c, revision 1.1

1.1     ! misho       1: /*
        !             2:  * Copyright (C) 2011 Martin Willi
        !             3:  * Copyright (C) 2011 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 "isakmp_dpd.h"
        !            17: 
        !            18: #include <daemon.h>
        !            19: #include <encoding/payloads/notify_payload.h>
        !            20: 
        !            21: typedef struct private_isakmp_dpd_t private_isakmp_dpd_t;
        !            22: 
        !            23: /**
        !            24:  * Private members of a isakmp_dpd_t task.
        !            25:  */
        !            26: struct private_isakmp_dpd_t {
        !            27: 
        !            28:        /**
        !            29:         * Public methods and task_t interface.
        !            30:         */
        !            31:        isakmp_dpd_t public;
        !            32: 
        !            33:        /**
        !            34:         * Sequence number.
        !            35:         */
        !            36:        uint32_t seqnr;
        !            37: 
        !            38:        /**
        !            39:         * DPD notify type
        !            40:         */
        !            41:        notify_type_t type;
        !            42: 
        !            43:        /**
        !            44:         * IKE SA we are serving.
        !            45:         */
        !            46:        ike_sa_t *ike_sa;
        !            47: };
        !            48: 
        !            49: METHOD(task_t, build, status_t,
        !            50:        private_isakmp_dpd_t *this, message_t *message)
        !            51: {
        !            52:        notify_payload_t *notify;
        !            53:        ike_sa_id_t *ike_sa_id;
        !            54:        uint64_t spi_i, spi_r;
        !            55:        uint32_t seqnr;
        !            56:        chunk_t spi;
        !            57: 
        !            58:        notify = notify_payload_create_from_protocol_and_type(PLV1_NOTIFY,
        !            59:                                                                                                                  PROTO_IKE, this->type);
        !            60:        seqnr = htonl(this->seqnr);
        !            61:        ike_sa_id = this->ike_sa->get_id(this->ike_sa);
        !            62:        spi_i = ike_sa_id->get_initiator_spi(ike_sa_id);
        !            63:        spi_r = ike_sa_id->get_responder_spi(ike_sa_id);
        !            64:        spi = chunk_cata("cc", chunk_from_thing(spi_i), chunk_from_thing(spi_r));
        !            65: 
        !            66:        notify->set_spi_data(notify, spi);
        !            67:        notify->set_notification_data(notify, chunk_from_thing(seqnr));
        !            68: 
        !            69:        message->add_payload(message, (payload_t*)notify);
        !            70: 
        !            71:        return SUCCESS;
        !            72: }
        !            73: 
        !            74: METHOD(task_t, process, status_t,
        !            75:        private_isakmp_dpd_t *this, message_t *message)
        !            76: {
        !            77:        /* done in task manager */
        !            78:        return FAILED;
        !            79: }
        !            80: 
        !            81: METHOD(task_t, get_type, task_type_t,
        !            82:        private_isakmp_dpd_t *this)
        !            83: {
        !            84:        return TASK_ISAKMP_DPD;
        !            85: }
        !            86: 
        !            87: METHOD(task_t, migrate, void,
        !            88:        private_isakmp_dpd_t *this, ike_sa_t *ike_sa)
        !            89: {
        !            90:        this->ike_sa = ike_sa;
        !            91: }
        !            92: 
        !            93: METHOD(task_t, destroy, void,
        !            94:        private_isakmp_dpd_t *this)
        !            95: {
        !            96:        free(this);
        !            97: }
        !            98: 
        !            99: /*
        !           100:  * Described in header.
        !           101:  */
        !           102: isakmp_dpd_t *isakmp_dpd_create(ike_sa_t *ike_sa, notify_type_t type,
        !           103:                                                                uint32_t seqnr)
        !           104: {
        !           105:        private_isakmp_dpd_t *this;
        !           106: 
        !           107:        INIT(this,
        !           108:                .public = {
        !           109:                        .task = {
        !           110:                                .get_type = _get_type,
        !           111:                                .build = _build,
        !           112:                                .process = _process,
        !           113:                                .migrate = _migrate,
        !           114:                                .destroy = _destroy,
        !           115:                        },
        !           116:                },
        !           117:                .ike_sa = ike_sa,
        !           118:                .seqnr = seqnr,
        !           119:                .type = type,
        !           120:        );
        !           121: 
        !           122:        return &this->public;
        !           123: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>