Describe dummy test model. Work on OpenFlow intro.
[openvswitch] / lib / vconn.c
index 24a369d8a1233f969cd78cca4fe1fc667646d8d2..4e92834edfc92100048b696b0345097e16307a3d 100644 (file)
@@ -343,6 +343,14 @@ vconn_get_allowed_versions(const struct vconn *vconn)
     return vconn->allowed_versions;
 }
 
+/* Sets the allowed_versions of 'vconn', overriding
+ * the allowed_versions passed to vconn_open(). */
+void
+vconn_set_allowed_versions(struct vconn *vconn, uint32_t allowed_versions)
+{
+    vconn->allowed_versions = allowed_versions;
+}
+
 /* Returns the IP address of the peer, or 0 if the peer is not connected over
  * an IP-based protocol or if its IP address is not yet known. */
 ovs_be32
@@ -406,8 +414,7 @@ vcs_send_hello(struct vconn *vconn)
     struct ofpbuf *b;
     int retval;
 
-    b = ofpraw_alloc(OFPRAW_OFPT_HELLO,
-                     leftmost_1bit_idx(vconn->allowed_versions), 0);
+    b = ofputil_encode_hello(vconn->allowed_versions);
     retval = do_send(vconn, b);
     if (!retval) {
         vconn->state = VCS_RECV_HELLO;
@@ -450,7 +457,6 @@ vcs_recv_hello(struct vconn *vconn)
 
     retval = do_recv(vconn, &b);
     if (!retval) {
-        const struct ofp_header *oh = b->data;
         enum ofptype type;
         enum ofperr error;
 
@@ -459,9 +465,10 @@ vcs_recv_hello(struct vconn *vconn)
             char *peer_s, *local_s;
             uint32_t common_versions;
 
-            if (b->size > sizeof *oh) {
+            if (!ofputil_decode_hello(b->data, &vconn->peer_versions)) {
                 struct ds msg = DS_EMPTY_INITIALIZER;
-                ds_put_format(&msg, "%s: extra-long hello:\n", vconn->name);
+                ds_put_format(&msg, "%s: unknown data in hello:\n",
+                              vconn->name);
                 ds_put_hex_dump(&msg, b->data, b->size, 0, true);
                 VLOG_WARN_RL(&bad_ofmsg_rl, "%s", ds_cstr(&msg));
                 ds_destroy(&msg);