diff --git a/cdr/cdr_mysql.c b/cdr/cdr_mysql.c
index f6093613361f2fb0c9f25f7c541b64182e38cedd..a74756b244e8ed2d24a8a4afccb41f0aeed4052d 100755
--- a/cdr/cdr_mysql.c
+++ b/cdr/cdr_mysql.c
@@ -37,8 +37,9 @@
 static char *desc = "MySQL CDR Backend";
 static char *name = "mysql";
 static char *config = "cdr_mysql.conf";
-static char *hostname = NULL, *dbname = NULL, *dbuser = NULL, *password = NULL;
-static int hostname_alloc = 0, dbname_alloc = 0, dbuser_alloc = 0, password_alloc = 0;
+static char *hostname = NULL, *dbname = NULL, *dbuser = NULL, *password = NULL, *dbsock = NULL;
+static int hostname_alloc = 0, dbname_alloc = 0, dbuser_alloc = 0, password_alloc = 0, dbsock_alloc = 0;
+static int dbport = 0;
 static int connected = 0;
 
 static ast_mutex_t mysql_lock = AST_MUTEX_INITIALIZER;
@@ -61,10 +62,10 @@ static int mysql_log(struct ast_cdr *cdr)
 	localtime_r(&t,&tm);
 	strftime(timestr,128,DATE_FORMAT,&tm);
 
-	if ((!connected) && hostname && dbuser && password && dbname) {
+	if ((!connected) && (hostname || dbsock) && dbuser && password && dbname) {
 		/* Attempt to connect */
 		mysql_init(&mysql);
-		if (mysql_real_connect(&mysql, hostname, dbuser, password, dbname, 0, NULL, 0)) {
+		if (mysql_real_connect(&mysql, hostname, dbuser, password, dbname, dbport, dbsock, 0)) {
 			connected = 1;
 		} else {
 			ast_log(LOG_ERROR, "cdr_mysql: cannot connect to database server %s.  Call will not be logged\n", hostname);
@@ -129,11 +130,17 @@ int unload_module(void)
 		dbuser = NULL;
 		dbuser_alloc = 0;
 	}
+	if (dbsock && dbsock_alloc) {
+		free(dbsock);
+		dbsock = NULL;
+		dbsock_alloc = 0;
+	}
 	if (password && password_alloc) {
 		free(password);
 		password = NULL;
 		password_alloc = 0;
 	}
+	dbport = 0;
 	ast_cdr_unregister(name);
 	return 0;
 }
@@ -202,6 +209,21 @@ int load_module(void)
 		dbuser = "root";
 	}
 
+	tmp = ast_variable_retrieve(cfg,"global","sock");
+	if (tmp) {
+		dbsock = malloc(strlen(tmp) + 1);
+		if (dbsock != NULL) {
+			dbsock_alloc = 1;
+			strcpy(dbsock,tmp);
+		} else {
+			ast_log(LOG_ERROR,"Out of memory error.\n");
+			return -1;
+		}
+	} else {
+		ast_log(LOG_WARNING,"MySQL database sock file not specified.  Assuming default\n");
+		dbsock = NULL;
+	}
+
 	tmp = ast_variable_retrieve(cfg,"global","password");
 	if (tmp) {
 		password = malloc(strlen(tmp) + 1);
@@ -217,9 +239,20 @@ int load_module(void)
 		password = "";
 	}
 
+	tmp = ast_variable_retrieve(cfg,"global","port");
+	if (tmp) {
+		if (sscanf(tmp,"%d",&dbport) < 1) {
+			ast_log(LOG_WARNING,"Invalid MySQL port number.  Using default\n");
+			dbport = 0;
+		}
+	}
+
 	ast_destroy(cfg);
 
 	ast_log(LOG_DEBUG,"cdr_mysql: got hostname of %s\n",hostname);
+	ast_log(LOG_DEBUG,"cdr_mysql: got port of %d\n",dbport);
+	if (dbsock)
+		ast_log(LOG_DEBUG,"cdr_mysql: got sock file of %s\n",dbsock);
 	ast_log(LOG_DEBUG,"cdr_mysql: got user of %s\n",dbuser);
 	ast_log(LOG_DEBUG,"cdr_mysql: got dbname of %s\n",dbname);
 	ast_log(LOG_DEBUG,"cdr_mysql: got password of %s\n",password);
diff --git a/configs/cdr_mysql.conf.sample b/configs/cdr_mysql.conf.sample
index 0c2fbb996ba33ac358c825d1cb5939b77854e604..46b1dd34e34b5a680e9a64e9cea0fd0e21e9852d 100755
--- a/configs/cdr_mysql.conf.sample
+++ b/configs/cdr_mysql.conf.sample
@@ -3,8 +3,17 @@
 ; asterisk server, you can achieve a local Unix socket connection by
 ; setting hostname=localhost
 ;
+; port and sock are both optional parameters.  If hostname is specified
+; and is not "localhost", then cdr_mysql will attempt to connect to the
+; port specified or use the default port.  If hostname is not specified
+; or if hostname is "localhost", then cdr_mysql will attempt to connect
+; to the socket file specified by sock or otherwise use the default socket
+; file.
+;
 ;[global]
 ;hostname=database.host.name
 ;dbname=asteriskcdrdb
 ;password=password 
 ;user=asteriskcdruser
+;port=3306
+;sock=/tmp/mysql.sock
diff --git a/frame.c b/frame.c
index 2e53f8d1e55c5671769e258d259c421792e8bbc6..b2f6736b09f137250a0b0f7bd5b898d57a922d9f 100755
--- a/frame.c
+++ b/frame.c
@@ -411,6 +411,112 @@ int ast_getformatbyname(char *name)
 	return 0;
 }
 
+char *ast_codec2str(int codec) {
+	static char codecs[25][30] = {
+		/* Audio formats */
+		"G.723.1",                    /*  0 */
+		"GSM",                        /*  1 */
+		"G.711 u-law",                /*  2 */
+		"G.711 A-law",                /*  3 */
+		"MPEG-2 layer 3",             /*  4 */
+		"ADPCM",                      /*  5 */
+		"16 bit Signed Linear PCM",   /*  6 */
+		"LPC10",                      /*  7 */
+		"G.729A audio",               /*  8 */
+		"SpeeX",                      /*  9 */
+		"iLBC",                       /* 10 */
+		"undefined",                  /* 11 */
+		"undefined",                  /* 12 */
+		"undefined",                  /* 13 */
+		"undefined",                  /* 14 */
+		"Maximum audio format",       /* 15 */
+        /* Image formats */
+		"JPEG image",                 /* 16 */
+		"PNG image",                  /* 17 */
+		"H.261 Video",                /* 18 */
+		"H.263 Video",                /* 19 */
+		"undefined",                  /* 20 */
+		"undefined",                  /* 21 */
+		"undefined",                  /* 22 */
+		"undefined",                  /* 23 */
+        "Maximum video format",       /* 24 */
+		};
+	return codecs[codec];
+}
+
+static int show_codecs(int fd, int argc, char *argv[])
+{
+	int i, found=0;
+
+	if ((argc < 2) || (argc > 3))
+		return RESULT_SHOWUSAGE;
+
+	if ((argc == 2) || (!strcasecmp(argv[1],"audio"))) {
+		found = 1;
+		for (i=0;i<11;i++)
+			ast_cli(fd, "%8d (1 << %2d)  %s\n",1 << i,i,ast_codec2str(i));
+	}
+
+	if ((argc == 2) || (!strcasecmp(argv[1],"image"))) {
+		found = 1;
+		for (i=16;i<18;i++)
+			ast_cli(fd, "%8d (1 << %2d)  %s\n",1 << i,i,ast_codec2str(i));
+	}
+
+	if ((argc == 2) || (!strcasecmp(argv[1],"video"))) {
+		found = 1;
+		for (i=18;i<20;i++)
+			ast_cli(fd, "%8d (1 << %2d)  %s\n",1 << i,i,ast_codec2str(i));
+	}
+
+	if (! found)
+		return RESULT_SHOWUSAGE;
+	else
+		return RESULT_SUCCESS;
+}
+
+static char frame_show_codecs_usage[] =
+"Usage: show [audio|video|image] codecs\n"
+"       Displays codec mapping\n";
+
+struct ast_cli_entry cli_show_codecs =
+{ { "show", "codecs", NULL }, show_codecs, "Shows codecs", frame_show_codecs_usage };
+struct ast_cli_entry cli_show_codecs_audio =
+{ { "show", "audio", "codecs", NULL }, show_codecs, "Shows audio codecs", frame_show_codecs_usage };
+struct ast_cli_entry cli_show_codecs_video =
+{ { "show", "video", "codecs", NULL }, show_codecs, "Shows video codecs", frame_show_codecs_usage };
+struct ast_cli_entry cli_show_codecs_image =
+{ { "show", "image", "codecs", NULL }, show_codecs, "Shows image codecs", frame_show_codecs_usage };
+
+static int show_codec_n(int fd, int argc, char *argv[])
+{
+	int codec, i, found=0;
+
+	if (argc != 3)
+		return RESULT_SHOWUSAGE;
+
+	if (sscanf(argv[2],"%d",&codec) != 1)
+		return RESULT_SHOWUSAGE;
+
+	for (i=0;i<32;i++)
+		if (codec == (1 << i)) {
+			found = 1;
+			ast_cli(fd, "%d (1 << %d)  %s\n",1 << i,i,ast_codec2str(i));
+		}
+
+	if (! found)
+		ast_cli(fd, "Codec %d not found\n", codec);
+
+	return RESULT_SUCCESS;
+}
+
+static char frame_show_codec_n_usage[] =
+"Usage: show codec <number>\n"
+"       Displays codec mapping\n";
+
+struct ast_cli_entry cli_show_codec_n =
+{ { "show", "codec", NULL }, show_codec_n, "Shows a specific codec", frame_show_codec_n_usage };
+
 void ast_frame_dump(char *name, struct ast_frame *f, char *prefix)
 {
 	char *n = "unknown";
@@ -598,5 +704,10 @@ int init_framer(void)
 #ifdef TRACE_FRAMES
 	ast_cli_register(&cli_frame_stats);
 #endif
+	ast_cli_register(&cli_show_codecs);
+	ast_cli_register(&cli_show_codecs_audio);
+	ast_cli_register(&cli_show_codecs_video);
+	ast_cli_register(&cli_show_codecs_image);
+	ast_cli_register(&cli_show_codec_n);
 	return 0;	
 }
diff --git a/include/asterisk/frame.h b/include/asterisk/frame.h
index bd1bb2a7287fea15924dc9787b749ce7b12f48c9..66b080f42fa555342ee353e30ba4957115d74444 100755
--- a/include/asterisk/frame.h
+++ b/include/asterisk/frame.h
@@ -323,6 +323,14 @@ extern char* ast_getformatname(int format);
  */
 extern int ast_getformatbyname(char *name);
 
+//! Get a name from a format
+/*!
+ * \param codec codec number (1,2,4,8,16,etc.)
+ * Gets a name from a format
+ * This returns a static string identifying the format on success, 0 on error.
+ */
+extern char *ast_codec2str(int codec);
+
 //! Pick the best codec 
 /* Choose the best codec...  Uhhh...   Yah. */
 extern int ast_best_codec(int fmts);