1a74702c6SGeorge Wang/* Copyright (c) 2017 - 2022 LiteSpeed Technologies Inc.  See LICENSE. */
25392f7a3SLiteSpeed Tech/*
35392f7a3SLiteSpeed Tech * test_chlo_gen.c -- Test Client Hello generation.
45392f7a3SLiteSpeed Tech */
55392f7a3SLiteSpeed Tech
65392f7a3SLiteSpeed Tech#include <assert.h>
75392f7a3SLiteSpeed Tech#include <stdlib.h>
85392f7a3SLiteSpeed Tech#include <unistd.h>
95392f7a3SLiteSpeed Tech
105392f7a3SLiteSpeed Tech#include <openssl/bio.h>
115392f7a3SLiteSpeed Tech
125392f7a3SLiteSpeed Tech#include "lsquic.h"
135392f7a3SLiteSpeed Tech#include "lsquic_hsk_cli_ietf.h"
145392f7a3SLiteSpeed Tech#include "lsquic_logger.h"
155392f7a3SLiteSpeed Tech
165392f7a3SLiteSpeed Tech
175392f7a3SLiteSpeed Techstatic int
185392f7a3SLiteSpeed Techmy_bwrite (BIO *bio, const char *buf, int len)
195392f7a3SLiteSpeed Tech{
205392f7a3SLiteSpeed Tech    return 0;
215392f7a3SLiteSpeed Tech}
225392f7a3SLiteSpeed Tech
235392f7a3SLiteSpeed Techstatic int
245392f7a3SLiteSpeed Techmy_bread (BIO *bio, char *buf, int len)
255392f7a3SLiteSpeed Tech{
265392f7a3SLiteSpeed Tech    return 0;
275392f7a3SLiteSpeed Tech}
285392f7a3SLiteSpeed Tech
295392f7a3SLiteSpeed Techstatic const BIO_METHOD bio_method = {
305392f7a3SLiteSpeed Tech    .type = 0,  /* XXX ? */
315392f7a3SLiteSpeed Tech    .name = __FILE__,
325392f7a3SLiteSpeed Tech    .bwrite = my_bwrite,
335392f7a3SLiteSpeed Tech    .bread  = my_bread,
345392f7a3SLiteSpeed Tech};
355392f7a3SLiteSpeed Tech
365392f7a3SLiteSpeed Techint
375392f7a3SLiteSpeed Techmain (int argc, char **argv)
385392f7a3SLiteSpeed Tech{
395392f7a3SLiteSpeed Tech    int opt, s;
405392f7a3SLiteSpeed Tech
415392f7a3SLiteSpeed Tech    lsquic_log_to_fstream(stderr, LLTS_NONE);
425392f7a3SLiteSpeed Tech
435392f7a3SLiteSpeed Tech    while (-1 != (opt = getopt(argc, argv, "l:L:")))
445392f7a3SLiteSpeed Tech    {
455392f7a3SLiteSpeed Tech        switch (opt)
465392f7a3SLiteSpeed Tech        {
475392f7a3SLiteSpeed Tech        case 'l':
485392f7a3SLiteSpeed Tech            lsquic_logger_lopt(optarg);
495392f7a3SLiteSpeed Tech            break;
505392f7a3SLiteSpeed Tech        case 'L':
515392f7a3SLiteSpeed Tech            lsquic_set_log_level(optarg);
525392f7a3SLiteSpeed Tech            break;
535392f7a3SLiteSpeed Tech        default:
545392f7a3SLiteSpeed Tech            exit(EXIT_FAILURE);
555392f7a3SLiteSpeed Tech        }
565392f7a3SLiteSpeed Tech    }
575392f7a3SLiteSpeed Tech
585392f7a3SLiteSpeed Tech    const lsquic_cid_t dcid = { .len = 10, .idbuf = "wild thing", };
595392f7a3SLiteSpeed Tech    struct hsk_cli *cli = lsquic_hsk_cli_new(&dcid, &bio_method, NULL,
605392f7a3SLiteSpeed Tech        (unsigned char *) "some params", 11);
615392f7a3SLiteSpeed Tech
625392f7a3SLiteSpeed Tech    assert(cli);
635392f7a3SLiteSpeed Tech    s = lsquic_hsk_cli_write(cli);
645392f7a3SLiteSpeed Tech    assert(0 == s);
655392f7a3SLiteSpeed Tech
665392f7a3SLiteSpeed Tech    (void)
675392f7a3SLiteSpeed Tech        lsquic_hsk_cli_write(cli);
685392f7a3SLiteSpeed Tech
695392f7a3SLiteSpeed Tech    lsquic_hsk_cli_destroy(cli);
705392f7a3SLiteSpeed Tech
715392f7a3SLiteSpeed Tech    exit(EXIT_SUCCESS);
725392f7a3SLiteSpeed Tech}
73