Signed-off-by: Simon Horman <[email protected]>
---
 ryu/ofproto/ofproto_v1_4_parser.py | 87 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)

diff --git a/ryu/ofproto/ofproto_v1_4_parser.py 
b/ryu/ofproto/ofproto_v1_4_parser.py
index 05dc115..50b08aa 100644
--- a/ryu/ofproto/ofproto_v1_4_parser.py
+++ b/ryu/ofproto/ofproto_v1_4_parser.py
@@ -4561,6 +4561,93 @@ class OFPGroupMod(MsgBase):
             offset += b.len
 
 
+class OFPPortModPropEthernet(StringifyMixin):
+    _PACK_STR = '!HHI'  # type, len, advertise
+
+    def __init__(self, type_=None, length=None, advertise=None):
+        self.type = type_
+        self.advertise = advertise
+
+    def serialize(self):
+        # fixup
+        self.length = struct.calcsize(self._PACK_STR)
+
+        buf = bytearray()
+        msg_pack_into(self._PACK_STR, buf, 0, self.type, self.length,
+                      self.advertise)
+        return buf
+
+
+@_set_msg_type(ofproto.OFPT_PORT_MOD)
+class OFPPortMod(MsgBase):
+    """
+    Port modification message
+
+    The controller sneds this message to modify the behavior of the port.
+
+    ================ ======================================================
+    Attribute        Description
+    ================ ======================================================
+    port_no          Port number to modify
+    hw_addr          The hardware address that must be the same as hw_addr
+                     of ``OFPPort`` of ``OFPSwitchFeatures``
+    config           Bitmap of configuration flags.
+                     OFPPC_PORT_DOWN
+                     OFPPC_NO_RECV
+                     OFPPC_NO_FWD
+                     OFPPC_NO_PACKET_IN
+    mask             Bitmap of configuration flags above to be changed
+    properties       List of ``OFPPortProp`` subclass instance
+    ================ ======================================================
+
+    Example::
+
+        def send_port_mod(self, datapath):
+            ofp = datapath.ofproto
+            ofp_parser = datapath.ofproto_parser
+
+            port_no = 3
+            hw_addr = 'fa:c8:e8:76:1d:7e'
+            config = 0
+            mask = (ofp.OFPPC_PORT_DOWN | ofp.OFPPC_NO_RECV |
+                    ofp.OFPPC_NO_FWD | ofp.OFPPC_NO_PACKET_IN)
+            advertise = (ofp.OFPPF_10MB_HD | ofp.OFPPF_100MB_FD |
+                         ofp.OFPPF_1GB_FD | ofp.OFPPF_COPPER |
+                         ofp.OFPPF_AUTONEG | ofp.OFPPF_PAUSE |
+                         ofp.OFPPF_PAUSE_ASYM)
+            properties = ofp_parser.OFPPortModPropEthernet(advertise)
+            req = ofp_parser.OFPPortMod(datapath, port_no, hw_addr, config,
+                                        mask, properties)
+            datapath.send_msg(req)
+    """
+
+    _TYPE = {
+        'ascii': [
+            'hw_addr',
+        ]
+    }
+
+    def __init__(self, datapath, port_no, hw_addr, config, mask, properties):
+        super(OFPPortMod, self).__init__(datapath)
+        self.port_no = port_no
+        self.hw_addr = hw_addr
+        self.config = config
+        self.mask = mask
+        self.properties = properties
+
+    def _serialize_body(self):
+        bin_props = bytearray()
+        for p in self.properties:
+            bin_props += p.serialize()
+
+        msg_pack_into(ofproto.OFP_PORT_MOD_PACK_STR, self.buf,
+                      ofproto.OFP_HEADER_SIZE,
+                      self.port_no, addrconv.mac.text_to_bin(self.hw_addr),
+                      self.config,
+                      self.mask)
+        self.buf += bin_props
+
+
 class OFPBucket(StringifyMixin):
     def __init__(self, weight, watch_port, watch_group, actions, len_=None):
         super(OFPBucket, self).__init__()
-- 
1.8.5.2


------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to