1 /* Copyright (c) 2008 The Board of Trustees of The Leland Stanford
4 * We are making the OpenFlow specification and associated documentation
5 * (Software) available for public use and benefit with the expectation
6 * that others will use, modify and enhance the Software and contribute
7 * those enhancements back to the community. However, since we would
8 * like to make the Software available for broadest use, with as few
9 * restrictions as possible permission is hereby granted, free of
10 * charge, to any person obtaining a copy of this Software to deal in
11 * the Software under the copyrights without restriction, including
12 * without limitation the rights to use, copy, modify, merge, publish,
13 * distribute, sublicense, and/or sell copies of the Software, and to
14 * permit persons to whom the Software is furnished to do so, subject to
15 * the following conditions:
17 * The above copyright notice and this permission notice shall be
18 * included in all copies or substantial portions of the Software.
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
24 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
25 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
26 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 * The name and trademarks of copyright holder(s) may NOT be used in
30 * advertising or publicity pertaining to the Software or any
31 * derivatives without specific, written prior permission.
35 #include "vconn-provider.h"
39 #include <netinet/in.h>
43 #include "dynamic-string.h"
45 #include "ofp-print.h"
48 #include "poll-loop.h"
52 #define THIS_MODULE VLM_vconn
55 /* State of an active vconn.*/
57 /* This is the ordinary progression of states. */
58 VCS_CONNECTING, /* Underlying vconn is not connected. */
59 VCS_SEND_HELLO, /* Waiting to send OFPT_HELLO message. */
60 VCS_RECV_HELLO, /* Waiting to receive OFPT_HELLO message. */
61 VCS_CONNECTED, /* Connection established. */
63 /* These states are entered only when something goes wrong. */
64 VCS_SEND_ERROR, /* Sending OFPT_ERROR message. */
65 VCS_DISCONNECTED /* Connection failed or connection closed. */
68 static struct vconn_class *vconn_classes[] = {
79 static struct pvconn_class *pvconn_classes[] = {
87 /* High rate limit because most of the rate-limiting here is individual
88 * OpenFlow messages going over the vconn. If those are enabled then we
89 * really need to see them. */
90 static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(600, 600);
92 static int do_recv(struct vconn *, struct ofpbuf **);
93 static int do_send(struct vconn *, struct ofpbuf *);
95 /* Check the validity of the vconn class structures. */
97 check_vconn_classes(void)
102 for (i = 0; i < ARRAY_SIZE(vconn_classes); i++) {
103 struct vconn_class *class = vconn_classes[i];
104 assert(class->name != NULL);
105 assert(class->open != NULL);
106 if (class->close || class->recv || class->send || class->wait) {
107 assert(class->close != NULL);
108 assert(class->recv != NULL);
109 assert(class->send != NULL);
110 assert(class->wait != NULL);
112 /* This class delegates to another one. */
116 for (i = 0; i < ARRAY_SIZE(pvconn_classes); i++) {
117 struct pvconn_class *class = pvconn_classes[i];
118 assert(class->name != NULL);
119 assert(class->listen != NULL);
120 if (class->close || class->accept || class->wait) {
121 assert(class->close != NULL);
122 assert(class->accept != NULL);
123 assert(class->wait != NULL);
125 /* This class delegates to another one. */
131 /* Prints information on active (if 'active') and passive (if 'passive')
132 * connection methods supported by the vconn. If 'bootstrap' is true, also
133 * advertises options to bootstrap the CA certificate. */
135 vconn_usage(bool active, bool passive, bool bootstrap UNUSED)
137 /* Really this should be implemented via callbacks into the vconn
138 * providers, but that seems too heavy-weight to bother with at the
143 printf("Active OpenFlow connection methods:\n");
146 "local datapath DP_IDX\n");
148 printf(" tcp:HOST[:PORT] "
149 "PORT (default: %d) on remote TCP HOST\n", OFP_TCP_PORT);
151 printf(" ssl:HOST[:PORT] "
152 "SSL PORT (default: %d) on remote HOST\n", OFP_SSL_PORT);
154 printf(" unix:FILE Unix domain socket named FILE\n");
158 printf("Passive OpenFlow connection methods:\n");
159 printf(" ptcp:[PORT] "
160 "listen to TCP PORT (default: %d)\n",
163 printf(" pssl:[PORT] "
164 "listen for SSL on PORT (default: %d)\n",
167 printf(" punix:FILE "
168 "listen on Unix domain socket FILE\n");
172 printf("PKI configuration (required to use SSL):\n"
173 " -p, --private-key=FILE file with private key\n"
174 " -c, --certificate=FILE file with certificate for private key\n"
175 " -C, --ca-cert=FILE file with peer CA certificate\n");
177 printf(" --bootstrap-ca-cert=FILE file with peer CA certificate "
178 "to read or create\n");
183 /* Attempts to connect to an OpenFlow device. 'name' is a connection name in
184 * the form "TYPE:ARGS", where TYPE is an active vconn class's name and ARGS
185 * are vconn class-specific.
187 * The vconn will automatically negotiate an OpenFlow protocol version
188 * acceptable to both peers on the connection. The version negotiated will be
189 * no lower than 'min_version' and no higher than OFP_VERSION.
191 * Returns 0 if successful, otherwise a positive errno value. If successful,
192 * stores a pointer to the new connection in '*vconnp', otherwise a null
195 vconn_open(const char *name, int min_version, struct vconn **vconnp)
200 check_vconn_classes();
203 prefix_len = strcspn(name, ":");
204 if (prefix_len == strlen(name)) {
207 for (i = 0; i < ARRAY_SIZE(vconn_classes); i++) {
208 struct vconn_class *class = vconn_classes[i];
209 if (strlen(class->name) == prefix_len
210 && !memcmp(class->name, name, prefix_len)) {
212 char *suffix_copy = xstrdup(name + prefix_len + 1);
213 int retval = class->open(name, suffix_copy, &vconn);
216 assert(vconn->state != VCS_CONNECTING
217 || vconn->class->connect);
218 vconn->min_version = min_version;
228 vconn_open_block(const char *name, int min_version, struct vconn **vconnp)
233 error = vconn_open(name, min_version, &vconn);
234 while (error == EAGAIN) {
235 vconn_connect_wait(vconn);
237 error = vconn_connect(vconn);
238 assert(error != EINPROGRESS);
249 /* Closes 'vconn'. */
251 vconn_close(struct vconn *vconn)
254 char *name = vconn->name;
255 (vconn->class->close)(vconn);
260 /* Returns the name of 'vconn', that is, the string passed to vconn_open(). */
262 vconn_get_name(const struct vconn *vconn)
267 /* Returns the IP address of the peer, or 0 if the peer is not connected over
268 * an IP-based protocol or if its IP address is not yet known. */
270 vconn_get_ip(const struct vconn *vconn)
276 vcs_connecting(struct vconn *vconn)
278 int retval = (vconn->class->connect)(vconn);
279 assert(retval != EINPROGRESS);
281 vconn->state = VCS_SEND_HELLO;
282 } else if (retval != EAGAIN) {
283 vconn->state = VCS_DISCONNECTED;
284 vconn->error = retval;
289 vcs_send_hello(struct vconn *vconn)
294 make_openflow(sizeof(struct ofp_header), OFPT_HELLO, &b);
295 retval = do_send(vconn, b);
297 vconn->state = VCS_RECV_HELLO;
300 if (retval != EAGAIN) {
301 vconn->state = VCS_DISCONNECTED;
302 vconn->error = retval;
308 vcs_recv_hello(struct vconn *vconn)
313 retval = do_recv(vconn, &b);
315 struct ofp_header *oh = b->data;
317 if (oh->type == OFPT_HELLO) {
318 if (b->size > sizeof *oh) {
319 struct ds msg = DS_EMPTY_INITIALIZER;
320 ds_put_format(&msg, "%s: extra-long hello:\n", vconn->name);
321 ds_put_hex_dump(&msg, b->data, b->size, 0, true);
322 VLOG_WARN_RL(&rl, ds_cstr(&msg));
326 vconn->version = MIN(OFP_VERSION, oh->version);
327 if (vconn->version < vconn->min_version) {
328 VLOG_WARN_RL(&rl, "%s: version negotiation failed: we support "
329 "versions 0x%02x to 0x%02x inclusive but peer "
330 "supports no later than version 0x%02"PRIx8,
331 vconn->name, vconn->min_version, OFP_VERSION,
333 vconn->state = VCS_SEND_ERROR;
335 VLOG_DBG("%s: negotiated OpenFlow version 0x%02x "
336 "(we support versions 0x%02x to 0x%02x inclusive, "
337 "peer no later than version 0x%02"PRIx8")",
338 vconn->name, vconn->version, vconn->min_version,
339 OFP_VERSION, oh->version);
340 vconn->state = VCS_CONNECTED;
345 char *s = ofp_to_string(b->data, b->size, 1);
346 VLOG_WARN_RL(&rl, "%s: received message while expecting hello: %s",
354 if (retval != EAGAIN) {
355 vconn->state = VCS_DISCONNECTED;
356 vconn->error = retval;
361 vcs_send_error(struct vconn *vconn)
363 struct ofp_error_msg *error;
368 snprintf(s, sizeof s, "We support versions 0x%02x to 0x%02x inclusive but "
369 "you support no later than version 0x%02"PRIx8".",
370 vconn->min_version, OFP_VERSION, vconn->version);
371 error = make_openflow(sizeof *error, OFPT_ERROR, &b);
372 error->type = htons(OFPET_HELLO_FAILED);
373 error->code = htons(OFPHFC_INCOMPATIBLE);
374 ofpbuf_put(b, s, strlen(s));
375 update_openflow_length(b);
376 retval = do_send(vconn, b);
380 if (retval != EAGAIN) {
381 vconn->state = VCS_DISCONNECTED;
382 vconn->error = retval ? retval : EPROTO;
386 /* Tries to complete the connection on 'vconn', which must be an active
387 * vconn. If 'vconn''s connection is complete, returns 0 if the connection
388 * was successful or a positive errno value if it failed. If the
389 * connection is still in progress, returns EAGAIN. */
391 vconn_connect(struct vconn *vconn)
393 enum vconn_state last_state;
395 assert(vconn->min_version >= 0);
397 last_state = vconn->state;
398 switch (vconn->state) {
400 vcs_connecting(vconn);
404 vcs_send_hello(vconn);
408 vcs_recv_hello(vconn);
415 vcs_send_error(vconn);
418 case VCS_DISCONNECTED:
424 } while (vconn->state != last_state);
429 /* Tries to receive an OpenFlow message from 'vconn', which must be an active
430 * vconn. If successful, stores the received message into '*msgp' and returns
431 * 0. The caller is responsible for destroying the message with
432 * ofpbuf_delete(). On failure, returns a positive errno value and stores a
433 * null pointer into '*msgp'. On normal connection close, returns EOF.
435 * vconn_recv will not block waiting for a packet to arrive. If no packets
436 * have been received, it returns EAGAIN immediately. */
438 vconn_recv(struct vconn *vconn, struct ofpbuf **msgp)
440 int retval = vconn_connect(vconn);
442 retval = do_recv(vconn, msgp);
448 do_recv(struct vconn *vconn, struct ofpbuf **msgp)
452 retval = (vconn->class->recv)(vconn, msgp);
454 struct ofp_header *oh;
456 if (VLOG_IS_DBG_ENABLED()) {
457 char *s = ofp_to_string((*msgp)->data, (*msgp)->size, 1);
458 VLOG_DBG_RL(&rl, "%s: received: %s", vconn->name, s);
462 oh = ofpbuf_at_assert(*msgp, 0, sizeof *oh);
463 if (oh->version != vconn->version
464 && oh->type != OFPT_HELLO
465 && oh->type != OFPT_ERROR
466 && oh->type != OFPT_ECHO_REQUEST
467 && oh->type != OFPT_ECHO_REPLY
468 && oh->type != OFPT_VENDOR)
470 if (vconn->version < 0) {
471 VLOG_ERR_RL(&rl, "%s: received OpenFlow version %02"PRIx8" "
472 "before version negotiation complete",
473 vconn->name, oh->version);
475 VLOG_ERR_RL(&rl, "%s: received OpenFlow version %02"PRIx8" "
477 vconn->name, oh->version, vconn->version);
479 ofpbuf_delete(*msgp);
489 /* Tries to queue 'msg' for transmission on 'vconn', which must be an active
490 * vconn. If successful, returns 0, in which case ownership of 'msg' is
491 * transferred to the vconn. Success does not guarantee that 'msg' has been or
492 * ever will be delivered to the peer, only that it has been queued for
495 * Returns a positive errno value on failure, in which case the caller
496 * retains ownership of 'msg'.
498 * vconn_send will not block. If 'msg' cannot be immediately accepted for
499 * transmission, it returns EAGAIN immediately. */
501 vconn_send(struct vconn *vconn, struct ofpbuf *msg)
503 int retval = vconn_connect(vconn);
505 retval = do_send(vconn, msg);
511 do_send(struct vconn *vconn, struct ofpbuf *msg)
515 assert(msg->size >= sizeof(struct ofp_header));
516 assert(((struct ofp_header *) msg->data)->length == htons(msg->size));
517 if (!VLOG_IS_DBG_ENABLED()) {
518 retval = (vconn->class->send)(vconn, msg);
520 char *s = ofp_to_string(msg->data, msg->size, 1);
521 retval = (vconn->class->send)(vconn, msg);
522 if (retval != EAGAIN) {
523 VLOG_DBG_RL(&rl, "%s: sent (%s): %s",
524 vconn->name, strerror(retval), s);
531 /* Same as vconn_send, except that it waits until 'msg' can be transmitted. */
533 vconn_send_block(struct vconn *vconn, struct ofpbuf *msg)
536 while ((retval = vconn_send(vconn, msg)) == EAGAIN) {
537 vconn_send_wait(vconn);
543 /* Same as vconn_recv, except that it waits until a message is received. */
545 vconn_recv_block(struct vconn *vconn, struct ofpbuf **msgp)
548 while ((retval = vconn_recv(vconn, msgp)) == EAGAIN) {
549 vconn_recv_wait(vconn);
555 /* Sends 'request' to 'vconn' and blocks until it receives a reply with a
556 * matching transaction ID. Returns 0 if successful, in which case the reply
557 * is stored in '*replyp' for the caller to examine and free. Otherwise
558 * returns a positive errno value, or EOF, and sets '*replyp' to null.
560 * 'request' is always destroyed, regardless of the return value. */
562 vconn_transact(struct vconn *vconn, struct ofpbuf *request,
563 struct ofpbuf **replyp)
565 uint32_t send_xid = ((struct ofp_header *) request->data)->xid;
569 error = vconn_send_block(vconn, request);
571 ofpbuf_delete(request);
576 struct ofpbuf *reply;
578 error = vconn_recv_block(vconn, &reply);
582 recv_xid = ((struct ofp_header *) reply->data)->xid;
583 if (send_xid == recv_xid) {
588 VLOG_DBG_RL(&rl, "%s: received reply with xid %08"PRIx32" != expected "
589 "%08"PRIx32, vconn->name, recv_xid, send_xid);
590 ofpbuf_delete(reply);
595 vconn_wait(struct vconn *vconn, enum vconn_wait_type wait)
597 assert(wait == WAIT_CONNECT || wait == WAIT_RECV || wait == WAIT_SEND);
599 switch (vconn->state) {
616 case VCS_DISCONNECTED:
617 poll_immediate_wake();
620 (vconn->class->wait)(vconn, wait);
624 vconn_connect_wait(struct vconn *vconn)
626 vconn_wait(vconn, WAIT_CONNECT);
630 vconn_recv_wait(struct vconn *vconn)
632 vconn_wait(vconn, WAIT_RECV);
636 vconn_send_wait(struct vconn *vconn)
638 vconn_wait(vconn, WAIT_SEND);
641 /* Attempts to start listening for OpenFlow connections. 'name' is a
642 * connection name in the form "TYPE:ARGS", where TYPE is an passive vconn
643 * class's name and ARGS are vconn class-specific.
645 * Returns 0 if successful, otherwise a positive errno value. If successful,
646 * stores a pointer to the new connection in '*pvconnp', otherwise a null
649 pvconn_open(const char *name, struct pvconn **pvconnp)
654 check_vconn_classes();
657 prefix_len = strcspn(name, ":");
658 if (prefix_len == strlen(name)) {
661 for (i = 0; i < ARRAY_SIZE(pvconn_classes); i++) {
662 struct pvconn_class *class = pvconn_classes[i];
663 if (strlen(class->name) == prefix_len
664 && !memcmp(class->name, name, prefix_len)) {
665 char *suffix_copy = xstrdup(name + prefix_len + 1);
666 int retval = class->listen(name, suffix_copy, pvconnp);
677 /* Closes 'pvconn'. */
679 pvconn_close(struct pvconn *pvconn)
681 if (pvconn != NULL) {
682 char *name = pvconn->name;
683 (pvconn->class->close)(pvconn);
688 /* Tries to accept a new connection on 'pvconn'. If successful, stores the new
689 * connection in '*new_vconn' and returns 0. Otherwise, returns a positive
692 * The new vconn will automatically negotiate an OpenFlow protocol version
693 * acceptable to both peers on the connection. The version negotiated will be
694 * no lower than 'min_version' and no higher than OFP_VERSION.
696 * pvconn_accept() will not block waiting for a connection. If no connection
697 * is ready to be accepted, it returns EAGAIN immediately. */
699 pvconn_accept(struct pvconn *pvconn, int min_version, struct vconn **new_vconn)
701 int retval = (pvconn->class->accept)(pvconn, new_vconn);
705 assert((*new_vconn)->state != VCS_CONNECTING
706 || (*new_vconn)->class->connect);
707 (*new_vconn)->min_version = min_version;
713 pvconn_wait(struct pvconn *pvconn)
715 (pvconn->class->wait)(pvconn);
718 /* Allocates and returns the first byte of a buffer 'openflow_len' bytes long,
719 * containing an OpenFlow header with the given 'type' and a random transaction
720 * id. Stores the new buffer in '*bufferp'. The caller must free the buffer
721 * when it is no longer needed. */
723 make_openflow(size_t openflow_len, uint8_t type, struct ofpbuf **bufferp)
725 return make_openflow_xid(openflow_len, type, random_uint32(), bufferp);
728 /* Allocates and returns the first byte of a buffer 'openflow_len' bytes long,
729 * containing an OpenFlow header with the given 'type' and transaction id
730 * 'xid'. Stores the new buffer in '*bufferp'. The caller must free the
731 * buffer when it is no longer needed. */
733 make_openflow_xid(size_t openflow_len, uint8_t type, uint32_t xid,
734 struct ofpbuf **bufferp)
736 struct ofpbuf *buffer;
737 struct ofp_header *oh;
739 assert(openflow_len >= sizeof *oh);
740 assert(openflow_len <= UINT16_MAX);
741 buffer = *bufferp = ofpbuf_new(openflow_len);
742 oh = ofpbuf_put_uninit(buffer, openflow_len);
743 memset(oh, 0, openflow_len);
744 oh->version = OFP_VERSION;
746 oh->length = htons(openflow_len);
751 /* Updates the 'length' field of the OpenFlow message in 'buffer' to
754 update_openflow_length(struct ofpbuf *buffer)
756 struct ofp_header *oh = ofpbuf_at_assert(buffer, 0, sizeof *oh);
757 oh->length = htons(buffer->size);
761 make_add_flow(const struct flow *flow, uint32_t buffer_id,
762 uint16_t idle_timeout, size_t n_actions)
764 struct ofp_flow_mod *ofm;
765 size_t size = sizeof *ofm + n_actions * sizeof ofm->actions[0];
766 struct ofpbuf *out = ofpbuf_new(size);
767 ofm = ofpbuf_put_uninit(out, size);
768 memset(ofm, 0, size);
769 ofm->header.version = OFP_VERSION;
770 ofm->header.type = OFPT_FLOW_MOD;
771 ofm->header.length = htons(size);
772 ofm->match.wildcards = htonl(0);
773 ofm->match.in_port = flow->in_port;
774 memcpy(ofm->match.dl_src, flow->dl_src, sizeof ofm->match.dl_src);
775 memcpy(ofm->match.dl_dst, flow->dl_dst, sizeof ofm->match.dl_dst);
776 ofm->match.dl_vlan = flow->dl_vlan;
777 ofm->match.dl_type = flow->dl_type;
778 ofm->match.nw_src = flow->nw_src;
779 ofm->match.nw_dst = flow->nw_dst;
780 ofm->match.nw_proto = flow->nw_proto;
781 ofm->match.tp_src = flow->tp_src;
782 ofm->match.tp_dst = flow->tp_dst;
783 ofm->command = htons(OFPFC_ADD);
784 ofm->idle_timeout = htons(idle_timeout);
785 ofm->hard_timeout = htons(OFP_FLOW_PERMANENT);
786 ofm->buffer_id = htonl(buffer_id);
791 make_add_simple_flow(const struct flow *flow,
792 uint32_t buffer_id, uint16_t out_port,
793 uint16_t idle_timeout)
795 struct ofpbuf *buffer = make_add_flow(flow, buffer_id, idle_timeout, 1);
796 struct ofp_flow_mod *ofm = buffer->data;
797 ofm->actions[0].type = htons(OFPAT_OUTPUT);
798 ofm->actions[0].arg.output.max_len = htons(0);
799 ofm->actions[0].arg.output.port = htons(out_port);
804 make_unbuffered_packet_out(const struct ofpbuf *packet,
805 uint16_t in_port, uint16_t out_port)
807 struct ofp_packet_out *opo;
808 size_t size = sizeof *opo + sizeof opo->actions[0];
809 struct ofpbuf *out = ofpbuf_new(size + packet->size);
810 opo = ofpbuf_put_uninit(out, size);
811 memset(opo, 0, size);
812 opo->header.version = OFP_VERSION;
813 opo->header.type = OFPT_PACKET_OUT;
814 opo->buffer_id = htonl(UINT32_MAX);
815 opo->in_port = htons(in_port);
816 opo->n_actions = htons(1);
817 opo->actions[0].type = htons(OFPAT_OUTPUT);
818 opo->actions[0].arg.output.max_len = htons(0);
819 opo->actions[0].arg.output.port = htons(out_port);
820 ofpbuf_put(out, packet->data, packet->size);
821 update_openflow_length(out);
826 make_buffered_packet_out(uint32_t buffer_id,
827 uint16_t in_port, uint16_t out_port)
829 struct ofp_packet_out *opo;
830 size_t size = sizeof *opo + sizeof opo->actions[0];
831 struct ofpbuf *out = ofpbuf_new(size);
832 opo = ofpbuf_put_uninit(out, size);
833 memset(opo, 0, size);
834 opo->header.version = OFP_VERSION;
835 opo->header.type = OFPT_PACKET_OUT;
836 opo->header.length = htons(size);
837 opo->buffer_id = htonl(buffer_id);
838 opo->in_port = htons(in_port);
839 opo->n_actions = htons(1);
840 opo->actions[0].type = htons(OFPAT_OUTPUT);
841 opo->actions[0].arg.output.max_len = htons(0);
842 opo->actions[0].arg.output.port = htons(out_port);
846 /* Creates and returns an OFPT_ECHO_REQUEST message with an empty payload. */
848 make_echo_request(void)
850 struct ofp_header *rq;
851 struct ofpbuf *out = ofpbuf_new(sizeof *rq);
852 rq = ofpbuf_put_uninit(out, sizeof *rq);
853 rq->version = OFP_VERSION;
854 rq->type = OFPT_ECHO_REQUEST;
855 rq->length = htons(sizeof *rq);
860 /* Creates and returns an OFPT_ECHO_REPLY message matching the
861 * OFPT_ECHO_REQUEST message in 'rq'. */
863 make_echo_reply(const struct ofp_header *rq)
865 size_t size = ntohs(rq->length);
866 struct ofpbuf *out = ofpbuf_new(size);
867 struct ofp_header *reply = ofpbuf_put(out, rq, size);
868 reply->type = OFPT_ECHO_REPLY;
873 vconn_init(struct vconn *vconn, struct vconn_class *class, int connect_status,
874 uint32_t ip, const char *name)
876 vconn->class = class;
877 vconn->state = (connect_status == EAGAIN ? VCS_CONNECTING
878 : !connect_status ? VCS_SEND_HELLO
880 vconn->error = connect_status;
882 vconn->min_version = -1;
884 vconn->name = xstrdup(name);
888 pvconn_init(struct pvconn *pvconn, struct pvconn_class *class,
891 pvconn->class = class;
892 pvconn->name = xstrdup(name);