From ef8284dfd16a429962c609a8e423ea746b25c0bc Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Fri, 5 Oct 2012 19:01:55 +0900 Subject: doc: update packet library Use Packet class iterator feature Signed-off-by: FUJITA Tomonori --- doc/source/library_packet.rst | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'doc') 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:: - - - - - vlan found: 10 + ethernet + vlan + vid = 10 + ipv4 + tcp -- cgit v1.2.3