4 Copyright (C) 2003-2004 Guus Sliepen <guus@tinc-vpn.org>,
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include <gnutls/gnutls.h>
27 #include <gnutls/extra.h>
31 #define TNL_PROTOCOL 0
33 #define TNL_RECORD_PACKET 0
34 #define TNL_RECORD_META 1
35 #define TNL_RECORD_HELLO 2
36 #define TNL_RECORD_BLA 3
38 typedef struct tnl_record {
44 typedef enum tnl_status {
46 TNL_STATUS_CONNECTING,
51 typedef struct tnl_ep_credentials {
52 gnutls_credentials_type type;
54 gnutls_anon_client_credentials anon_client;
55 gnutls_anon_server_credentials anon_server;
56 gnutls_srp_client_credentials srp_client;
57 gnutls_srp_server_credentials srp_server;
58 gnutls_certificate_credentials certificate;
60 } tnl_ep_credentials_t;
62 typedef struct tnl_ep_cryptoparm {
63 } tnl_ep_cryptoparm_t;
65 typedef struct tnl_ep {
66 struct sockaddr_storage address;
69 struct tnl_ep_credentials cred;
70 struct tnl_ep_cryptoparm parm;
79 enum tnl_status status;
82 bool (*send_packet)(struct tnl *tnl, const void *buf, int len);
83 bool (*send_meta)(struct tnl *tnl, const void *buf, int len);
84 bool (*close)(struct tnl *tnl);
86 bool (*recv_packet)(struct tnl *tnl, const void *buf, int len);
87 bool (*recv_meta)(struct tnl *tnl, const void *buf, int len);
88 bool (*accept)(struct tnl *tnl);
89 bool (*error)(struct tnl *tnl, int errnum);
93 gnutls_session session;
99 typedef struct tnl_listen {
104 bool (*accept)(struct tnl *tnl);
105 bool (*close)(struct tnl_listen *listener);
110 extern bool tnl_listen(struct tnl_listen *listener);
111 extern bool tnl_connect(struct tnl *tnl);
113 extern bool tnl_ep_set_x509_credentials(tnl_ep_t *tnl_ep, const char *key, const char *certificate, const char *trust, const char *crl);
114 extern bool tnl_ep_set_openpgp_credentials(tnl_ep_t *tnl_ep, const char *privkey, const char *pubkey, const char *keyring, const char *trustdb);
116 #endif /* __TNL_H__ */