summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorShaun Crampton <Shaun.Crampton@metaswitch.com>2013-06-05 10:39:37 -0700
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-06-08 18:44:07 -0700
commit95f79d6a512b34b4f53509dbc30b58be29d631a6 (patch)
tree2b57d0cf5897716cf2b9323e4e9501aeb860de21
parent43b439770b6a14be993e7c3aec54d431ba1ff609 (diff)
packet lib: For convenience, make packet into a sequence type
Protocols can mow be accesed as packet[n]. Signed-off-by: Shaun Crampton <Shaun.Crampton@metaswitch.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/lib/packet/packet.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/ryu/lib/packet/packet.py b/ryu/lib/packet/packet.py
index 84e5bf89..2ef08c15 100644
--- a/ryu/lib/packet/packet.py
+++ b/ryu/lib/packet/packet.py
@@ -95,3 +95,15 @@ class Packet(object):
def __iter__(self):
return self
+
+ def __getitem__(self, idx):
+ return self.protocols[idx]
+
+ def __setitem__(self, idx, item):
+ self.protocols[idx] = item
+
+ def __delitem__(self, idx):
+ del self.protocols[idx]
+
+ def __len__(self):
+ return len(self.protocols)