chan_sip: Add TLS and SRTP status to CLI command 'sip show channel'
authorJonathan Rose <jrose@digium.com>
Tue, 13 May 2014 18:09:13 +0000 (18:09 +0000)
committerJonathan Rose <jrose@digium.com>
Tue, 13 May 2014 18:09:13 +0000 (18:09 +0000)
ASTERISK-23564 #close
Reported by: Patrick Laimbock
Review: https://reviewboard.asterisk.org/r/3474/
........

Merged revisions 413876 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 413877 from http://svn.asterisk.org/svn/asterisk/branches/12

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@413878 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c
include/asterisk/netsock2.h
main/netsock2.c

index 16a8a55..a9a1379 100644 (file)
@@ -21527,6 +21527,10 @@ static char *sip_show_channel(struct ast_cli_entry *e, int cmd, struct ast_cli_a
                                }
                        }
 
+                       /* add transport and media types */
+                       ast_cli(a->fd, "  Transport:              %s\n", ast_transport2str(cur->socket.type));
+                       ast_cli(a->fd, "  Media:                  %s\n", cur->srtp ? "SRTP" : cur->rtp ? "RTP" : "None");
+
                        ast_cli(a->fd, "\n\n");
 
                        found++;
index b4513c6..2db8b80 100644 (file)
@@ -567,6 +567,17 @@ int ast_sockaddr_is_any(const struct ast_sockaddr *addr);
 int ast_sockaddr_hash(const struct ast_sockaddr *addr);
 
 /*!
+ * \since 12.3
+ *
+ * \brief
+ * Returns a string representation of an ast_transport
+ *
+ * \retval Name of the tranpsort if it is defined
+ * \retval Undefined if the transport is undefined
+ */
+const char *ast_transport2str(enum ast_transport transport);
+
+/*!
  * \since 1.8
  *
  * \brief
index bee88c2..bd682b1 100644 (file)
@@ -489,6 +489,24 @@ int ast_sockaddr_hash(const struct ast_sockaddr *addr)
        }
 }
 
+const char *ast_transport2str(enum ast_transport transport)
+{
+       switch (transport) {
+       case AST_TRANSPORT_TLS:
+               return "TLS";
+       case AST_TRANSPORT_UDP:
+               return "UDP";
+       case AST_TRANSPORT_TCP:
+               return "TCP";
+       case AST_TRANSPORT_WS:
+               return "WS";
+       case AST_TRANSPORT_WSS:
+               return "WSS";
+       }
+
+       return "Undefined";
+}
+
 int ast_accept(int sockfd, struct ast_sockaddr *addr)
 {
        addr->len = sizeof(addr->ss);