aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/encoding/payloads/transform_attribute.c
diff options
context:
space:
mode:
authorMartin Willi <martin@revosec.ch>2011-11-24 15:25:22 +0100
committerMartin Willi <martin@revosec.ch>2012-03-20 17:30:53 +0100
commit914ec2dbf29ea70a397418860fb304196131d845 (patch)
tree15c15b466a8c981e2d2cb64d44004215150e6afd /src/libcharon/encoding/payloads/transform_attribute.c
parentfbebc2a068942d16c20f8439b140027395ba25a0 (diff)
downloadstrongswan-914ec2dbf29ea70a397418860fb304196131d845.tar.bz2
strongswan-914ec2dbf29ea70a397418860fb304196131d845.tar.xz
Implemented IKEv1 attribute encoding in SA payload
Diffstat (limited to 'src/libcharon/encoding/payloads/transform_attribute.c')
-rw-r--r--src/libcharon/encoding/payloads/transform_attribute.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/libcharon/encoding/payloads/transform_attribute.c b/src/libcharon/encoding/payloads/transform_attribute.c
index 7e8a9c7c7..0be39316a 100644
--- a/src/libcharon/encoding/payloads/transform_attribute.c
+++ b/src/libcharon/encoding/payloads/transform_attribute.c
@@ -209,10 +209,22 @@ METHOD(transform_attribute_t, get_value_chunk, chunk_t,
return this->attribute_value;
}
-METHOD(transform_attribute_t, get_value, u_int16_t,
+METHOD(transform_attribute_t, get_value, u_int64_t,
private_transform_attribute_t *this)
{
- return this->attribute_length_or_value;
+ u_int64_t value = 0;
+
+ if (this->attribute_format)
+ {
+ return this->attribute_length_or_value;
+ }
+ if (this->attribute_value.len > sizeof(value))
+ {
+ return UINT64_MAX;
+ }
+ memcpy(((char*)&value) + sizeof(value) - this->attribute_value.len,
+ this->attribute_value.ptr, this->attribute_value.len);
+ return be64toh(value);
}
METHOD(transform_attribute_t, set_attribute_type, void,