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 retval = do_send(vconn, b);
379 if (retval != EAGAIN) {
380 vconn->state = VCS_DISCONNECTED;
381 vconn->error = retval ? retval : EPROTO;
385 /* Tries to complete the connection on 'vconn', which must be an active
386 * vconn. If 'vconn''s connection is complete, returns 0 if the connection
387 * was successful or a positive errno value if it failed. If the
388 * connection is still in progress, returns EAGAIN. */
390 vconn_connect(struct vconn *vconn)
392 enum vconn_state last_state;
394 assert(vconn->min_version >= 0);
396 last_state = vconn->state;
397 switch (vconn->state) {
399 vcs_connecting(vconn);
403 vcs_send_hello(vconn);
407 vcs_recv_hello(vconn);
414 vcs_send_error(vconn);
417 case VCS_DISCONNECTED:
423 } while (vconn->state != last_state);
428 /* Tries to receive an OpenFlow message from 'vconn', which must be an active
429 * vconn. If successful, stores the received message into '*msgp' and returns
430 * 0. The caller is responsible for destroying the message with
431 * ofpbuf_delete(). On failure, returns a positive errno value and stores a
432 * null pointer into '*msgp'. On normal connection close, returns EOF.
434 * vconn_recv will not block waiting for a packet to arrive. If no packets
435 * have been received, it returns EAGAIN immediately. */
437 vconn_recv(struct vconn *vconn, struct ofpbuf **msgp)
439 int retval = vconn_connect(vconn);
441 retval = do_recv(vconn, msgp);
447 do_recv(struct vconn *vconn, struct ofpbuf **msgp)
451 retval = (vconn->class->recv)(vconn, msgp);
453 struct ofp_header *oh;
455 if (VLOG_IS_DBG_ENABLED()) {
456 char *s = ofp_to_string((*msgp)->data, (*msgp)->size, 1);
457 VLOG_DBG_RL(&rl, "%s: received: %s", vconn->name, s);
461 oh = ofpbuf_at_assert(*msgp, 0, sizeof *oh);
462 if (oh->version != vconn->version
463 && oh->type != OFPT_HELLO
464 && oh->type != OFPT_ERROR
465 && oh->type != OFPT_ECHO_REQUEST
466 && oh->type != OFPT_ECHO_REPLY
467 && oh->type != OFPT_VENDOR)
469 if (vconn->version < 0) {
470 VLOG_ERR_RL(&rl, "%s: received OpenFlow version %02"PRIx8" "
471 "before version negotiation complete",
472 vconn->name, oh->version);
474 VLOG_ERR_RL(&rl, "%s: received OpenFlow version %02"PRIx8" "
476 vconn->name, oh->version, vconn->version);
478 ofpbuf_delete(*msgp);
488 /* Tries to queue 'msg' for transmission on 'vconn', which must be an active
489 * vconn. If successful, returns 0, in which case ownership of 'msg' is
490 * transferred to the vconn. Success does not guarantee that 'msg' has been or
491 * ever will be delivered to the peer, only that it has been queued for
494 * Returns a positive errno value on failure, in which case the caller
495 * retains ownership of 'msg'.
497 * vconn_send will not block. If 'msg' cannot be immediately accepted for
498 * transmission, it returns EAGAIN immediately. */
500 vconn_send(struct vconn *vconn, struct ofpbuf *msg)
502 int retval = vconn_connect(vconn);
504 retval = do_send(vconn, msg);
510 do_send(struct vconn *vconn, struct ofpbuf *msg)
514 assert(msg->size >= sizeof(struct ofp_header));
515 assert(((struct ofp_header *) msg->data)->length == htons(msg->size));
516 if (!VLOG_IS_DBG_ENABLED()) {
517 retval = (vconn->class->send)(vconn, msg);
519 char *s = ofp_to_string(msg->data, msg->size, 1);
520 retval = (vconn->class->send)(vconn, msg);
521 if (retval != EAGAIN) {
522 VLOG_DBG_RL(&rl, "%s: sent (%s): %s",
523 vconn->name, strerror(retval), s);
530 /* Same as vconn_send, except that it waits until 'msg' can be transmitted. */
532 vconn_send_block(struct vconn *vconn, struct ofpbuf *msg)
535 while ((retval = vconn_send(vconn, msg)) == EAGAIN) {
536 vconn_send_wait(vconn);
542 /* Same as vconn_recv, except that it waits until a message is received. */
544 vconn_recv_block(struct vconn *vconn, struct ofpbuf **msgp)
547 while ((retval = vconn_recv(vconn, msgp)) == EAGAIN) {
548 vconn_recv_wait(vconn);
554 /* Sends 'request' to 'vconn' and blocks until it receives a reply with a
555 * matching transaction ID. Returns 0 if successful, in which case the reply
556 * is stored in '*replyp' for the caller to examine and free. Otherwise
557 * returns a positive errno value, or EOF, and sets '*replyp' to null.
559 * 'request' is always destroyed, regardless of the return value. */
561 vconn_transact(struct vconn *vconn, struct ofpbuf *request,
562 struct ofpbuf **replyp)
564 uint32_t send_xid = ((struct ofp_header *) request->data)->xid;
568 error = vconn_send_block(vconn, request);
570 ofpbuf_delete(request);
575 struct ofpbuf *reply;
577 error = vconn_recv_block(vconn, &reply);
581 recv_xid = ((struct ofp_header *) reply->data)->xid;
582 if (send_xid == recv_xid) {
587 VLOG_DBG_RL(&rl, "%s: received reply with xid %08"PRIx32" != expected "
588 "%08"PRIx32, vconn->name, recv_xid, send_xid);
589 ofpbuf_delete(reply);
594 vconn_wait(struct vconn *vconn, enum vconn_wait_type wait)
596 assert(wait == WAIT_CONNECT || wait == WAIT_RECV || wait == WAIT_SEND);
598 switch (vconn->state) {
615 case VCS_DISCONNECTED:
616 poll_immediate_wake();
619 (vconn->class->wait)(vconn, wait);
623 vconn_connect_wait(struct vconn *vconn)
625 vconn_wait(vconn, WAIT_CONNECT);
629 vconn_recv_wait(struct vconn *vconn)
631 vconn_wait(vconn, WAIT_RECV);
635 vconn_send_wait(struct vconn *vconn)
637 vconn_wait(vconn, WAIT_SEND);
640 /* Attempts to start listening for OpenFlow connections. 'name' is a
641 * connection name in the form "TYPE:ARGS", where TYPE is an passive vconn
642 * class's name and ARGS are vconn class-specific.
644 * Returns 0 if successful, otherwise a positive errno value. If successful,
645 * stores a pointer to the new connection in '*pvconnp', otherwise a null
648 pvconn_open(const char *name, struct pvconn **pvconnp)
653 check_vconn_classes();
656 prefix_len = strcspn(name, ":");
657 if (prefix_len == strlen(name)) {
660 for (i = 0; i < ARRAY_SIZE(pvconn_classes); i++) {
661 struct pvconn_class *class = pvconn_classes[i];
662 if (strlen(class->name) == prefix_len
663 && !memcmp(class->name, name, prefix_len)) {
664 char *suffix_copy = xstrdup(name + prefix_len + 1);
665 int retval = class->listen(name, suffix_copy, pvconnp);
676 /* Closes 'pvconn'. */
678 pvconn_close(struct pvconn *pvconn)
680 if (pvconn != NULL) {
681 char *name = pvconn->name;
682 (pvconn->class->close)(pvconn);
687 /* Tries to accept a new connection on 'pvconn'. If successful, stores the new
688 * connection in '*new_vconn' and returns 0. Otherwise, returns a positive
691 * The new vconn will automatically negotiate an OpenFlow protocol version
692 * acceptable to both peers on the connection. The version negotiated will be
693 * no lower than 'min_version' and no higher than OFP_VERSION.
695 * pvconn_accept() will not block waiting for a connection. If no connection
696 * is ready to be accepted, it returns EAGAIN immediately. */
698 pvconn_accept(struct pvconn *pvconn, int min_version, struct vconn **new_vconn)
700 int retval = (pvconn->class->accept)(pvconn, new_vconn);
704 assert((*new_vconn)->state != VCS_CONNECTING
705 || (*new_vconn)->class->connect);
706 (*new_vconn)->min_version = min_version;
712 pvconn_wait(struct pvconn *pvconn)
714 (pvconn->class->wait)(pvconn);
717 /* Allocates and returns the first byte of a buffer 'openflow_len' bytes long,
718 * containing an OpenFlow header with the given 'type' and a random transaction
719 * id. Stores the new buffer in '*bufferp'. The caller must free the buffer
720 * when it is no longer needed. */
722 make_openflow(size_t openflow_len, uint8_t type, struct ofpbuf **bufferp)
724 return make_openflow_xid(openflow_len, type, random_uint32(), bufferp);
727 /* Allocates and returns the first byte of a buffer 'openflow_len' bytes long,
728 * containing an OpenFlow header with the given 'type' and transaction id
729 * 'xid'. Stores the new buffer in '*bufferp'. The caller must free the
730 * buffer when it is no longer needed. */
732 make_openflow_xid(size_t openflow_len, uint8_t type, uint32_t xid,
733 struct ofpbuf **bufferp)
735 struct ofpbuf *buffer;
736 struct ofp_header *oh;
738 assert(openflow_len >= sizeof *oh);
739 assert(openflow_len <= UINT16_MAX);
740 buffer = *bufferp = ofpbuf_new(openflow_len);
741 oh = ofpbuf_put_uninit(buffer, openflow_len);
742 memset(oh, 0, openflow_len);
743 oh->version = OFP_VERSION;
745 oh->length = htons(openflow_len);
750 /* Updates the 'length' field of the OpenFlow message in 'buffer' to
753 update_openflow_length(struct ofpbuf *buffer)
755 struct ofp_header *oh = ofpbuf_at_assert(buffer, 0, sizeof *oh);
756 oh->length = htons(buffer->size);
760 make_add_flow(const struct flow *flow, uint32_t buffer_id,
761 uint16_t idle_timeout, size_t n_actions)
763 struct ofp_flow_mod *ofm;
764 size_t size = sizeof *ofm + n_actions * sizeof ofm->actions[0];
765 struct ofpbuf *out = ofpbuf_new(size);
766 ofm = ofpbuf_put_uninit(out, size);
767 memset(ofm, 0, size);
768 ofm->header.version = OFP_VERSION;
769 ofm->header.type = OFPT_FLOW_MOD;
770 ofm->header.length = htons(size);
771 ofm->match.wildcards = htonl(0);
772 ofm->match.in_port = flow->in_port;
773 memcpy(ofm->match.dl_src, flow->dl_src, sizeof ofm->match.dl_src);
774 memcpy(ofm->match.dl_dst, flow->dl_dst, sizeof ofm->match.dl_dst);
775 ofm->match.dl_vlan = flow->dl_vlan;
776 ofm->match.dl_type = flow->dl_type;
777 ofm->match.nw_src = flow->nw_src;
778 ofm->match.nw_dst = flow->nw_dst;
779 ofm->match.nw_proto = flow->nw_proto;
780 ofm->match.tp_src = flow->tp_src;
781 ofm->match.tp_dst = flow->tp_dst;
782 ofm->command = htons(OFPFC_ADD);
783 ofm->idle_timeout = htons(idle_timeout);
784 ofm->hard_timeout = htons(OFP_FLOW_PERMANENT);
785 ofm->buffer_id = htonl(buffer_id);
790 make_add_simple_flow(const struct flow *flow,
791 uint32_t buffer_id, uint16_t out_port,
792 uint16_t idle_timeout)
794 struct ofpbuf *buffer = make_add_flow(flow, buffer_id, idle_timeout, 1);
795 struct ofp_flow_mod *ofm = buffer->data;
796 ofm->actions[0].type = htons(OFPAT_OUTPUT);
797 ofm->actions[0].arg.output.max_len = htons(0);
798 ofm->actions[0].arg.output.port = htons(out_port);
803 make_unbuffered_packet_out(const struct ofpbuf *packet,
804 uint16_t in_port, uint16_t out_port)
806 struct ofp_packet_out *opo;
807 size_t size = sizeof *opo + sizeof opo->actions[0];
808 struct ofpbuf *out = ofpbuf_new(size + packet->size);
809 opo = ofpbuf_put_uninit(out, size);
810 memset(opo, 0, size);
811 opo->header.version = OFP_VERSION;
812 opo->header.type = OFPT_PACKET_OUT;
813 opo->buffer_id = htonl(UINT32_MAX);
814 opo->in_port = htons(in_port);
815 opo->n_actions = htons(1);
816 opo->actions[0].type = htons(OFPAT_OUTPUT);
817 opo->actions[0].arg.output.max_len = htons(0);
818 opo->actions[0].arg.output.port = htons(out_port);
819 ofpbuf_put(out, packet->data, packet->size);
820 update_openflow_length(out);
825 make_buffered_packet_out(uint32_t buffer_id,
826 uint16_t in_port, uint16_t out_port)
828 struct ofp_packet_out *opo;
829 size_t size = sizeof *opo + sizeof opo->actions[0];
830 struct ofpbuf *out = ofpbuf_new(size);
831 opo = ofpbuf_put_uninit(out, size);
832 memset(opo, 0, size);
833 opo->header.version = OFP_VERSION;
834 opo->header.type = OFPT_PACKET_OUT;
835 opo->header.length = htons(size);
836 opo->buffer_id = htonl(buffer_id);
837 opo->in_port = htons(in_port);
838 opo->n_actions = htons(1);
839 opo->actions[0].type = htons(OFPAT_OUTPUT);
840 opo->actions[0].arg.output.max_len = htons(0);
841 opo->actions[0].arg.output.port = htons(out_port);
845 /* Creates and returns an OFPT_ECHO_REQUEST message with an empty payload. */
847 make_echo_request(void)
849 struct ofp_header *rq;
850 struct ofpbuf *out = ofpbuf_new(sizeof *rq);
851 rq = ofpbuf_put_uninit(out, sizeof *rq);
852 rq->version = OFP_VERSION;
853 rq->type = OFPT_ECHO_REQUEST;
854 rq->length = htons(sizeof *rq);
859 /* Creates and returns an OFPT_ECHO_REPLY message matching the
860 * OFPT_ECHO_REQUEST message in 'rq'. */
862 make_echo_reply(const struct ofp_header *rq)
864 size_t size = ntohs(rq->length);
865 struct ofpbuf *out = ofpbuf_new(size);
866 struct ofp_header *reply = ofpbuf_put(out, rq, size);
867 reply->type = OFPT_ECHO_REPLY;
872 vconn_init(struct vconn *vconn, struct vconn_class *class, int connect_status,
873 uint32_t ip, const char *name)
875 vconn->class = class;
876 vconn->state = (connect_status == EAGAIN ? VCS_CONNECTING
877 : !connect_status ? VCS_SEND_HELLO
879 vconn->error = connect_status;
881 vconn->min_version = -1;
883 vconn->name = xstrdup(name);
887 pvconn_init(struct pvconn *pvconn, struct pvconn_class *class,
890 pvconn->class = class;
891 pvconn->name = xstrdup(name);