On Wed, Jun 06, 2012 at 11:22:57PM +0900, FUJITA Tomonori wrote:
> Signed-off-by: FUJITA Tomonori <fujita.tomon...@lab.ntt.co.jp>
> ---
>  ryu/ofproto/ofproto_v1_0.py        |    6 ++++++
>  ryu/ofproto/ofproto_v1_0_parser.py |   32 ++++++++++++++++++++++++++++++++
>  2 files changed, 38 insertions(+), 0 deletions(-)
> 
> diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py
> index 5c9c205..624bc76 100644
> --- a/ryu/ofproto/ofproto_v1_0.py
> +++ b/ryu/ofproto/ofproto_v1_0.py
> @@ -574,6 +574,7 @@ NXT_FLOW_MOD = 13
>  NXT_FLOW_REMOVED = 14
>  NXT_FLOW_MOD_TABLE_ID = 15
>  NXT_SET_PACKET_IN_FORMAT = 16
> +NXT_PACKET_IN = 17
>  NXT_SET_CONTROLLER_ID = 20
>  
>  # enum nx_role
> @@ -624,6 +625,11 @@ NX_SET_PACKET_IN_FORMAT_SIZE = 20
>  assert (calcsize(NX_SET_PACKET_IN_FORMAT_PACK_STR) +
>          NICIRA_HEADER_SIZE == NX_SET_PACKET_IN_FORMAT_SIZE)
>  
> +NX_PACKET_IN_PACK_STR = '!IHBBQH6x'
> +NX_PACKET_IN_SIZE = 40
> +assert (calcsize(NX_PACKET_IN_PACK_STR) +
> +        NICIRA_HEADER_SIZE == NX_PACKET_IN_SIZE)
> +
>  NX_CONTROLLER_ID_PACK_STR = '!6xH'
>  NX_CONTROLLER_ID_SIZE = 24
>  assert (calcsize(NX_CONTROLLER_ID_PACK_STR) +
> diff --git a/ryu/ofproto/ofproto_v1_0_parser.py 
> b/ryu/ofproto/ofproto_v1_0_parser.py
> index 07acce4..af2082c 100644
> --- a/ryu/ofproto/ofproto_v1_0_parser.py
> +++ b/ryu/ofproto/ofproto_v1_0_parser.py
> @@ -1368,6 +1368,38 @@ class NXTSetPacketInFormat(NiciraHeader):
>                        self.format)
>  
>  
> +@NiciraHeader.register_nx_subtype(ofproto_v1_0.NXT_PACKET_IN)
> +class NXTPacketIn(NiciraHeader):
> +    def __init__(self, datapath, buffer_id, total_len, reason, table_id,
> +                 cookie, match_len, match, frame):
> +        super(NXTPacketIn, self).__init__(
> +            datapath, ofproto_v1_0.NXT_PACKET_IN)
> +        self.buffer_id = buffer_id
> +        self.total_len = total_len
> +        self.reason = reason
> +        self.table_id = table_id
> +        self.cookie = cookie
> +        self.match_len = match_len
> +        self.match = match
> +        self.frame = frame
> +
> +    @classmethod
> +    def parser(cls, datapath, buf, offset):
> +        (buffer_id, total_len, reason, table_id,
> +                 cookie, match_len) = struct.unpack_from(
> +            ofproto_v1_0.NX_PACKET_IN_PACK_STR, buf, offset)
> +
> +        offset += (ofproto_v1_0.NX_PACKET_IN_SIZE
> +                   - ofproto_v1_0.NICIRA_HEADER_SIZE)
> +
> +        match = nx_match.NXMatch.parser(buf, offset, match_len)
> +        pad_len = (match_len + 7) / 8 * 8
> +        offset += match_len + pad_len
> +        frame = buf[offset:]

           if total_len < len(frame):
                frame = frame[:total_len]

of packet can be padded for alignment at the end, so the padding
needs to be discarded. Otherwise packet parser can't know frame size.
Please see OFPPacketIn parser.


> +        return cls(datapath, buffer_id, total_len, reason, table_id,
> +                   cookie, match_len, match, frame)
> +
> +
>  class NXTSetControllerId(NiciraHeader):
>      def __init__(self, datapath, controller_id):
>          super(NXTSetControllerId, self).__init__(
> -- 
> 1.7.4.4
> 
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Ryu-devel mailing list
> Ryu-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
> 

-- 
yamahata

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to