Hi all,

A while ago I sent a patch to add the ability to send switch config messages to switches from within Python apps. This diff appears not to have made it into the 0.50 release.

Here's my patch once again. This patch was made against an old version of the 0.40 branch -- as a result the patch refers to the old "apps" directory instead of the new "coreapps" directory.

Thanks,
Glen
diff --git a/src/nox/apps/pyrt/context.i b/src/nox/apps/pyrt/context.i
index 9b53c4a..8676b8e 100644
--- a/src/nox/apps/pyrt/context.i
+++ b/src/nox/apps/pyrt/context.i
@@ -111,6 +111,8 @@ public:
                        ethernetaddr addr, uint32_t mask, uint32_t config);
     void send_aggregate_stats_request(uint64_t datapath_ids, const
         struct ofp_match& match, uint8_t table_id);
+    int send_switch_config(uint64_t datapath_id, uint16_t flags);
+
 private:
     PyContext();
 
diff --git a/src/nox/apps/pyrt/pycontext.cc b/src/nox/apps/pyrt/pycontext.cc
index a525ae3..3acdcd9 100644
--- a/src/nox/apps/pyrt/pycontext.cc
+++ b/src/nox/apps/pyrt/pycontext.cc
@@ -411,6 +411,31 @@ PyContext::send_port_mod(uint64_t datapath_id, uint16_t port_no, ethernetaddr ad
     return error;
 }
 
+int
+PyContext::send_switch_config(uint64_t datapath_id, uint16_t flags)
+{
+    ofp_switch_config* osc = NULL;
+    size_t msize = sizeof(ofp_switch_config);
+    boost::shared_array<uint8_t> raw_sr(new uint8_t[msize]);
+
+    // Send OFPT_STATS_REQUEST
+    osc = (ofp_switch_config*) raw_sr.get();
+    osc->header.type    = OFPT_SET_CONFIG;
+    osc->header.version = OFP_VERSION;
+    osc->header.length  = htons(msize);
+    osc->header.xid     = 0;
+    osc->flags          = htons(flags);
+    osc->miss_send_len  = htons(OFP_DEFAULT_MISS_SEND_LEN);
+
+    int error = c->send_openflow_command(datapathid::from_host(datapath_id),
+                                         &osc->header, false);
+    if (error == EAGAIN) {
+        vlog().log(vlog().get_module_val("pyrt"), Vlog::LEVEL_ERR,
+                   "unable to send switch_config");
+    }
+
+    return error;
+}
 
 bool
 PyContext::unregister_handler(uint32_t rule_id) {
diff --git a/src/nox/apps/pyrt/pycontext.hh b/src/nox/apps/pyrt/pycontext.hh
index 5cc8222..814da6b 100644
--- a/src/nox/apps/pyrt/pycontext.hh
+++ b/src/nox/apps/pyrt/pycontext.hh
@@ -143,6 +143,7 @@ public:
                       ethernetaddr addr, uint32_t mask, uint32_t config);
     void send_aggregate_stats_request(uint64_t datapath_ids, const
         struct ofp_match& match, uint8_t table_id);
+    int send_switch_config(uint64_t datapath_id, uint16_t flags);
 
     /* C++ context */
     const container::Context* ctxt;
_______________________________________________
nox-dev mailing list
nox-dev@noxrepo.org
http://noxrepo.org/mailman/listinfo/nox-dev_noxrepo.org

Reply via email to