summaryrefslogtreecommitdiff
path: root/src/libimcv/ita
diff options
context:
space:
mode:
Diffstat (limited to 'src/libimcv/ita')
-rw-r--r--src/libimcv/ita/ita_attr.c19
-rw-r--r--src/libimcv/ita/ita_attr.h8
-rw-r--r--src/libimcv/ita/ita_attr_angel.c12
-rw-r--r--src/libimcv/ita/ita_attr_angel.h5
-rw-r--r--src/libimcv/ita/ita_attr_command.c30
-rw-r--r--src/libimcv/ita/ita_attr_command.h7
-rw-r--r--src/libimcv/ita/ita_attr_device_id.c27
-rw-r--r--src/libimcv/ita/ita_attr_device_id.h7
-rw-r--r--src/libimcv/ita/ita_attr_dummy.c34
-rw-r--r--src/libimcv/ita/ita_attr_dummy.h9
-rw-r--r--src/libimcv/ita/ita_attr_get_settings.c29
-rw-r--r--src/libimcv/ita/ita_attr_get_settings.h8
-rw-r--r--src/libimcv/ita/ita_attr_settings.c28
-rw-r--r--src/libimcv/ita/ita_attr_settings.h5
14 files changed, 171 insertions, 57 deletions
diff --git a/src/libimcv/ita/ita_attr.c b/src/libimcv/ita/ita_attr.c
index f3956717d..9d7706dba 100644
--- a/src/libimcv/ita/ita_attr.c
+++ b/src/libimcv/ita/ita_attr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2012 Andreas Steffen
+ * Copyright (C) 2011-2014 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -35,24 +35,25 @@ ENUM(ita_attr_names, ITA_ATTR_COMMAND, ITA_ATTR_DEVICE_ID,
/**
* See header
*/
-pa_tnc_attr_t* ita_attr_create_from_data(u_int32_t type, chunk_t value)
+pa_tnc_attr_t* ita_attr_create_from_data(u_int32_t type, size_t length,
+ chunk_t value)
{
switch (type)
{
case ITA_ATTR_COMMAND:
- return ita_attr_command_create_from_data(value);
+ return ita_attr_command_create_from_data(length, value);
case ITA_ATTR_DUMMY:
- return ita_attr_dummy_create_from_data(value);
+ return ita_attr_dummy_create_from_data(length, value);
case ITA_ATTR_GET_SETTINGS:
- return ita_attr_get_settings_create_from_data(value);
+ return ita_attr_get_settings_create_from_data(length, value);
case ITA_ATTR_SETTINGS:
- return ita_attr_settings_create_from_data(value);
+ return ita_attr_settings_create_from_data(length, value);
case ITA_ATTR_START_ANGEL:
- return ita_attr_angel_create_from_data(TRUE, value);
+ return ita_attr_angel_create_from_data(TRUE);
case ITA_ATTR_STOP_ANGEL:
- return ita_attr_angel_create_from_data(FALSE, value);
+ return ita_attr_angel_create_from_data(FALSE);
case ITA_ATTR_DEVICE_ID:
- return ita_attr_device_id_create_from_data(value);
+ return ita_attr_device_id_create_from_data(length, value);
default:
return NULL;
}
diff --git a/src/libimcv/ita/ita_attr.h b/src/libimcv/ita/ita_attr.h
index ac5d8abaa..7378a1cbe 100644
--- a/src/libimcv/ita/ita_attr.h
+++ b/src/libimcv/ita/ita_attr.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2012 Andreas Steffen
+ * Copyright (C) 2011-2014 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -50,8 +50,10 @@ extern enum_name_t *ita_attr_names;
* Create a ITA PA-TNC attribute from data
*
* @param type attribute type
- * @param value attribute value
+ * @param length attribute length
+ * @param value attribute value or segment
*/
-pa_tnc_attr_t* ita_attr_create_from_data(u_int32_t type, chunk_t value);
+pa_tnc_attr_t* ita_attr_create_from_data(u_int32_t type, size_t length,
+ chunk_t value);
#endif /** ITA_ATTR_H_ @}*/
diff --git a/src/libimcv/ita/ita_attr_angel.c b/src/libimcv/ita/ita_attr_angel.c
index 0e9cff0a9..110863608 100644
--- a/src/libimcv/ita/ita_attr_angel.c
+++ b/src/libimcv/ita/ita_attr_angel.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -86,6 +86,12 @@ METHOD(pa_tnc_attr_t, process, status_t,
return SUCCESS;
}
+METHOD(pa_tnc_attr_t, add_segment, void,
+ private_ita_attr_angel_t *this, chunk_t segment)
+{
+ /* nothing to add */
+}
+
METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
private_ita_attr_angel_t *this)
{
@@ -118,6 +124,7 @@ pa_tnc_attr_t *ita_attr_angel_create(bool start)
.set_noskip_flag = _set_noskip_flag,
.build = _build,
.process = _process,
+ .add_segment = _add_segment,
.get_ref = _get_ref,
.destroy = _destroy,
},
@@ -132,7 +139,7 @@ pa_tnc_attr_t *ita_attr_angel_create(bool start)
/**
* Described in header.
*/
-pa_tnc_attr_t *ita_attr_angel_create_from_data(bool start, chunk_t data)
+pa_tnc_attr_t *ita_attr_angel_create_from_data(bool start)
{
private_ita_attr_angel_t *this;
@@ -145,6 +152,7 @@ pa_tnc_attr_t *ita_attr_angel_create_from_data(bool start, chunk_t data)
.set_noskip_flag = _set_noskip_flag,
.build = _build,
.process = _process,
+ .add_segment = _add_segment,
.get_ref = _get_ref,
.destroy = _destroy,
},
diff --git a/src/libimcv/ita/ita_attr_angel.h b/src/libimcv/ita/ita_attr_angel.h
index d42e7119a..8cd979b01 100644
--- a/src/libimcv/ita/ita_attr_angel.h
+++ b/src/libimcv/ita/ita_attr_angel.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -49,8 +49,7 @@ pa_tnc_attr_t* ita_attr_angel_create(bool start);
* Creates an ita_attr_angel_t object from received data
*
* @param start TRUE for Start, FALSE for Stop Angel attribute
- * @param value binary value blob
*/
-pa_tnc_attr_t* ita_attr_angel_create_from_data(bool start, chunk_t value);
+pa_tnc_attr_t* ita_attr_angel_create_from_data(bool start);
#endif /** ITA_ATTR_ANGEL_H_ @}*/
diff --git a/src/libimcv/ita/ita_attr_command.c b/src/libimcv/ita/ita_attr_command.c
index 9692e1ffd..a6b187f13 100644
--- a/src/libimcv/ita/ita_attr_command.c
+++ b/src/libimcv/ita/ita_attr_command.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011-2012 Andreas Steffen
+ * Copyright (C) 2011-2014 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -40,7 +40,12 @@ struct private_ita_attr_command_t {
pen_type_t type;
/**
- * Attribute value
+ * Length of attribute value
+ */
+ size_t length;
+
+ /**
+ * Attribute value or segment
*/
chunk_t value;
@@ -91,18 +96,30 @@ METHOD(pa_tnc_attr_t, build, void,
{
return;
}
- this->value = chunk_create(this->command, strlen(this->command));
- this->value = chunk_clone(this->value);
+ this->value = chunk_clone(chunk_from_str(this->command));
+ this->length = this->value.len;
}
METHOD(pa_tnc_attr_t, process, status_t,
private_ita_attr_command_t *this, u_int32_t *offset)
{
+ *offset = 0;
+
+ if (this->value.len < this->length)
+ {
+ return NEED_MORE;
+ }
this->command = strndup(this->value.ptr, this->value.len);
return SUCCESS;
}
+METHOD(pa_tnc_attr_t, add_segment, void,
+ private_ita_attr_command_t *this, chunk_t segment)
+{
+ this->value = chunk_cat("mc", this->value, segment);
+}
+
METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
private_ita_attr_command_t *this)
{
@@ -143,6 +160,7 @@ pa_tnc_attr_t *ita_attr_command_create(char *command)
.set_noskip_flag = _set_noskip_flag,
.build = _build,
.process = _process,
+ .add_segment = _add_segment,
.get_ref = _get_ref,
.destroy = _destroy,
},
@@ -159,7 +177,7 @@ pa_tnc_attr_t *ita_attr_command_create(char *command)
/**
* Described in header.
*/
-pa_tnc_attr_t *ita_attr_command_create_from_data(chunk_t data)
+pa_tnc_attr_t *ita_attr_command_create_from_data(size_t length, chunk_t data)
{
private_ita_attr_command_t *this;
@@ -172,12 +190,14 @@ pa_tnc_attr_t *ita_attr_command_create_from_data(chunk_t data)
.set_noskip_flag = _set_noskip_flag,
.build = _build,
.process = _process,
+ .add_segment = _add_segment,
.get_ref = _get_ref,
.destroy = _destroy,
},
.get_command = _get_command,
},
.type = {PEN_ITA, ITA_ATTR_COMMAND },
+ .length = length,
.value = chunk_clone(data),
.ref = 1,
);
diff --git a/src/libimcv/ita/ita_attr_command.h b/src/libimcv/ita/ita_attr_command.h
index 3926c3887..dd4701e12 100644
--- a/src/libimcv/ita/ita_attr_command.h
+++ b/src/libimcv/ita/ita_attr_command.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Andreas Steffen
+ * Copyright (C) 2011-2014 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -54,8 +54,9 @@ pa_tnc_attr_t* ita_attr_command_create(char *command);
/**
* Creates an ita_attr_command_t object from received data
*
- * @param value binary value blob
+ * @param length Total length of attribute value
+ * @param value Unparsed attribute value (might be a segment)
*/
-pa_tnc_attr_t* ita_attr_command_create_from_data(chunk_t value);
+pa_tnc_attr_t* ita_attr_command_create_from_data(size_t length, chunk_t value);
#endif /** ITA_ATTR_COMMAND_H_ @}*/
diff --git a/src/libimcv/ita/ita_attr_device_id.c b/src/libimcv/ita/ita_attr_device_id.c
index 36907eb34..232842695 100644
--- a/src/libimcv/ita/ita_attr_device_id.c
+++ b/src/libimcv/ita/ita_attr_device_id.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Andreas Steffen
+ * Copyright (C) 2013-2014 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -38,7 +38,12 @@ struct private_ita_attr_device_id_t {
pen_type_t type;
/**
- * Attribute value
+ * Length of attribute value
+ */
+ size_t length;
+
+ /**
+ * Attribute value or segment
*/
chunk_t value;
@@ -86,9 +91,21 @@ METHOD(pa_tnc_attr_t, build, void,
METHOD(pa_tnc_attr_t, process, status_t,
private_ita_attr_device_id_t *this, u_int32_t *offset)
{
+ *offset = 0;
+
+ if (this->value.len < this->length)
+ {
+ return NEED_MORE;
+ }
return SUCCESS;
}
+METHOD(pa_tnc_attr_t, add_segment, void,
+ private_ita_attr_device_id_t *this, chunk_t segment)
+{
+ this->value = chunk_cat("mc", this->value, segment);
+}
+
METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
private_ita_attr_device_id_t *this)
{
@@ -109,7 +126,7 @@ METHOD(pa_tnc_attr_t, destroy, void,
/**
* Described in header.
*/
-pa_tnc_attr_t *ita_attr_device_id_create_from_data(chunk_t value)
+pa_tnc_attr_t *ita_attr_device_id_create_from_data(size_t length, chunk_t value)
{
private_ita_attr_device_id_t *this;
@@ -122,11 +139,13 @@ pa_tnc_attr_t *ita_attr_device_id_create_from_data(chunk_t value)
.set_noskip_flag = _set_noskip_flag,
.build = _build,
.process = _process,
+ .add_segment = _add_segment,
.get_ref = _get_ref,
.destroy = _destroy,
},
},
.type = { PEN_ITA, ITA_ATTR_DEVICE_ID },
+ .length = length,
.value = chunk_clone(value),
.ref = 1,
);
@@ -139,6 +158,6 @@ pa_tnc_attr_t *ita_attr_device_id_create_from_data(chunk_t value)
*/
pa_tnc_attr_t *ita_attr_device_id_create(chunk_t value)
{
- return ita_attr_device_id_create_from_data(value);
+ return ita_attr_device_id_create_from_data(value.len, value);
}
diff --git a/src/libimcv/ita/ita_attr_device_id.h b/src/libimcv/ita/ita_attr_device_id.h
index ffacdba1e..94bb778c0 100644
--- a/src/libimcv/ita/ita_attr_device_id.h
+++ b/src/libimcv/ita/ita_attr_device_id.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Andreas Steffen
+ * Copyright (C) 2013-2014 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -48,8 +48,9 @@ pa_tnc_attr_t* ita_attr_device_id_create(chunk_t value);
/**
* Creates an ita_attr_device_id_t object from received data
*
- * @param value binary value blob
+ * @param length Total length of attribute value
+ * @param value Unparsed attribute value (might be a segment)
*/
-pa_tnc_attr_t* ita_attr_device_id_create_from_data(chunk_t value);
+pa_tnc_attr_t* ita_attr_device_id_create_from_data(size_t length, chunk_t value);
#endif /** ITA_ATTR_DEVICE_ID_H_ @}*/
diff --git a/src/libimcv/ita/ita_attr_dummy.c b/src/libimcv/ita/ita_attr_dummy.c
index 6497d4645..0d21ac6ea 100644
--- a/src/libimcv/ita/ita_attr_dummy.c
+++ b/src/libimcv/ita/ita_attr_dummy.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -38,7 +38,12 @@ struct private_ita_attr_dummy_t {
pen_type_t type;
/**
- * Attribute value
+ * Length of attribute value
+ */
+ size_t length;
+
+ /**
+ * Attribute value or segment
*/
chunk_t value;
@@ -89,18 +94,28 @@ METHOD(pa_tnc_attr_t, build, void,
{
return;
}
- this->value = chunk_alloc(this->size);
+ this->value = chunk_alloc(this->length);
memset(this->value.ptr, 0xdd, this->value.len);
}
METHOD(pa_tnc_attr_t, process, status_t,
private_ita_attr_dummy_t *this, u_int32_t *offset)
{
- this->size = this->value.len;
+ *offset = 0;
+ if (this->value.len < this->length)
+ {
+ return NEED_MORE;
+ }
return SUCCESS;
}
+METHOD(pa_tnc_attr_t, add_segment, void,
+ private_ita_attr_dummy_t *this, chunk_t segment)
+{
+ this->value = chunk_cat("mc", this->value, segment);
+}
+
METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
private_ita_attr_dummy_t *this)
{
@@ -121,13 +136,13 @@ METHOD(pa_tnc_attr_t, destroy, void,
METHOD(ita_attr_dummy_t, get_size, int,
private_ita_attr_dummy_t *this)
{
- return this->size;
+ return this->length;
}
/**
* Described in header.
*/
-pa_tnc_attr_t *ita_attr_dummy_create(int size)
+pa_tnc_attr_t *ita_attr_dummy_create(size_t size)
{
private_ita_attr_dummy_t *this;
@@ -140,13 +155,14 @@ pa_tnc_attr_t *ita_attr_dummy_create(int size)
.set_noskip_flag = _set_noskip_flag,
.build = _build,
.process = _process,
+ .add_segment = _add_segment,
.get_ref = _get_ref,
.destroy = _destroy,
},
.get_size = _get_size,
},
.type = { PEN_ITA, ITA_ATTR_DUMMY },
- .size = size,
+ .length = size,
.ref = 1,
);
@@ -156,7 +172,7 @@ pa_tnc_attr_t *ita_attr_dummy_create(int size)
/**
* Described in header.
*/
-pa_tnc_attr_t *ita_attr_dummy_create_from_data(chunk_t data)
+pa_tnc_attr_t *ita_attr_dummy_create_from_data(size_t length, chunk_t data)
{
private_ita_attr_dummy_t *this;
@@ -169,12 +185,14 @@ pa_tnc_attr_t *ita_attr_dummy_create_from_data(chunk_t data)
.set_noskip_flag = _set_noskip_flag,
.build = _build,
.process = _process,
+ .add_segment = _add_segment,
.get_ref = _get_ref,
.destroy = _destroy,
},
.get_size = _get_size,
},
.type = { PEN_ITA, ITA_ATTR_DUMMY },
+ .length = length,
.value = chunk_clone(data),
.ref = 1,
);
diff --git a/src/libimcv/ita/ita_attr_dummy.h b/src/libimcv/ita/ita_attr_dummy.h
index 1f85ece54..717862efe 100644
--- a/src/libimcv/ita/ita_attr_dummy.h
+++ b/src/libimcv/ita/ita_attr_dummy.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -49,13 +49,14 @@ struct ita_attr_dummy_t {
*
* @param size size of dummy attribute value
*/
-pa_tnc_attr_t* ita_attr_dummy_create(int size);
+pa_tnc_attr_t* ita_attr_dummy_create(size_t size);
/**
* Creates an ita_attr_dummy_t object from received data
*
- * @param value binary value blob
+ * @param length Total length of attribute value
+ * @param value Unparsed attribute value (might be a segment)
*/
-pa_tnc_attr_t* ita_attr_dummy_create_from_data(chunk_t value);
+pa_tnc_attr_t* ita_attr_dummy_create_from_data(size_t length, chunk_t value);
#endif /** ITA_ATTR_DUMMY_H_ @}*/
diff --git a/src/libimcv/ita/ita_attr_get_settings.c b/src/libimcv/ita/ita_attr_get_settings.c
index d0bc31d32..3c047fb82 100644
--- a/src/libimcv/ita/ita_attr_get_settings.c
+++ b/src/libimcv/ita/ita_attr_get_settings.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -64,7 +64,12 @@ struct private_ita_attr_get_settings_t {
pen_type_t type;
/**
- * Attribute value
+ * Length of attribute value
+ */
+ size_t length;
+
+ /**
+ * Attribute value or segment
*/
chunk_t value;
@@ -130,6 +135,7 @@ METHOD(pa_tnc_attr_t, build, void,
enumerator->destroy(enumerator);
this->value = writer->extract_buf(writer);
+ this->length = this->value.len;
writer->destroy(writer);
}
@@ -141,10 +147,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
chunk_t name;
status_t status = FAILED;
+ *offset = 0;
+
+ if (this->value.len < this->length)
+ {
+ return NEED_MORE;
+ }
if (this->value.len < ITA_GET_SETTINGS_MIN_SIZE)
{
DBG1(DBG_TNC, "insufficient data for ITA Get Settings attribute");
- *offset = 0;
return FAILED;
}
@@ -171,6 +182,12 @@ end:
return status;
}
+METHOD(pa_tnc_attr_t, add_segment, void,
+ private_ita_attr_get_settings_t *this, chunk_t segment)
+{
+ this->value = chunk_cat("mc", this->value, segment);
+}
+
METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
private_ita_attr_get_settings_t *this)
{
@@ -217,6 +234,7 @@ pa_tnc_attr_t *ita_attr_get_settings_create(char *name)
.set_noskip_flag = _set_noskip_flag,
.build = _build,
.process = _process,
+ .add_segment = _add_segment,
.get_ref = _get_ref,
.destroy = _destroy,
},
@@ -238,7 +256,8 @@ pa_tnc_attr_t *ita_attr_get_settings_create(char *name)
/**
* Described in header.
*/
-pa_tnc_attr_t *ita_attr_get_settings_create_from_data(chunk_t data)
+pa_tnc_attr_t *ita_attr_get_settings_create_from_data(size_t length,
+ chunk_t data)
{
private_ita_attr_get_settings_t *this;
@@ -251,6 +270,7 @@ pa_tnc_attr_t *ita_attr_get_settings_create_from_data(chunk_t data)
.set_noskip_flag = _set_noskip_flag,
.build = _build,
.process = _process,
+ .add_segment = _add_segment,
.get_ref = _get_ref,
.destroy = _destroy,
},
@@ -258,6 +278,7 @@ pa_tnc_attr_t *ita_attr_get_settings_create_from_data(chunk_t data)
.create_enumerator = _create_enumerator,
},
.type = { PEN_ITA, ITA_ATTR_GET_SETTINGS },
+ .length = length,
.value = chunk_clone(data),
.list = linked_list_create(),
.ref = 1,
diff --git a/src/libimcv/ita/ita_attr_get_settings.h b/src/libimcv/ita/ita_attr_get_settings.h
index 975fd0d9d..2eb43f5c1 100644
--- a/src/libimcv/ita/ita_attr_get_settings.h
+++ b/src/libimcv/ita/ita_attr_get_settings.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -61,8 +61,10 @@ pa_tnc_attr_t* ita_attr_get_settings_create(char *name);
/**
* Creates an ita_attr_get_settings_t object from received data
*
- * @param value binary value blob
+ * @param length Total length of attribute value
+ * @param value Unparsed attribute value (might be a segment)
*/
-pa_tnc_attr_t* ita_attr_get_settings_create_from_data(chunk_t value);
+pa_tnc_attr_t* ita_attr_get_settings_create_from_data(size_t length,
+ chunk_t value);
#endif /** ITA_ATTR_GET_SETTINGS_H_ @}*/
diff --git a/src/libimcv/ita/ita_attr_settings.c b/src/libimcv/ita/ita_attr_settings.c
index 0d2967e66..ced347705 100644
--- a/src/libimcv/ita/ita_attr_settings.c
+++ b/src/libimcv/ita/ita_attr_settings.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Andreas Steffen
+ * Copyright (C) 2012-2014 Andreas Steffen
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -91,7 +91,12 @@ struct private_ita_attr_settings_t {
pen_type_t type;
/**
- * Attribute value
+ * Length of attribute value
+ */
+ size_t length;
+
+ /**
+ * Attribute value or segment
*/
chunk_t value;
@@ -159,6 +164,7 @@ METHOD(pa_tnc_attr_t, build, void,
enumerator->destroy(enumerator);
this->value = writer->extract_buf(writer);
+ this->length = this->value.len;
writer->destroy(writer);
}
@@ -171,10 +177,15 @@ METHOD(pa_tnc_attr_t, process, status_t,
entry_t *entry;
status_t status = FAILED;
+ *offset = 0;
+
+ if (this->value.len < this->length)
+ {
+ return NEED_MORE;
+ }
if (this->value.len < ITA_SETTINGS_MIN_SIZE)
{
DBG1(DBG_TNC, "insufficient data for ITA Settings attribute");
- *offset = 0;
return FAILED;
}
@@ -216,6 +227,12 @@ end:
return status;
}
+METHOD(pa_tnc_attr_t, add_segment, void,
+ private_ita_attr_settings_t *this, chunk_t segment)
+{
+ this->value = chunk_cat("mc", this->value, segment);
+}
+
METHOD(pa_tnc_attr_t, get_ref, pa_tnc_attr_t*,
private_ita_attr_settings_t *this)
{
@@ -279,6 +296,7 @@ pa_tnc_attr_t *ita_attr_settings_create(void)
.set_noskip_flag = _set_noskip_flag,
.build = _build,
.process = _process,
+ .add_segment = _add_segment,
.get_ref = _get_ref,
.destroy = _destroy,
},
@@ -296,7 +314,7 @@ pa_tnc_attr_t *ita_attr_settings_create(void)
/**
* Described in header.
*/
-pa_tnc_attr_t *ita_attr_settings_create_from_data(chunk_t data)
+pa_tnc_attr_t *ita_attr_settings_create_from_data(size_t length, chunk_t data)
{
private_ita_attr_settings_t *this;
@@ -309,6 +327,7 @@ pa_tnc_attr_t *ita_attr_settings_create_from_data(chunk_t data)
.set_noskip_flag = _set_noskip_flag,
.build = _build,
.process = _process,
+ .add_segment = _add_segment,
.get_ref = _get_ref,
.destroy = _destroy,
},
@@ -316,6 +335,7 @@ pa_tnc_attr_t *ita_attr_settings_create_from_data(chunk_t data)
.create_enumerator = _create_enumerator,
},
.type = { PEN_ITA, ITA_ATTR_SETTINGS },
+ .length = length,
.value = chunk_clone(data),
.list = linked_list_create(),
.ref = 1,
diff --git a/src/libimcv/ita/ita_attr_settings.h b/src/libimcv/ita/ita_attr_settings.h
index eb7eedae3..87eb87f60 100644
--- a/src/libimcv/ita/ita_attr_settings.h
+++ b/src/libimcv/ita/ita_attr_settings.h
@@ -60,8 +60,9 @@ pa_tnc_attr_t* ita_attr_settings_create(void);
/**
* Creates an ita_attr_settings_t object from received data
*
- * @param value binary value blob
+ * @param length Total length of attribute value
+ * @param value Unparsed attribute value (might be a segment)
*/
-pa_tnc_attr_t* ita_attr_settings_create_from_data(chunk_t value);
+pa_tnc_attr_t* ita_attr_settings_create_from_data(size_t length, chunk_t value);
#endif /** ITA_ATTR_SETTINGS_H_ @}*/