src/liblsquic/lsquic_engine.c
/* Note: if returning an error, err_buf must be valid if non-NULL */
if returning an error, err_buf must be valid if non-NULL
if returning an error err_buf must be valid if non - NULL
int
lsquic_engine_check_settings (const struct lsquic_engine_settings *settings,
                              unsigned flags,
                              char *err_buf, size_t err_buf_sz)
{
    if (settings->es_cfcw < LSQUIC_MIN_FCW ||
        settings->es_sfcw < LSQUIC_MIN_FCW)
    {
        if (err_buf)
            snprintf(err_buf, err_buf_sz, "%s",
                                            "flow control window set too low");
        return -1;
    }
    if (0 == (settings->es_versions & LSQUIC_SUPPORTED_VERSIONS))
    {
        if (err_buf)
            snprintf(err_buf, err_buf_sz, "%s",
                        "No supported QUIC versions specified");
        return -1;
    }
    if (settings->es_versions & ~LSQUIC_SUPPORTED_VERSIONS)
    {
        if (err_buf)
            snprintf(err_buf, err_buf_sz, "%s",
                        "one or more unsupported QUIC version is specified");
        return -1;
    }
    if (flags & ENG_SERVER)
    {
        if (settings->es_handshake_to >
                                    MAX_MINI_CONN_LIFESPAN_IN_USEC)
        {
            if (err_buf)
                snprintf(err_buf, err_buf_sz, "handshake timeout %lu"
                    " usec is too large.  The maximum for server is %u usec",
                    settings->es_handshake_to, MAX_MINI_CONN_LIFESPAN_IN_USEC);
            return -1;
        }
    }
    if (settings->es_idle_timeout > 600)
    {
        if (err_buf)
            snprintf(err_buf, err_buf_sz, "%s",
                        "The maximum value of idle timeout is 600 seconds");
        return -1;
    }
    if (settings->es_scid_len > MAX_CID_LEN)
    {
        if (err_buf)
            snprintf(err_buf, err_buf_sz, "Source connection ID cannot be %u "
                        "bytes long; it must be between 0 and %u.",
                        settings->es_scid_len, MAX_CID_LEN);
        return -1;
    }
    if (settings->es_cc_algo > 2)
    {
        if (err_buf)
            snprintf(err_buf, err_buf_sz, "Invalid congestion control "
                "algorithm value %u", settings->es_cc_algo);
        return -1;
    }
    if (!(settings->es_ql_bits >= 0 && settings->es_ql_bits <= 2))
    {
        if (err_buf)
            snprintf(err_buf, err_buf_sz, "Invalid QL bits value %d ",
                settings->es_ql_bits);
        return -1;
    }
    if (!(settings->es_spin == 0 || settings->es_spin == 1))
    {
        if (err_buf)
            snprintf(err_buf, err_buf_sz, "Invalid spin value %d",
                settings->es_spin);
        return -1;
    }
    return 0;
}
int lsquic_engine_check_settings ( const struct lsquic_engine_settings * settings , unsigned flags , char * err_buf , size_t err_buf_sz ) { if ( settings -> es_cfcw < LSQUIC_MIN_FCW || settings -> es_sfcw < LSQUIC_MIN_FCW ) { if ( err_buf ) snprintf ( err_buf , err_buf_sz , " " , " " ) ; return -1 ; } if ( 0 == ( settings -> es_versions & LSQUIC_SUPPORTED_VERSIONS ) ) { if ( err_buf ) snprintf ( err_buf , err_buf_sz , " " , " " ) ; return -1 ; } if ( settings -> es_versions & ~ LSQUIC_SUPPORTED_VERSIONS ) { if ( err_buf ) snprintf ( err_buf , err_buf_sz , " " , " " ) ; return -1 ; } if ( flags & ENG_SERVER ) { if ( settings -> es_handshake_to > MAX_MINI_CONN_LIFESPAN_IN_USEC ) { if ( err_buf ) snprintf ( err_buf , err_buf_sz , " " " " , settings -> es_handshake_to , MAX_MINI_CONN_LIFESPAN_IN_USEC ) ; return -1 ; } } if ( settings -> es_idle_timeout > 600 ) { if ( err_buf ) snprintf ( err_buf , err_buf_sz , " " , " " ) ; return -1 ; } if ( settings -> es_scid_len > MAX_CID_LEN ) { if ( err_buf ) snprintf ( err_buf , err_buf_sz , " " " " , settings -> es_scid_len , MAX_CID_LEN ) ; return -1 ; } if ( settings -> es_cc_algo > 2 ) { if ( err_buf ) snprintf ( err_buf , err_buf_sz , " " " " , settings -> es_cc_algo ) ; return -1 ; } if ( ! ( settings -> es_ql_bits >= 0 && settings -> es_ql_bits <= 2 ) ) { if ( err_buf ) snprintf ( err_buf , err_buf_sz , " " , settings -> es_ql_bits ) ; return -1 ; } if ( ! ( settings -> es_spin == 0 || settings -> es_spin == 1 ) ) { if ( err_buf ) snprintf ( err_buf , err_buf_sz , " " , settings -> es_spin ) ; return -1 ; } return 0 ; }
Note: if returning an error, err_buf must be valid if non-NULL
Note : if returning an error err_buf must be valid if non - NULL