--- /dev/null
+/*
+ * Copyright (c) 2011 Nicira Networks.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <config.h>
+
+#include "ofproto/ofproto.h"
+
+#include "dpif.h"
+
+/* This function is in a separate file because it is the only ofproto function
+ * required by ovs-ofctl, which allows ovs-ofctl to avoid linking in extra
+ * baggage. */
+
+/* Parses 'ofproto_name', which is of the form [type@]name into component
+ * pieces that are suitable for passing to ofproto_create(). The caller must
+ * free 'name' and 'type'. */
+void
+ofproto_parse_name(const char *ofproto_name, char **name, char **type)
+{
+ dp_parse_name(ofproto_name, name, type);
+}
+
#include "command-line.h"
#include "compiler.h"
#include "dirs.h"
-#include "dpif.h"
#include "dynamic-string.h"
#include "netlink.h"
#include "nx-match.h"
#include "ofp-print.h"
#include "ofp-util.h"
#include "ofpbuf.h"
+#include "ofproto/ofproto.h"
#include "openflow/nicira-ext.h"
#include "openflow/openflow.h"
#include "random.h"
open_vconn__(const char *name, const char *default_suffix,
struct vconn **vconnp)
{
- struct dpif *dpif;
+ char *datapath_name, *datapath_type, *socket_name;
+ char *bridge_path;
struct stat s;
- char *bridge_path, *datapath_name, *datapath_type;
bridge_path = xasprintf("%s/%s.%s", ovs_rundir(), name, default_suffix);
- dp_parse_name(name, &datapath_name, &datapath_type);
+
+ ofproto_parse_name(name, &datapath_name, &datapath_type);
+ socket_name = xasprintf("%s/%s.%s",
+ ovs_rundir(), datapath_name, default_suffix);
+ free(datapath_name);
+ free(datapath_type);
if (strstr(name, ":")) {
run(vconn_open_block(name, OFP_VERSION, vconnp),
open_vconn_socket(name, vconnp);
} else if (!stat(bridge_path, &s) && S_ISSOCK(s.st_mode)) {
open_vconn_socket(bridge_path, vconnp);
- } else if (!dpif_open(datapath_name, datapath_type, &dpif)) {
- char dpif_name[IF_NAMESIZE + 1];
- char *socket_name;
-
- run(dpif_port_get_name(dpif, ODPP_LOCAL, dpif_name, sizeof dpif_name),
- "obtaining name of %s", dpif_name);
- dpif_close(dpif);
- if (strcmp(dpif_name, name)) {
- VLOG_DBG("datapath %s is named %s", name, dpif_name);
- }
-
- socket_name = xasprintf("%s/%s.%s",
- ovs_rundir(), dpif_name, default_suffix);
- if (stat(socket_name, &s)) {
- ovs_fatal(errno, "cannot connect to %s: stat failed on %s",
- name, socket_name);
- } else if (!S_ISSOCK(s.st_mode)) {
+ } else if (!stat(socket_name, &s)) {
+ if (!S_ISSOCK(s.st_mode)) {
ovs_fatal(0, "cannot connect to %s: %s is not a socket",
name, socket_name);
}
-
open_vconn_socket(socket_name, vconnp);
- free(socket_name);
} else {
ovs_fatal(0, "%s is not a valid connection method", name);
}
- free(datapath_name);
- free(datapath_type);
free(bridge_path);
+ free(socket_name);
}
static void