-
Notifications
You must be signed in to change notification settings - Fork 2
/
tconn.h
65 lines (56 loc) · 1.74 KB
/
tconn.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* dvpn, a multipoint vpn implementation
* Copyright (C) 2015 Lennert Buytenhek
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version
* 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 2.1 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License version 2.1 along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __TCONN_H
#define __TCONN_H
#include <gnutls/gnutls.h>
#include <iv.h>
#include <stdint.h>
struct tconn {
const char *name;
struct iv_fd *fd;
int role;
gnutls_x509_privkey_t mykey;
int numcrts;
gnutls_x509_crt_t *mycrts;
void *cookie;
int (*verify_key_ids)(void *cookie,
const uint8_t *ids, int num);
void (*handshake_done)(void *cookie, char *desc);
void (*record_received)(void *cookie,
const uint8_t *rec, int len);
void (*connection_lost)(void *cookie);
gnutls_session_t sess;
gnutls_certificate_credentials_t cert;
int state;
int io_error;
struct iv_task rx_task;
uint8_t rx_buf[32768];
int rx_start;
int rx_end;
int rx_eof;
struct iv_task tx_task;
uint8_t tx_buf[32768];
int tx_bytes;
};
#define TCONN_ROLE_SERVER 0
#define TCONN_ROLE_CLIENT 1
int tconn_start(struct tconn *tc);
void tconn_destroy(struct tconn *tc);
int tconn_record_send(struct tconn *tc, const uint8_t *rec, int len);
#endif