Annotation of embedaddon/strongswan/src/libimcv/ita/ita_attr_angel.c, revision 1.1.1.1

1.1       misho       1: /*
                      2:  * Copyright (C) 2012-2014 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 "ita_attr.h"
                     17: #include "ita_attr_angel.h"
                     18: 
                     19: #include <bio/bio_reader.h>
                     20: #include <bio/bio_writer.h>
                     21: #include <collections/linked_list.h>
                     22: #include <pen/pen.h>
                     23: #include <utils/debug.h>
                     24: 
                     25: typedef struct private_ita_attr_angel_t private_ita_attr_angel_t;
                     26: 
                     27: /**
                     28:  * Private data of an ita_attr_angel_t object.
                     29:  */
                     30: struct private_ita_attr_angel_t {
                     31: 
                     32:        /**
                     33:         * Public members of ita_attr_angel_t
                     34:         */
                     35:        ita_attr_angel_t public;
                     36: 
                     37:        /**
                     38:         * Vendor-specific attribute type
                     39:         */
                     40:        pen_type_t type;
                     41: 
                     42:        /**
                     43:         * Noskip flag
                     44:         */
                     45:        bool noskip_flag;
                     46: 
                     47:        /**
                     48:         * Reference count
                     49:         */
                     50:        refcount_t ref;
                     51: };
                     52: 
                     53: METHOD(pa_tnc_attr_t, get_type, pen_type_t,
                     54:        private_ita_attr_angel_t *this)
                     55: {
                     56:        return this->type;
                     57: }
                     58: 
                     59: METHOD(pa_tnc_attr_t, get_value, chunk_t,
                     60:        private_ita_attr_angel_t *this)
                     61: {
                     62:        return chunk_empty;
                     63: }
                     64: 
                     65: METHOD(pa_tnc_attr_t, get_noskip_flag, bool,
                     66:        private_ita_attr_angel_t *this)
                     67: {
                     68:        return this->noskip_flag;
                     69: }
                     70: 
                     71: METHOD(pa_tnc_attr_t, set_noskip_flag,void,
                     72:        private_ita_attr_angel_t *this, bool noskip)
                     73: {
                     74:        this->noskip_flag = noskip;
                     75: }
                     76: 
                     77: METHOD(pa_tnc_attr_t, build, void,
                     78:        private_ita_attr_angel_t *this)
                     79: {
                     80:        /* nothing to build */
                     81: }
                     82: 
                     83: METHOD(pa_tnc_attr_t, process, status_t,
                     84:        private_ita_attr_angel_t *this, uint32_t *offset)
                     85: {
                     86:        return SUCCESS;
                     87: }
                     88: 
                     89: METHOD(pa_tnc_attr_t, add_segment, void,
                     90:        private_ita_attr_angel_t *this, chunk_t segment)
                     91: {
                     92:        /* nothing to add */
                     93: }
                     94: 
                     95: METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
                     96:        private_ita_attr_angel_t *this)
                     97: {
                     98:        ref_get(&this->ref);
                     99:        return &this->public.pa_tnc_attribute;
                    100: }
                    101: 
                    102: METHOD(pa_tnc_attr_t, destroy, void,
                    103:        private_ita_attr_angel_t *this)
                    104: {
                    105:        if (ref_put(&this->ref))
                    106:        {
                    107:                free(this);
                    108:        }
                    109: }
                    110: 
                    111: /**
                    112:  * Described in header.
                    113:  */
                    114: pa_tnc_attr_t *ita_attr_angel_create(bool start)
                    115: {
                    116:        private_ita_attr_angel_t *this;
                    117: 
                    118:        INIT(this,
                    119:                .public = {
                    120:                        .pa_tnc_attribute = {
                    121:                                .get_type = _get_type,
                    122:                                .get_value = _get_value,
                    123:                                .get_noskip_flag = _get_noskip_flag,
                    124:                                .set_noskip_flag = _set_noskip_flag,
                    125:                                .build = _build,
                    126:                                .process = _process,
                    127:                                .add_segment = _add_segment,
                    128:                                .get_ref = _get_ref,
                    129:                                .destroy = _destroy,
                    130:                        },
                    131:                },
                    132:                .type = { PEN_ITA, start ? ITA_ATTR_START_ANGEL : ITA_ATTR_STOP_ANGEL },
                    133:                .ref = 1,
                    134:        );
                    135: 
                    136:        return &this->public.pa_tnc_attribute;
                    137: }
                    138: 
                    139: /**
                    140:  * Described in header.
                    141:  */
                    142: pa_tnc_attr_t *ita_attr_angel_create_from_data(bool start)
                    143: {
                    144:        private_ita_attr_angel_t *this;
                    145: 
                    146:        INIT(this,
                    147:                .public = {
                    148:                        .pa_tnc_attribute = {
                    149:                                .get_type = _get_type,
                    150:                                .get_value = _get_value,
                    151:                                .get_noskip_flag = _get_noskip_flag,
                    152:                                .set_noskip_flag = _set_noskip_flag,
                    153:                                .build = _build,
                    154:                                .process = _process,
                    155:                                .add_segment = _add_segment,
                    156:                                .get_ref = _get_ref,
                    157:                                .destroy = _destroy,
                    158:                        },
                    159:                },
                    160:                .type = { PEN_ITA, start ? ITA_ATTR_START_ANGEL : ITA_ATTR_STOP_ANGEL },
                    161:                .ref = 1,
                    162:        );
                    163: 
                    164:        return &this->public.pa_tnc_attribute;
                    165: }
                    166: 
                    167: 

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