replace Packet.__iter__ which doesn't work in cases like nested iterations.
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
get_protocols returns the list of protocols. This is useful for a
packet including the same protocol multiple times (e.g. tunneling such
GRE). However, it's a rare use case. Instead of
'get_protocols(hoge)[0]', let's do 'get_protocol(hoge)' simply.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
The patch teaches packet library to truncate padding octets.
Change packet_base.parser() to return (header, next_type, rest_of_packet)
The protocol class that knows its payload length should rest_of_packet
where padding octets at the last of packet is truncated.
As bonus,
- fix ipv6 parser as ipv6 header doesn't have options.
It seems copy-and-paste from ipv4
- improve ipv4, tcp a bit
Cc: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
Cc: Shaun Crampton <Shaun.Crampton@metaswitch.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
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>
you can do something like:
if arp.arp in Packet(msg.data):
a = arp.arp(...)
if a in Packet(msg.data):
>>> from ryu.lib.packet import packet
>>> from ryu.lib.packet import arp
>>> a = arp.arp_ip(1, 0, 0, 0, 0)
>>> p = packet.Packet()
>>> p.protocols = [a]
>>> arp.arp in p
True
>>> a in p
True
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
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>
The current implementation doesn't allow inheriting twice from class PacketBase.
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
- Now easy to know the protocol name and iterate protocols.
- find_protocol doesn't handle the case the same protocols are stacked.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
- we need to serialize in reverse order since some need to know
payload.
- TCP and UDP need the previous protocol info (IP) to calculate the
checksum.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
As discussed on the mailing list, there is no good packet library
(parses and builds various protocol packets). dpkt isn't flexible
enough (can't nicely handle stacked protocols such as vlan, mpls,
gre). NOX's one is nice but released under GPL3.
So we need our own packet library.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>