[Asterisk-cvs] asterisk/channels chan_h323.c,1.10,1.11
jeremy at lists.digium.com
jeremy at lists.digium.com
Mon Dec 8 23:22:56 CST 2003
Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv6998
Modified Files:
chan_h323.c
Log Message:
implement userbyalias. This will look to IP instead of H.323ID, if enabled Bug #251
Index: chan_h323.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_h323.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- chan_h323.c 3 Dec 2003 20:08:58 -0000 1.10
+++ chan_h323.c 9 Dec 2003 05:14:23 -0000 1.11
@@ -75,6 +75,12 @@
static int port = 1720;
static int gkroute = 0;
+/* to find user by alias is default, alternative is the incomming call's source IP
+address*/
+static int userbyalias = 1;
+
+static int bridge_default = 1;
+
/* Just about everybody seems to support ulaw, so make it a nice default */
static int capability = AST_FORMAT_ULAW;
@@ -205,8 +211,8 @@
strncpy(alias->context, v->value, sizeof(alias->context)-1);
} else if (!strcasecmp(v->name, "secret")) {
strncpy(alias->secret, v->value, sizeof(alias->secret)-1);
- } else {
- ast_log(LOG_WARNING, "Keyword %s does not make sense in type=h323\n", v->value);
+ } else {
+ ast_log(LOG_WARNING, "Keyword %s does not make sense in type=h323\n", v->value);
}
v = v->next;
}
@@ -227,7 +233,7 @@
/* set the usage flag to a sane starting value*/
user->inUse = 0;
/* Assume we can native bridge */
- user->bridge = 1;
+ user->bridge = bridge_default;
while(v) {
if (!strcasecmp(v->name, "context")) {
@@ -722,7 +728,7 @@
ast_mutex_init(&p->lock);
p->cd.call_reference = callid;
- p->bridge = 1;
+ p->bridge = bridge_default;
p->dtmfmode = dtmfmode;
if (p->dtmfmode & H323_DTMF_RFC2833)
@@ -843,18 +849,28 @@
return a;
}
-struct oh323_user *find_user(const char *source_aliases)
+struct oh323_user *find_user(const call_details_t cd)
{
struct oh323_user *u;
u = userl.users;
+ if(userbyalias == 1){
+ while(u) {
+ if (!strcasecmp(u->name, cd.call_source_aliases)) {
+ break;
+ }
+ u = u->next;
+ }
- while(u) {
-
- if (!strcasecmp(u->name, source_aliases)) {
- break;
+ } else {
+ while(u) {
+ if (!strcasecmp(cd.sourceIp, inet_ntoa(u->addr.sin_addr))) {
+ break;
+ }
+ u = u->next;
}
- u = u->next;
+
+
}
return u;
@@ -933,14 +949,14 @@
info->addr = inet_ntoa(us.sin_addr);
info->port = ntohs(us.sin_port);
-
-#if 0
- printf(" us: %s:%d\n", inet_ntoa(us.sin_addr), ntohs(us.sin_port));
- printf("them: %s:%d\n", inet_ntoa(them.sin_addr), ntohs(them.sin_port));
+
+#if 0
+ printf(" us: %s:%d\n", inet_ntoa(us.sin_addr), ntohs(us.sin_port));
+ printf("them: %s:%d\n", inet_ntoa(them.sin_addr), ntohs(them.sin_port));
printf("info: %s:%d\n", info->addr, info->port);
-#endif
-
+#endif
+
return info;
}
@@ -1008,7 +1024,7 @@
or we are not allowing gk routed calls */
- user = find_user(cd.call_source_aliases);
+ user = find_user(cd);
if (!user) {
@@ -1176,7 +1192,7 @@
/* Decrement usage counter */
if (!p->outgoing) {
- user = find_user(cd.call_source_aliases);
+ user = find_user(cd);
if(user)
user->inUse--;
@@ -1187,7 +1203,7 @@
peer = find_peer(cd.call_dest_alias);
peer->inUse--;
} else {
- user = find_user(cd.call_source_aliases);
+ user = find_user(cd);
user->inUse--;
}
#endif
@@ -1466,7 +1482,11 @@
ast_log(LOG_WARNING, "Unknown dtmf mode '%s', using rfc2833\n", v->value);
dtmfmode = H323_DTMF_RFC2833;
}
- }
+ } else if (!strcasecmp(v->name, "UserByAlias")) {
+ userbyalias = ast_true(v->value);
+ } else if (!strcasecmp(v->name, "bridge")) {
+ bridge_default = ast_true(v->value);
+ }
v = v->next;
}
More information about the svn-commits
mailing list