[asterisk-addons-commits] objsys: branch 1.2 r332 - in
/branches/1.2/asterisk-ooh323c: ./ src/
asterisk-addons-commits at lists.digium.com
asterisk-addons-commits at lists.digium.com
Thu Jan 25 10:36:04 MST 2007
Author: objsys
Date: Thu Jan 25 11:36:03 2007
New Revision: 332
URL: http://svn.digium.com/view/asterisk-addons?view=rev&rev=332
Log:
find user to use IP for searching user
Modified:
branches/1.2/asterisk-ooh323c/README
branches/1.2/asterisk-ooh323c/src/chan_h323.c
branches/1.2/asterisk-ooh323c/src/chan_h323.h
Modified: branches/1.2/asterisk-ooh323c/README
URL: http://svn.digium.com/view/asterisk-addons/branches/1.2/asterisk-ooh323c/README?view=diff&rev=332&r1=331&r2=332
==============================================================================
--- branches/1.2/asterisk-ooh323c/README (original)
+++ branches/1.2/asterisk-ooh323c/README Thu Jan 25 11:36:03 2007
@@ -1,5 +1,5 @@
- Copyright (C) 2005, Objective Systems, Inc.
+ Copyright (C) 2007, Objective Systems, Inc.
Objective Systems asterisk-ooh323c driver for supporting H323 on asterisk
Modified: branches/1.2/asterisk-ooh323c/src/chan_h323.c
URL: http://svn.digium.com/view/asterisk-addons/branches/1.2/asterisk-ooh323c/src/chan_h323.c?view=diff&rev=332&r1=331&r2=332
==============================================================================
--- branches/1.2/asterisk-ooh323c/src/chan_h323.c (original)
+++ branches/1.2/asterisk-ooh323c/src/chan_h323.c Thu Jan 25 11:36:03 2007
@@ -142,6 +142,8 @@
struct ast_codec_pref prefs;
int dtmfmode;
int rtptimeout;
+ int mUseIP; /* Use IP address or H323-ID to search user */
+ char mIP[20];
struct ooh323_user *next;
};
@@ -156,6 +158,7 @@
char accountcode[20];
int amaflags;
int dtmfmode;
+ int mFriend; /* indicates defined as friend */
char ip[20];
int port;
char *h323id; /* H323-ID alias, which asterisk will register with gk to reach this peer*/
@@ -461,6 +464,9 @@
char tmp[256];
char formats[512];
int oldformat;
+ char *sport = NULL;
+ int port = 0;
+
if(gH323Debug)
ast_verbose("--- ooh323_request - data %s format %s\n", (char*)data,
ast_getformatname_multiple(formats,512,format) );
@@ -505,9 +511,16 @@
dest = tmp;
ext = NULL;
}
-
- if(dest)
- peer = find_peer(dest);
+
+ /*if((sport = strchr(dest, ':'))) {
+ *sport = '\0';
+ sport++;
+ port = atoi(sport);
+ }*/
+
+ if(dest) {
+ peer = find_peer(dest, port);
+ }
else{
ast_log(LOG_ERROR, "Destination format is not supported\n");
return NULL;
@@ -527,7 +540,7 @@
if(peer->capability & format)
p->capability = peer->capability & format;
else{
- p->capability = peer->capability;
+ p->capability = peer->capability;
}
memcpy(&p->prefs, &peer->prefs, sizeof(struct ast_codec_pref));
p->dtmfmode = peer->dtmfmode;
@@ -540,11 +553,14 @@
memcpy(&p->prefs, &gPrefs, sizeof(struct ast_codec_pref));
p->username = strdup(dest);
-
p->host = strdup(dest);
- if(ext)
+ if(port > 0) {
+ p->port = port;
+ }
+ if(ext) {
strncpy(p->exten, ext, sizeof(p->exten)-1);
+ }
}
@@ -595,53 +611,104 @@
return p;
}
-struct ooh323_user *find_user(const char * name)
+struct ooh323_user *find_user(const char * name, const char* ip)
{
struct ooh323_user *user=NULL;
if(gH323Debug)
- ast_verbose("--- find_user\n");
-
+ ast_verbose("--- find_user \n");
user = userl.users;
ast_mutex_lock(&userl.lock);
while(user)
{
- if(name && !strcmp(user->name, name))
+ if(ip && user->mUseIP && !strcmp(user->mIP, ip)) {
break;
+ }
+ if(name && !strcmp(user->name, name)) {
+ break;
+ }
user = user->next;
}
ast_mutex_unlock(&userl.lock);
+
if(gH323Debug)
ast_verbose("+++ find_user\n");
return user;
}
-struct ooh323_peer *find_peer(const char * name)
-{
- struct ooh323_peer *peer=NULL;
-
- if(gH323Debug)
- ast_verbose("--- find_peer\n");
+struct ooh323_peer *find_friend(const char *name, int port)
+{
+ struct ooh323_peer *peer=NULL;
+
+ if(gH323Debug)
+ ast_verbose("--- find_friend \"%s\"\n", name);
peer = peerl.peers;
ast_mutex_lock(&peerl.lock);
while(peer)
{
+ if(gH323Debug) {
+ ast_verbose(" comparing with \"%s\"\n", peer->ip);
+ }
+ if(!strcmp(peer->ip, name)) {
+ if(port > 0 && peer->port == port) { break; }
+ else if (port <= 0) { break; }
+ }
+ peer = peer->next;
+ }
+ ast_mutex_unlock(&peerl.lock);
+
+ if(gH323Debug) {
+ if(peer) {
+ ast_verbose(" found matching friend\n");
+ }
+ ast_verbose("+++ find_friend \"%s\"\n", name);
+ }
+
+ return peer;
+}
+
+
+struct ooh323_peer *find_peer(const char * name, int port)
+{
+ struct ooh323_peer *peer=NULL;
+
+ if(gH323Debug)
+ ast_verbose("--- find_peer \"%s\"\n", name);
+
+
+ peer = peerl.peers;
+ ast_mutex_lock(&peerl.lock);
+ while(peer)
+ {
+ if(gH323Debug) {
+ ast_verbose(" comparing with \"%s\"\n", peer->ip);
+ }
if(!strcasecmp(peer->name, name))
break;
if(peer->h323id && !strcasecmp(peer->h323id, name))
break;
if(peer->e164 && !strcasecmp(peer->e164, name))
break;
+ /*
+ if(!strcmp(peer->ip, name)) {
+ if(port > 0 && peer->port == port) { break; }
+ else if (port <= 0) { break; }
+ }
+ */
peer = peer->next;
}
ast_mutex_unlock(&peerl.lock);
- if(gH323Debug)
- ast_verbose("+++ find_peer\n");
+ if(gH323Debug) {
+ if(peer) {
+ ast_verbose(" found matching peer\n");
+ }
+ ast_verbose("+++ find_peer \"%s\"\n", name);
+ }
return peer;
}
@@ -1238,7 +1305,7 @@
if(p->callerid_name)
{
p->username = strdup(p->callerid_name);
- user = find_user(p->username);
+ user = find_user(p->username, call->remoteIP);
if(user)
{
ast_mutex_lock(&user->lock);
@@ -1579,6 +1646,10 @@
else if (!strcasecmp(v->name, "amaflags")) {
user->amaflags = ast_cdr_amaflags2int(v->value);
}
+ else if (!strcasecmp(v->name, "ip")) {
+ strncpy(user->mIP, v->value, sizeof(user->mIP)-1);
+ user->mUseIP = 1;
+ }
else if (!strcasecmp(v->name, "dtmfmode")) {
if(!strcasecmp(v->value, "rfc2833"))
user->dtmfmode = H323_DTMF_RFC2833;
@@ -1599,7 +1670,7 @@
return user;
}
-static struct ooh323_peer *build_peer(const char *name, struct ast_variable *v)
+static struct ooh323_peer *build_peer(const char *name, struct ast_variable *v, int friend_type)
{
struct ooh323_peer *peer=NULL;
@@ -1617,6 +1688,9 @@
strncpy(peer->accountcode, gAccountcode, sizeof(peer->accountcode)-1);
peer->amaflags = gAMAFLAGS;
peer->dtmfmode = gDTMFMode;
+ if(0 == friend_type) {
+ peer->mFriend = 1;
+ }
while(v) {
if (!strcasecmp(v->name, "h323id")) {
@@ -1956,10 +2030,11 @@
{
if(strcasecmp(cat, "general"))
{
+ int friend_type = strcasecmp(utype, "friend");
utype = ast_variable_retrieve(cfg, cat, "type");
if(utype)
{
- if(!strcmp(utype, "user") || !strcasecmp(utype, "friend"))
+ if(!strcmp(utype, "user") || 0 == friend_type)
{
user = build_user(cat, ast_variable_browse(cfg, cat));
if (user)
@@ -1973,15 +2048,15 @@
ast_log(LOG_WARNING, "Failed to build user %s\n", cat);
}
}
- if(!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend"))
+ if(!strcasecmp(utype, "peer") || 0 == friend_type)
{
- peer = build_peer(cat, ast_variable_browse(cfg, cat));
+ peer = build_peer(cat, ast_variable_browse(cfg, cat), friend_type);
if(peer)
{
- ast_mutex_lock(&userl.lock);
+ ast_mutex_lock(&peerl.lock);
peer->next = peerl.peers;
peerl.peers = peer;
- ast_mutex_unlock(&userl.lock);
+ ast_mutex_unlock(&peerl.lock);
}
else {
ast_log(LOG_WARNING, "Failed to build peer %s\n", cat);
@@ -2529,6 +2604,7 @@
}
ooh323_do_reload();
}
+
/* Check for interfaces needing to be killed */
ast_mutex_lock(&iflock);
struct ooh323_pvt *h323_next;
@@ -2545,6 +2621,7 @@
}
ast_mutex_unlock(&iflock);
pthread_testcancel();
+
/* Wait for sched or io */
res = ast_sched_wait(sched);
if ((res < 0) || (res > 1000)) {
Modified: branches/1.2/asterisk-ooh323c/src/chan_h323.h
URL: http://svn.digium.com/view/asterisk-addons/branches/1.2/asterisk-ooh323c/src/chan_h323.h?view=diff&rev=332&r1=331&r2=332
==============================================================================
--- branches/1.2/asterisk-ooh323c/src/chan_h323.h (original)
+++ branches/1.2/asterisk-ooh323c/src/chan_h323.h Thu Jan 25 11:36:03 2007
@@ -69,8 +69,8 @@
struct ooh323_user;
struct ooh323_peer;
/* Helper functions */
-struct ooh323_user *find_user(const char * name);
-struct ooh323_peer *find_peer(const char * name);
+struct ooh323_user *find_user(const char * name, const char *ip);
+struct ooh323_peer *find_peer(const char * name, int port);
void ooh323_delete_peer(struct ooh323_peer *peer);
int delete_users(void);
More information about the asterisk-addons-commits
mailing list