[PATCH v2 2/2] Support SRTP profile negotiation in the client and server tools

Martin Storsjo martin at martin.st
Thu Nov 1 00:34:55 CET 2012


The cli/serv-args files haven't been regenerated in the patch,
to avoid the extra stray changes due to differing autogen versions.
---
 src/cli-args.def  |    7 +++++++
 src/cli.c         |    3 +++
 src/common.c      |    7 ++++++-
 src/serv-args.def |    7 +++++++
 src/serv.c        |    3 +++
 5 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/cli-args.def b/src/cli-args.def
index 85952d7..8fafbf4 100644
--- a/src/cli-args.def
+++ b/src/cli-args.def
@@ -113,6 +113,13 @@ flag = {
 };
 
 flag = {
+    name      = srtp_profiles;
+    arg-type  = string;
+    descrip   = "Offer SRTP profiles";
+    doc       = "";
+};
+
+flag = {
     name      = crlf;
     descrip   = "Send CR LF instead of LF";
     doc      = "";
diff --git a/src/cli.c b/src/cli.c
index a454606..d60a563 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -675,6 +675,9 @@ init_tls_session (const char *hostname)
   if (HAVE_OPT(HEARTBEAT))
     gnutls_heartbeat_enable (session, GNUTLS_HB_PEER_ALLOWED_TO_SEND);
 
+  if (HAVE_OPT(SRTP_PROFILES))
+    gnutls_srtp_set_profile_direct (session, OPT_ARG(SRTP_PROFILES), NULL);
+
   return session;
 }
 
diff --git a/src/common.c b/src/common.c
index 3e8932a..4705c86 100644
--- a/src/common.c
+++ b/src/common.c
@@ -456,6 +456,8 @@ print_info (gnutls_session_t session, int verbose, int print_cert)
     gnutls_kx_algorithm_t kx;
     unsigned char session_id[33];
     size_t session_id_size = sizeof (session_id);
+    gnutls_srtp_profile_t srtp_profile;
+    int rc;
 
     /* print session ID */
     gnutls_session_get_id (session, session_id, &session_id_size);
@@ -551,10 +553,13 @@ print_info (gnutls_session_t session, int verbose, int print_cert)
             (gnutls_compression_get (session)));
     printf ("- Compression: %s\n", tmp);
 
+    rc = gnutls_srtp_get_selected_profile (session, &srtp_profile);
+    if (rc == 0)
+      printf ("- SRTP profile: %s\n", gnutls_srtp_get_profile_name (srtp_profile));
+
     if (verbose)
       {
           gnutls_datum_t cb;
-          int rc;
 
           rc = gnutls_session_channel_binding (session,
                                                GNUTLS_CB_TLS_UNIQUE, &cb);
diff --git a/src/serv-args.def b/src/serv-args.def
index df196ba..2132ca8 100644
--- a/src/serv-args.def
+++ b/src/serv-args.def
@@ -62,6 +62,13 @@ flag = {
 };
 
 flag = {
+    name      = srtp_profiles;
+    arg-type  = string;
+    descrip   = "Offer SRTP profiles";
+    doc       = "";
+};
+
+flag = {
     name      = disable-client-cert;
     value     = a;
     descrip   = "Do not request a client certificate";
diff --git a/src/serv.c b/src/serv.c
index 6be7a6d..7bf349b 100644
--- a/src/serv.c
+++ b/src/serv.c
@@ -393,6 +393,9 @@ gnutls_session_t initialize_session (int dtls)
   if (HAVE_OPT (HEARTBEAT))
     gnutls_heartbeat_enable(session, GNUTLS_HB_PEER_ALLOWED_TO_SEND);
 
+  if (HAVE_OPT (SRTP_PROFILES))
+    gnutls_srtp_set_profile_direct (session, OPT_ARG(SRTP_PROFILES), NULL);
+
   return session;
 }
 
-- 
1.7.9.4





More information about the Gnutls-devel mailing list