-int
-ofproto_set_in_band(struct ofproto *p, bool in_band)
-{
- if (in_band != (p->in_band != NULL)) {
- if (in_band) {
- int error;
-
- error = in_band_create(p, p->dpif, p->switch_status, &p->in_band);
- if (error) {
- return error;
- }
- in_band_set_remotes(p->in_band, &p->controller->rconn, 1);
- } else {
- ofproto_set_discovery(p, false, NULL, true);
- in_band_destroy(p->in_band);
- p->in_band = NULL;
- }
- rconn_reconnect(p->controller->rconn);
- }
- return 0;
-}
-
-int
-ofproto_set_discovery(struct ofproto *p, bool discovery,
- const char *re, bool update_resolv_conf)
-{
- if (discovery != (p->discovery != NULL)) {
- if (discovery) {
- int error = ofproto_set_in_band(p, true);
- if (error) {
- return error;
- }
- error = discovery_create(re, update_resolv_conf,
- p->dpif, p->switch_status,
- &p->discovery);
- if (error) {
- return error;
- }
- } else {
- discovery_destroy(p->discovery);
- p->discovery = NULL;
- }
- rconn_disconnect(p->controller->rconn);
- } else if (discovery) {
- discovery_set_update_resolv_conf(p->discovery, update_resolv_conf);
- return discovery_set_accept_controller_re(p->discovery, re);
- }
- return 0;
-}
-
-int
-ofproto_set_controller(struct ofproto *ofproto, const char *controller)
-{
- if (ofproto->discovery) {
- return EINVAL;
- } else if (controller) {
- if (strcmp(rconn_get_name(ofproto->controller->rconn), controller)) {
- return rconn_connect(ofproto->controller->rconn, controller);
- } else {
- return 0;
- }
- } else {
- rconn_disconnect(ofproto->controller->rconn);
- return 0;
- }
-}
-