summaryrefslogtreecommitdiff
path: root/src/libimcv/imv
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@debian.org>2015-10-22 11:43:58 +0200
committerYves-Alexis Perez <corsac@debian.org>2015-10-22 11:43:58 +0200
commit5dca9ea0e2931f0e2a056c7964d311bcc30a01b8 (patch)
tree037f1ec5bb860846938ddcf29771c24e9c529be0 /src/libimcv/imv
parentb238cf34df3fe4476ae6b7012e7cb3e9769d4d51 (diff)
downloadvyos-strongswan-5dca9ea0e2931f0e2a056c7964d311bcc30a01b8.tar.gz
vyos-strongswan-5dca9ea0e2931f0e2a056c7964d311bcc30a01b8.zip
Imported Upstream version 5.3.3
Diffstat (limited to 'src/libimcv/imv')
-rw-r--r--src/libimcv/imv/imv_msg.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/libimcv/imv/imv_msg.c b/src/libimcv/imv/imv_msg.c
index fdf63325d..039124c2a 100644
--- a/src/libimcv/imv/imv_msg.c
+++ b/src/libimcv/imv/imv_msg.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012-2014 Andreas Steffen
+ * Copyright (C) 2012-2015 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -125,6 +125,7 @@ METHOD(imv_msg_t, send_, TNC_Result,
pa_tnc_attr_t *attr;
TNC_UInt32 msg_flags;
TNC_MessageType msg_type;
+ size_t max_msg_len, min_seg_attr_len, space_left;
bool attr_added, oversize;
chunk_t msg;
seg_contract_t *contract;
@@ -137,23 +138,37 @@ METHOD(imv_msg_t, send_, TNC_Result,
contract = contracts->get_contract(contracts, this->msg_type,
FALSE, this->dst_id);
+ /* Retrieve maximum allowed PA-TNC message size if set */
+ max_msg_len = this->state->get_max_msg_len(this->state);
+
+ /* Minimum size needed for Segmentation Envelope Attribute */
+ min_seg_attr_len = PA_TNC_ATTR_HEADER_SIZE + TCG_SEG_ATTR_SEG_ENV_HEADER +
+ PA_TNC_ATTR_HEADER_SIZE;
+
while (this->attr_list->get_count(this->attr_list))
{
- pa_tnc_msg = pa_tnc_msg_create(this->state->get_max_msg_len(this->state));
+ pa_tnc_msg = pa_tnc_msg_create(max_msg_len);
attr_added = FALSE;
enumerator = this->attr_list->create_enumerator(this->attr_list);
while (enumerator->enumerate(enumerator, &attr))
{
+ space_left = pa_tnc_msg->get_space(pa_tnc_msg);
+
if (contract && contract->check_size(contract, attr, &oversize))
{
if (oversize)
{
- /* TODO generate SWID error msg */
+ /* TODO handle oversized attributes */
+ }
+ else if (max_msg_len == 0 || space_left >= min_seg_attr_len)
+ {
+ attr = contract->first_segment(contract, attr, space_left);
}
else
{
- attr = contract->first_segment(contract, attr);
+ /* segment attribute in next iteration */
+ break;
}
}
if (pa_tnc_msg->add_attribute(pa_tnc_msg, attr))
@@ -164,6 +179,7 @@ METHOD(imv_msg_t, send_, TNC_Result,
{
if (attr_added)
{
+ /* there might be space for attribute in next iteration */
break;
}
else
@@ -377,9 +393,7 @@ METHOD(imv_msg_t, receive, TNC_Result,
my_max_seg_size = this->state->get_max_msg_len(this->state)
- PA_TNC_HEADER_SIZE
- PA_TNC_ATTR_HEADER_SIZE
- - TCG_SEG_ATTR_SEG_ENV_HEADER
- - PA_TNC_ATTR_HEADER_SIZE
- - TCG_SEG_ATTR_MAX_SIZE_SIZE;
+ - TCG_SEG_ATTR_SEG_ENV_HEADER;
/* If segmentation is possible select lower segment size */
if (max_seg_size != SEG_CONTRACT_NO_FRAGMENTATION &&