summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-09-03 22:35:02 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-09-03 22:35:02 +0900
commite47c5bf16ab006a8c831840fe8c96deccabaa471 (patch)
tree2e5d1b16d15ce350065ded1a59f5186e89764cb1
parent22387e09e41e5319978f47b04796067e2e6da3f7 (diff)
packet: udp should detect dhcp
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/packet/udp.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/ryu/lib/packet/udp.py b/ryu/lib/packet/udp.py
index a80e1010..bae6d735 100644
--- a/ryu/lib/packet/udp.py
+++ b/ryu/lib/packet/udp.py
@@ -17,6 +17,7 @@ import struct
from . import packet_base
from . import packet_utils
+from . import dhcp
class udp(packet_base.PacketBase):
@@ -49,11 +50,17 @@ class udp(packet_base.PacketBase):
self.csum = csum
@classmethod
+ def get_packet_type(cls, src_port, dst_port):
+ if (src_port == 68 and dst_port == 67) or (src_port == 67 and dst_port == 68):
+ return dhcp.dhcp
+ return None
+
+ @classmethod
def parser(cls, buf):
(src_port, dst_port, total_length, csum) = struct.unpack_from(
cls._PACK_STR, buf)
msg = cls(src_port, dst_port, total_length, csum)
- return msg, None, buf[msg._MIN_LEN:total_length]
+ return msg, cls.get_packet_type(src_port, dst_port), buf[msg._MIN_LEN:total_length]
def serialize(self, payload, prev):
if self.total_length == 0: