summaryrefslogtreecommitdiffhomepage
path: root/doc
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2012-10-05 19:01:55 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2012-10-06 13:16:18 +0900
commitef8284dfd16a429962c609a8e423ea746b25c0bc (patch)
tree59d19822df8c31897fc866eb9da43ab6aae6a5be /doc
parentfd692d330dda484a7b687a3d7b35c8015bc4886e (diff)
doc: update packet library
Use Packet class iterator feature Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'doc')
-rw-r--r--doc/source/library_packet.rst19
1 files changed, 9 insertions, 10 deletions
diff --git a/doc/source/library_packet.rst b/doc/source/library_packet.rst
index 8ca0e299..86bdbd4c 100644
--- a/doc/source/library_packet.rst
+++ b/doc/source/library_packet.rst
@@ -55,19 +55,18 @@ is used:
@handler.set_ev_cls(ofp_event.EventOFPPacketIn, handler.MAIN_DISPATCHER)
def packet_in_handler(self, ev):
pkt = packet.Packet(array.array('B', ev.msg.data))
- for p in pkt.protocols:
- print p
- vp = pkt.find_protocol('vlan')
- if vp:
- print "vlan found:", vp.vid
+ for p in pkt:
+ print p.protocol_name, p
+ if p.protocol_name == 'vlan':
+ print 'vid = ', p.vid
You see something like::
- <ryu.lib.packet.ethernet.ethernet object at 0x107a5d790>
- <ryu.lib.packet.vlan.vlan object at 0x107a5d7d0>
- <ryu.lib.packet.ipv4.ipv4 object at 0x107a5d810>
- <ryu.lib.packet.tcp.tcp object at 0x107a5d850>
- vlan found: 10
+ ethernet <ryu.lib.packet.ethernet.ethernet object at 0x107a5d790>
+ vlan <ryu.lib.packet.vlan.vlan object at 0x107a5d7d0>
+ vid = 10
+ ipv4 <ryu.lib.packet.ipv4.ipv4 object at 0x107a5d810>
+ tcp <ryu.lib.packet.tcp.tcp object at 0x107a5d850>