src/sock_gnutls.h
changeset 2 a834f0559939
child 3 cc94ae754e2a
equal deleted inserted replaced
1:cf0e1bb6bcab 2:a834f0559939
       
     1 #ifndef SOCK_GNUTLS_H
       
     2 #define SOCK_GNUTLS_H
       
     3 
       
     4 /*
       
     5  * A sock_stream implementation using GnuTLS
       
     6  */
       
     7 
       
     8 #include "sock_internal.h"
       
     9 #include "sock_tcp.h"
       
    10 
       
    11 #include <gnutls/gnutls.h>
       
    12 
       
    13 /*
       
    14  * Additional gnutls configuration for client sockets.
       
    15  *
       
    16  * XXX: currently, we just have one global instance, set up by sock_gnutls_init, used for all sockets
       
    17  */
       
    18 struct sock_gnutls_client_ctx {
       
    19     gnutls_certificate_credentials_t xcred;
       
    20 };
       
    21 
       
    22 /*
       
    23  * Per-sock state, this includes the sock_tcp connection
       
    24  */
       
    25 struct sock_gnutls {
       
    26     /* SSL connections use TCP connections */
       
    27     struct sock_tcp base_tcp;
       
    28     
       
    29     /* Additional SSL info XXX: do we need to keep a ref to this? */
       
    30     struct sock_gnutls_ctx *ctx;
       
    31 
       
    32     /* The GnuTLS session for this connection */
       
    33     gnutls_session_t session;
       
    34 };
       
    35 
       
    36 #define SOCK_GNUTLS_BASE(sock_ptr) (&(sock_ptr)->base_tcp.base)
       
    37 #define SOCK_GNUTLS_TCP(sock_ptr) (&(sock_ptr)->base_tcp)
       
    38 
       
    39 /*
       
    40  * Initialize the global gnutls state
       
    41  */
       
    42 void sock_gnutls_init (void);
       
    43 
       
    44 #endif /* SOCK_GNUTLS_H */