[Asterisk-cvs] asterisk/channels chan_iax.c,1.18,1.19 chan_iax2.c,1.56,1.57
markster at lists.digium.com
markster at lists.digium.com
Wed Nov 12 22:06:19 CST 2003
- Previous message: [Asterisk-cvs] asterisk/apps Makefile,1.26,1.27 app_voicemail.c,1.14,1.15 app_voicemail2.c,1.65,NONE
- Next message: [Asterisk-cvs] asterisk/channels chan_iax.c,1.19,1.20 chan_iax2.c,1.57,1.58
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv7765/channels
Modified Files:
chan_iax.c chan_iax2.c
Log Message:
Start on mysql_user, move to misery
Index: chan_iax.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- chan_iax.c 12 Nov 2003 18:23:09 -0000 1.18
+++ chan_iax.c 13 Nov 2003 04:32:32 -0000 1.19
@@ -161,6 +161,7 @@
char inkeys[80]; /* Key(s) this user can use to authenticate to us */
int amaflags;
int hascallerid;
+ int delme;
char callerid[AST_MAX_EXTENSION];
struct ast_ha *ha;
struct iax_context *contexts;
@@ -1591,6 +1592,70 @@
p = NULL;
} else {
strncpy(p->name, peer, sizeof(p->name) - 1);
+ p->dynamic = 1;
+ p->delme = 1;
+ p->capability = iax_capability;
+ strcpy(p->methods, "md5,plaintext");
+ }
+ return p;
+}
+
+static struct iax_user *mysql_user(char *user)
+{
+ struct iax_user *p;
+ int success = 0;
+
+ p = malloc(sizeof(struct iax_user));
+ memset(p, 0, sizeof(struct iax_user));
+ if (mysql && (strlen(user) < 128)) {
+ char query[512];
+ char *name;
+ int numfields, x;
+ int port;
+ time_t regseconds, nowtime;
+ MYSQL_RES *result;
+ MYSQL_FIELD *fields;
+ MYSQL_ROW rowval;
+ name = alloca(strlen(user) * 2 + 1);
+ mysql_real_escape_string(mysql, name, user, strlen(user));
+ snprintf(query, sizeof(query), "SELECT * FROM iax1friends WHERE name=\"%s\"", name);
+ ast_mutex_lock(&mysqllock);
+ mysql_query(mysql, query);
+ if ((result = mysql_store_result(mysql))) {
+ if ((rowval = mysql_fetch_row(result))) {
+ numfields = mysql_num_fields(result);
+ fields = mysql_fetch_fields(result);
+ success = 1;
+ for (x=0;x<numfields;x++) {
+ if (rowval[x]) {
+ if (!strcasecmp(fields[x].name, "secret")) {
+ strncpy(p->secret, rowval[x], sizeof(p->secret));
+ } else if (!strcasecmp(fields[x].name, "context")) {
+ strncpy(p->context, rowval[x], sizeof(p->context) - 1);
+ } else if (!strcasecmp(fields[x].name, "ipaddr")) {
+ inet_aton(rowval[x], &p->addr.sin_addr);
+ } else if (!strcasecmp(fields[x].name, "port")) {
+ if (sscanf(rowval[x], "%i", &port) != 1)
+ port = 0;
+ p->addr.sin_port = htons(port);
+ } else if (!strcasecmp(fields[x].name, "regseconds")) {
+ if (sscanf(rowval[x], "%li", ®seconds) != 1)
+ regseconds = 0;
+ }
+ }
+ }
+ time(&nowtime);
+ if ((nowtime - regseconds) > AST_DEFAULT_REG_EXPIRE)
+ memset(&p->addr, 0, sizeof(p->addr));
+ }
+ }
+ ast_mutex_unlock(&mysqllock);
+ }
+ if (!success) {
+ free(p);
+ p = NULL;
+ } else {
+ strncpy(p->name, user, sizeof(p->name) - 1);
p->dynamic = 1;
p->delme = 1;
p->capability = iax_capability;
Index: chan_iax2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_iax2.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- chan_iax2.c 12 Nov 2003 08:58:55 -0000 1.56
+++ chan_iax2.c 13 Nov 2003 04:32:32 -0000 1.57
@@ -179,6 +179,7 @@
char inkeys[80]; /* Key(s) this user can use to authenticate to us */
int amaflags;
int hascallerid;
+ int delme;
int capability;
int trunk;
char callerid[AST_MAX_EXTENSION];
- Previous message: [Asterisk-cvs] asterisk/apps Makefile,1.26,1.27 app_voicemail.c,1.14,1.15 app_voicemail2.c,1.65,NONE
- Next message: [Asterisk-cvs] asterisk/channels chan_iax.c,1.19,1.20 chan_iax2.c,1.57,1.58
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the svn-commits
mailing list