Ping? On Mon, Jun 10, 2013 at 11:00:18AM +0900, Isaku Yamahata wrote: > The patch teaches packet library to truncate padding octets. > The protocol class that knows its payload length should set its payload > length as payload_length > 0 attributes. > Then, the packet.parser truncates its payload. > If payload_length = 0, do nothing. > > Cc: YAMAMOTO Takashi <yamam...@valinux.co.jp> > Cc: Shaun Crampton <shaun.cramp...@metaswitch.com> > Signed-off-by: Isaku Yamahata <yamah...@valinux.co.jp> > --- > Changes v1 -> v2: > - typo in ipv4 > - s/payload_length_/payload_length/g > --- > ryu/lib/packet/ipv4.py | 2 ++ > ryu/lib/packet/lldp.py | 1 + > ryu/lib/packet/packet.py | 4 ++++ > ryu/lib/packet/packet_base.py | 1 + > ryu/lib/packet/udp.py | 2 ++ > 5 files changed, 10 insertions(+) > > diff --git a/ryu/lib/packet/ipv4.py b/ryu/lib/packet/ipv4.py > index 09ed734..823c480 100644 > --- a/ryu/lib/packet/ipv4.py > +++ b/ryu/lib/packet/ipv4.py > @@ -83,6 +83,8 @@ class ipv4(packet_base.PacketBase): > self.length = header_length * 4 > self.option = option > > + self.payload_length = total_length > + > @classmethod > def parser(cls, buf): > (version, tos, total_length, identification, flags, ttl, proto, csum, > diff --git a/ryu/lib/packet/lldp.py b/ryu/lib/packet/lldp.py > index f343359..b4fc931 100644 > --- a/ryu/lib/packet/lldp.py > +++ b/ryu/lib/packet/lldp.py > @@ -116,6 +116,7 @@ class lldp(packet_base.PacketBase): > length += LLDP_TLV_SIZE + tlv.len > > self.length = length > + self.payload_length = length > > # at least it must have chassis id, port id, ttl and end > def _tlvs_len_valid(self): > diff --git a/ryu/lib/packet/packet.py b/ryu/lib/packet/packet.py > index f5fd82d..da1077b 100644 > --- a/ryu/lib/packet/packet.py > +++ b/ryu/lib/packet/packet.py > @@ -46,6 +46,10 @@ class Packet(object): > if proto: > self.parsed_bytes += proto.length > self.protocols.append(proto) > + if proto.payload_length > 0: > + truncation_length = (self.parsed_bytes + > + proto.payload_length) > + self.data = self.data[:truncation_length] > > if len(self.data) > self.parsed_bytes: > self.protocols.append(self.data[self.parsed_bytes:]) > diff --git a/ryu/lib/packet/packet_base.py b/ryu/lib/packet/packet_base.py > index b0aeca0..33b5984 100644 > --- a/ryu/lib/packet/packet_base.py > +++ b/ryu/lib/packet/packet_base.py > @@ -37,6 +37,7 @@ class PacketBase(object): > def __init__(self): > super(PacketBase, self).__init__() > self.length = 0 > + self.payload_length = 0 > self.protocol_name = self.__class__.__name__ > > @classmethod > diff --git a/ryu/lib/packet/udp.py b/ryu/lib/packet/udp.py > index c1bb10c..7084697 100644 > --- a/ryu/lib/packet/udp.py > +++ b/ryu/lib/packet/udp.py > @@ -49,6 +49,8 @@ class udp(packet_base.PacketBase): > self.csum = csum > self.length = udp._MIN_LEN > > + self.payload_length = total_length > + > @classmethod > def parser(cls, buf): > (src_port, dst_port, total_length, csum) = struct.unpack_from( > -- > 1.7.10.4 > > > ------------------------------------------------------------------------------ > How ServiceNow helps IT people transform IT departments: > 1. A cloud service to automate IT design, transition and operations > 2. Dashboards that offer high-level views of enterprise services > 3. A single system of record for all IT processes > http://p.sf.net/sfu/servicenow-d2d-j > _______________________________________________ > Ryu-devel mailing list > Ryu-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/ryu-devel >
-- yamahata ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Ryu-devel mailing list Ryu-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ryu-devel