Note that this heuristic may generate false positives, i.e. it may interpret some non-µTP UDP packets as µTP. There does not seem to be an easy way to avoid this.
Signed-off-by: Baptiste Jonglez <[email protected]> --- ryu/lib/packet/udp.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ryu/lib/packet/udp.py b/ryu/lib/packet/udp.py index bae6d73..7116aae 100644 --- a/ryu/lib/packet/udp.py +++ b/ryu/lib/packet/udp.py @@ -18,6 +18,7 @@ import struct from . import packet_base from . import packet_utils from . import dhcp +from . import utp class udp(packet_base.PacketBase): @@ -50,17 +51,19 @@ class udp(packet_base.PacketBase): self.csum = csum @classmethod - def get_packet_type(cls, src_port, dst_port): + def get_packet_type(cls, src_port, dst_port, payload): if (src_port == 68 and dst_port == 67) or (src_port == 67 and dst_port == 68): return dhcp.dhcp - return None + if utp.utp.detect_utp(payload): + return utp.utp @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, cls.get_packet_type(src_port, dst_port), buf[msg._MIN_LEN:total_length] + payload = buf[msg._MIN_LEN:total_length] + return msg, cls.get_packet_type(src_port, dst_port, payload), payload def serialize(self, payload, prev): if self.total_length == 0: -- 2.6.4 ------------------------------------------------------------------------------ _______________________________________________ Ryu-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ryu-devel
