packet lib: packet class accepts protocols list argument

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
FUJITA Tomonori 2013-06-10 08:30:54 +09:00
parent 00261be526
commit da5c7f13cf

View File

@ -31,10 +31,13 @@ class Packet(object):
*data* should be omitted when encoding a packet.
"""
def __init__(self, data=None, parse_cls=ethernet.ethernet):
def __init__(self, data=None, protocols=None, parse_cls=ethernet.ethernet):
super(Packet, self).__init__()
self.data = data
self.protocols = []
if protocols is None:
self.protocols = []
else:
self.protocols = protocols
self.protocol_idx = 0
self.parsed_bytes = 0
if self.data: