Mon Mar 10 07:00:00 CET 2003
authorMatteo Brancaleoni <mbrancaleoni@espia.it>
Mon, 10 Mar 2003 06:00:17 +0000 (06:00 +0000)
committerMatteo Brancaleoni <mbrancaleoni@espia.it>
Mon, 10 Mar 2003 06:00:17 +0000 (06:00 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@637 65c4cc65-6c06-0410-ace0-fbb531ad65f3

CHANGES
apps/app_dial.c
channels/chan_modem_i4l.c
configs/sip.conf.sample
include/asterisk/manager.h
include/asterisk/vmodem.h
manager.c

diff --git a/CHANGES b/CHANGES
index b2c18ff..4ddbb11 100755 (executable)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,4 @@
+ -- Add 'C' flag to dial command to reset call detail record (handy for calling cards)
  -- Add NAT and dynamic support to MGCP
  -- Allow selection of in-band, out-of-band, or INFO based DTMF
  -- Add contributed "*80" support to blacklist numbers (Thanks James!)
  -- Add NAT and dynamic support to MGCP
  -- Allow selection of in-band, out-of-band, or INFO based DTMF
  -- Add contributed "*80" support to blacklist numbers (Thanks James!)
index cd26974..8743e0b 100755 (executable)
@@ -64,6 +64,7 @@ static char *descrip =
 "      'm' -- provide hold music to the calling party until answered.\n"
 "      'd' -- data-quality (modem) call (minimum delay).\n"
 "      'H' -- allow caller to hang up by hitting *.\n"
 "      'm' -- provide hold music to the calling party until answered.\n"
 "      'd' -- data-quality (modem) call (minimum delay).\n"
 "      'H' -- allow caller to hang up by hitting *.\n"
+"      'C' -- reset call detail record for this call.\n"
 "      'P[(x)]' -- privacy mode, using 'x' as database if provided.\n"
 "  In addition to transferring the call, a call may be parked and then picked\n"
 "up by another user.\n"
 "      'P[(x)]' -- privacy mode, using 'x' as database if provided.\n"
 "  In addition to transferring the call, a call may be parked and then picked\n"
 "up by another user.\n"
@@ -295,6 +296,7 @@ static int dial_exec(struct ast_channel *chan, void *data)
        int allowredir=0;
        int allowdisconnect=0;
        int privacy=0;
        int allowredir=0;
        int allowdisconnect=0;
        int privacy=0;
+       int resetcdr=0;
        char numsubst[AST_MAX_EXTENSION];
        char restofit[AST_MAX_EXTENSION];
        char *transfer = NULL;
        char numsubst[AST_MAX_EXTENSION];
        char restofit[AST_MAX_EXTENSION];
        char *transfer = NULL;
@@ -364,8 +366,12 @@ static int dial_exec(struct ast_channel *chan, void *data)
                } else if (strchr(transfer, 'P')) {
                        /* No specified privdb */
                        privacy = 1;
                } else if (strchr(transfer, 'P')) {
                        /* No specified privdb */
                        privacy = 1;
+               } else if (strchr(transfer, 'C')) {
+                       resetcdr = 1;
                }
        }
                }
        }
+       if (resetcdr && chan->cdr)
+               ast_cdr_reset(chan->cdr, 0);
        if (!strlen(privdb) && privacy) {
                /* If privdb is not specified and we are using privacy, copy from extension */
                strncpy(privdb, chan->exten, sizeof(privdb) - 1);
        if (!strlen(privdb) && privacy) {
                /* If privdb is not specified and we are using privacy, copy from extension */
                strncpy(privdb, chan->exten, sizeof(privdb) - 1);
index 18b5a50..277c16b 100755 (executable)
@@ -474,7 +474,7 @@ static char *i4l_identify(struct ast_modem_pvt *p)
        return strdup("Linux ISDN");
 }
 
        return strdup("Linux ISDN");
 }
 
-static void i4l_incusecnt()
+static void i4l_incusecnt(void)
 {
        ast_pthread_mutex_lock(&usecnt_lock);
        usecnt++;
 {
        ast_pthread_mutex_lock(&usecnt_lock);
        usecnt++;
@@ -482,7 +482,7 @@ static void i4l_incusecnt()
        ast_update_use_count();
 }
 
        ast_update_use_count();
 }
 
-static void i4l_decusecnt()
+static void i4l_decusecnt(void)
 {
        ast_pthread_mutex_lock(&usecnt_lock);
        usecnt++;
 {
        ast_pthread_mutex_lock(&usecnt_lock);
        usecnt++;
index c1aee75..7559d4f 100755 (executable)
@@ -17,12 +17,11 @@ context = default           ; Default for incoming calls
 ;type=friend
 ;secret=blah
 ;host=dynamic
 ;type=friend
 ;secret=blah
 ;host=dynamic
-;dtmf=inband                   ; Choices are inband, rfc2833, or info
+;dtmfmode=inband               ; Choices are inband, rfc2833, or info
 ;defaultip=192.168.0.59
 
 ;[pingtel]
 ;type=friend
 ;defaultip=192.168.0.59
 
 ;[pingtel]
 ;type=friend
-;insecure=yes                  ; Pingtel sends from different portno
 ;username=pingtel
 ;secret=blah
 ;host=dynamic
 ;username=pingtel
 ;secret=blah
 ;host=dynamic
@@ -32,6 +31,7 @@ context = default             ; Default for incoming calls
 ;type=friend
 ;username=cisco
 ;secret=blah
 ;type=friend
 ;username=cisco
 ;secret=blah
+;nat=yes                       ; This phone may be natted
 ;host=dynamic
 ;canreinvite=no                        ; Cisco poops on reinvite sometimes
 ;qualify=200                   ; Qualify peer is no more than 200ms away
 ;host=dynamic
 ;canreinvite=no                        ; Cisco poops on reinvite sometimes
 ;qualify=200                   ; Qualify peer is no more than 200ms away
@@ -39,7 +39,6 @@ context = default             ; Default for incoming calls
 
 ;[cisco1]
 ;type=friend
 
 ;[cisco1]
 ;type=friend
-;insecure=yes
 ;username=cisco1
 ;secret=blah
 ;host=dynamic
 ;username=cisco1
 ;secret=blah
 ;host=dynamic
index 4a26774..980909e 100755 (executable)
@@ -57,6 +57,7 @@ struct mansession {
        int fd;
        int blocking;
        char username[80];
        int fd;
        int blocking;
        char username[80];
+       char challenge[10];
        int authenticated;
        int readperm;
        int writeperm;
        int authenticated;
        int readperm;
        int writeperm;
index 2dfc43a..2d80a14 100755 (executable)
@@ -40,8 +40,8 @@ struct ast_modem_driver {
        char **idents;
        int formats;
        int fullduplex;
        char **idents;
        int formats;
        int fullduplex;
-       void (*incusecnt)();
-       void (*decusecnt)();
+       void (*incusecnt)(void);
+       void (*decusecnt)(void);
        char * (*identify)(struct ast_modem_pvt *);
        int (*init)(struct ast_modem_pvt *);
        int (*setdev)(struct ast_modem_pvt *, int dev);
        char * (*identify)(struct ast_modem_pvt *);
        int (*init)(struct ast_modem_pvt *);
        int (*setdev)(struct ast_modem_pvt *, int dev);
index f9d224d..0305c9f 100755 (executable)
--- a/manager.c
+++ b/manager.c
@@ -32,6 +32,7 @@
 #include <asterisk/cli.h>
 #include <asterisk/app.h>
 #include <asterisk/pbx.h>
 #include <asterisk/cli.h>
 #include <asterisk/app.h>
 #include <asterisk/pbx.h>
+#include <asterisk/md5.h>
 
 static int enabled = 0;
 static int portno = DEFAULT_MANAGER_PORT;
 
 static int enabled = 0;
 static int portno = DEFAULT_MANAGER_PORT;
@@ -191,6 +192,9 @@ static int authenticate(struct mansession *s, struct message *m)
        char *cat;
        char *user = get_header(m, "Username");
        char *pass = get_header(m, "Secret");
        char *cat;
        char *user = get_header(m, "Username");
        char *pass = get_header(m, "Secret");
+       char *authtype = get_header(m, "AuthType");
+       char *key = get_header(m, "Key");
+
        cfg = ast_load("manager.conf");
        if (!cfg)
                return -1;
        cfg = ast_load("manager.conf");
        if (!cfg)
                return -1;
@@ -200,7 +204,27 @@ static int authenticate(struct mansession *s, struct message *m)
                        /* This is a user */
                        if (!strcasecmp(cat, user)) {
                                char *password = ast_variable_retrieve(cfg, cat, "secret");
                        /* This is a user */
                        if (!strcasecmp(cat, user)) {
                                char *password = ast_variable_retrieve(cfg, cat, "secret");
-                               if (password && !strcasecmp(password, pass)) {
+                               if (!strcasecmp(authtype, "MD5")) {
+                                       if (key && strlen(key) && s->challenge) {
+                                               int x;
+                                               int len=0;
+                                               char md5key[256] = "";
+                                               struct MD5Context md5;
+                                               unsigned char digest[16];
+                                               MD5Init(&md5);
+                                               MD5Update(&md5, s->challenge, strlen(s->challenge));
+                                               MD5Update(&md5, password, strlen(password));
+                                               MD5Final(digest, &md5);
+                                               for (x=0;x<16;x++)
+                                                       len += sprintf(md5key + len, "%2.2x", digest[x]);
+                                               if (!strcmp(md5key, key))
+                                                       break;
+                                               else {
+                                                       ast_destroy(cfg);
+                                                       return -1;
+                                               }
+                                       }
+                               } else if (password && !strcasecmp(password, pass)) {
                                        break;
                                } else {
                                        ast_log(LOG_NOTICE, "%s failed to authenticate as '%s'\n", inet_ntoa(s->sin.sin_addr), user);
                                        break;
                                } else {
                                        ast_log(LOG_NOTICE, "%s failed to authenticate as '%s'\n", inet_ntoa(s->sin.sin_addr), user);
@@ -414,7 +438,22 @@ static int process_message(struct mansession *s, struct message *m)
                return 0;
        }
        if (!s->authenticated) {
                return 0;
        }
        if (!s->authenticated) {
-               if (!strcasecmp(action, "Login")) {
+               if (!strcasecmp(action, "Challenge")) {
+                       char *authtype;
+                       authtype = get_header(m, "AuthType");
+                       if (!strcasecmp(authtype, "MD5")) {
+                               if (!s->challenge || !strlen(s->challenge)) {
+                                       ast_pthread_mutex_lock(&s->lock);
+                                       snprintf(s->challenge, sizeof(s->challenge), "%d", rand());
+                                       ast_pthread_mutex_unlock(&s->lock);
+                               }
+                               ast_cli(s->fd, "Challenge: %s\r\n\r\n", s->challenge);
+                               return 0;
+                       } else {
+                               send_error(s, "Must specify AuthType");
+                               return 0;
+                       }
+               } else if (!strcasecmp(action, "Login")) {
                        if (authenticate(s, m)) {
                                sleep(1);
                                send_error(s, "Authentication failed");
                        if (authenticate(s, m)) {
                                sleep(1);
                                send_error(s, "Authentication failed");