packet lib: allow packet type to be specified when parsing packet

Signed-off-by: Shaun Crampton <Shaun.Crampton@metaswitch.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
Shaun Crampton 2013-05-24 17:05:32 +00:00 committed by FUJITA Tomonori
parent 95f79d6a51
commit f0dbb92011
1 changed files with 2 additions and 3 deletions

View File

@ -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: