2 * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira Networks.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "vconn-provider.h"
22 #include <netinet/in.h>
27 #include "dynamic-string.h"
28 #include "fatal-signal.h"
30 #include "ofp-errors.h"
31 #include "ofp-print.h"
34 #include "openflow/nicira-ext.h"
35 #include "openflow/openflow.h"
37 #include "poll-loop.h"
42 VLOG_DEFINE_THIS_MODULE(vconn);
44 COVERAGE_DEFINE(vconn_open);
45 COVERAGE_DEFINE(vconn_received);
46 COVERAGE_DEFINE(vconn_sent);
48 /* State of an active vconn.*/
50 /* This is the ordinary progression of states. */
51 VCS_CONNECTING, /* Underlying vconn is not connected. */
52 VCS_SEND_HELLO, /* Waiting to send OFPT_HELLO message. */
53 VCS_RECV_HELLO, /* Waiting to receive OFPT_HELLO message. */
54 VCS_CONNECTED, /* Connection established. */
56 /* These states are entered only when something goes wrong. */
57 VCS_SEND_ERROR, /* Sending OFPT_ERROR message. */
58 VCS_DISCONNECTED /* Connection failed or connection closed. */
61 static struct vconn_class *vconn_classes[] = {
69 static struct pvconn_class *pvconn_classes[] = {
77 /* Rate limit for individual OpenFlow messages going over the vconn, output at
78 * DBG level. This is very high because, if these are enabled, it is because
79 * we really need to see them. */
80 static struct vlog_rate_limit ofmsg_rl = VLOG_RATE_LIMIT_INIT(600, 600);
82 /* Rate limit for OpenFlow message parse errors. These always indicate a bug
83 * in the peer and so there's not much point in showing a lot of them. */
84 static struct vlog_rate_limit bad_ofmsg_rl = VLOG_RATE_LIMIT_INIT(1, 5);
86 static int do_recv(struct vconn *, struct ofpbuf **);
87 static int do_send(struct vconn *, struct ofpbuf *);
89 /* Check the validity of the vconn class structures. */
91 check_vconn_classes(void)
96 for (i = 0; i < ARRAY_SIZE(vconn_classes); i++) {
97 struct vconn_class *class = vconn_classes[i];
98 assert(class->name != NULL);
99 assert(class->open != NULL);
100 if (class->close || class->recv || class->send
101 || class->run || class->run_wait || class->wait) {
102 assert(class->close != NULL);
103 assert(class->recv != NULL);
104 assert(class->send != NULL);
105 assert(class->wait != NULL);
107 /* This class delegates to another one. */
111 for (i = 0; i < ARRAY_SIZE(pvconn_classes); i++) {
112 struct pvconn_class *class = pvconn_classes[i];
113 assert(class->name != NULL);
114 assert(class->listen != NULL);
115 if (class->close || class->accept || class->wait) {
116 assert(class->close != NULL);
117 assert(class->accept != NULL);
118 assert(class->wait != NULL);
120 /* This class delegates to another one. */
126 /* Prints information on active (if 'active') and passive (if 'passive')
127 * connection methods supported by the vconn. If 'bootstrap' is true, also
128 * advertises options to bootstrap the CA certificate. */
130 vconn_usage(bool active, bool passive, bool bootstrap OVS_UNUSED)
132 /* Really this should be implemented via callbacks into the vconn
133 * providers, but that seems too heavy-weight to bother with at the
138 printf("Active OpenFlow connection methods:\n");
139 printf(" tcp:IP[:PORT] "
140 "PORT (default: %d) at remote IP\n", OFP_TCP_PORT);
142 printf(" ssl:IP[:PORT] "
143 "SSL PORT (default: %d) at remote IP\n", OFP_SSL_PORT);
145 printf(" unix:FILE Unix domain socket named FILE\n");
149 printf("Passive OpenFlow connection methods:\n");
150 printf(" ptcp:[PORT][:IP] "
151 "listen to TCP PORT (default: %d) on IP\n",
154 printf(" pssl:[PORT][:IP] "
155 "listen for SSL on PORT (default: %d) on IP\n",
158 printf(" punix:FILE "
159 "listen on Unix domain socket FILE\n");
163 printf("PKI configuration (required to use SSL):\n"
164 " -p, --private-key=FILE file with private key\n"
165 " -c, --certificate=FILE file with certificate for private key\n"
166 " -C, --ca-cert=FILE file with peer CA certificate\n");
168 printf(" --bootstrap-ca-cert=FILE file with peer CA certificate "
169 "to read or create\n");
174 /* Given 'name', a connection name in the form "TYPE:ARGS", stores the class
175 * named "TYPE" into '*classp' and returns 0. Returns EAFNOSUPPORT and stores
176 * a null pointer into '*classp' if 'name' is in the wrong form or if no such
179 vconn_lookup_class(const char *name, struct vconn_class **classp)
183 prefix_len = strcspn(name, ":");
184 if (name[prefix_len] != '\0') {
187 for (i = 0; i < ARRAY_SIZE(vconn_classes); i++) {
188 struct vconn_class *class = vconn_classes[i];
189 if (strlen(class->name) == prefix_len
190 && !memcmp(class->name, name, prefix_len)) {
201 /* Returns 0 if 'name' is a connection name in the form "TYPE:ARGS" and TYPE is
202 * a supported connection type, otherwise EAFNOSUPPORT. */
204 vconn_verify_name(const char *name)
206 struct vconn_class *class;
207 return vconn_lookup_class(name, &class);
210 /* Attempts to connect to an OpenFlow device. 'name' is a connection name in
211 * the form "TYPE:ARGS", where TYPE is an active vconn class's name and ARGS
212 * are vconn class-specific.
214 * The vconn will automatically negotiate an OpenFlow protocol version
215 * acceptable to both peers on the connection. The version negotiated will be
216 * no lower than 'min_version' and no higher than OFP_VERSION.
218 * Returns 0 if successful, otherwise a positive errno value. If successful,
219 * stores a pointer to the new connection in '*vconnp', otherwise a null
222 vconn_open(const char *name, int min_version, struct vconn **vconnp)
224 struct vconn_class *class;
229 COVERAGE_INC(vconn_open);
230 check_vconn_classes();
232 /* Look up the class. */
233 error = vconn_lookup_class(name, &class);
238 /* Call class's "open" function. */
239 suffix_copy = xstrdup(strchr(name, ':') + 1);
240 error = class->open(name, suffix_copy, &vconn);
247 assert(vconn->state != VCS_CONNECTING || vconn->class->connect);
248 vconn->min_version = min_version;
257 /* Allows 'vconn' to perform maintenance activities, such as flushing output
260 vconn_run(struct vconn *vconn)
262 if (vconn->class->run) {
263 (vconn->class->run)(vconn);
267 /* Arranges for the poll loop to wake up when 'vconn' needs to perform
268 * maintenance activities. */
270 vconn_run_wait(struct vconn *vconn)
272 if (vconn->class->run_wait) {
273 (vconn->class->run_wait)(vconn);
278 vconn_open_block(const char *name, int min_version, struct vconn **vconnp)
285 error = vconn_open(name, min_version, &vconn);
287 while ((error = vconn_connect(vconn)) == EAGAIN) {
289 vconn_run_wait(vconn);
290 vconn_connect_wait(vconn);
293 assert(error != EINPROGRESS);
305 /* Closes 'vconn'. */
307 vconn_close(struct vconn *vconn)
310 char *name = vconn->name;
311 (vconn->class->close)(vconn);
316 /* Returns the name of 'vconn', that is, the string passed to vconn_open(). */
318 vconn_get_name(const struct vconn *vconn)
323 /* Returns the IP address of the peer, or 0 if the peer is not connected over
324 * an IP-based protocol or if its IP address is not yet known. */
326 vconn_get_remote_ip(const struct vconn *vconn)
328 return vconn->remote_ip;
331 /* Returns the transport port of the peer, or 0 if the connection does not
332 * contain a port or if the port is not yet known. */
334 vconn_get_remote_port(const struct vconn *vconn)
336 return vconn->remote_port;
339 /* Returns the IP address used to connect to the peer, or 0 if the
340 * connection is not an IP-based protocol or if its IP address is not
343 vconn_get_local_ip(const struct vconn *vconn)
345 return vconn->local_ip;
348 /* Returns the transport port used to connect to the peer, or 0 if the
349 * connection does not contain a port or if the port is not yet known. */
351 vconn_get_local_port(const struct vconn *vconn)
353 return vconn->local_port;
357 vcs_connecting(struct vconn *vconn)
359 int retval = (vconn->class->connect)(vconn);
360 assert(retval != EINPROGRESS);
362 vconn->state = VCS_SEND_HELLO;
363 } else if (retval != EAGAIN) {
364 vconn->state = VCS_DISCONNECTED;
365 vconn->error = retval;
370 vcs_send_hello(struct vconn *vconn)
375 make_openflow(sizeof(struct ofp_header), OFPT_HELLO, &b);
376 retval = do_send(vconn, b);
378 vconn->state = VCS_RECV_HELLO;
381 if (retval != EAGAIN) {
382 vconn->state = VCS_DISCONNECTED;
383 vconn->error = retval;
389 vcs_recv_hello(struct vconn *vconn)
394 retval = do_recv(vconn, &b);
396 struct ofp_header *oh = b->data;
398 if (oh->type == OFPT_HELLO) {
399 if (b->size > sizeof *oh) {
400 struct ds msg = DS_EMPTY_INITIALIZER;
401 ds_put_format(&msg, "%s: extra-long hello:\n", vconn->name);
402 ds_put_hex_dump(&msg, b->data, b->size, 0, true);
403 VLOG_WARN_RL(&bad_ofmsg_rl, "%s", ds_cstr(&msg));
407 vconn->version = MIN(OFP_VERSION, oh->version);
408 if (vconn->version < vconn->min_version) {
409 VLOG_WARN_RL(&bad_ofmsg_rl,
410 "%s: version negotiation failed: we support "
411 "versions 0x%02x to 0x%02x inclusive but peer "
412 "supports no later than version 0x%02"PRIx8,
413 vconn->name, vconn->min_version, OFP_VERSION,
415 vconn->state = VCS_SEND_ERROR;
417 VLOG_DBG("%s: negotiated OpenFlow version 0x%02x "
418 "(we support versions 0x%02x to 0x%02x inclusive, "
419 "peer no later than version 0x%02"PRIx8")",
420 vconn->name, vconn->version, vconn->min_version,
421 OFP_VERSION, oh->version);
422 vconn->state = VCS_CONNECTED;
427 char *s = ofp_to_string(b->data, b->size, 1);
428 VLOG_WARN_RL(&bad_ofmsg_rl,
429 "%s: received message while expecting hello: %s",
437 if (retval != EAGAIN) {
438 vconn->state = VCS_DISCONNECTED;
439 vconn->error = retval == EOF ? ECONNRESET : retval;
444 vcs_send_error(struct vconn *vconn)
450 snprintf(s, sizeof s, "We support versions 0x%02x to 0x%02x inclusive but "
451 "you support no later than version 0x%02"PRIx8".",
452 vconn->min_version, OFP_VERSION, vconn->version);
453 b = ofperr_encode_hello(OFPERR_OFPHFC_INCOMPATIBLE,
454 ofperr_domain_from_version(vconn->version), s);
455 retval = do_send(vconn, b);
459 if (retval != EAGAIN) {
460 vconn->state = VCS_DISCONNECTED;
461 vconn->error = retval ? retval : EPROTO;
465 /* Tries to complete the connection on 'vconn'. If 'vconn''s connection is
466 * complete, returns 0 if the connection was successful or a positive errno
467 * value if it failed. If the connection is still in progress, returns
470 vconn_connect(struct vconn *vconn)
472 enum vconn_state last_state;
474 assert(vconn->min_version >= 0);
476 last_state = vconn->state;
477 switch (vconn->state) {
479 vcs_connecting(vconn);
483 vcs_send_hello(vconn);
487 vcs_recv_hello(vconn);
494 vcs_send_error(vconn);
497 case VCS_DISCONNECTED:
503 } while (vconn->state != last_state);
508 /* Tries to receive an OpenFlow message from 'vconn'. If successful, stores
509 * the received message into '*msgp' and returns 0. The caller is responsible
510 * for destroying the message with ofpbuf_delete(). On failure, returns a
511 * positive errno value and stores a null pointer into '*msgp'. On normal
512 * connection close, returns EOF.
514 * vconn_recv will not block waiting for a packet to arrive. If no packets
515 * have been received, it returns EAGAIN immediately. */
517 vconn_recv(struct vconn *vconn, struct ofpbuf **msgp)
519 int retval = vconn_connect(vconn);
521 retval = do_recv(vconn, msgp);
527 do_recv(struct vconn *vconn, struct ofpbuf **msgp)
529 int retval = (vconn->class->recv)(vconn, msgp);
531 struct ofp_header *oh;
533 COVERAGE_INC(vconn_received);
534 if (VLOG_IS_DBG_ENABLED()) {
535 char *s = ofp_to_string((*msgp)->data, (*msgp)->size, 1);
536 VLOG_DBG_RL(&ofmsg_rl, "%s: received: %s", vconn->name, s);
540 oh = ofpbuf_at_assert(*msgp, 0, sizeof *oh);
541 if (oh->version != vconn->version
542 && oh->type != OFPT_HELLO
543 && oh->type != OFPT_ERROR
544 && oh->type != OFPT_ECHO_REQUEST
545 && oh->type != OFPT_ECHO_REPLY
546 && oh->type != OFPT_VENDOR)
548 if (vconn->version < 0) {
549 VLOG_ERR_RL(&bad_ofmsg_rl,
550 "%s: received OpenFlow message type %"PRIu8" "
551 "before version negotiation complete",
552 vconn->name, oh->type);
554 VLOG_ERR_RL(&bad_ofmsg_rl,
555 "%s: received OpenFlow version 0x%02"PRIx8" "
557 vconn->name, oh->version, vconn->version);
559 ofpbuf_delete(*msgp);
569 /* Tries to queue 'msg' for transmission on 'vconn'. If successful, returns 0,
570 * in which case ownership of 'msg' is transferred to the vconn. Success does
571 * not guarantee that 'msg' has been or ever will be delivered to the peer,
572 * only that it has been queued for transmission.
574 * Returns a positive errno value on failure, in which case the caller
575 * retains ownership of 'msg'.
577 * vconn_send will not block. If 'msg' cannot be immediately accepted for
578 * transmission, it returns EAGAIN immediately. */
580 vconn_send(struct vconn *vconn, struct ofpbuf *msg)
582 int retval = vconn_connect(vconn);
584 retval = do_send(vconn, msg);
590 do_send(struct vconn *vconn, struct ofpbuf *msg)
594 assert(msg->size >= sizeof(struct ofp_header));
595 assert(((struct ofp_header *) msg->data)->length == htons(msg->size));
596 if (!VLOG_IS_DBG_ENABLED()) {
597 COVERAGE_INC(vconn_sent);
598 retval = (vconn->class->send)(vconn, msg);
600 char *s = ofp_to_string(msg->data, msg->size, 1);
601 retval = (vconn->class->send)(vconn, msg);
602 if (retval != EAGAIN) {
603 VLOG_DBG_RL(&ofmsg_rl, "%s: sent (%s): %s",
604 vconn->name, strerror(retval), s);
611 /* Same as vconn_send, except that it waits until 'msg' can be transmitted. */
613 vconn_send_block(struct vconn *vconn, struct ofpbuf *msg)
619 while ((retval = vconn_send(vconn, msg)) == EAGAIN) {
621 vconn_run_wait(vconn);
622 vconn_send_wait(vconn);
628 /* Same as vconn_recv, except that it waits until a message is received. */
630 vconn_recv_block(struct vconn *vconn, struct ofpbuf **msgp)
636 while ((retval = vconn_recv(vconn, msgp)) == EAGAIN) {
638 vconn_run_wait(vconn);
639 vconn_recv_wait(vconn);
645 /* Waits until a message with a transaction ID matching 'xid' is recived on
646 * 'vconn'. Returns 0 if successful, in which case the reply is stored in
647 * '*replyp' for the caller to examine and free. Otherwise returns a positive
648 * errno value, or EOF, and sets '*replyp' to null.
650 * 'request' is always destroyed, regardless of the return value. */
652 vconn_recv_xid(struct vconn *vconn, ovs_be32 xid, struct ofpbuf **replyp)
656 struct ofpbuf *reply;
659 error = vconn_recv_block(vconn, &reply);
664 recv_xid = ((struct ofp_header *) reply->data)->xid;
665 if (xid == recv_xid) {
670 VLOG_DBG_RL(&bad_ofmsg_rl, "%s: received reply with xid %08"PRIx32
671 " != expected %08"PRIx32,
672 vconn->name, ntohl(recv_xid), ntohl(xid));
673 ofpbuf_delete(reply);
677 /* Sends 'request' to 'vconn' and blocks until it receives a reply with a
678 * matching transaction ID. Returns 0 if successful, in which case the reply
679 * is stored in '*replyp' for the caller to examine and free. Otherwise
680 * returns a positive errno value, or EOF, and sets '*replyp' to null.
682 * 'request' should be an OpenFlow request that requires a reply. Otherwise,
683 * if there is no reply, this function can end up blocking forever (or until
684 * the peer drops the connection).
686 * 'request' is always destroyed, regardless of the return value. */
688 vconn_transact(struct vconn *vconn, struct ofpbuf *request,
689 struct ofpbuf **replyp)
691 ovs_be32 send_xid = ((struct ofp_header *) request->data)->xid;
695 error = vconn_send_block(vconn, request);
697 ofpbuf_delete(request);
699 return error ? error : vconn_recv_xid(vconn, send_xid, replyp);
702 /* Sends 'request' followed by a barrier request to 'vconn', then blocks until
703 * it receives a reply to the barrier. If successful, stores the reply to
704 * 'request' in '*replyp', if one was received, and otherwise NULL, then
705 * returns 0. Otherwise returns a positive errno value, or EOF, and sets
708 * This function is useful for sending an OpenFlow request that doesn't
709 * ordinarily include a reply but might report an error in special
712 * 'request' is always destroyed, regardless of the return value. */
714 vconn_transact_noreply(struct vconn *vconn, struct ofpbuf *request,
715 struct ofpbuf **replyp)
717 ovs_be32 request_xid;
718 ovs_be32 barrier_xid;
719 struct ofpbuf *barrier;
725 request_xid = ((struct ofp_header *) request->data)->xid;
726 error = vconn_send_block(vconn, request);
728 ofpbuf_delete(request);
733 barrier = ofputil_encode_barrier_request();
734 barrier_xid = ((struct ofp_header *) barrier->data)->xid;
735 error = vconn_send_block(vconn, barrier);
737 ofpbuf_delete(barrier);
746 error = vconn_recv_block(vconn, &msg);
748 ofpbuf_delete(*replyp);
753 msg_xid = ((struct ofp_header *) msg->data)->xid;
754 if (msg_xid == request_xid) {
756 VLOG_WARN_RL(&bad_ofmsg_rl, "%s: duplicate replies with "
757 "xid %08"PRIx32, vconn->name, ntohl(msg_xid));
758 ofpbuf_delete(*replyp);
763 if (msg_xid == barrier_xid) {
766 VLOG_DBG_RL(&bad_ofmsg_rl, "%s: reply with xid %08"PRIx32
767 " != expected %08"PRIx32" or %08"PRIx32,
768 vconn->name, ntohl(msg_xid),
769 ntohl(request_xid), ntohl(barrier_xid));
775 /* vconn_transact_noreply() for a list of "struct ofpbuf"s, sent one by one.
776 * All of the requests on 'requests' are always destroyed, regardless of the
779 vconn_transact_multiple_noreply(struct vconn *vconn, struct list *requests,
780 struct ofpbuf **replyp)
782 struct ofpbuf *request, *next;
784 LIST_FOR_EACH_SAFE (request, next, list_node, requests) {
787 list_remove(&request->list_node);
789 error = vconn_transact_noreply(vconn, request, replyp);
790 if (error || *replyp) {
791 ofpbuf_list_delete(requests);
801 vconn_wait(struct vconn *vconn, enum vconn_wait_type wait)
803 assert(wait == WAIT_CONNECT || wait == WAIT_RECV || wait == WAIT_SEND);
805 switch (vconn->state) {
822 case VCS_DISCONNECTED:
823 poll_immediate_wake();
826 (vconn->class->wait)(vconn, wait);
830 vconn_connect_wait(struct vconn *vconn)
832 vconn_wait(vconn, WAIT_CONNECT);
836 vconn_recv_wait(struct vconn *vconn)
838 vconn_wait(vconn, WAIT_RECV);
842 vconn_send_wait(struct vconn *vconn)
844 vconn_wait(vconn, WAIT_SEND);
847 /* Given 'name', a connection name in the form "TYPE:ARGS", stores the class
848 * named "TYPE" into '*classp' and returns 0. Returns EAFNOSUPPORT and stores
849 * a null pointer into '*classp' if 'name' is in the wrong form or if no such
852 pvconn_lookup_class(const char *name, struct pvconn_class **classp)
856 prefix_len = strcspn(name, ":");
857 if (name[prefix_len] != '\0') {
860 for (i = 0; i < ARRAY_SIZE(pvconn_classes); i++) {
861 struct pvconn_class *class = pvconn_classes[i];
862 if (strlen(class->name) == prefix_len
863 && !memcmp(class->name, name, prefix_len)) {
874 /* Returns 0 if 'name' is a connection name in the form "TYPE:ARGS" and TYPE is
875 * a supported connection type, otherwise EAFNOSUPPORT. */
877 pvconn_verify_name(const char *name)
879 struct pvconn_class *class;
880 return pvconn_lookup_class(name, &class);
883 /* Attempts to start listening for OpenFlow connections. 'name' is a
884 * connection name in the form "TYPE:ARGS", where TYPE is an passive vconn
885 * class's name and ARGS are vconn class-specific.
887 * Returns 0 if successful, otherwise a positive errno value. If successful,
888 * stores a pointer to the new connection in '*pvconnp', otherwise a null
891 pvconn_open(const char *name, struct pvconn **pvconnp)
893 struct pvconn_class *class;
894 struct pvconn *pvconn;
898 check_vconn_classes();
900 /* Look up the class. */
901 error = pvconn_lookup_class(name, &class);
906 /* Call class's "open" function. */
907 suffix_copy = xstrdup(strchr(name, ':') + 1);
908 error = class->listen(name, suffix_copy, &pvconn);
923 /* Returns the name that was used to open 'pvconn'. The caller must not
924 * modify or free the name. */
926 pvconn_get_name(const struct pvconn *pvconn)
931 /* Closes 'pvconn'. */
933 pvconn_close(struct pvconn *pvconn)
935 if (pvconn != NULL) {
936 char *name = pvconn->name;
937 (pvconn->class->close)(pvconn);
942 /* Tries to accept a new connection on 'pvconn'. If successful, stores the new
943 * connection in '*new_vconn' and returns 0. Otherwise, returns a positive
946 * The new vconn will automatically negotiate an OpenFlow protocol version
947 * acceptable to both peers on the connection. The version negotiated will be
948 * no lower than 'min_version' and no higher than OFP_VERSION.
950 * pvconn_accept() will not block waiting for a connection. If no connection
951 * is ready to be accepted, it returns EAGAIN immediately. */
953 pvconn_accept(struct pvconn *pvconn, int min_version, struct vconn **new_vconn)
955 int retval = (pvconn->class->accept)(pvconn, new_vconn);
959 assert((*new_vconn)->state != VCS_CONNECTING
960 || (*new_vconn)->class->connect);
961 (*new_vconn)->min_version = min_version;
967 pvconn_wait(struct pvconn *pvconn)
969 (pvconn->class->wait)(pvconn);
972 /* Initializes 'vconn' as a new vconn named 'name', implemented via 'class'.
973 * The initial connection status, supplied as 'connect_status', is interpreted
976 * - 0: 'vconn' is connected. Its 'send' and 'recv' functions may be
977 * called in the normal fashion.
979 * - EAGAIN: 'vconn' is trying to complete a connection. Its 'connect'
980 * function should be called to complete the connection.
982 * - Other positive errno values indicate that the connection failed with
983 * the specified error.
985 * After calling this function, vconn_close() must be used to destroy 'vconn',
986 * otherwise resources will be leaked.
988 * The caller retains ownership of 'name'. */
990 vconn_init(struct vconn *vconn, struct vconn_class *class, int connect_status,
993 vconn->class = class;
994 vconn->state = (connect_status == EAGAIN ? VCS_CONNECTING
995 : !connect_status ? VCS_SEND_HELLO
997 vconn->error = connect_status;
999 vconn->min_version = -1;
1000 vconn->remote_ip = 0;
1001 vconn->remote_port = 0;
1002 vconn->local_ip = 0;
1003 vconn->local_port = 0;
1004 vconn->name = xstrdup(name);
1005 assert(vconn->state != VCS_CONNECTING || class->connect);
1009 vconn_set_remote_ip(struct vconn *vconn, ovs_be32 ip)
1011 vconn->remote_ip = ip;
1015 vconn_set_remote_port(struct vconn *vconn, ovs_be16 port)
1017 vconn->remote_port = port;
1021 vconn_set_local_ip(struct vconn *vconn, ovs_be32 ip)
1023 vconn->local_ip = ip;
1027 vconn_set_local_port(struct vconn *vconn, ovs_be16 port)
1029 vconn->local_port = port;
1033 pvconn_init(struct pvconn *pvconn, struct pvconn_class *class,
1036 pvconn->class = class;
1037 pvconn->name = xstrdup(name);