]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Add gnutls_init_dtls function.
authorJonathan Bastien-Filiatrault <joe@x2a.org>
Sat, 25 Jul 2009 23:58:22 +0000 (19:58 -0400)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 17 Feb 2011 21:23:29 +0000 (22:23 +0100)
Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
lib/gnutls_int.h
lib/gnutls_state.c
lib/includes/gnutls/gnutls.h.in
lib/libgnutls.map

index 987026002edfc69854014b14f096eb3c72964bc9..81563215f584f2bf4e5e163f969a48d5f43e5d87 100644 (file)
@@ -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;
 
 
index 3e08f9b7a7f33b7ff294b107adf9a3798a81ef0d..88824eaf597e7c2a32d9d42d5f5981f20bee99ae 100644 (file)
@@ -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
index 177d9786e2b3db9010997953879aa48bf8c7587b..882baf3576939ee203d459a532f583ca06e7a922 100644 (file)
@@ -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)
 
index 1dda938e2c553fdd82336dab8ec26740d3cd296a..945b45d1448365d1c9d6137b262b4c2e92b2b489 100644 (file)
@@ -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;