test_qlog.c revision 7483dee0
17d09751dSDmitri Tikhonov/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc.  See LICENSE. */
255cd0b38SDmitri Tikhonov#include <assert.h>
355cd0b38SDmitri Tikhonov#include <stdio.h>
455cd0b38SDmitri Tikhonov#include <stdlib.h>
555cd0b38SDmitri Tikhonov#include <string.h>
65392f7a3SLiteSpeed Tech#include <sys/queue.h>
755cd0b38SDmitri Tikhonov
855cd0b38SDmitri Tikhonov#include "lsquic.h"
955cd0b38SDmitri Tikhonov#include "lsquic_int_types.h"
105392f7a3SLiteSpeed Tech#include "lsquic_hash.h"
1155cd0b38SDmitri Tikhonov#include "lsquic_conn.h"
1255cd0b38SDmitri Tikhonov
1355cd0b38SDmitri Tikhonov#include "lsquic_qlog.h"
1455cd0b38SDmitri Tikhonov
1555cd0b38SDmitri Tikhonov#define LSQUIC_LOGGER_MODULE LSQLM_NOMODULE
1655cd0b38SDmitri Tikhonov#include "lsquic_logger.h"
1755cd0b38SDmitri Tikhonov
1855cd0b38SDmitri Tikhonov
1955cd0b38SDmitri Tikhonovint
2055cd0b38SDmitri Tikhonovmain (void)
2155cd0b38SDmitri Tikhonov{
229b4d33c7SDmitri Tikhonov    lsquic_global_init(LSQUIC_GLOBAL_CLIENT | LSQUIC_GLOBAL_CLIENT);
2355cd0b38SDmitri Tikhonov    lsquic_log_to_fstream(stderr, LLTS_HHMMSSMS);
2455cd0b38SDmitri Tikhonov    lsquic_set_log_level("debug");
2555cd0b38SDmitri Tikhonov
2655cd0b38SDmitri Tikhonov    lsquic_qlog_create_connection(0, NULL, NULL);
2755cd0b38SDmitri Tikhonov    struct in_addr local_addr = {.s_addr = htonl(0x0a000001),};
2855cd0b38SDmitri Tikhonov    struct sockaddr_in local =
2955cd0b38SDmitri Tikhonov    {
3055cd0b38SDmitri Tikhonov        .sin_family = AF_INET,
3155cd0b38SDmitri Tikhonov        .sin_port = htons(12345),
3255cd0b38SDmitri Tikhonov        .sin_addr = local_addr,
3355cd0b38SDmitri Tikhonov    };
3455cd0b38SDmitri Tikhonov    struct in_addr peer_addr = {.s_addr = htonl(0x0a000002),};
3555cd0b38SDmitri Tikhonov    struct sockaddr_in peer =
3655cd0b38SDmitri Tikhonov    {
3755cd0b38SDmitri Tikhonov        .sin_family = AF_INET,
3855cd0b38SDmitri Tikhonov        .sin_port = htons(443),
3955cd0b38SDmitri Tikhonov        .sin_addr = peer_addr,
4055cd0b38SDmitri Tikhonov    };
41fb3e20e0SDmitri Tikhonov    lsquic_cid_t cid;   memset(&cid, 0, sizeof(cid));
425392f7a3SLiteSpeed Tech    lsquic_qlog_create_connection(&cid, (const struct sockaddr *)&local,
4355cd0b38SDmitri Tikhonov                                        (const struct sockaddr *)&peer);
4455cd0b38SDmitri Tikhonov
455392f7a3SLiteSpeed Tech    lsquic_qlog_packet_rx(&cid, NULL, NULL, 0);
465392f7a3SLiteSpeed Tech    lsquic_qlog_hsk_completed(&cid);
477483dee0SDmitri Tikhonov    lsquic_qlog_sess_resume(&cid);
485392f7a3SLiteSpeed Tech    lsquic_qlog_check_certs(&cid, NULL, 0);
495392f7a3SLiteSpeed Tech
505392f7a3SLiteSpeed Tech    lsquic_qlog_version_negotiation(&cid, NULL, NULL);
515392f7a3SLiteSpeed Tech    lsquic_qlog_version_negotiation(&cid, "proposed", NULL);
525392f7a3SLiteSpeed Tech    lsquic_qlog_version_negotiation(&cid, "proposed", "Q035");
535392f7a3SLiteSpeed Tech    lsquic_qlog_version_negotiation(&cid, "proposed", "Q046");
545392f7a3SLiteSpeed Tech    lsquic_qlog_version_negotiation(&cid, "agreed", "Q044");
555392f7a3SLiteSpeed Tech    lsquic_qlog_version_negotiation(&cid, "agreed", "Q098");
565392f7a3SLiteSpeed Tech    lsquic_qlog_version_negotiation(&cid, "something else", "Q098");
5755cd0b38SDmitri Tikhonov    return 0;
5855cd0b38SDmitri Tikhonov}
59