summaryrefslogtreecommitdiff
path: root/plainPacket.cpp
diff options
context:
space:
mode:
authorErwin Nindl <nine@wirdorange.org>2007-12-24 17:05:26 +0000
committerErwin Nindl <nine@wirdorange.org>2007-12-24 17:05:26 +0000
commit00febb25de92b1cd01309cc0f253ed4c3a761b13 (patch)
treeba0ffffdaf897e96ec2237a03cc523a4025b52f5 /plainPacket.cpp
parentmesh syncing works now (diff)
weihnachtlicher checkin
* packet processing now with less memory operations than before * todo: * testing * set cipher / authalgo via commandline * set key operations for hmac calculation
Diffstat (limited to 'plainPacket.cpp')
-rw-r--r--plainPacket.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/plainPacket.cpp b/plainPacket.cpp
index c48cd8c..1df611d 100644
--- a/plainPacket.cpp
+++ b/plainPacket.cpp
@@ -41,12 +41,15 @@
PlainPacket::~PlainPacket()
{
buf_ = reinterpret_cast<u_int8_t*>(payload_type_);
+ length_ = size_;
}
PlainPacket::PlainPacket(u_int32_t max_payload_length) : Buffer(max_payload_length + sizeof(payload_type_t))
{
payload_type_ = reinterpret_cast<payload_type_t*>(buf_);
- buf_ = buf_ + sizeof(payload_type_t);
+ buf_ += sizeof(payload_type_t);
+ length_ = max_payload_length;
+ size_ = length_;
}
payload_type_t PlainPacket::getPayloadType() const
@@ -59,3 +62,15 @@ void PlainPacket::setPayloadType(payload_type_t payload_type)
payload_type = PAYLOAD_TYPE_T_HTON(payload_type);
}
+void PlainPacket::setLength(u_int32_t length)
+{
+ if(length > size_)
+ throw std::out_of_range("can't set length greater then size ofsize of allocated memory");
+
+ length_ = length;
+}
+
+u_int32_t PlainPacket::getSize() const
+{
+ return size_;
+}