From f0dbb920116c1ac1375a88ced59cc9dfcdbc4efc Mon Sep 17 00:00:00 2001 From: Shaun Crampton Date: Fri, 24 May 2013 17:05:32 +0000 Subject: packet lib: allow packet type to be specified when parsing packet Signed-off-by: Shaun Crampton Signed-off-by: FUJITA Tomonori --- ryu/lib/packet/packet.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ryu/lib/packet/packet.py b/ryu/lib/packet/packet.py index 2ef08c15..f5fd82df 100644 --- a/ryu/lib/packet/packet.py +++ b/ryu/lib/packet/packet.py @@ -31,15 +31,14 @@ class Packet(object): *data* should be omitted when encoding a packet. """ - def __init__(self, data=None): + def __init__(self, data=None, parse_cls=ethernet.ethernet): super(Packet, self).__init__() self.data = data self.protocols = [] self.protocol_idx = 0 self.parsed_bytes = 0 if self.data: - # Do we need to handle non ethernet? - self._parser(ethernet.ethernet) + self._parser(parse_cls) def _parser(self, cls): while cls: -- cgit v1.2.3