On Sun, 13 May 2012 21:03:01 +0900
FUJITA Tomonori <[email protected]> wrote:

> Signed-off-by: FUJITA Tomonori <[email protected]>
> ---
>  ryu/ofproto/ofproto_v1_0.py        |    5 +++++
>  ryu/ofproto/ofproto_v1_0_parser.py |   36 
> ++++++++++++++++++++++++++++++++++++
>  2 files changed, 41 insertions(+), 0 deletions(-)

>From b95a5687ee5b875816a1e20e91091d7838573ee2 Mon Sep 17 00:00:00 2001
From: FUJITA Tomonori <[email protected]>
Date: Mon, 14 May 2012 09:51:37 +0900
Subject: [PATCH 4/4] add Nicira Extension NXAST_BUNDLE support

Signed-off-by: FUJITA Tomonori <[email protected]>
---
 ryu/ofproto/ofproto_v1_0.py        |    5 +++
 ryu/ofproto/ofproto_v1_0_parser.py |   50 ++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+), 0 deletions(-)

diff --git a/ryu/ofproto/ofproto_v1_0.py b/ryu/ofproto/ofproto_v1_0.py
index 90bfdf4..b3c9c95 100644
--- a/ryu/ofproto/ofproto_v1_0.py
+++ b/ryu/ofproto/ofproto_v1_0.py
@@ -238,6 +238,7 @@ NXAST_REG_MOVE = 6
 NXAST_REG_LOAD = 7
 NXAST_SET_TUNNEL64 = 9
 NXAST_MULTIPATH = 10
+NXAST_BUNDLE = 12
 NXAST_BUNDLE_LOAD = 13
 NXAST_RESUBMIT_TABLE = 14
 
@@ -265,6 +266,10 @@ NX_ACTION_MULTIPATH_PACK_STR = '!HHIHHH2xHHI2xHI'
 NX_ACTION_MULTIPATH_SIZE = 32
 assert calcsize(NX_ACTION_MULTIPATH_PACK_STR) == NX_ACTION_MULTIPATH_SIZE
 
+NX_ACTION_BUNDLE_PACK_STR = '!HHIHHHHIHHI4x'
+NX_ACTION_BUNDLE_SIZE = 32
+assert calcsize(NX_ACTION_BUNDLE_PACK_STR) == NX_ACTION_BUNDLE_SIZE
+
 NX_ACTION_BUNDLE_LOAD_PACK_STR = '!HHIHHHHIHHI4x'
 NX_ACTION_BUNDLE_LOAD_SIZE = 32
 assert calcsize(NX_ACTION_BUNDLE_LOAD_PACK_STR) == NX_ACTION_BUNDLE_LOAD_SIZE
diff --git a/ryu/ofproto/ofproto_v1_0_parser.py 
b/ryu/ofproto/ofproto_v1_0_parser.py
index 73a3465..ca93091 100644
--- a/ryu/ofproto/ofproto_v1_0_parser.py
+++ b/ryu/ofproto/ofproto_v1_0_parser.py
@@ -580,6 +580,56 @@ class NXActionMultipath(NXActionHeader):
                    dst)
 
 
[email protected]_nx_action_subtype(ofproto_v1_0.NXAST_BUNDLE)
+class NXActionBundle(NXActionHeader):
+    def __init__(self, algorithm, fields, basis, slave_type, n_slaves,
+                 ofs_nbits, dst, slaves):
+        _len = ofproto_v1_0.NX_ACTION_BUNDLE_LOAD_SIZE + len(slaves) * 2
+        _len += (_len % 8)
+        super(NXActionBundle, self).__init__(
+            ofproto_v1_0.NXAST_BUNDLE, _len)
+        self.algorithm = algorithm
+        self.fields = fields
+        self.basis = basis
+        self.slave_type = slave_type
+        self.n_slaves = n_slaves
+        self.ofs_nbits = ofs_nbits
+        self.dst = dst
+        self.slaves = slaves
+
+    def serialize(self, buf, offset):
+        slave_offset = offset + ofproto_v1_0.NX_ACTION_BUNDLE_SIZE
+
+        for s in self.slaves:
+            msg_pack_into('!H', buf, slave_offset, s)
+            slave_offset += 2
+
+        pad_len = (len(self.slaves) * 2 + 
ofproto_v1_0.NX_ACTION_BUNDLE_LOAD_SIZE) % 8
+        if pad_len != 0:
+            msg_pack_into('%dx' % pad_len, buf, slave_offset)
+
+        msg_pack_into(ofproto_v1_0.NX_ACTION_BUNDLE_PACK_STR, buf,
+                      offset, self.type, self.len, self.vendor, self.subtype,
+                      self.algorithm, self.fields, self.basis,
+                      self.slave_type, self.n_slaves,
+                      self.ofs_nbits, self.dst)
+
+    @classmethod
+    def parser(cls, buf, offset):
+        type_, len_, vendor, subtype, algorithm, fields, basis, slave_type, 
n_slaves, ofs_nbits, dst = struct.unpack_from(
+            ofproto_v1_0.NX_ACTION_BUNDLE_PACK_STR, buf, offset)
+        slave_offset = offset + ofproto_v1_0.NX_ACTION_BUNDLE_SIZE
+
+        slaves = []
+        for i in range(0, n_slaves):
+            s = struct.unpack_from('!H', buf, slave_offset)
+            slaves.append(s[0])
+            slave_offset += 2
+
+        return cls(algorithm, fields, basis, slave_type,
+                   n_slaves, ofs_nbits, dst, slaves)
+
+
 @NXActionHeader.register_nx_action_subtype(ofproto_v1_0.NXAST_BUNDLE_LOAD)
 class NXActionBundleLoad(NXActionHeader):
     def __init__(self, algorithm, fields, basis, slave_type, n_slaves,
-- 
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to