mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-08 13:56:09 +02:00
packet lib: packet class supports get_protocol method
returns a list of protocols that matches to the specified protocol. Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
178b1dd2bc
commit
6d414d0cdd
@ -87,6 +87,14 @@ class Packet(object):
|
||||
|
||||
self.protocols.append(proto)
|
||||
|
||||
def get_protocols(self, protocol):
|
||||
"""Returns a list of protocols that matches to the specified protocol.
|
||||
"""
|
||||
if isinstance(protocol, packet_base.PacketBase):
|
||||
protocol = protocol.__class__
|
||||
assert issubclass(protocol, packet_base.PacketBase)
|
||||
return [p for p in self.protocols if isinstance(p, protocol)]
|
||||
|
||||
def next(self):
|
||||
try:
|
||||
p = self.protocols[self.protocol_idx]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user