mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-05 12:26:11 +02:00
packet: udp should detect dhcp
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
22387e09e4
commit
e47c5bf16a
@ -17,6 +17,7 @@ import struct
|
||||
|
||||
from . import packet_base
|
||||
from . import packet_utils
|
||||
from . import dhcp
|
||||
|
||||
|
||||
class udp(packet_base.PacketBase):
|
||||
@ -48,12 +49,18 @@ class udp(packet_base.PacketBase):
|
||||
self.total_length = total_length
|
||||
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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user