Annotation of embedaddon/strongswan/src/libimcv/imv/imv_msg.h, 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: /**
                     17:  * @defgroup imv_msg_t imv_msg
                     18:  * @{ @ingroup libimcv_imv
                     19:  */
                     20: 
                     21: #ifndef IMV_MSG_H_
                     22: #define IMV_MSG_H_
                     23: 
                     24: #include <imv/imv_agent.h>
                     25: 
                     26: typedef struct imv_msg_t imv_msg_t;
                     27: 
                     28: #include <library.h>
                     29: 
                     30: /**
                     31:  * Interface for a PA-TNC message handled by an IMV.
                     32:  *
                     33:  */
                     34: struct imv_msg_t {
                     35: 
                     36:        /**
                     37:         * Get source ID of PA-TNC message
                     38:         *
                     39:         * @return                                      src ID
                     40:         */
                     41:        TNC_UInt32 (*get_src_id)(imv_msg_t *this);
                     42: 
                     43:        /**
                     44:         * Get destination ID of PA-TNC message
                     45:         *
                     46:         * @return                                      destination ID
                     47:         */
                     48:        TNC_UInt32 (*get_dst_id)(imv_msg_t *this);
                     49: 
                     50:        /**
                     51:         * Set the type of a PA-TNC message
                     52:         *
                     53:         * @param msg_type                      message type
                     54:         */
                     55:        void (*set_msg_type)(imv_msg_t *this, pen_type_t msg_type);
                     56: 
                     57:        /**
                     58:         * Get the type of a PA-TNC message.
                     59:         *
                     60:         * @return                                      message type
                     61:         */
                     62:        pen_type_t (*get_msg_type)(imv_msg_t *this);
                     63: 
                     64:        /**
                     65:         * Sends one or multiple PA-TNC messages
                     66:         *
                     67:         * @param excl                          set the excl message flag if supported
                     68:         * @return                                      TNC result code
                     69:         */
                     70:        TNC_Result (*send)(imv_msg_t *this, bool excl);
                     71: 
                     72:        /**
                     73:         * Send a PA-TNC message containing an IETF Assessment Result attribute
                     74:         *
                     75:         * @return                                      TNC result code
                     76:         */
                     77:        TNC_Result (*send_assessment)(imv_msg_t *this);
                     78: 
                     79:        /**
                     80:         * Processes a received PA-TNC message
                     81:         *
                     82:         * @param out_msg                       outgoing PA-TN message
                     83:         * @param fatal_error           TRUE if IMC sent a fatal error message
                     84:         * @return                                      TNC result code
                     85:         */
                     86:        TNC_Result (*receive)(imv_msg_t *this, imv_msg_t *out_msg,
                     87:                                                  bool *fatal_error);
                     88: 
                     89:        /**
                     90:         * Add a PA-TNC attribute to the send queue
                     91:         *
                     92:         * @param attr                          PA-TNC attribute to be added
                     93:         */
                     94:        void (*add_attribute)(imv_msg_t *this, pa_tnc_attr_t *attr);
                     95: 
                     96:        /**
                     97:         * Get the number of PA-TNC attributes in the send queue
                     98:         *
                     99:         * @return                                      number of PA-TNC attribute in send queue
                    100:         */
                    101:        int (*get_attribute_count)(imv_msg_t *this);
                    102: 
                    103:        /**
                    104:         * Enumerator over PA-TNC attributes contained in the PA-TNC message
                    105:         *
                    106:         * @return                                      PA-TNC attribute enumerator
                    107:         */
                    108:        enumerator_t* (*create_attribute_enumerator)(imv_msg_t *this);
                    109: 
                    110:        /**
                    111:         * Get the full encoding of an IMV message.
                    112:         *
                    113:         * @return                                      message encoding, internal data
                    114:         */
                    115:        chunk_t (*get_encoding)(imv_msg_t *this);
                    116: 
                    117:        /**
                    118:         * Destroys a imv_msg_t object.
                    119:         */
                    120:        void (*destroy)(imv_msg_t *this);
                    121: };
                    122: 
                    123: /**
                    124:  * Create a wrapper for an outbound message
                    125:  *
                    126:  * @param agent                                        IMV agent responsible for the message
                    127:  * @param state                                        IMV state for the given connection ID
                    128:  * @param connection_id                        connection ID
                    129:  * @param src_id                               source IMV ID
                    130:  * @param dst_id                               destination IMC ID
                    131:  * @param msg_type                             PA-TNC message type
                    132:  */
                    133: imv_msg_t* imv_msg_create(imv_agent_t *agent, imv_state_t *state,
                    134:                                                  TNC_ConnectionID connection_id,
                    135:                                                  TNC_UInt32 src_id, TNC_UInt32 dst_id,
                    136:                                                  pen_type_t msg_type);
                    137: 
                    138: /**
                    139:  * Create a wrapper for an outbound message based on a received message
                    140:  *
                    141:  * @param msg                                  received message the reply is based on
                    142:  */
                    143: imv_msg_t* imv_msg_create_as_reply(imv_msg_t *msg);
                    144: 
                    145: /**
                    146:  * Create a wrapper around message data received via the legacy IF-IMV interface
                    147:  *
                    148:  * @param agent                                        IMV agent responsible for the message
                    149:  * @param state                                        IMV state for the given connection ID
                    150:  * @param connection_id                        connection ID
                    151:  * @param msg_type                             PA-TNC message type
                    152:  * @param msg                                  received PA-TNC message blob
                    153:  */
                    154: imv_msg_t* imv_msg_create_from_data(imv_agent_t *agent, imv_state_t *state,
                    155:                                                                        TNC_ConnectionID connection_id,
                    156:                                                                        TNC_MessageType msg_type,
                    157:                                                                        chunk_t msg);
                    158: 
                    159: /**
                    160:  * Create a wrapper around message data received via the long IF-IMV interface
                    161:  *
                    162:  * @param agent                                        IMV agent responsible for the message
                    163:  * @param state                                        IMV state for the given connection ID
                    164:  * @param connection_id                        connection ID
                    165:  * @param src_id                               source IMC ID
                    166:  * @param dst_id                               destination IMV ID
                    167:  * @param msg_vid                              PA-TNC message vendor ID
                    168:  * @param msg_subtype                  PA-TNC subtype
                    169:  * @param msg                                  received PA-TNC message blob
                    170:  */
                    171: imv_msg_t* imv_msg_create_from_long_data(imv_agent_t *agent, imv_state_t *state,
                    172:                                                                                 TNC_ConnectionID connection_id,
                    173:                                                                                 TNC_UInt32 src_id, TNC_UInt32 dst_id,
                    174:                                                                                 TNC_VendorID msg_vid,
                    175:                                                                                 TNC_MessageSubtype msg_subtype,
                    176:                                                                                 chunk_t msg);
                    177: 
                    178: #endif /** IMV_MSG_H_ @}*/

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