+ enum ofputil_protocol usable_protocols;
+ struct ofpbuf *msg = NULL;
+ int error = 0;
+ size_t i;
+
+ /* If the initial protocol isn't good enough for default_flows, then
+ * pick one that will work and encode messages to set up that
+ * protocol.
+ *
+ * This could be improved by actually negotiating a mutually acceptable
+ * flow format with the switch, but that would require an asynchronous
+ * state machine. This version ought to work fine in practice. */
+ usable_protocols = ofputil_flow_mod_usable_protocols(
+ cfg->default_flows, cfg->n_default_flows);
+ if (!(protocol & usable_protocols)) {
+ enum ofputil_protocol want = rightmost_1bit(usable_protocols);
+ while (!error) {
+ msg = ofputil_encode_set_protocol(protocol, want, &protocol);
+ if (!msg) {
+ break;
+ }
+ error = rconn_send(rconn, msg, NULL);
+ }
+ }