src/sock_gnutls.h
author Tero Marttila <terom@fixme.fi>
Tue, 10 Mar 2009 02:34:11 +0200
changeset 28 9c1050bc8709
parent 12 4147fae232d9
child 29 3f0f2898fea3
permissions -rw-r--r--
add sock_stream_release/line_proto_release/irc_conn_release functions, and add proper cleanup to irc_net_create
#ifndef SOCK_GNUTLS_H
#define SOCK_GNUTLS_H

/*
 * A sock_stream implementation using GnuTLS
 */

#include "sock_internal.h"
#include "sock_tcp.h"

#include <gnutls/gnutls.h>

/*
 * Additional gnutls configuration for client sockets.
 *
 * XXX: currently, we just have one global instance, set up by sock_gnutls_init, used for all sockets
 */
struct sock_gnutls_client_ctx {
    gnutls_certificate_credentials_t xcred;
};

/*
 * Per-sock state, this includes the sock_tcp connection
 */
struct sock_gnutls {
    /* SSL connections use TCP connections */
    struct sock_tcp base_tcp;
    
    /* Additional SSL info XXX: do we need to keep a ref to this? */
    struct sock_gnutls_ctx *ctx;

    /* The GnuTLS session for this connection */
    gnutls_session_t session;

    /* The current event_enable mask */
    int ev_mask;
};

#define SOCK_GNUTLS_BASE(sock_ptr) (&(sock_ptr)->base_tcp.base)
#define SOCK_GNUTLS_TCP(sock_ptr) (&(sock_ptr)->base_tcp)
#define SOCK_GNUTLS_ERR(sock_ptr) SOCK_ERR(SOCK_GNUTLS_BASE(sock_ptr))

/**
 * Initialize the global gnutls state
 */
err_t sock_gnutls_global_init (struct error_info *err);

#endif /* SOCK_GNUTLS_H */