From: Jonathan Bastien-Filiatrault Date: Sat, 25 Jul 2009 23:58:22 +0000 (-0400) Subject: Add gnutls_init_dtls function. X-Git-Tag: gnutls_2_99_0~257 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9f63e9aec1cd3f4720a02062bfb27bcfc4b097eb;p=thirdparty%2Fgnutls.git Add gnutls_init_dtls function. Signed-off-by: Nikos Mavrogiannopoulos --- diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h index 987026002e..81563215f5 100644 --- a/lib/gnutls_int.h +++ b/lib/gnutls_int.h @@ -515,6 +515,7 @@ typedef struct /* HelloVerifyRequest DOS prevention cookie */ opaque cookie[DTLS_MAX_COOKIE_SIZE]; uint8_t cookie_len; + gnutls_dtls_flags_t flags; } dtls_st; diff --git a/lib/gnutls_state.c b/lib/gnutls_state.c index 3e08f9b7a7..88824eaf59 100644 --- a/lib/gnutls_state.c +++ b/lib/gnutls_state.c @@ -363,6 +363,36 @@ gnutls_init (gnutls_session_t * session, gnutls_connection_end_t con_end) return 0; } +/** + * gnutls_init_dtls - initialize the session like gnutls_init, but + * with a DTLS compatible transport. + * @con_end: indicate if this session is to be used for server or client. + * @session: is a pointer to a #gnutls_session_t structure. + * @flags: dtls flags for optional behavior. + * + * Returns: %GNUTLS_E_SUCCESS on success, or an error code. + **/ +int +gnutls_init_dtls (gnutls_session_t * session, + gnutls_connection_end_t con_end, + gnutls_dtls_flags_t flags) +{ + int ret; + + /* FIXME, we should inhibit the allocation of many buffers that are + useless with datagram transport. */ + ret = gnutls_init(session, con_end); + + if(ret != 0) + return ret; + + /* Flags do nothing, so just copy them into the struct for now. */ + (*session)->internals.dtls.flags = flags; + (*session)->internals.transport = GNUTLS_DGRAM; + + return 0; +} + /* returns RESUME_FALSE or RESUME_TRUE. */ int diff --git a/lib/includes/gnutls/gnutls.h.in b/lib/includes/gnutls/gnutls.h.in index 177d9786e2..882baf3576 100644 --- a/lib/includes/gnutls/gnutls.h.in +++ b/lib/includes/gnutls/gnutls.h.in @@ -298,6 +298,13 @@ extern "C" * * Enumeration of different TLS alert severities. */ + typedef enum + { + /* Nothing for now. There will be flags for transport-dependent + behavior (DCCP, SCTP) here in the future. */ + GNUTLS_DTLS_DUMMY = 0 + } gnutls_dtls_flags_t; + typedef enum { GNUTLS_AL_WARNING = 1, @@ -678,6 +685,9 @@ extern "C" int gnutls_init (gnutls_session_t * session, gnutls_connection_end_t con_end); + int gnutls_init_dtls (gnutls_session_t * session, + gnutls_connection_end_t con_end, + gnutls_dtls_flags_t flags); void gnutls_deinit (gnutls_session_t session); #define _gnutls_deinit(x) gnutls_deinit(x) diff --git a/lib/libgnutls.map b/lib/libgnutls.map index 1dda938e2c..945b45d144 100644 --- a/lib/libgnutls.map +++ b/lib/libgnutls.map @@ -153,6 +153,7 @@ GNUTLS_1_4 gnutls_hex_decode; gnutls_hex_encode; gnutls_init; + gnutls_init_dtls; gnutls_kx_get; gnutls_kx_get_id; gnutls_kx_get_name;