X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=tnl%2Ftnl.h;h=77a8b2a0c200108f6f9efc76d49a1b143fc2865a;hb=d1cb8f5355ab449dffe10abf81402e5303d5721a;hp=9f1f8369642d02872451ba84bab1cf5069dc963d;hpb=7d12cbb6e6acebbe8f9bcab75f5ec878a3360eb9;p=tinc diff --git a/tnl/tnl.h b/tnl/tnl.h index 9f1f8369..77a8b2a0 100644 --- a/tnl/tnl.h +++ b/tnl/tnl.h @@ -24,9 +24,12 @@ #define __TNL_H__ #include +#include #include "fd/fd.h" +#define TNL_PROTOCOL 0 + #define TNL_RECORD_PACKET 0 #define TNL_RECORD_META 1 #define TNL_RECORD_HELLO 2 @@ -45,11 +48,26 @@ typedef enum tnl_status { TNL_STATUS_UP, } tnl_status_t; +typedef struct tnl_ep_credentials { + gnutls_credentials_type type; + union { + gnutls_anon_client_credentials anon_client; + gnutls_anon_server_credentials anon_server; + gnutls_srp_client_credentials srp_client; + gnutls_srp_server_credentials srp_server; + gnutls_certificate_credentials certificate; + }; +} tnl_ep_credentials_t; + +typedef struct tnl_ep_cryptoparm { +} tnl_ep_cryptoparm_t; + typedef struct tnl_ep { struct sockaddr_storage address; - struct tnl_ep_identity *id; - struct tnl_ep_credentials *cred; - struct tnl_ep_cryptoparm *parm; + char *id; + char *hostname; + struct tnl_ep_credentials cred; + struct tnl_ep_cryptoparm parm; } tnl_ep_t; typedef struct tnl { @@ -61,19 +79,19 @@ typedef struct tnl { enum tnl_status status; void *data; - bool (*send_packet)(struct tnl *tnl, const char *buf, int len); - bool (*send_meta)(struct tnl *tnl, const char *buf, int len); + bool (*send_packet)(struct tnl *tnl, const void *buf, int len); + bool (*send_meta)(struct tnl *tnl, const void *buf, int len); bool (*close)(struct tnl *tnl); - bool (*recv_packet)(struct tnl *tnl, const char *buf, int len); - bool (*recv_meta)(struct tnl *tnl, const char *buf, int len); + bool (*recv_packet)(struct tnl *tnl, const void *buf, int len); + bool (*recv_meta)(struct tnl *tnl, const void *buf, int len); bool (*accept)(struct tnl *tnl); bool (*error)(struct tnl *tnl, int errnum); /* private */ - struct fd fd; gnutls_session session; + struct fd fd; char buf[4096]; int bufread; } tnl_t; @@ -89,16 +107,10 @@ typedef struct tnl_listen { struct fd fd; } tnl_listen_t; -extern bool tnl_init(void); -extern bool tnl_exit(void); extern bool tnl_listen(struct tnl_listen *listener); extern bool tnl_connect(struct tnl *tnl); -extern bool tnl_credentials_sprint(const char *buf, int len, const struct tnl_ep_credentials *cred); -extern bool tnl_credentials_sscan(const char *buf, struct tnl_ep_credentials *cred); -extern bool tnl_cryptoparm_sprint(const char *buf, int len, const struct tnl_ep_cryptoparm *parm); -extern bool tnl_cryptoparm_sscan(const char *buf, struct tnl_ep_cryptoparm *parm); -extern bool tnl_credentials_fprint(FILE *stream, const struct tnl_ep_credentials *cred); -extern bool tnl_credentials_fscan(FILE *stream, struct tnl_ep_credentials *cred); +extern bool tnl_ep_set_x509_credentials(tnl_ep_t *tnl_ep, const char *key, const char *certificate, const char *trust, const char *crl); +extern bool tnl_ep_set_openpgp_credentials(tnl_ep_t *tnl_ep, const char *privkey, const char *pubkey, const char *keyring, const char *trustdb); #endif /* __TNL_H__ */