Annotation of embedaddon/strongswan/src/libcharon/plugins/tnc_ifmap/tnc_ifmap_renew_session_job.c, revision 1.1

1.1     ! misho       1: /*
        !             2:  * Copyright (C) 2013 Andreas Steffen
        !             3:  * HSR Hochschule fuer Technik Rapperswil
        !             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 <stdlib.h>
        !            17: 
        !            18: #include "tnc_ifmap_renew_session_job.h"
        !            19: 
        !            20: #include <daemon.h>
        !            21: 
        !            22: 
        !            23: typedef struct private_tnc_ifmap_renew_session_job_t private_tnc_ifmap_renew_session_job_t;
        !            24: 
        !            25: /**
        !            26:  * Private data
        !            27:  */
        !            28: struct private_tnc_ifmap_renew_session_job_t {
        !            29: 
        !            30:        /**
        !            31:         * public tnc_ifmap_renew_session_job_t interface
        !            32:         */
        !            33:        tnc_ifmap_renew_session_job_t public;
        !            34: 
        !            35:        /**
        !            36:         * TNC IF-MAP 2.0 SOAP interface
        !            37:         */
        !            38:        tnc_ifmap_soap_t *ifmap;
        !            39: 
        !            40:        /**
        !            41:         * Reschedule time interval in seconds
        !            42:         */
        !            43:        uint32_t reschedule;
        !            44: };
        !            45: 
        !            46: METHOD(job_t, destroy, void,
        !            47:        private_tnc_ifmap_renew_session_job_t *this)
        !            48: {
        !            49:        this->ifmap->destroy(this->ifmap);
        !            50:        free(this);
        !            51: }
        !            52: 
        !            53: METHOD(job_t, execute, job_requeue_t,
        !            54:        private_tnc_ifmap_renew_session_job_t *this)
        !            55: {
        !            56:        char *session_id;
        !            57: 
        !            58:        if (this->ifmap->orphaned(this->ifmap))
        !            59:        {
        !            60:                session_id = this->ifmap->get_session_id(this->ifmap);
        !            61:                DBG2(DBG_TNC, "removing orphaned ifmap renewSession job for '%s'",
        !            62:                                           session_id);
        !            63:                return JOB_REQUEUE_NONE;
        !            64:        }
        !            65:        else
        !            66:        {
        !            67:                if (!this->ifmap->renewSession(this->ifmap))
        !            68:                {
        !            69:                        DBG1(DBG_TNC, "sending ifmap renewSession failed");
        !            70:                        /* TODO take some action */
        !            71:                }
        !            72:                return JOB_RESCHEDULE(this->reschedule);
        !            73:        }
        !            74: }
        !            75: 
        !            76: METHOD(job_t, get_priority, job_priority_t,
        !            77:        private_tnc_ifmap_renew_session_job_t *this)
        !            78: {
        !            79:        return JOB_PRIO_MEDIUM;
        !            80: }
        !            81: 
        !            82: /*
        !            83:  * Described in header
        !            84:  */
        !            85: tnc_ifmap_renew_session_job_t *tnc_ifmap_renew_session_job_create(
        !            86:                                                                tnc_ifmap_soap_t *ifmap, uint32_t reschedule)
        !            87: {
        !            88:        private_tnc_ifmap_renew_session_job_t *this;
        !            89: 
        !            90:        INIT(this,
        !            91:                .public = {
        !            92:                        .job_interface = {
        !            93:                                .execute = _execute,
        !            94:                                .get_priority = _get_priority,
        !            95:                                .destroy = _destroy,
        !            96:                        },
        !            97:                },
        !            98:                .ifmap = ifmap,
        !            99:                .reschedule = reschedule,
        !           100:        );
        !           101: 
        !           102:        return &this->public;
        !           103: }

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