summaryrefslogtreecommitdiff
path: root/plainPacket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plainPacket.cpp')
-rw-r--r--plainPacket.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/plainPacket.cpp b/plainPacket.cpp
index c3aa089..ab9ccea 100644
--- a/plainPacket.cpp
+++ b/plainPacket.cpp
@@ -58,8 +58,12 @@ void PlainPacket::setPayloadType(payload_type_t payload_type)
if(!payload_type_)
return;
- if(payload_type == PAYLOAD_TYPE_TUN)
- {
+ if(payload_type == PAYLOAD_TYPE_TUN) {
+ if(!payload_) {
+ *payload_type_ = PAYLOAD_TYPE_T_HTON(0);
+ return;
+ }
+
struct ip* hdr = reinterpret_cast<struct ip*>(payload_);
if(hdr->ip_v == 4)
*payload_type_ = PAYLOAD_TYPE_T_HTON(PAYLOAD_TYPE_TUN4);