Added request variable to get_info_string method
authorAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 19 Aug 2014 05:42:40 +0000 (07:42 +0200)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Fri, 3 Oct 2014 20:25:09 +0000 (22:25 +0200)
src/libimcv/imc/imc_msg.c
src/libimcv/imv/imv_msg.c
src/libimcv/seg_contract/seg_contract.c
src/libimcv/seg_contract/seg_contract.h
src/libpts/plugins/imv_swid/imv_swid_agent.c

index 4c4455e..9b9aeca 100644 (file)
@@ -305,7 +305,7 @@ METHOD(imc_msg_t, receive, TNC_Result,
                                                                        max_seg_size, FALSE, this->src_id, TRUE);
                                contracts->add_contract(contracts, contract);
                        }
-                       contract->get_info_string(contract, buf, BUF_LEN);
+                       contract->get_info_string(contract, buf, BUF_LEN, TRUE);
                        DBG2(DBG_IMC, "%s", buf);
 
                        /* Determine maximum PA-TNC attribute segment size */
@@ -348,7 +348,7 @@ METHOD(imc_msg_t, receive, TNC_Result,
                                        my_max_seg_size = max_seg_size;
                                        contract->set_max_size(contract, my_max_attr_size,
                                                                                                         my_max_seg_size);
-                                       contract->get_info_string(contract, buf, BUF_LEN);
+                                       contract->get_info_string(contract, buf, BUF_LEN, FALSE);
                                        DBG2(DBG_IMC, "%s", buf);
                                }
                        }
index e25857d..35209dc 100644 (file)
@@ -353,7 +353,7 @@ METHOD(imv_msg_t, receive, TNC_Result,
                                                                        max_seg_size, FALSE, this->src_id, FALSE);
                                contracts->add_contract(contracts, contract);
                        }
-                       contract->get_info_string(contract, buf, BUF_LEN);
+                       contract->get_info_string(contract, buf, BUF_LEN, TRUE);
                        DBG2(DBG_IMV, "%s", buf);
 
                        /* Determine maximum PA-TNC attribute segment size */
@@ -370,7 +370,6 @@ METHOD(imv_msg_t, receive, TNC_Result,
                        {
                                max_seg_size = my_max_seg_size;
                                contract->set_max_size(contract, max_attr_size, max_seg_size);
-                               contract->get_info_string(contract, buf, BUF_LEN);
                                DBG2(DBG_IMV, "  lowered maximum segment size to %u bytes",
                                         max_seg_size);
                        }
@@ -404,7 +403,7 @@ METHOD(imv_msg_t, receive, TNC_Result,
                                        my_max_seg_size = max_seg_size;
                                        contract->set_max_size(contract, my_max_attr_size,
                                                                                                         my_max_seg_size);
-                                       contract->get_info_string(contract, buf, BUF_LEN);
+                                       contract->get_info_string(contract, buf, BUF_LEN, FALSE);
                                        DBG2(DBG_IMV, "%s", buf);
                                }
                        }
index 729bcbc..dab2c23 100644 (file)
@@ -110,7 +110,7 @@ METHOD(seg_contract_t, is_null, bool,
 }
 
 METHOD(seg_contract_t, get_info_string, void,
-       private_seg_contract_t *this, char *buf, size_t len)
+       private_seg_contract_t *this, char *buf, size_t len, bool request)
 {
        enum_name_t *pa_subtype_names;
        uint32_t msg_vid, msg_subtype;
@@ -120,7 +120,7 @@ METHOD(seg_contract_t, get_info_string, void,
        /* nul-terminate the string buffer */
        buf[--len] = '\0';
 
-       if (this->is_issuer)
+       if (this->is_issuer && request)
        {
                written = snprintf(pos, len, "%s %d requests",
                                                  this->is_imc ? "IMC" : "IMV", this->issuer_id);
@@ -136,8 +136,8 @@ METHOD(seg_contract_t, get_info_string, void,
        pos += written;
        len -= written;
 
-       written = snprintf(pos, len, " a %ssegmentation contract ",
-                                          this->is_null ? "null" : "");
+       written = snprintf(pos, len, " a %ssegmentation contract%s ",
+                                          this->is_null ? "null" : "", request ? "" : " response");
        if (written < 0 || written > len)
        {
                return;
index eaa1142..26f55c9 100644 (file)
@@ -82,8 +82,10 @@ struct seg_contract_t {
         *
         * @param buf                           String buffer of at least size len
         * @param len                           Size of string buffer
+        * @param request                       TRUE if contract request, FALSE if response
         */
-       void (*get_info_string)(seg_contract_t *this, char *buf, size_t len);
+       void (*get_info_string)(seg_contract_t *this, char *buf, size_t len,
+                                                       bool request);
 
        /**
         * Destroys a seg_contract_t object.
index b17eb4a..80b4453 100644 (file)
@@ -455,7 +455,7 @@ METHOD(imv_agent_if_t, batch_ending, TNC_Result,
                                /* Announce support of PA-TNC segmentation to IMC */
                                contract = seg_contract_create(msg_types[0], max_attr_size,
                                                                        max_seg_size, TRUE, imv_id, FALSE);
-                               contract->get_info_string(contract, buf, BUF_LEN);
+                               contract->get_info_string(contract, buf, BUF_LEN, TRUE);
                                DBG2(DBG_IMV, "%s", buf);
                                contracts = state->get_contracts(state);
                                contracts->add_contract(contracts, contract);