[svn-commits] branch mogorman/asterisk-xmpp r19093 - in
/team/mogorman/asterisk-xmpp: ./ ch...
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Mon Apr 10 22:26:39 MST 2006
Author: mogorman
Date: Tue Apr 11 00:26:38 2006
New Revision: 19093
URL: http://svn.digium.com/view/asterisk?rev=19093&view=rev
Log:
broken to bits but updated
Added:
team/mogorman/asterisk-xmpp/channels/chan_jingle.c (contents, props changed)
- copied, changed from r18748, team/mogorman/asterisk-xmpp/channels/chan_xmpp.c
team/mogorman/asterisk-xmpp/configs/jingle.conf.sample (with props)
Removed:
team/mogorman/asterisk-xmpp/channels/chan_xmpp.c
Modified:
team/mogorman/asterisk-xmpp/app.c
team/mogorman/asterisk-xmpp/channels/Makefile
team/mogorman/asterisk-xmpp/channels/chan_agent.c
team/mogorman/asterisk-xmpp/configs/agents.conf.sample
team/mogorman/asterisk-xmpp/include/asterisk/app.h
team/mogorman/asterisk-xmpp/include/asterisk/xmpp.h
team/mogorman/asterisk-xmpp/res/res_xmpp.c
Modified: team/mogorman/asterisk-xmpp/app.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/app.c?rev=19093&r1=19092&r2=19093&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/app.c (original)
+++ team/mogorman/asterisk-xmpp/app.c Tue Apr 11 00:26:38 2006
@@ -49,7 +49,6 @@
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/indications.h"
-#include "asterisk/xmpp.h"
#define MAX_OTHER_FORMATS 10
@@ -230,62 +229,6 @@
static int (*ast_has_voicemail_func)(const char *mailbox, const char *folder) = NULL;
static int (*ast_messagecount_func)(const char *mailbox, int *newmsgs, int *oldmsgs) = NULL;
-
-static int (*astjab_register_func)(const char *action, int (*func)(struct axi_client *client, char *user, char *m,int type), const char *synopsis, const char *description)=NULL;
-static int (*astjab_send)(struct axi_client *client, char *address, char *message) =NULL;
-static int (*astjab_check_roster)(void)=NULL;
-
-void ast_install_xmpp_functions(int (*axi_check_roster)(void), int (*axi_send)(struct axi_client *client, char *address, char *message), int (*axi_register)(const char *action, int (*func)(struct axi_client *client,char *user, char *m, int type), const char *synopsis, const char *description))
-{
- astjab_send = axi_send;
- astjab_register_func=axi_register;
- astjab_check_roster=axi_check_roster;
-}
-
-void ast_uninstall_xmpp_functions(void)
-{
- astjab_send=NULL;
- astjab_register_func=NULL;
- astjab_check_roster=NULL;
-}
-
-int ast_xmpp_check_roster(void)
-{
- static int warned = 0;
- if (astjab_check_roster)
- return astjab_check_roster();
-
- if (option_verbose > 2) {
- warned++;
- ast_verbose(VERBOSE_PREFIX_3 "XMPP check_roster was not used because res_xmpp.so is not loaded.\nyou have been warned %itimes.\n",warned);
- }
- return 0;
-}
-int ast_xmpp_send(struct axi_client *client, char *address, char *message)
-{
- static int warned = 0;
- if (astjab_send)
- return astjab_send(client,address,message);
-
- if (option_verbose > 2 ) {
- warned++;
- ast_verbose(VERBOSE_PREFIX_3 "XMPP %s was not sent because res_xmpp.so is not loaded.\nyou have been warned %itimes.\n",message,warned);
- }
- return 0;
-}
-
-int ast_xmpp_register(const char *action, int (*func)(struct axi_client *client, char *user, char *m, int type), const char *synopsis, const char *description)
-{
- static int warned = 0;
- if (astjab_register_func)
- return astjab_register_func(action,func,synopsis,description);
-
- if (option_verbose > 2) {
- warned++;
- ast_verbose(VERBOSE_PREFIX_3 "XMPP function%s was not loaded because res_xmpp.so is not loaded.\nyou have been warned %itimes.\n",action,warned);
- }
- return 0;
-}
void ast_install_vm_functions(int (*has_voicemail_func)(const char *mailbox, const char *folder),
int (*messagecount_func)(const char *mailbox, int *newmsgs, int *oldmsgs))
Modified: team/mogorman/asterisk-xmpp/channels/Makefile
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/channels/Makefile?rev=19093&r1=19092&r2=19093&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/channels/Makefile (original)
+++ team/mogorman/asterisk-xmpp/channels/Makefile Tue Apr 11 00:26:38 2006
@@ -90,7 +90,7 @@
#ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/iksemel.h),)
# ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/iksemel.h),)
-# MODS:=$(filter-out chan_xmpp.so,$(MODS))
+# MODS:=$(filter-out chan_jingle.so,$(MODS))
# endif
#endif
@@ -252,7 +252,7 @@
chan_misdn.o: chan_misdn.c
$(CC) $(CFLAGS) -DCHAN_MISDN_VERSION=\"0.3.0\" -c $< -o $@
-chan_xmpp.so: chan_xmpp.o
+chan_jingle.so: chan_jingle.o
$(CC) $(SOLINK) -o $@ $< $(XMPPLIB)
misdn_config.o: misdn_config.c misdn/chan_misdn_config.h
Modified: team/mogorman/asterisk-xmpp/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/channels/chan_agent.c?rev=19093&r1=19092&r2=19093&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/channels/chan_agent.c (original)
+++ team/mogorman/asterisk-xmpp/channels/chan_agent.c Tue Apr 11 00:26:38 2006
@@ -71,7 +71,6 @@
#include "asterisk/astdb.h"
#include "asterisk/devicestate.h"
#include "asterisk/monitor.h"
-#include "asterisk/xmpp.h"
#include "asterisk/stringfields.h"
static const char desc[] = "Agent Proxy Channel";
@@ -161,7 +160,6 @@
static int multiplelogin = 1;
static int autologoffunavail = 0;
-static int xmpplogon=1,xmpplogoff=6;
static int maxlogintries = 3;
static char agentgoodbye[AST_MAX_FILENAME_LEN] = "vm-goodbye";
@@ -204,9 +202,6 @@
struct ast_channel *owner; /**< Agent */
char loginchan[80]; /**< channel they logged in from */
char logincallerid[80]; /**< Caller ID they had when they logged in */
- int xmpplogoff; /**< Logout agent based on xmpp presence */
- int xmpplogon; /**< Logon agent based on xmpp presence */
- char xuser[AST_MAX_AGENT]; /**< Username for xmpp presence */
struct ast_channel *chan; /**< Channel we use */
AST_LIST_ENTRY(agent_pvt) list; /**< Next Agent in the linked list. */
};
@@ -259,8 +254,6 @@
static int agent_indicate(struct ast_channel *ast, int condition);
static int agent_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
static struct ast_channel *agent_bridgedchannel(struct ast_channel *chan, struct ast_channel *bridge);
-static int xmpp_agent_status(struct axi_client *client,char *user,char *message, int type);
-static int xmpp_login(char *agent,char *exten, char *context);
static void set_agentbycallerid(const char *callerid, const char *agent);
static const struct ast_channel_tech agent_tech = {
@@ -298,17 +291,10 @@
AST_APP_ARG(agt);
AST_APP_ARG(password);
AST_APP_ARG(name);
- AST_APP_ARG(xlogon);
- AST_APP_ARG(xlogoff);
);
char *password = NULL;
char *name = NULL;
char *agt = NULL;
- char *xuser = NULL;
- int xlogon=0,xlogoff=0;
- xlogon=xmpplogon;
- xlogoff=xmpplogoff;
- char status[100];
struct agent_pvt *p;
if (!(parse = ast_strdupa(agent)))
@@ -335,36 +321,6 @@
if(!ast_strlen_zero(args.name)) {
name = args.name;
while (*name && *name < 33) name++;
- }
-
- if(!ast_strlen_zero(args.xlogon)) {
- if(!strcasecmp(args.xlogon, "online"))
- xlogon=1;
- if(!strcasecmp(args.xlogon, "chatty"))
- xlogon=2;
- if(!strcasecmp(args.xlogon, "away"))
- xlogon=3;
- if(!strcasecmp(args.xlogon, "xaway"))
- xlogon=4;
- if(!strcasecmp(args.xlogon, "dnd"))
- xlogon=5;
- if(!strcasecmp(args.xlogon, "offline"))
- xlogon=6;
- }
-
- if(!ast_strlen_zero(args.xlogoff)) {
- if(!strcasecmp(args.xlogoff, "online"))
- xlogon=1;
- if(!strcasecmp(args.xlogoff, "chatty"))
- xlogon=2;
- if(!strcasecmp(args.xlogoff, "away"))
- xlogon=3;
- if(!strcasecmp(args.xlogoff, "xaway"))
- xlogon=4;
- if(!strcasecmp(args.xlogoff, "dnd"))
- xlogon=5;
- if(!strcasecmp(args.xlogoff, "offline"))
- xlogon=6;
}
/* Are we searching for the agent here ? To see if it exists already ? */
@@ -389,18 +345,9 @@
ast_copy_string(p->password, password ? password : "", sizeof(p->password));
ast_copy_string(p->name, name ? name : "", sizeof(p->name));
ast_copy_string(p->moh, moh, sizeof(p->moh));
- ast_copy_string(p->xuser,xuser ? xuser :"",sizeof(p->xuser));
- p->xmpplogon=xlogon;
- p->xmpplogoff=xlogoff;
p->ackcall = ackcall;
p->autologoff = autologoff;
- if(p->xuser)
- {
- sprintf(status,"axi_agent%s",p->xuser);
- ast_xmpp_register(status,xmpp_agent_status,"Handles Agent status.\n",mandescr_agent_logoff);
- }
-
/* If someone reduces the wrapuptime and reloads, we want it
* to change the wrapuptime immediately on all calls */
if (p->wrapuptime > wrapuptime) {
@@ -1085,32 +1032,6 @@
autologoff = atoi(v->value);
if (autologoff < 0)
autologoff = 0;
- } else if (!strcasecmp(v->name, "xmpplogon")) {
- if(!strcasecmp(v->value,"online"))
- xmpplogon=1;
- if(!strcasecmp(v->value,"chatty"))
- xmpplogon=2;
- if(!strcasecmp(v->value,"away"))
- xmpplogon=3;
- if(!strcasecmp(v->value,"xaway"))
- xmpplogon=4;
- if(!strcasecmp(v->value,"dnd"))
- xmpplogon=5;
- if(!strcasecmp(v->value,"offline"))
- xmpplogon=6;
- } else if (!strcasecmp(v->name, "xmpplogoff")) {
- if(!strcasecmp(v->value,"online"))
- xmpplogoff=1;
- if(!strcasecmp(v->value,"chatty"))
- xmpplogoff=2;
- if(!strcasecmp(v->value,"away"))
- xmpplogoff=3;
- if(!strcasecmp(v->value,"xaway"))
- xmpplogoff=4;
- if(!strcasecmp(v->value,"dnd"))
- xmpplogoff=5;
- if(!strcasecmp(v->value,"offline"))
- xmpplogoff=6;
} else if (!strcasecmp(v->name, "ackcall")) {
if (!strcasecmp(v->value, "always"))
ackcall = 2;
@@ -1627,42 +1548,6 @@
astman_send_error(s, m, "No such agent");
return 0;
-}
-
-static int xmpp_agent_status(struct axi_client *client,char *user,char *message, int type)
-{
- char *m=NULL;
- m=(char*)malloc(strlen(message));
- //ast_copy_string(m, message, sizeof(m));
- strcpy(m,message);
- char *context=NULL;
- char *extension=NULL;
- struct agent_pvt *p;
-
- if(m){
- context=strchr(m,'@');
- *context='\0';
- context++;
- extension=m;
- }
-
- AST_LIST_TRAVERSE(&agents, p, list) {
- if(!strncasecmp(p->xuser,user,strlen(p->xuser)))
- {
- if(p->xmpplogon >= type){
- xmpp_login(p->agent,extension,context);
- ast_xmpp_send(client,user,"Agent is logged in.");
- }
- if(p->xmpplogoff <= type){
- agent_logoff(p->agent, 1);
- ast_xmpp_send(client,user,"Agent is logged out.");
- }
-
- }
- }
-
- free(m);
- return 1;
}
static char *complete_agent_logoff_cmd(const char *line, const char *word, int pos, int state)
@@ -2237,58 +2122,6 @@
return __login_exec(chan, data, 1);
}
-static int xmpp_login(char *agent,char *exten, char *context)
-{
- char *wrapuptime_s=NULL;
- char *ackcall_s=NULL;
- struct agent_pvt *p;
- int login_state = 0;
-
- AST_LIST_TRAVERSE(&agents, p, list) {
- if (strncmp(p->agent, agent,strlen(p->agent)) || p->pending) {
- continue;
- }
- if (p->chan) {
- login_state = 2; /* already logged in (and on the phone)*/
- break;
- }
- login_state = 1; /* Successful Login */
- ast_copy_string(p->loginchan, exten, sizeof(p->loginchan));
-
- if (ast_strlen_zero(context))
- snprintf(p->loginchan, sizeof(p->loginchan), "%s", exten);
- else
- snprintf(p->loginchan, sizeof(p->loginchan), "%s@%s", exten, context);
-
- if (wrapuptime_s && !ast_strlen_zero(wrapuptime_s)) {
- p->wrapuptime = atoi(wrapuptime_s);
- if (p->wrapuptime < 0)
- p->wrapuptime = 0;
- }
-
- if (ast_true(ackcall_s))
- p->ackcall = 1;
- else
- p->ackcall = 0;
-
- if (p->loginstart == 0)
- time(&p->loginstart);
- ast_queue_log("NONE", "NONE", agent, "AGENTCALLBACKLOGIN", "%s", p->loginchan);
- if (option_verbose > 1)
- ast_verbose(VERBOSE_PREFIX_2 "Callback Agent '%s' logged in on %s\n", p->agent, p->loginchan);
- ast_device_state_changed("Agent/%s", p->agent);
- }
-
- if (login_state == 1)
- ast_verbose("Agent logged in\n");
- else if (login_state == 0)
- ast_verbose("No such agent\n");
- else if (login_state == 2)
- ast_verbose("Agent already logged in\n");
-
- return 0;
-}
-
/**
* Sets an agent as logged in by callback in the Manager API.
* It is registered on load_module() and it gets called by the manager backend.
@@ -2675,7 +2508,6 @@
read_agent_config();
if (persistent_agents)
reload_agents();
- ast_xmpp_check_roster();
return 0;
}
@@ -2684,7 +2516,6 @@
read_agent_config();
if (persistent_agents)
reload_agents();
- ast_xmpp_check_roster();
return 0;
}
Copied: team/mogorman/asterisk-xmpp/channels/chan_jingle.c (from r18748, team/mogorman/asterisk-xmpp/channels/chan_xmpp.c)
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/channels/chan_jingle.c?p2=team/mogorman/asterisk-xmpp/channels/chan_jingle.c&p1=team/mogorman/asterisk-xmpp/channels/chan_xmpp.c&r1=18748&r2=19093&rev=19093&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/channels/chan_xmpp.c (original)
+++ team/mogorman/asterisk-xmpp/channels/chan_jingle.c Tue Apr 11 00:26:38 2006
@@ -1,9 +1,9 @@
-/*
+jingle/*
* Asterisk -- An open source telephony toolkit.
*
* Copyright (C) 1999 - 2005, Digium, Inc.
*
- * Matthew O'Gorman <mogorman at digium.com>
+ * Matt O'Gorman <mogorman at digium.com>
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
@@ -18,13 +18,14 @@
/*! \file
*
- * \author Matthew O'Gorman <mogorman at digium.com>
+ * \author Matt O'Gorman <mogorman at digium.com>
*
- * \brief XMPP Channel Driver
+ * \brief Jingle Channel Driver
*
* \ingroup channel_drivers
*/
+#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
@@ -40,7 +41,7 @@
#include "asterisk.h"
-ASTERISK_FILE_VERSION(__FILE__, "$Revision: 1 $")
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/lock.h"
#include "asterisk/channel.h"
@@ -63,54 +64,59 @@
#include "asterisk/stringfields.h"
#include "asterisk/utils.h"
#include "asterisk/xmpp.h"
-
-static const char desc[] = "XMPP Channel";
-static const char type[] = "XMPP";
-static const char tdesc[] = "XMPP Channel Driver";
+#include "asterisk/jingle.h"
+
+#define JINGLE_CONFIG "jingle.conf"
+
+static const char desc[] = "Jingle Channel";
+static const char type[] = "Jingle";
+static const char tdesc[] = "Jingle Channel Driver";
static int usecnt =0;
AST_MUTEX_DEFINE_STATIC(usecnt_lock);
+static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;
+
/* Protect the interface list (of sip_pvt's) */
-AST_MUTEX_DEFINE_STATIC(xmpplock);
+AST_MUTEX_DEFINE_STATIC(jinglelock);
AST_MUTEX_DEFINE_STATIC(rand_lock); /*!< Lock for thread-safe random generator */
-static struct ast_channel *xmpp_request(const char *type, int format, void *data, int *cause);
-static int xmpp_digit(struct ast_channel *ast, char digit);
-static int xmpp_call(struct ast_channel *ast, char *dest, int timeout);
-static int xmpp_hangup(struct ast_channel *ast);
-static int xmpp_answer(struct ast_channel *ast);
-static int xmpp_answer2(struct axi_client *client, ikspak *pak);
-static struct ast_frame *xmpp_read(struct ast_channel *ast);
-static int xmpp_write(struct ast_channel *ast, struct ast_frame *f);
-static int xmpp_indicate(struct ast_channel *ast, int condition);
-static int xmpp_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
-static int xmpp_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen);
-static struct xmpp_pvt *xmpp_alloc(char *data, int format);
+static struct ast_channel *jingle_request(const char *type, int format, void *data, int *cause);
+static int jingle_digit(struct ast_channel *ast, char digit);
+static int jingle_call(struct ast_channel *ast, char *dest, int timeout);
+static int jingle_hangup(struct ast_channel *ast);
+static int jingle_answer(struct ast_channel *ast);
+static int jingle_answer2(struct axi_client *client, ikspak *pak);
+static struct ast_frame *jingle_read(struct ast_channel *ast);
+static int jingle_write(struct ast_channel *ast, struct ast_frame *f);
+static int jingle_indicate(struct ast_channel *ast, int condition);
+static int jingle_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
+static int jingle_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen);
+static struct jingle_pvt *jingle_alloc(char *data, int format);
/* PBX interface structure for channel registration */
-static const struct ast_channel_tech xmpp_tech = {
+static const struct ast_channel_tech jingle_tech = {
.type = type,
.description = tdesc,
.capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
- .requester = xmpp_request,
- .send_digit = xmpp_digit,
-// .requester = xmpp_request_call,
-// .devicestate = xmpp_devicestate,
-// .transfer = xmpp_transfer,
+ .requester = jingle_request,
+ .send_digit = jingle_digit,
+// .requester = jingle_request_call,
+// .devicestate = jingle_devicestate,
+// .transfer = jingle_transfer,
.bridge = ast_rtp_bridge,
- .call = xmpp_call,
- .hangup = xmpp_hangup,
- .answer = xmpp_answer,
- .read = xmpp_read,
- .write = xmpp_write,
- .exception = xmpp_read,
- .indicate = xmpp_indicate,
- .fixup = xmpp_fixup,
- .send_html = xmpp_sendhtml,
+ .call = jingle_call,
+ .hangup = jingle_hangup,
+ .answer = jingle_answer,
+ .read = jingle_read,
+ .write = jingle_write,
+ .exception = jingle_read,
+ .indicate = jingle_indicate,
+ .fixup = jingle_fixup,
+ .send_html = jingle_sendhtml,
};
static struct sockaddr_in bindaddr = { 0, }; /*!< The address we bind to */
@@ -119,20 +125,39 @@
static struct io_context *io; /*!< The IO context */
static struct in_addr __ourip;
/*----- RTP interface functions */
-static int xmpp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, int codecs, int nat_active);
-static struct ast_rtp *xmpp_get_rtp_peer(struct ast_channel *chan);
-static int xmpp_get_codec(struct ast_channel *chan);
-
-static struct ast_rtp_protocol xmpp_rtp = {
- type: "XMPP",
- get_rtp_info: xmpp_get_rtp_peer,
- set_rtp_peer: xmpp_set_rtp_peer,
- get_codec: xmpp_get_codec,
+static int jingle_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, int codecs, int nat_active);
+static struct ast_rtp *jingle_get_rtp_peer(struct ast_channel *chan);
+static int jingle_get_codec(struct ast_channel *chan);
+
+static struct ast_rtp_protocol jingle_rtp = {
+ type: "jingle",
+ get_rtp_info: jingle_get_rtp_peer,
+ set_rtp_peer: jingle_set_rtp_peer,
+ get_codec: jingle_get_codec,
};
+char externip[16];
+char localip[16];
+
+struct jingle_container jingles;
+
static int flipflop = 0;
-static int xmpp_queue_frame(struct xmpp_pvt *p, int isoutbound, struct ast_frame *f, struct ast_channel *us)
+struct jingle *find_jingle(struct axi_client *client, ikspak *pak)
+{
+ struct jingle *res=NULL;
+ ASTOBJ_CONTAINER_TRAVERSE(&jingles,1, {
+ ASTOBJ_RDLOCK(iterator);
+ if(iterator->connection==client ) {
+ if(!strncasecmp(iterator->user,pak->from->full,sizeof(iterator->user)))
+ res = iterator;
+ }
+ ASTOBJ_UNLOCK(iterator);
+ });
+ return res;
+}
+
+static int jingle_queue_frame(struct jingle_pvt *p, int isoutbound, struct ast_frame *f, struct ast_channel *us)
{
struct ast_channel *other;
retrylock:
@@ -180,16 +205,16 @@
return 0;
}
-static int xmpp_answer(struct ast_channel *ast)
-{
- struct xmpp_pvt *p = ast->tech_pvt;
+static int jingle_answer(struct ast_channel *ast)
+{
+ struct jingle_pvt *p = ast->tech_pvt;
int isoutbound =1;
int res = -1;
ast_mutex_lock(&p->lock);
// Pass along answer since somebody answered us
struct ast_frame answer = { AST_FRAME_CONTROL, AST_CONTROL_ANSWER };
- res = xmpp_queue_frame(p, isoutbound, &answer, ast);
+ res = jingle_queue_frame(p, isoutbound, &answer, ast);
ast_mutex_unlock(&p->lock);
return res;
}
@@ -205,9 +230,9 @@
return val;
}
-static struct ast_rtp *xmpp_get_rtp_peer(struct ast_channel *chan)
-{
- struct xmpp_pvt *p;
+static struct ast_rtp *jingle_get_rtp_peer(struct ast_channel *chan)
+{
+ struct jingle_pvt *p;
struct ast_rtp *rtp = NULL;
p = chan->tech_pvt;
if (!p)
@@ -219,15 +244,15 @@
return rtp;
}
-static int xmpp_get_codec(struct ast_channel *chan)
-{
- struct xmpp_pvt *p = chan->tech_pvt;
+static int jingle_get_codec(struct ast_channel *chan)
+{
+ struct jingle_pvt *p = chan->tech_pvt;
return p->peercapability;
}
-static int xmpp_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, int codecs, int nat_active)
-{
- struct xmpp_pvt *p;
+static int jingle_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, int codecs, int nat_active)
+{
+ struct jingle_pvt *p;
p = chan->tech_pvt;
if (!p)
@@ -245,16 +270,19 @@
return 0;
}
-static int xmpp_bridge_call(struct axi_client *client,ikspak *pak)
+static int jingle_bridge_call(struct axi_client *client,ikspak *pak)
{
char *data, sid[100];
- struct xmpp_pvt *p = client->xmpps;
+ struct jingle_pvt *p=NULL;
+ struct jingle *peer=NULL;
struct ast_channel *bridgepeer = NULL;
struct hostent *hp;
struct ast_hostent ahp;
char iabuf[INET_ADDRSTRLEN];
struct sockaddr_in sin;
-
+
+ if((peer = find_jingle(client,pak)))
+ p = peer->p;
ast_verbose("ONLY A Little further %s\n",(iks_find_attrib(pak->x,"id")));
data = iks_find_attrib(pak->x,"id");
data = data + 9;
@@ -270,7 +298,7 @@
hp = ast_gethostbyname(p->candidates->ip, &ahp);
sin.sin_family = AF_INET;
memcpy(&sin.sin_addr, hp->h_addr, sizeof(sin.sin_addr));
- sin.sin_port = htons(client->candidates->port);
+ sin.sin_port = htons(p->candidates->port);
if (p->rtp && sin.sin_port) {
ast_rtp_set_peer(p->rtp, &sin);
ast_verbose("Peer audio RTP is at port %s:%d\n", ast_inet_ntoa(iabuf,sizeof(iabuf), sin.sin_addr), ntohs(sin.sin_port));
@@ -284,7 +312,7 @@
ast_log(LOG_DEBUG, "Oooh, we need to change our formats since our peer supports only %s and not %s\n",
ast_getformatname_multiple(s1, slen, p->jointcapability),
ast_getformatname_multiple(s2, slen, p->owner->nativeformats));
- p->owner->nativeformats = ast_codec_choose(&client->prefs, p->jointcapability, 1);
+ p->owner->nativeformats = ast_codec_choose(&peer->prefs, p->jointcapability, 1);
ast_set_read_format(p->owner, p->owner->readformat);
ast_set_write_format(p->owner, p->owner->writeformat);
}
@@ -337,29 +365,33 @@
return 1;
}
-static int xmpp_hangup_farend(struct axi_client *client,ikspak *pak)
+static int jingle_hangup_farend(struct axi_client *client,ikspak *pak)
{
ast_verbose("END CALL\n");
return 1;
}
-static int xmpp_create_candidates(struct axi_client *client,ikspak *pak)
-{
- struct axi_candidate *tmp;
- struct xmpp_pvt *p = client->xmpps;
+static int jingle_create_candidates(struct axi_client *client,ikspak *pak)
+{
+ struct jingle_candidate *tmp;
+ struct jingle_pvt *p = NULL;
+ struct jingle *peer= NULL;
struct sockaddr_in sin;
struct sockaddr_in dest;
char iabuf[INET_ADDRSTRLEN];
iks *iq, *jingle, *candidate;
char user[17], pass[17], preference[5], port[7];
- tmp = client->candidates;
+ if((peer = find_jingle(client,pak)))
+ p = peer->p;
+ tmp = p->candidates;
iq = iks_new("iq");
jingle = iks_new(GOOGLE_NODE);
candidate = iks_new("candidate");
iks_insert_node(iq,jingle);
iks_insert_node(jingle,candidate);
+
while(p) {
if(!strcasecmp(p->sid,iks_find_attrib(pak->query,GOOGLE_SID))) {
break;
@@ -373,7 +405,7 @@
ast_verbose("We're at %s port %d\n", ast_inet_ntoa(iabuf, sizeof(iabuf), __ourip), ntohs(sin.sin_port)); /// THIS IS BAD NEED TO FIX
snprintf(port, sizeof(port),"%d",ntohs(sin.sin_port));
- snprintf(client->localip, sizeof(client->localip),"%s",ast_inet_ntoa(iabuf, sizeof(iabuf), __ourip)); // hack
+ snprintf(localip, sizeof(localip),"%s",ast_inet_ntoa(iabuf, sizeof(iabuf), __ourip)); // hack
while(tmp) { /*send standard candidates*/
snprintf(user, sizeof(user),"%08x%08x",thread_safe_rand() ,thread_safe_rand());
@@ -389,7 +421,7 @@
iks_insert_attrib(jingle,"initiator",iks_find_attrib(pak->x,"from"));
iks_insert_attrib(jingle,"xmlns", GOOGLE_NS);
iks_insert_attrib(candidate, "name", tmp->name);
- iks_insert_attrib(candidate, "address", client->localip); /*FIX ME*/
+ iks_insert_attrib(candidate, "address",localip); /*FIX ME*/
iks_insert_attrib(candidate, "port", port);
iks_insert_attrib(candidate, "username", user);
iks_insert_attrib(candidate, "password", pass);
@@ -410,7 +442,7 @@
iks_send(client->p,iq);
tmp=tmp->next;
}
- if(!client->candidates) { /*send default stun, and local, and relay */
+ if(!p->candidates) { /*send default stun, and local, and relay */
snprintf(user, sizeof(user),"%08x%08x",thread_safe_rand(),thread_safe_rand());
snprintf(pass, sizeof(pass),"%08x%08x",thread_safe_rand(),thread_safe_rand());
iks_insert_attrib(iq,"from", client->jid->full);
@@ -423,7 +455,7 @@
iks_insert_attrib(jingle,"initiator",iks_find_attrib(pak->x,"from"));
iks_insert_attrib(jingle,"xmlns", GOOGLE_NS);
iks_insert_attrib(candidate, "name", "rtp");
- iks_insert_attrib(candidate, "address", client->localip);
+ iks_insert_attrib(candidate, "address",localip);
iks_insert_attrib(candidate, "port", port); /*FIX ME*/
iks_insert_attrib(candidate, "username", user);
iks_insert_attrib(candidate, "password", pass);
@@ -438,7 +470,7 @@
snprintf(pass, sizeof(pass),"%08x%08x",thread_safe_rand(),thread_safe_rand());
iks_insert_attrib(iq,"id", client->mid);
axi_increment_mid(client->mid);
- iks_insert_attrib(candidate, "address", client->externip);
+ iks_insert_attrib(candidate, "address", externip);
iks_insert_attrib(candidate, "port", port);
iks_insert_attrib(candidate, "username", user);
iks_insert_attrib(candidate, "password", pass);
@@ -450,7 +482,7 @@
snprintf(pass, sizeof(pass),"%08x%08x",thread_safe_rand(),thread_safe_rand());
iks_insert_attrib(iq,"id", client->mid);
axi_increment_mid(client->mid);
- iks_insert_attrib(candidate, "address", client->localip);
+ iks_insert_attrib(candidate, "address", localip);
iks_insert_attrib(candidate, "port", port); /*FIX ME*/
iks_insert_attrib(candidate, "username", user);
iks_insert_attrib(candidate, "password", pass);
@@ -465,7 +497,7 @@
return 1;
}
-static void add_codec_to_answer(const struct xmpp_pvt *p, int codec, iks *description)
+static void add_codec_to_answer(const struct jingle_pvt *p, int codec, iks *description)
{
ast_verbose("Adding codec 0x%x (%s) to SDP\n", codec, ast_getformatname(codec));
if(!strcasecmp("ulaw",ast_getformatname(codec))) {
@@ -513,14 +545,19 @@
ast_rtp_lookup_code(p->rtp, 1, codec);
}
-static int xmpp_accept_call(struct axi_client *client, ikspak *pak)
-{
- struct xmpp_pvt *tmp = client->xmpps;
+static int jingle_accept_call(struct axi_client *client, ikspak *pak)
+{
+ struct jingle_pvt *tmp = NULL;
+ struct jingle *peer = NULL;
iks *iq, *jingle, *description, /* *payload_ipcmwb, *payload_isac,*/ *payload_red, *payload_audio, *payload_cn;
int x;
int pref_codec = 0;
int alreadysent = 0;
char mid[50];
+
+ if((peer = find_jingle(client,pak)))
+ tmp = peer->p;
+
while(tmp) {
if(!strcasecmp(tmp->sid,iks_find_attrib(pak->query,GOOGLE_SID))) {
iq = iks_new("iq");
@@ -529,9 +566,9 @@
iks_insert_attrib(description,"xmlns",GOOGLE_NS);
for (x = 0; x < 32; x++) {
- if (!(pref_codec = ast_codec_pref_index(&client->prefs, x)))
+ if (!(pref_codec = ast_codec_pref_index(&peer->prefs, x)))
break;
- if (!(client->capability & pref_codec))
+ if (!(peer->capability & pref_codec))
continue;
if (alreadysent & pref_codec)
continue;
@@ -596,9 +633,13 @@
return 1;
}
-static struct xmpp_pvt *xmpp_alloc2(struct axi_client *client)
-{
- struct xmpp_pvt *tmp;
+static struct jingle_pvt *jingle_alloc2(struct axi_client *client, ikspak *pak)
+{
+ struct jingle_pvt *tmp = NULL;
+ struct jingle *peer =NULL;
+
+ if((peer = find_jingle(client,pak)))
+ tmp = peer->p;
if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
return NULL;
@@ -606,21 +647,26 @@
tmp->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
ast_mutex_init(&tmp->lock);
- ast_mutex_lock(&xmpplock);
- tmp->next = client->xmpps;
- client->xmpps = tmp;
- ast_mutex_unlock(&xmpplock);
+ ast_mutex_lock(&jinglelock);
+ tmp->next = peer->p;
+ peer->p = tmp;
+ ast_mutex_unlock(&jinglelock);
return tmp;
}
-static int xmpp_answer2(struct axi_client *client,ikspak *pak)
-{
- struct xmpp_pvt *p ,*tmp = client->xmpps;
+static int jingle_answer2(struct axi_client *client,ikspak *pak)
+{
+ struct jingle_pvt *p ,*tmp = NULL;
+ struct jingle *peer = NULL;
struct ast_channel *chan;
iks *accept, *codec;
+
+ if((peer = find_jingle(client,pak)))
+ tmp = peer->p;
+
codec = iks_child(iks_child(iks_child(pak->x)));
chan = ast_channel_alloc(1);
- chan->tech = &xmpp_tech;
+ chan->tech = &jingle_tech;
while(tmp) {
if(iks_find_with_attrib(pak->x,GOOGLE_NODE,GOOGLE_SID,tmp->sid))
{
@@ -628,7 +674,7 @@
}
tmp=tmp->next;
}
- p = xmpp_alloc2(client);
+ p = jingle_alloc2(client, pak);
ast_mutex_lock(&p->lock);
if(iks_find_attrib(pak->x,"from"))
ast_copy_string(p->from,iks_find_attrib(pak->x,"from"),sizeof(p->from));
@@ -652,24 +698,25 @@
iks_insert_attrib(accept,"id",iks_find_attrib(pak->x,"id"));
iks_send(client->p,accept);
iks_delete(accept);
- xmpp_create_candidates(client,pak);
+ jingle_create_candidates(client,pak);
return 1;
}
-static int xmpp_add_candidate(struct axi_client *client,ikspak *pak)
-{
- struct xmpp_pvt *p =NULL,*tmp = client->xmpps;
- struct axi_candidate *newcandidate = NULL;
+static int jingle_add_candidate(struct axi_client *client,ikspak *pak)
+{
+ struct jingle_pvt *p =NULL,*tmp = NULL;
+ struct jingle *peer = NULL;
+ struct jingle_candidate *newcandidate = NULL;
struct sockaddr_in sin;
struct hostent *hp;
struct ast_hostent ahp;
char iabuf[INET_ADDRSTRLEN];
iks *candidate_node = NULL;
iks *receipt = NULL;
- newcandidate = (struct axi_candidate *)malloc(sizeof(struct axi_candidate));
+ newcandidate = (struct jingle_candidate *)malloc(sizeof(struct jingle_candidate));
if(!newcandidate)
return NULL;
- memset(newcandidate,0,sizeof(struct axi_candidate));
+ memset(newcandidate,0,sizeof(struct jingle_candidate));
candidate_node = iks_find(pak->query,"candidate");
ast_copy_string(newcandidate->name,iks_find_attrib(candidate_node, "name"),sizeof(newcandidate->name));
ast_copy_string(newcandidate->ip, iks_find_attrib(candidate_node, "address"),sizeof(newcandidate->ip));
@@ -727,11 +774,11 @@
return 0;
}
-static void check_bridge(struct xmpp_pvt *p, int isoutbound)
-{
-}
-
-static struct ast_frame *xmpp_rtp_read(struct ast_channel *ast, struct xmpp_pvt *p)
+static void check_bridge(struct jingle_pvt *p, int isoutbound)
+{
+}
+
+static struct ast_frame *jingle_rtp_read(struct ast_channel *ast, struct jingle_pvt *p)
{
struct ast_frame *f;
if (!p->rtp) {
@@ -758,20 +805,20 @@
return f;
}
-static struct ast_frame *xmpp_read(struct ast_channel *ast)
+static struct ast_frame *jingle_read(struct ast_channel *ast)
{
struct ast_frame *fr;
- struct xmpp_pvt *p = ast->tech_pvt;
+ struct jingle_pvt *p = ast->tech_pvt;
ast_mutex_lock(&p->lock);
- fr = xmpp_rtp_read(ast, p);
+ fr = jingle_rtp_read(ast, p);
ast_mutex_unlock(&p->lock);
return fr;
}
-static int xmpp_write(struct ast_channel *ast, struct ast_frame *f)
-{
- struct xmpp_pvt *p = ast->tech_pvt;
+static int jingle_write(struct ast_channel *ast, struct ast_frame *f)
+{
+ struct jingle_pvt *p = ast->tech_pvt;
int res = -1;
int isoutbound;
@@ -781,7 +828,7 @@
if (f && (f->frametype == AST_FRAME_VOICE))
check_bridge(p, isoutbound);
// if (!p->alreadymasqed)
-// res = xmpp_queue_frame(p, isoutbound, f, ast);
+// res = jingle_queue_frame(p, isoutbound, f, ast);
// else {
// ast_log(LOG_DEBUG, "Not posting to queue since already masked on '%s'\n", ast->name);
// res = 0;
@@ -790,9 +837,9 @@
return res;
}
-static int xmpp_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
-{
- struct xmpp_pvt *p = newchan->tech_pvt;
+static int jingle_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
+{
+ struct jingle_pvt *p = newchan->tech_pvt;
ast_mutex_lock(&p->lock);
if ((p->owner != oldchan) ) {
@@ -805,9 +852,9 @@
return 0;
}
-static int xmpp_indicate(struct ast_channel *ast, int condition)
-{
- struct xmpp_pvt *p = ast->tech_pvt;
+static int jingle_indicate(struct ast_channel *ast, int condition)
+{
+ struct jingle_pvt *p = ast->tech_pvt;
int res = -1;
struct ast_frame f = { AST_FRAME_CONTROL, };
int isoutbound;
@@ -816,14 +863,14 @@
ast_mutex_lock(&p->lock);
// isoutbound = IS_OUTBOUND(ast, p);
f.subclass = condition;
- res = xmpp_queue_frame(p, isoutbound, &f, ast);
+ res = jingle_queue_frame(p, isoutbound, &f, ast);
ast_mutex_unlock(&p->lock);
return res;
}
-static int xmpp_digit(struct ast_channel *ast, char digit)
-{
- struct xmpp_pvt *p = ast->tech_pvt;
+static int jingle_digit(struct ast_channel *ast, char digit)
+{
+ struct jingle_pvt *p = ast->tech_pvt;
int res = -1;
struct ast_frame f = { AST_FRAME_DTMF, };
int isoutbound;
@@ -831,14 +878,14 @@
ast_mutex_lock(&p->lock);
// isoutbound = IS_OUTBOUND(ast, p);
f.subclass = digit;
- res = xmpp_queue_frame(p, isoutbound, &f, ast);
+ res = jingle_queue_frame(p, isoutbound, &f, ast);
ast_mutex_unlock(&p->lock);
return res;
}
-static int xmpp_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen)
-{
- struct xmpp_pvt *p = ast->tech_pvt;
+static int jingle_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen)
+{
+ struct jingle_pvt *p = ast->tech_pvt;
int res = -1;
struct ast_frame f = { AST_FRAME_HTML, };
int isoutbound;
@@ -848,16 +895,16 @@
f.subclass = subclass;
f.data = (char *)data;
f.datalen = datalen;
- res = xmpp_queue_frame(p, isoutbound, &f, ast);
+ res = jingle_queue_frame(p, isoutbound, &f, ast);
ast_mutex_unlock(&p->lock);
return res;
}
/*! \brief Initiate new call, part of PBX interface
* dest is the dial string */
-static int xmpp_call(struct ast_channel *ast, char *dest, int timeout)
-{
- struct xmpp_pvt *p = ast->tech_pvt;
+static int jingle_call(struct ast_channel *ast, char *dest, int timeout)
+{
+ struct jingle_pvt *p = ast->tech_pvt;
int res;
struct ast_var_t *varptr = NULL, *new;
size_t len, namelen;
@@ -894,17 +941,17 @@
}
#if 0
-static void xmpp_destroy(struct xmpp_pvt *p)
-{
- struct xmpp_pvt *cur, *prev = NULL;
- ast_mutex_lock(&xmpplock);
- cur = client->xmpps;
+static void jingle_destroy(struct jingle_pvt *p)
+{
+ struct jingle_pvt *cur, *prev = NULL;
+ ast_mutex_lock(&jinglelock);
+ cur = jingles->p;
while(cur) {
if (cur == p) {
if (prev)
prev->next = cur->next;
else
- client->xmpps = cur->next;
+ jingles->p = cur->next;
ast_mutex_destroy(cur);
free(cur);
break;
@@ -912,22 +959,23 @@
prev = cur;
cur = cur->next;
}
- ast_mutex_unlock(&xmpplock);
+ ast_mutex_unlock(&jinglelock);
if (!cur)
- ast_log(LOG_WARNING, "Unable ot find xmpp '%s@%s' in xmpp list\n", p->exten, p->context);
+ ast_log(LOG_WARNING, "Unable ot find jingle '%s@%s' in jingle list\n", p->exten, p->context);
}
#endif
-/*! \brief Hangup a call through the xmpp proxy channel */
-static int xmpp_hangup(struct ast_channel *ast)
-{
- return 0;
- struct xmpp_pvt *p = ast->tech_pvt;
+/*! \brief Hangup a call through the jingle proxy channel */
+static int jingle_hangup(struct ast_channel *ast)
+{
+#if 0
+ struct jingle_pvt *p = ast->tech_pvt;
+ struct jingle *peer = NULL;
struct axi_client *client = NULL;
client = ast_axi_get_client("asterisk");
int isoutbound;
struct ast_frame f = { AST_FRAME_CONTROL, AST_CONTROL_HANGUP };
- struct xmpp_pvt *cur, *prev=NULL;
+ struct jingle_pvt *cur, *prev=NULL;
struct ast_channel *ochan = NULL;
int glaredetect;
const char *status;
@@ -951,25 +999,27 @@
/* Okay, done with the private part now, too. */
// glaredetect = p->glaredetect;
/* If we have a queue holding, don't actually destroy p yet, but
- let xmpp_queue do it. */
+ let jingle_queue do it. */
// if (p->glaredetect)
// p->cancelqueue = 1;
ast_mutex_unlock(&p->lock);
/* Remove from list */
- ast_mutex_lock(&xmpplock);
- cur = client->xmpps;
+ ast_mutex_lock(&jinglelock);
+
+ if((peer = find_jingle(client,pak)))
+ cur = peer->p;
while(cur) {
if (cur == p) {
if (prev)
prev->next = cur->next;
else
- client->xmpps = cur->next;
+ peer->p = cur->next;
break;
}
prev = cur;
cur = cur->next;
}
- ast_mutex_unlock(&xmpplock);
+ ast_mutex_unlock(&jinglelock);
/* Grab / release lock just in case */
ast_mutex_lock(&p->lock);
ast_mutex_unlock(&p->lock);
@@ -984,17 +1034,18 @@
// /* Need to actually hangup since there is no PBX */
// ochan = p->chan;
// else
-// xmpp_queue_frame(p, isoutbound, &f, NULL);
+// jingle_queue_frame(p, isoutbound, &f, NULL);
ast_mutex_unlock(&p->lock);
if (ochan)
ast_hangup(ochan);
+#endif
return 0;
}
/*! \brief Create a call structure */
-static struct xmpp_pvt *xmpp_alloc(char *data, int format)
-{
- struct xmpp_pvt *tmp;
+static struct jingle_pvt *jingle_alloc(char *data, int format)
+{
+ struct jingle_pvt *tmp;
if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
return NULL;
@@ -1002,8 +1053,8 @@
return tmp;
}
-/*! \brief Start new xmpp channel */
-static struct ast_channel *xmpp_new(struct xmpp_pvt *p, int state)
+/*! \brief Start new jingle channel */
+static struct ast_channel *jingle_new(struct jingle_pvt *p, int state)
{
struct ast_channel *tmp;
@@ -1017,29 +1068,31 @@
/*! \brief Part of PBX interface */
-static struct ast_channel *xmpp_request(const char *type, int format, void *data, int *cause)
-{
- struct xmpp_pvt *p;
+static struct ast_channel *jingle_request(const char *type, int format, void *data, int *cause)
+{
+ struct jingle_pvt *p;
struct ast_channel *chan = NULL;
- p = xmpp_alloc(data, format);
+ p = jingle_alloc(data, format);
if (p)
- chan = xmpp_new(p, AST_STATE_DOWN);
+ chan = jingle_new(p, AST_STATE_DOWN);
return chan;
}
-/*! \brief CLI command "xmpp show channels" */
-static int xmpp_show(int fd, int argc, char **argv)
-{
- struct xmpp_pvt *p;
- struct axi_candidate *tmp;
+#if 0
+/*! \brief CLI command "jingle show channels" */
+static int jingle_show(int fd, int argc, char **argv)
+{
+ struct jingle_pvt *p=NULL;
+ struct jingle *peer=NULL;
+ struct jingle_candidate *tmp;
struct axi_client *client = NULL;
client = ast_axi_get_client("asterisk");
if (argc != 3)
return RESULT_SHOWUSAGE;
- ast_mutex_lock(&xmpplock);
+ ast_mutex_lock(&jinglelock);
if(client)
- p = client->xmpps;
+ p = jingles->p;
while(p) {
ast_mutex_lock(&p->lock);
ast_cli(fd, "SID = %s\n",p->sid );
@@ -1051,33 +1104,33 @@
ast_mutex_unlock(&p->lock);
p = p->next;
}
- if (!client->xmpps)
- ast_cli(fd, "No xmpp channels in use\n");
- ast_mutex_unlock(&xmpplock);
+ if (!jingles->p)
+ ast_cli(fd, "No jingle channels in use\n");
+ ast_mutex_unlock(&jinglelock);
return RESULT_SUCCESS;
}
-
-static char show_xmpps_usage[] =
-"Usage: xmpp show channels\n"
-" Provides summary information on active xmpp proxy channels.\n";
-
-static struct ast_cli_entry cli_show_xmpps = {
- { "xmpp", "show", "channels", NULL }, xmpp_show,
- "Show status of xmpp channels", show_xmpps_usage, NULL };
-
-
-static int xmpp_parser(struct axi_client *client, iks *node)
-{
+#endif
+static char show_jingle_usage[] =
+"Usage: jingle show channels\n"
[... 844 lines stripped ...]
More information about the svn-commits
mailing list