quicwind/quicwind_proc.c
int quicwind_start_connection(picoquic_quic_t * qclient,
    char const * name, char const *port_number, char const * doc_name,
    char const * alpn, char const *sni)
{

    int ret = 0;
    int port = 443;
    struct sockaddr_storage server_address;
    int is_name = 0;
    picoquic_cnx_t * cnx_client = NULL;

    if (qclient == NULL) {
        ret = -1;
    } else if (port_number != NULL) {
        port = atoi(port_number);
        if (port <= 0) {
            ret = -1;
        }
    }

    if (ret == 0) {
        ret = picoquic_get_server_address(name, port, &server_address, &is_name);
        if (sni == NULL && is_name != 0) {
            sni = name;
        }
    }
    /* Create the client connection */
    if (ret == 0) {
        /* Create a client connection */
        cnx_client = picoquic_create_cnx(qclient, picoquic_null_connection_id, picoquic_null_connection_id,
            (struct sockaddr*)&server_address, picoquic_get_quic_time(qclient),
            0xFF000012, sni, alpn, 1);

        if (cnx_client == NULL) {
            ret = -1;
        }
        else {
            /* create callback context! */
            quicwind_callback_ctx_t * ctx = (quicwind_callback_ctx_t *)malloc(sizeof(quicwind_callback_ctx_t));
            if (ctx == NULL) {
                ret = -1;
            }
            else {
                memset(ctx, 0, sizeof(quicwind_callback_ctx_t));

                ctx->alpn = picoquic_parse_alpn(alpn);

                picoquic_set_callback(cnx_client, quicwind_callback, ctx);

                ret = picoquic_start_client_cnx(cnx_client);

                if (ret == 0) {
                    switch (ctx->alpn) {
                    case picoquic_alpn_http_3:
                        ret = h3zero_client_init(cnx_client);
                        break;
                    default:
                        break;
                    }
                }

                if (ret == 0 && doc_name != 0) {
                    /* TODO: Start the download scenario */
                    ret = quicwind_start_download(cnx_client, ctx, doc_name);
                }
            }
        }
    }

    return ret;
}
/* Start a new connection.
 * Create a connection in the client context,
 * set addresses, etc. Add a first stream if needed.
 */
Start a new connection.
Create a connection in the client context,
set addresses, etc. Add a first stream if needed.
Start a new connection . Create a connection in the client context set addresses etc . Add a first stream if needed .
int quicwind_start_connection(picoquic_quic_t * qclient,
    char const * name, char const *port_number, char const * doc_name,
    char const * alpn, char const *sni)
{
    int ret = 0;
    int port = 443;
    struct sockaddr_storage server_address;
    int is_name = 0;
    picoquic_cnx_t * cnx_client = NULL;
    if (qclient == NULL) {
        ret = -1;
    } else if (port_number != NULL) {
        port = atoi(port_number);
        if (port <= 0) {
            ret = -1;
        }
    }
    if (ret == 0) {
        ret = picoquic_get_server_address(name, port, &server_address, &is_name);
        if (sni == NULL && is_name != 0) {
            sni = name;
        }
    }
    if (ret == 0) {
        cnx_client = picoquic_create_cnx(qclient, picoquic_null_connection_id, picoquic_null_connection_id,
            (struct sockaddr*)&server_address, picoquic_get_quic_time(qclient),
            0xFF000012, sni, alpn, 1);
        if (cnx_client == NULL) {
            ret = -1;
        }
        else {
            quicwind_callback_ctx_t * ctx = (quicwind_callback_ctx_t *)malloc(sizeof(quicwind_callback_ctx_t));
            if (ctx == NULL) {
                ret = -1;
            }
            else {
                memset(ctx, 0, sizeof(quicwind_callback_ctx_t));
                ctx->alpn = picoquic_parse_alpn(alpn);
                picoquic_set_callback(cnx_client, quicwind_callback, ctx);
                ret = picoquic_start_client_cnx(cnx_client);
                if (ret == 0) {
                    switch (ctx->alpn) {
                    case picoquic_alpn_http_3:
                        ret = h3zero_client_init(cnx_client);
                        break;
                    default:
                        break;
                    }
                }
                if (ret == 0 && doc_name != 0) {
                    ret = quicwind_start_download(cnx_client, ctx, doc_name);
                }
            }
        }
    }
    return ret;
}
int quicwind_start_connection ( picoquic_quic_t * qclient , char const * name , char const * port_number , char const * doc_name , char const * alpn , char const * sni ) { int ret = 0 ; int port = 443 ; struct sockaddr_storage server_address ; int is_name = 0 ; picoquic_cnx_t * cnx_client = NULL ; if ( qclient == NULL ) { ret = -1 ; } else if ( port_number != NULL ) { port = atoi ( port_number ) ; if ( port <= 0 ) { ret = -1 ; } } if ( ret == 0 ) { ret = picoquic_get_server_address ( name , port , & server_address , & is_name ) ; if ( sni == NULL && is_name != 0 ) { sni = name ; } } if ( ret == 0 ) { cnx_client = picoquic_create_cnx ( qclient , picoquic_null_connection_id , picoquic_null_connection_id , ( struct sockaddr * ) & server_address , picoquic_get_quic_time ( qclient ) , 0xFF000012 , sni , alpn , 1 ) ; if ( cnx_client == NULL ) { ret = -1 ; } else { quicwind_callback_ctx_t * ctx = ( quicwind_callback_ctx_t * ) malloc ( sizeof ( quicwind_callback_ctx_t ) ) ; if ( ctx == NULL ) { ret = -1 ; } else { memset ( ctx , 0 , sizeof ( quicwind_callback_ctx_t ) ) ; ctx -> alpn = picoquic_parse_alpn ( alpn ) ; picoquic_set_callback ( cnx_client , quicwind_callback , ctx ) ; ret = picoquic_start_client_cnx ( cnx_client ) ; if ( ret == 0 ) { switch ( ctx -> alpn ) { case picoquic_alpn_http_3 : ret = h3zero_client_init ( cnx_client ) ; break ; default : break ; } } if ( ret == 0 && doc_name != 0 ) { ret = quicwind_start_download ( cnx_client , ctx , doc_name ) ; } } } } return ret ; }
Start a new connection.
Start a new connection .
/* Create the client connection */ /* Create a client connection */ /* create callback context! */ /* TODO: Start the download scenario */