[asterisk-commits] anthonyl: branch anthonyl/testing-branch r42056 - in /team/anthonyl/testing-b...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Sep 5 13:13:18 MST 2006


Author: anthonyl
Date: Tue Sep  5 15:13:17 2006
New Revision: 42056

URL: http://svn.digium.com/view/asterisk?rev=42056&view=rev
Log:
working ish tests

Modified:
    team/anthonyl/testing-branch/include/asterisk/channel.h
    team/anthonyl/testing-branch/main/Makefile
    team/anthonyl/testing-branch/main/manager.c

Modified: team/anthonyl/testing-branch/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/anthonyl/testing-branch/include/asterisk/channel.h?rev=42056&r1=42055&r2=42056&view=diff
==============================================================================
--- team/anthonyl/testing-branch/include/asterisk/channel.h (original)
+++ team/anthonyl/testing-branch/include/asterisk/channel.h Tue Sep  5 15:13:17 2006
@@ -1348,8 +1348,77 @@
  */
 void ast_channel_whisper_stop(struct ast_channel *chan);
 
+/* Placing this in here for testing for res_openssl.c */
+
+/****** openssl specific ********/
+#include <openssl/ssl.h>
+#include <openssl/err.h>
+/***** end openssl specific ******/
+
+
+
+#define AST_SSL_DIRECTORY ""
+#define CA_LIST    "root.pem"
+#define HOST       "localhost"
+#define RANDOM     "random.pem"
+#define SSL_PORT   4433
+
+#define CA_LIST    "root.pem"
+#define HOST       "localhost"
+#define RANDOM     "random.pem"
+#define SSL_PORT   4433
+
+#define KEYFILE "/var/lib/asterisk/keys/server.pem"
+
+#define ALLOC(x) malloc((x)+1)
+#define ZERO(p,i) memset((p),0x00,(i))
+#define SIZE 4092
+
+#define AST_SSL_DIR "/var/lib/asterisk/keys"
+#define AST_SSL_CFG "/etc/asterisk/ssl.conf"
+
+/* these are the types i plan on using for socket_type */
+#define AST_SOCKET_TLS1  1
+#define AST_SOCKET_DTLS1 2
+#define AST_SOCKET_SSL2  3
+#define AST_SOCKET_SSL3  4
+
+#define AST_TLS_BUFSZ 2048
+
+struct ast_tls_context{
+  int sd;
+  int accept_sock;
+  int port;
+  int socket_type;
+  int packetsize;
+  struct sockaddr_in tls_saddr;
+  char *keyfile;
+  char *certfile;
+  char *password;
+  char *directory;
+  /* struct ast_netsock ns; */
+  
+  /*! the connection maintaining bits */
+  fd_set readfds;
+ 
+  SSL *connection;
+  SSL_CIPHER *cipher;
+  SSL_METHOD *mehtod;
+  SSL_CTX    *context;
+  BIO        *io;
+  BIO        *ssl_bio;
+
+  struct timeval timeout;
+  struct timeval tv;
+};
+
+int ast_socket_openssl(int port,int type);
+/* removing once finished testing the res_openssl.c code */
+
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
+
 #endif
 
 #endif /* _ASTERISK_CHANNEL_H */

Modified: team/anthonyl/testing-branch/main/Makefile
URL: http://svn.digium.com/view/asterisk/team/anthonyl/testing-branch/main/Makefile?rev=42056&r1=42055&r2=42056&view=diff
==============================================================================
--- team/anthonyl/testing-branch/main/Makefile (original)
+++ team/anthonyl/testing-branch/main/Makefile Tue Sep  5 15:13:17 2006
@@ -25,8 +25,8 @@
 	astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
 	utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
 	netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
-	cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o
-
+	cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o \
+	openssl.o
 # we need to link in the objects statically, not as a library, because
 # otherwise modules will not have them available if none of the static
 # objects use it.
@@ -48,7 +48,7 @@
   ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
   AST_LIBS+=-ldl
   endif
-  AST_LIBS+=-lpthread $(EDITLINE_LIB) -lm -lresolv
+  AST_LIBS+=-lpthread $(EDITLINE_LIB) -lm -lresolv -lssl -lcrypto
 else
   AST_LIBS+=$(EDITLINE_LIB) -lm
 endif

Modified: team/anthonyl/testing-branch/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/testing-branch/main/manager.c?rev=42056&r1=42055&r2=42056&view=diff
==============================================================================
--- team/anthonyl/testing-branch/main/manager.c (original)
+++ team/anthonyl/testing-branch/main/manager.c Tue Sep  5 15:13:17 2006
@@ -69,6 +69,8 @@
 #include "asterisk/threadstorage.h"
 #include "asterisk/linkedlists.h"
 
+
+
 struct fast_originate_helper {
 	char tech[AST_MAX_MANHEADER_LEN];
 	char data[AST_MAX_MANHEADER_LEN];
@@ -100,6 +102,7 @@
 static int httptimeout = 60;
 
 static pthread_t t;
+static pthread_t ssl_main_thread;
 static int block_sockets = 0;
 static int num_sessions = 0;
 
@@ -175,10 +178,45 @@
 	AST_LIST_ENTRY(mansession) list;
 };
 
+
 static AST_LIST_HEAD_STATIC(sessions, mansession);
 
 static struct manager_action *first_action = NULL;
 AST_MUTEX_DEFINE_STATIC(actionlock);
+
+
+/* this is the main thread for manaing ssl manager connections */
+static int *astman_ssl_thread(void)
+{
+  int ret;
+  pthread_attr_t attr;
+  time_t now;
+  struct pollfd pfds[1];
+
+	pthread_attr_init(&attr);
+	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+  ret = ast_socket_openssl(5039,AST_SOCKET_TLS1);
+  
+  if(!ret) {
+    ast_log(LOG_WARNING, "Error binding SSL socket\n");
+  }
+    
+  return 0;
+}
+
+static int get_input_ssl(void)
+{
+  
+  return 0;
+}
+
+
+void astman_send_response_ssl(struct mansession *s, struct message *m, char *resp, char *msg)
+{
+
+}
+
+
 
 /*! \brief Convert authority code to string with serveral options */
 static char *authority_to_str(int authority, char *res, int reslen)
@@ -1860,6 +1898,7 @@
 	return process_events(s);
 }
 
+
 static int get_input(struct mansession *s, char *output)
 {
 	/* output must have at least sizeof(s->inbuf) space */
@@ -2447,6 +2486,7 @@
 	int oldportno = portno;
 	static struct sockaddr_in ba;
 	int x = 1;
+	int ret = 0;
 	int flags;
 	int webenabled = 0;
 	int newhttptimeout = 60;
@@ -2586,6 +2626,8 @@
 		if (option_verbose)
 			ast_verbose("Asterisk Management interface listening on port %d\n", portno);
 		ast_pthread_create(&t, NULL, accept_thread, NULL);
+		ast_pthread_create(&ssl_main_thread,NULL,astman_ssl_thread ,NULL);
+		//astman_ssl_thread();
 	}
 	return 0;
 }



More information about the asterisk-commits mailing list