ovn-controller: Use ofputil_encode_set_config to set the switch config
authorNuman Siddique <nusiddiq@redhat.com>
Wed, 10 Feb 2016 20:18:58 +0000 (12:18 -0800)
committerBen Pfaff <blp@ovn.org>
Wed, 10 Feb 2016 20:36:05 +0000 (12:36 -0800)
This is cleaner.

Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
ovn/controller/pinctrl.c

index 239b3ad..545ee47 100644 (file)
@@ -62,14 +62,11 @@ get_switch_config(struct rconn *swconn)
 }
 
 static void
-set_switch_config(struct rconn *swconn, const struct ofp_switch_config *config)
+set_switch_config(struct rconn *swconn,
+                  const struct ofputil_switch_config *config)
 {
-    struct ofpbuf *request;
-
-    request =
-        ofpraw_alloc(OFPRAW_OFPT_SET_CONFIG, rconn_get_version(swconn), 0);
-    ofpbuf_put(request, config, sizeof *config);
-
+    enum ofp_version version = rconn_get_version(swconn);
+    struct ofpbuf *request = ofputil_encode_set_config(config, version);
     queue_msg(request);
 }
 
@@ -98,13 +95,9 @@ pinctrl_recv(struct controller_ctx *ctx, const struct ofp_header *oh,
     if (type == OFPTYPE_ECHO_REQUEST) {
         queue_msg(make_echo_reply(oh));
     } else if (type == OFPTYPE_GET_CONFIG_REPLY) {
-        struct ofpbuf rq_buf;
-        struct ofp_switch_config *config_, config;
+        struct ofputil_switch_config config;
 
-        ofpbuf_use_const(&rq_buf, oh, ntohs(oh->length));
-        ofpraw_pull_assert(&rq_buf);
-        config_ = ofpbuf_pull(&rq_buf, sizeof *config_);
-        config = *config_;
+        ofputil_decode_get_config_reply(oh, &config);
         config.miss_send_len = htons(UINT16_MAX);
         set_switch_config(swconn, &config);
     } else if (type == OFPTYPE_PACKET_IN) {