picoquic/tls_api.c
static int picoquic_add_to_tls_stream(picoquic_cnx_t* cnx, const uint8_t* data, size_t length, int epoch)
{
    int ret = 0;
    picoquic_stream_head_t* stream = &cnx->tls_stream[epoch];

    if (length > 0) {
        picoquic_stream_data_node_t* stream_data = (picoquic_stream_data_node_t*)malloc(sizeof(picoquic_stream_data_node_t));

        if (stream_data == 0) {
            ret = -1;
        }
        else {
            stream_data->bytes = (uint8_t*)malloc(length);

            if (stream_data->bytes == NULL) {
                free(stream_data);
                stream_data = NULL;
                ret = -1;
            }
            else {
                picoquic_stream_data_node_t** pprevious = &stream->send_queue;
                picoquic_stream_data_node_t* next = stream->send_queue;

                memcpy(stream_data->bytes, data, length);
                stream_data->length = length;
                stream_data->offset = 0;
                stream_data->next_stream_data = NULL;

                while (next != NULL) {
                    pprevious = &next->next_stream_data;
                    next = next->next_stream_data;
                }

                *pprevious = stream_data;
            }
        }
    }

    return ret;
}
/*
* Sending data on the crypto stream.
*/
Sending data on the crypto stream.
Sending data on the crypto stream .
static int picoquic_add_to_tls_stream(picoquic_cnx_t* cnx, const uint8_t* data, size_t length, int epoch)
{
    int ret = 0;
    picoquic_stream_head_t* stream = &cnx->tls_stream[epoch];
    if (length > 0) {
        picoquic_stream_data_node_t* stream_data = (picoquic_stream_data_node_t*)malloc(sizeof(picoquic_stream_data_node_t));
        if (stream_data == 0) {
            ret = -1;
        }
        else {
            stream_data->bytes = (uint8_t*)malloc(length);
            if (stream_data->bytes == NULL) {
                free(stream_data);
                stream_data = NULL;
                ret = -1;
            }
            else {
                picoquic_stream_data_node_t** pprevious = &stream->send_queue;
                picoquic_stream_data_node_t* next = stream->send_queue;
                memcpy(stream_data->bytes, data, length);
                stream_data->length = length;
                stream_data->offset = 0;
                stream_data->next_stream_data = NULL;
                while (next != NULL) {
                    pprevious = &next->next_stream_data;
                    next = next->next_stream_data;
                }
                *pprevious = stream_data;
            }
        }
    }
    return ret;
}
static int picoquic_add_to_tls_stream ( picoquic_cnx_t * cnx , const uint8_t * data , size_t length , int epoch ) { int ret = 0 ; picoquic_stream_head_t * stream = & cnx -> tls_stream [ epoch ] ; if ( length > 0 ) { picoquic_stream_data_node_t * stream_data = ( picoquic_stream_data_node_t * ) malloc ( sizeof ( picoquic_stream_data_node_t ) ) ; if ( stream_data == 0 ) { ret = -1 ; } else { stream_data -> bytes = ( uint8_t * ) malloc ( length ) ; if ( stream_data -> bytes == NULL ) { free ( stream_data ) ; stream_data = NULL ; ret = -1 ; } else { picoquic_stream_data_node_t * * pprevious = & stream -> send_queue ; picoquic_stream_data_node_t * next = stream -> send_queue ; memcpy ( stream_data -> bytes , data , length ) ; stream_data -> length = length ; stream_data -> offset = 0 ; stream_data -> next_stream_data = NULL ; while ( next != NULL ) { pprevious = & next -> next_stream_data ; next = next -> next_stream_data ; } * pprevious = stream_data ; } } } return ret ; }
Sending data on the crypto stream.
Sending data on the crypto stream .