Add getters for the raw encoding in IMV/IMC messages
authorMartin Willi <martin@revosec.ch>
Mon, 19 Nov 2012 15:11:59 +0000 (16:11 +0100)
committerMartin Willi <martin@revosec.ch>
Fri, 30 Nov 2012 14:49:07 +0000 (15:49 +0100)
src/libimcv/imc/imc_msg.c
src/libimcv/imc/imc_msg.h
src/libimcv/imv/imv_msg.c
src/libimcv/imv/imv_msg.h

index 250f5c7..a03bbc3 100644 (file)
@@ -347,6 +347,16 @@ METHOD(imc_msg_t, create_attribute_enumerator, enumerator_t*,
        return this->pa_msg->create_attribute_enumerator(this->pa_msg);
 }
 
+METHOD(imc_msg_t, get_encoding, chunk_t,
+       private_imc_msg_t *this)
+{
+       if (this->pa_msg)
+       {
+               return this->pa_msg->get_encoding(this->pa_msg);
+       }
+       return chunk_empty;
+}
+
 METHOD(imc_msg_t, destroy, void,
        private_imc_msg_t *this)
 {
@@ -374,6 +384,7 @@ imc_msg_t *imc_msg_create(imc_agent_t *agent, imc_state_t *state,
                        .receive = _receive,
                        .add_attribute = _add_attribute,
                        .create_attribute_enumerator = _create_attribute_enumerator,
+                       .get_encoding = _get_encoding,
                        .destroy = _destroy,
                },
                .connection_id = connection_id,
@@ -444,6 +455,7 @@ imc_msg_t *imc_msg_create_from_long_data(imc_agent_t *agent, imc_state_t *state,
                        .receive = _receive,
                        .add_attribute = _add_attribute,
                        .create_attribute_enumerator = _create_attribute_enumerator,
+                       .get_encoding = _get_encoding,
                        .destroy = _destroy,
                },
                .connection_id = connection_id,
index 7c7d75a..6dd712e 100644 (file)
@@ -78,6 +78,13 @@ struct imc_msg_t {
        enumerator_t* (*create_attribute_enumerator)(imc_msg_t *this);
 
        /**
+        * Get the encoding of the IMC message.
+        *
+        * @return                                      message encoding, internal data
+        */
+       chunk_t (*get_encoding)(imc_msg_t *this);
+
+       /**
         * Destroys a imc_msg_t object.
         */
        void (*destroy)(imc_msg_t *this);
index 9ec297b..5555f95 100644 (file)
@@ -323,6 +323,16 @@ METHOD(imv_msg_t, create_attribute_enumerator, enumerator_t*,
        return this->pa_msg->create_attribute_enumerator(this->pa_msg);
 }
 
+METHOD(imv_msg_t, get_encoding, chunk_t,
+       private_imv_msg_t *this)
+{
+       if (this->pa_msg)
+       {
+               return this->pa_msg->get_encoding(this->pa_msg);
+       }
+       return chunk_empty;
+}
+
 METHOD(imv_msg_t, destroy, void,
        private_imv_msg_t *this)
 {
@@ -353,6 +363,7 @@ imv_msg_t *imv_msg_create(imv_agent_t *agent, imv_state_t *state,
                        .add_attribute = _add_attribute,
                        .delete_attributes = _delete_attributes,
                        .create_attribute_enumerator = _create_attribute_enumerator,
+                       .get_encoding = _get_encoding,
                        .destroy = _destroy,
                },
                .connection_id = connection_id,
@@ -426,6 +437,7 @@ imv_msg_t *imv_msg_create_from_long_data(imv_agent_t *agent, imv_state_t *state,
                        .add_attribute = _add_attribute,
                        .delete_attributes = _delete_attributes,
                        .create_attribute_enumerator = _create_attribute_enumerator,
+                       .get_encoding = _get_encoding,
                        .destroy = _destroy,
                },
                .connection_id = connection_id,
index 4c39150..9234793 100644 (file)
@@ -98,6 +98,13 @@ struct imv_msg_t {
        enumerator_t* (*create_attribute_enumerator)(imv_msg_t *this);
 
        /**
+        * Get the full encoding of an IMV message.
+        *
+        * @return                                      message encoding, internal data
+        */
+       chunk_t (*get_encoding)(imv_msg_t *this);
+
+       /**
         * Destroys a imv_msg_t object.
         */
        void (*destroy)(imv_msg_t *this);