41 #include <sys/socket.h>
44 #include <netinet/in.h>
45 #include <arpa/inet.h>
46 #include <sys/signal.h>
73 #define JINGLE_CONFIG "jingle.conf"
80 .resync_threshold = -1,
165 static const char desc[] =
"Jingle Channel";
193 .description =
"Jingle Channel Driver",
238 if (!jingle && strchr(name,
'@'))
245 if (!strcasecmp(iterator->name,
"guest")) {
263 if (!strcasecmp(
"ulaw", format)) {
264 iks *payload_eg711u, *payload_pcmu;
265 payload_pcmu = iks_new(
"payload-type");
266 iks_insert_attrib(payload_pcmu,
"id",
"0");
267 iks_insert_attrib(payload_pcmu,
"name",
"PCMU");
268 payload_eg711u = iks_new(
"payload-type");
269 iks_insert_attrib(payload_eg711u,
"id",
"100");
270 iks_insert_attrib(payload_eg711u,
"name",
"EG711U");
271 iks_insert_node(dcodecs, payload_pcmu);
272 iks_insert_node(dcodecs, payload_eg711u);
274 if (!strcasecmp(
"alaw", format)) {
276 iks *payload_pcma = iks_new(
"payload-type");
277 iks_insert_attrib(payload_pcma,
"id",
"8");
278 iks_insert_attrib(payload_pcma,
"name",
"PCMA");
279 payload_eg711a = iks_new(
"payload-type");
280 iks_insert_attrib(payload_eg711a,
"id",
"101");
281 iks_insert_attrib(payload_eg711a,
"name",
"EG711A");
282 iks_insert_node(dcodecs, payload_pcma);
283 iks_insert_node(dcodecs, payload_eg711a);
285 if (!strcasecmp(
"ilbc", format)) {
286 iks *payload_ilbc = iks_new(
"payload-type");
287 iks_insert_attrib(payload_ilbc,
"id",
"97");
288 iks_insert_attrib(payload_ilbc,
"name",
"iLBC");
289 iks_insert_node(dcodecs, payload_ilbc);
291 if (!strcasecmp(
"g723", format)) {
292 iks *payload_g723 = iks_new(
"payload-type");
293 iks_insert_attrib(payload_g723,
"id",
"4");
294 iks_insert_attrib(payload_g723,
"name",
"G723");
295 iks_insert_node(dcodecs, payload_g723);
303 iks *iq, *
jingle, *dcodecs, *payload_red, *payload_audio, *payload_cn;
313 dcodecs = iks_new(
"description");
314 if (iq && jingle && dcodecs) {
317 for (x = 0; x < 64; x++) {
322 if (alreadysent & pref_codec)
325 alreadysent |= pref_codec;
327 payload_red = iks_new(
"payload-type");
328 iks_insert_attrib(payload_red,
"id",
"117");
329 iks_insert_attrib(payload_red,
"name",
"red");
330 payload_audio = iks_new(
"payload-type");
331 iks_insert_attrib(payload_audio,
"id",
"106");
332 iks_insert_attrib(payload_audio,
"name",
"audio/telephone-event");
333 payload_cn = iks_new(
"payload-type");
334 iks_insert_attrib(payload_cn,
"id",
"13");
335 iks_insert_attrib(payload_cn,
"name",
"CN");
338 iks_insert_attrib(iq,
"type",
"set");
339 iks_insert_attrib(iq,
"to", (p->
them) ? p->
them : client->
user);
343 iks_insert_attrib(jingle,
"xmlns",
JINGLE_NS);
347 iks_insert_node(iq, jingle);
348 iks_insert_node(jingle, dcodecs);
349 iks_insert_node(dcodecs, payload_red);
350 iks_insert_node(dcodecs, payload_audio);
351 iks_insert_node(dcodecs, payload_cn);
355 iks_delete(payload_red);
356 iks_delete(payload_audio);
357 iks_delete(payload_cn);
374 return IKS_FILTER_EAT;
444 iks *response = NULL, *error = NULL, *reason = NULL;
447 response = iks_new(
"iq");
449 iks_insert_attrib(response,
"type",
"result");
450 iks_insert_attrib(response,
"from", client->
connection->
jid->full);
451 iks_insert_attrib(response,
"to", iks_find_attrib(pak->x,
"from"));
452 iks_insert_attrib(response,
"id", iks_find_attrib(pak->x,
"id"));
454 error = iks_new(
"error");
456 iks_insert_attrib(error,
"type",
"cancel");
457 reason = iks_new(reasonstr);
459 iks_insert_node(error, reason);
460 iks_insert_node(response, error);
469 iks_delete(response);
480 for (tmp = client->
p; tmp; tmp = tmp->
next) {
497 iks *dtmfnode = NULL, *dtmfchild = NULL;
500 for (tmp = client->
p; tmp; tmp = tmp->
next) {
506 if(iks_find_with_attrib(pak->x,
"dtmf-method",
"method",
"rtp")) {
508 "feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'",
509 "unsupported-dtmf-method xmlns='http://www.xmpp.org/extensions/xep-0181.html#ns-errors'");
512 if ((dtmfnode = iks_find(pak->x,
"dtmf"))) {
513 if((dtmf = iks_find_attrib(dtmfnode,
"code"))) {
514 if(iks_find_with_attrib(pak->x,
"dtmf",
"action",
"button-up")) {
519 }
else if(iks_find_with_attrib(pak->x,
"dtmf",
"action",
"button-down")) {
524 }
else if(iks_find_attrib(pak->x,
"dtmf")) {
531 }
else if ((dtmfnode = iks_find_with_attrib(pak->x,
JINGLE_NODE,
"action",
"session-info"))) {
532 if((dtmfchild = iks_find(dtmfnode,
"dtmf"))) {
533 if((dtmf = iks_find_attrib(dtmfchild,
"code"))) {
534 if(iks_find_with_attrib(dtmfnode,
"dtmf",
"action",
"button-up")) {
539 }
else if(iks_find_with_attrib(dtmfnode,
"dtmf",
"action",
"button-down")) {
564 for (tmp = client->
p; tmp; tmp = tmp->
next) {
584 struct sockaddr_in sin = { 0, };
589 struct in_addr externaddr;
590 iks *iq, *
jingle, *content, *transport, *candidate;
591 char component[16], foundation[16], generation[16], network[16],
pass[16], port[7], priority[16],
user[16];
596 content = iks_new(
"content");
597 transport = iks_new(
"transport");
598 candidate = iks_new(
"candidate");
599 if (!iq || !jingle || !content || !transport || !candidate) {
605 if (!ours1 || !ours2)
608 iks_insert_node(iq, jingle);
609 iks_insert_node(jingle, content);
610 iks_insert_node(content, transport);
611 iks_insert_node(transport, candidate);
613 for (; p; p = p->
next) {
614 if (!strcasecmp(p->
sid, sid))
635 ours1->
port = ntohs(sin.sin_port);
638 snprintf(pass,
sizeof(pass),
"%08lx%08lx", (
unsigned long)
ast_random(), (
unsigned long)
ast_random());
641 snprintf(user,
sizeof(user),
"%08lx%08lx", (
unsigned long)
ast_random(), (
unsigned long)
ast_random());
650 ours2->component = 1;
652 ours2->generation = 0;
655 ours2->port = ntohs(sin.sin_port);
656 ours2->priority = 1678246397;
658 snprintf(pass,
sizeof(pass),
"%08lx%08lx", (
unsigned long)
ast_random(), (
unsigned long)
ast_random());
662 snprintf(user,
sizeof(user),
"%08lx%08lx", (
unsigned long)
ast_random(), (
unsigned long)
ast_random());
670 snprintf(component,
sizeof(component),
"%u", tmp->
component);
671 snprintf(foundation,
sizeof(foundation),
"%u", tmp->
foundation);
672 snprintf(generation,
sizeof(generation),
"%u", tmp->
generation);
673 snprintf(network,
sizeof(network),
"%u", tmp->
network);
674 snprintf(port,
sizeof(port),
"%u", tmp->
port);
675 snprintf(priority,
sizeof(priority),
"%u", tmp->
priority);
677 iks_insert_attrib(iq,
"from", c->
jid->full);
678 iks_insert_attrib(iq,
"to", from);
679 iks_insert_attrib(iq,
"type",
"set");
680 iks_insert_attrib(iq,
"id", c->
mid);
684 iks_insert_attrib(jingle,
"initiator", (p->
initiator) ? c->
jid->full : from);
685 iks_insert_attrib(jingle,
"xmlns",
JINGLE_NS);
686 iks_insert_attrib(content,
"creator", p->
initiator ?
"initiator" :
"responder");
687 iks_insert_attrib(content,
"name",
"asterisk-audio-content");
689 iks_insert_attrib(candidate,
"component", component);
690 iks_insert_attrib(candidate,
"foundation", foundation);
691 iks_insert_attrib(candidate,
"generation", generation);
692 iks_insert_attrib(candidate,
"ip", tmp->
ip);
693 iks_insert_attrib(candidate,
"network", network);
694 iks_insert_attrib(candidate,
"port", port);
695 iks_insert_attrib(candidate,
"priority", priority);
698 iks_insert_attrib(candidate,
"protocol",
"udp");
701 iks_insert_attrib(candidate,
"protocol",
"ssltcp");
704 iks_insert_attrib(candidate,
"pwd", tmp->
password);
707 iks_insert_attrib(candidate,
"type",
"host");
710 iks_insert_attrib(candidate,
"type",
"prflx");
713 iks_insert_attrib(candidate,
"type",
"relay");
716 iks_insert_attrib(candidate,
"type",
"srflx");
719 iks_insert_attrib(candidate,
"ufrag", tmp->
ufrag);
733 iks_delete(transport);
734 iks_delete(candidate);
748 if (!sid && !strchr(from,
'/')) {
749 if (!strcasecmp(client->
name,
"guest")) {
754 }
else if (client->
buddy)
760 resources = resources->
next;
763 snprintf(idroster,
sizeof(idroster),
"%s/%s", from, resources->
resource);
800 tmp->
next = client->
p;
818 tmp =
ast_channel_alloc(1, state, i->
cid_num, i->
cid_name,
"",
"",
"", linkedid, 0,
"Jingle/%s-%04lx", str, (
unsigned long)(
ast_random() & 0xffff));
901 jingle = iks_new(
"jingle");
904 iks_insert_attrib(iq,
"type",
"set");
905 iks_insert_attrib(iq,
"from", client->
connection->
jid->full);
906 iks_insert_attrib(iq,
"to", p->
them);
910 iks_insert_attrib(jingle,
"action", action);
913 iks_insert_attrib(jingle,
"xmlns",
JINGLE_NS);
915 iks_insert_node(iq, jingle);
933 candidate = candidate->
next;
971 iks *codec, *content, *description;
975 from = iks_find_attrib(pak->x,
"to");
988 if (!strcasecmp(client->
name,
"guest")){
996 ast_log(
LOG_ERROR,
"No XMPP client to talk to, us (partial JID) : %s\n", from);
1013 if (iks_find_attrib(pak->query,
JINGLE_SID)) {
1019 content = iks_child(iks_child(pak->x));
1024 codec = iks_child(iks_child(content));
1030 codec = iks_next(codec);
1040 codec = iks_child(iks_child(content));
1046 codec = iks_next(codec);
1050 content = iks_next(content);
1070 iks_find_attrib(pak->x,
"from"));
1083 struct sockaddr_in sin;
1094 sin.sin_family = AF_INET;
1095 memcpy(&sin.sin_addr, hp->h_addr,
sizeof(sin.sin_addr));
1096 sin.sin_port = htons(tmp->
port);
1111 iks *traversenodes = NULL, *receipt = NULL;
1113 for (tmp = client->
p; tmp; tmp = tmp->
next) {
1123 traversenodes = pak->query;
1124 while(traversenodes) {
1125 if(!strcasecmp(iks_name(traversenodes),
"jingle")) {
1126 traversenodes = iks_child(traversenodes);
1129 if(!strcasecmp(iks_name(traversenodes),
"content")) {
1130 traversenodes = iks_child(traversenodes);
1133 if(!strcasecmp(iks_name(traversenodes),
"transport")) {
1134 traversenodes = iks_child(traversenodes);
1138 if(!strcasecmp(iks_name(traversenodes),
"candidate")) {
1139 newcandidate =
ast_calloc(1,
sizeof(*newcandidate));
1142 ast_copy_string(newcandidate->
ip, iks_find_attrib(traversenodes,
"ip"),
sizeof(newcandidate->
ip));
1143 newcandidate->
port = atoi(iks_find_attrib(traversenodes,
"port"));
1145 if (!strcasecmp(iks_find_attrib(traversenodes,
"protocol"),
"udp"))
1147 else if (!strcasecmp(iks_find_attrib(traversenodes,
"protocol"),
"ssltcp"))
1150 if (!strcasecmp(iks_find_attrib(traversenodes,
"type"),
"host"))
1152 else if (!strcasecmp(iks_find_attrib(traversenodes,
"type"),
"prflx"))
1154 else if (!strcasecmp(iks_find_attrib(traversenodes,
"type"),
"relay"))
1156 else if (!strcasecmp(iks_find_attrib(traversenodes,
"type"),
"srflx"))
1159 newcandidate->
network = atoi(iks_find_attrib(traversenodes,
"network"));
1160 newcandidate->
generation = atoi(iks_find_attrib(traversenodes,
"generation"));
1161 newcandidate->
next = NULL;
1167 newcandidate = NULL;
1169 traversenodes = iks_next(traversenodes);
1172 receipt = iks_new(
"iq");
1173 iks_insert_attrib(receipt,
"type",
"result");
1174 iks_insert_attrib(receipt,
"from", c->
jid->full);
1175 iks_insert_attrib(receipt,
"to", iks_find_attrib(pak->x,
"from"));
1176 iks_insert_attrib(receipt,
"id", iks_find_attrib(pak->x,
"id"));
1179 iks_delete(receipt);
1234 "Asked to transmit frame type %s, while native formats is %s (read/write = %s/%s)\n",
1275 if ((p->
owner != oldchan)) {
1279 if (p->
owner == oldchan)
1289 switch (condition) {
1329 char buffer[2] = {digit,
'\0'};
1331 jingle = iks_new(
"jingle");
1332 dtmf = iks_new(
"dtmf");
1333 if(!iq || !jingle || !dtmf) {
1341 iks_insert_attrib(iq,
"type",
"set");
1342 iks_insert_attrib(iq,
"to", p->
them);
1343 iks_insert_attrib(iq,
"from", client->
connection->
jid->full);
1346 iks_insert_attrib(jingle,
"xmlns",
JINGLE_NS);
1347 iks_insert_attrib(jingle,
"action",
"session-info");
1349 iks_insert_attrib(jingle,
"sid", p->
sid);
1351 iks_insert_attrib(dtmf,
"code", buffer);
1352 iks_insert_node(iq, jingle);
1353 iks_insert_node(jingle, dtmf);
1357 iks_insert_attrib(dtmf,
"action",
"button-down");
1359 iks_insert_attrib(dtmf,
"action",
"button-up");
1388 struct jingle *aux = NULL;
1390 iks *iq, *
jingle, *content, *description, *transport;
1391 iks *payload_eg711u, *payload_pcmu;
1397 content = iks_new(
"content");
1398 description = iks_new(
"description");
1399 transport = iks_new(
"transport");
1400 payload_pcmu = iks_new(
"payload-type");
1401 payload_eg711u = iks_new(
"payload-type");
1405 iks_insert_attrib(iq,
"type",
"set");
1406 iks_insert_attrib(iq,
"to", p->
them);
1407 iks_insert_attrib(iq,
"from", client->
jid->full);
1408 iks_insert_attrib(iq,
"id", client->
mid);
1412 iks_insert_attrib(jingle,
"initiator", client->
jid->full);
1413 iks_insert_attrib(jingle,
"xmlns",
JINGLE_NS);
1416 iks_insert_attrib(content,
"creator",
"initiator");
1418 iks_insert_attrib(content,
"profile",
"RTP/AVP");
1421 iks_insert_attrib(payload_pcmu,
"id",
"0");
1422 iks_insert_attrib(payload_pcmu,
"name",
"PCMU");
1423 iks_insert_attrib(payload_eg711u,
"id",
"100");
1424 iks_insert_attrib(payload_eg711u,
"name",
"EG711U");
1425 iks_insert_node(description, payload_pcmu);
1426 iks_insert_node(description, payload_eg711u);
1427 iks_insert_node(content, description);
1428 iks_insert_node(content, transport);
1429 iks_insert_node(jingle, content);
1430 iks_insert_node(iq, jingle);
1436 iks_delete(content);
1437 iks_delete(description);
1438 iks_delete(transport);
1439 iks_delete(payload_eg711u);
1440 iks_delete(payload_pcmu);
1478 IKS_RULE_ID, p->
ring, IKS_RULE_DONE);
1511 struct jingle *client = NULL;
1512 char *sender = NULL, *to = NULL, *s = NULL;
1517 sender =
strsep(&s,
"/");
1518 if (sender && (sender[0] !=
'\0')) {
1522 ast_log(
LOG_ERROR,
"Bad arguments in Jingle Dialstring: %s\n", (
char*) data);
1532 if (!strcasecmp(client->
name,
"guest")){
1540 ast_log(
LOG_ERROR,
"No XMPP client to talk to, us (partial JID) : %s\n", sender);
1557 #define FORMAT "%-30.30s %-30.30s %-15.15s %-5.5s %-5.5s \n"
1563 char *resource = NULL;
1567 e->
command =
"jingle show channels";
1569 "Usage: jingle show channels\n"
1570 " Shows current state of the Jingle channels.\n";
1580 ast_cli(a->
fd,
FORMAT,
"Channel",
"Jabber ID",
"Resource",
"Read",
"Write");
1588 resource = strchr(them,
'/');
1613 ast_cli(a->
fd,
"%d active jingle channel%s\n", numchans, (numchans != 1) ?
"s" :
"");
1625 "Usage: jingle reload\n"
1626 " Reload jingle channel driver.\n";
1644 ast_debug(3,
"About to add candidate!\n");
1653 }
else if (iks_find_with_attrib(pak->x,
JINGLE_NODE,
"action",
"reject")) {
1657 return IKS_FILTER_EAT;
1726 if (!strcasecmp(var->
name,
"username"))
1728 else if (!strcasecmp(var->
name,
"disallow"))
1730 else if (!strcasecmp(var->
name,
"allow"))
1732 else if (!strcasecmp(var->
name,
"context"))
1735 else if (!strcasecmp(var->
name,
"candidate")) {
1736 candidate = jingle_create_candidate(var->
value);
1738 candidate->
next = member->ourcandidates;
1739 member->ourcandidates = candidate;
1743 else if (!strcasecmp(var->
name,
"connection")) {
1747 IKS_RULE_TYPE, IKS_PAK_IQ,
1748 IKS_RULE_FROM_PARTIAL, member->
user,
1795 if (!strcasecmp(var->
name,
"allowguest"))
1798 else if (!strcasecmp(var->
name,
"disallow"))
1800 else if (!strcasecmp(var->
name,
"allow"))
1802 else if (!strcasecmp(var->
name,
"context"))
1804 else if (!strcasecmp(var->
name,
"externip"))
1806 else if (!strcasecmp(var->
name,
"bindaddr")) {
1810 memcpy(&bindaddr.sin_addr, hp->h_addr,
sizeof(bindaddr.sin_addr));
1825 if (strcasecmp(cat,
"general")) {
1830 if (!strcasecmp(cat,
"guest")) {
1837 if (!strcasecmp(var->
name,
"disallow"))
1840 else if (!strcasecmp(var->
name,
"allow"))
1843 else if (!strcasecmp(var->
name,
"context"))
1846 else if (!strcasecmp(var->
name,
"parkinglot"))
1871 iks_filter_add_rule(iterator->f,
jingle_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS,
JINGLE_NS, IKS_RULE_DONE);
1902 free(jabber_loaded);
1903 if (!jabber_loaded) {
1906 free(jabber_loaded);
1907 if (!jabber_loaded) {
1929 bindaddr.sin_family = AF_INET;
1966 privates = iterator->p;
1968 if (privates->
owner)
1970 privates = privates->
next;
Jingle definitions for chan_jingle.
void ast_rtp_codecs_packetization_set(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, struct ast_codec_pref *prefs)
Set codec packetization preferences.
static char musicclass[MAX_MUSICCLASS]
static struct ast_channel_tech jingle_tech
PBX interface structure for channel registration.
static int unload_module(void)
Unload the jingle channel from Asterisk.
int ast_queue_hangup(struct ast_channel *chan)
Queue a hangup frame.
unsigned long long ast_group_t
union ast_frame_subclass subclass
enum jingle_connect_type type
int ast_hangup(struct ast_channel *chan)
Hang up a channel.
static char accountcode[AST_MAX_ACCOUNT_CODE]
int presentation
Q.931 encoded presentation-indicator encoded field.
Main Channel structure associated with a channel.
#define AST_CLI_DEFINE(fn, txt,...)
char * str
Subscriber phone number (Malloced)
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
static int jingle_answer(struct ast_channel *ast)
static struct jingle_pvt * jingle_alloc(struct jingle *client, const char *from, const char *sid)
static int jingle_ringing_ack(void *data, ikspak *pak)
void ast_aji_buddy_destroy(struct aji_buddy *obj)
const char * ast_variable_retrieve(const struct ast_config *config, const char *category, const char *variable)
Gets a variable.
char * str
Subscriber phone number (Malloced)
int ast_queue_control(struct ast_channel *chan, enum ast_control_frame_type control)
Queue a control frame with payload.
struct ast_frame ast_null_frame
struct ast_party_caller caller
Channel Caller ID information.
struct jingle_candidate * next
char * strsep(char **str, const char *delims)
int presentation
Q.931 presentation-indicator and screening-indicator encoded fields.
static struct in_addr __ourip
CallerID (and other GR30) management and generation Includes code and algorithms from the Zapata libr...
static int jingle_transmit_invite(struct jingle_pvt *p)
char musicclass[MAX_MUSICCLASS]
int ast_aji_send(struct aji_client *client, iks *x)
Wraps raw sending.
int ast_find_ourip(struct ast_sockaddr *ourip, const struct ast_sockaddr *bindaddr, int family)
Find our IP address.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
static enum ast_rtp_glue_result jingle_get_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance **instance)
#define AST_CAUSE_SWITCH_CONGESTION
static int jingle_add_candidate(struct jingle *client, ikspak *pak)
static struct ast_jb_conf global_jbconf
struct ast_party_name name
Subscriber name.
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
char context[AST_MAX_CONTEXT]
static struct ast_frame * jingle_read(struct ast_channel *ast)
static void jingle_free_candidates(struct jingle_candidate *candidate)
struct ast_rtp_codecs * ast_rtp_instance_get_codecs(struct ast_rtp_instance *instance)
Get the codecs structure of an RTP instance.
descriptor for a cli entry.
enum ast_pbx_result ast_pbx_start(struct ast_channel *c)
Create a new thread and start the PBX.
struct ast_variable * ast_variable_browse(const struct ast_config *config, const char *category)
Goes through variables.
static int jingle_digit_begin(struct ast_channel *ast, char digit)
int ast_jb_read_conf(struct ast_jb_conf *conf, const char *varname, const char *value)
Sets jitterbuffer configuration property.
void ast_verbose(const char *fmt,...)
char parkinglot[AST_MAX_CONTEXT]
struct jingle_candidate * theircandidates
Structure for variables, used for configurations and for channel variables.
char audio_content_name[100]
static int jingle_set_rtp_peer(struct ast_channel *chan, struct ast_rtp_instance *rtp, struct ast_rtp_instance *vrtp, struct ast_rtp_instance *tpeer, format_t codecs, int nat_active)
#define AST_MAX_ACCOUNT_CODE
int ast_rtp_instance_write(struct ast_rtp_instance *instance, struct ast_frame *frame)
Send a frame out over RTP.
#define ast_rtp_glue_register(glue)
format_t ast_codec_pref_index(struct ast_codec_pref *pref, int index)
Codec located at a particular place in the preference index.
static int jingle_update_stun(struct jingle *client, struct jingle_pvt *p)
static int jingle_parser(void *data, ikspak *pak)
static int jingle_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
Configuration File Parser.
uint32_t ast_sockaddr_ipv4(const struct ast_sockaddr *addr)
Get an IPv4 address of an ast_sockaddr.
static int jingle_call(struct ast_channel *ast, char *dest, int timeout)
Initiate new call, part of PBX interface dest is the dial string.
format_t ast_best_codec(format_t fmts)
Pick the best audio codec.
static int jingle_write(struct ast_channel *ast, struct ast_frame *f)
Send frame to media channel (rtp)
#define ASTOBJ_WRLOCK(object)
Lock an ASTOBJ for writing.
#define ast_mutex_lock(a)
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
static int jingle_load_config(void)
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
static int load_module(void)
Load module into PBX, register channel.
I/O Management (derived from Cheops-NG)
Common implementation-independent jitterbuffer stuff.
void ast_cli(int fd, const char *fmt,...)
static int jingle_create_candidates(struct jingle *client, struct jingle_pvt *p, char *sid, char *from)
#define JINGLE_VIDEO_RTP_NS
const ast_string_field linkedid
AJI - The Asterisk Jabber Interface.
enum ast_channel_adsicpe adsicpe
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
static struct jingle_container jingle_list
Socket address structure.
void ast_config_destroy(struct ast_config *config)
Destroys a config.
struct ast_channel * owner
struct ast_codec_pref prefs
#define JINGLE_AUDIO_RTP_NS
struct ast_channel * ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const char *linkedid, const int amaflag, const char *name_fmt,...)
int ast_aji_send_chat(struct aji_client *client, const char *address, const char *message)
sends messages.
#define JINGLE_ICE_UDP_NS
String fields in structures.
static const char channel_type[]
#define ASTOBJ_COMPONENTS(type)
Add ASTOBJ components to a struct (with locking support).
void ast_rtp_instance_stun_request(struct ast_rtp_instance *instance, struct ast_sockaddr *suggestion, const char *username)
Request that the underlying RTP engine send a STUN BIND request.
#define ASTOBJ_CONTAINER_INIT(container)
Initialize a container.
struct ast_party_id id
Caller party ID.
static int jingle_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen)
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of "format" is ...
char resource[AJI_MAX_RESJIDLEN]
static void jingle_member_destroy(struct jingle *obj)
int ast_set_read_format(struct ast_channel *chan, format_t format)
Sets read format on channel chan Set read format for channel to whichever component of "format" is be...
#define ast_debug(level,...)
Log a DEBUG message.
char language[MAX_LANGUAGE]
struct ast_party_id ani
Automatic Number Identification (ANI)
General Asterisk PBX channel definitions.
struct ast_party_dialed::@155 number
Dialed/Called number.
struct aji_buddy_container buddies
#define ast_sockaddr_from_sin(addr, sin)
Converts a struct sockaddr_in to a struct ast_sockaddr.
static int jingle_response(struct jingle *client, ikspak *pak, const char *reasonstr, const char *reasonstr2)
ASTOBJ_CONTAINER_COMPONENTS(struct jingle)
#define ast_config_load(filename, flags)
Load a config file.
char * ast_module_helper(const char *line, const char *word, int pos, int state, int rpos, int needsreload)
Match modules names for the Asterisk cli.
static format_t jingle_get_codec(struct ast_channel *chan)
static force_inline int attribute_pure ast_strlen_zero(const char *s)
struct sla_ringing_trunk * last
Access Control of various sorts.
Global IO variables are now in a struct in order to be made threadsafe.
Scheduler Routines (derived from cheops)
char * ast_category_browse(struct ast_config *config, const char *prev)
Goes through categories.
#define ao2_ref(o, delta)
int ast_softhangup(struct ast_channel *chan, int reason)
Softly hangup up a channel.
long int ast_random(void)
#define ASTOBJ_INIT(object)
Initialize an object.
static char language[MAX_LANGUAGE]
char them[AJI_MAX_JIDLEN]
static int jingle_hangup_farend(struct jingle *client, ikspak *pak)
static int jingle_digit_end(struct ast_channel *ast, char digit, unsigned int duration)
enum jingle_protocol protocol
static int jingle_accept_call(struct jingle *client, struct jingle_pvt *p)
struct aji_resource * next
static int jingle_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen)
int ast_rtp_codecs_payloads_set_rtpmap_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload, char *mimetype, char *mimesubtype, enum ast_rtp_options options)
Record payload information that was seen in an a=rtpmap: SDP line.
static struct ast_frame * jingle_rtp_read(struct ast_channel *ast, struct jingle_pvt *p)
Structure to describe a channel "technology", ie a channel driver See for examples: ...
Core PBX routines and definitions.
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
char video_content_name[100]
static struct sched_context * sched
#define ASTOBJ_UNREF(object, destructor)
Decrement the reference count on an object.
struct ast_rtp_instance * vrtp
struct ast_party_dialed dialed
Dialed/Called information.
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
#define ast_strdupa(s)
duplicate a string in memory from the stack
char * ast_getformatname(format_t format)
Get the name of a format.
#define ASTOBJ_CONTAINER_DESTROY(container)
Destroy a container.
#define ASTOBJ_CONTAINER_DESTROYALL(container, destructor)
Empty a container.
A set of macros implementing objects and containers. Macros are used for maximum performance, to support multiple inheritance, and to be easily integrated into existing structures without additional malloc calls, etc.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
static void add_codec_to_answer(const struct jingle_pvt *p, int codec, iks *dcodecs)
static struct ast_rtp_glue jingle_rtp_glue
static char * jingle_do_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command "jingle reload".
#define ASTOBJ_CONTAINER_LINK(container, newobj)
Add an object to a container.
static int reload(void)
Reload module.
static int jingle_create_member(char *label, struct ast_variable *var, int allowguest, struct ast_codec_pref prefs, char *context, struct jingle *member)
static struct ast_codec_pref prefs
enum ast_channel_state _state
const ast_string_field name
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static struct io_context * io
format_t ast_codec_choose(struct ast_codec_pref *pref, format_t formats, int find_best)
Select the best audio format according to preference list from supplied options. If "find_best" is no...
#define ASTOBJ_CONTAINER_TRAVERSE(container, continue, eval)
Iterate through the objects in a container.
static struct ast_jb_conf default_jbconf
static int jingle_handle_dtmf(struct jingle *client, ikspak *pak)
char accountcode[AST_MAX_ACCOUNT_CODE]
struct aji_client * ast_aji_get_client(const char *name)
grab a aji_client structure by label name or JID. Bumps the refcount. (without the resource string) ...
#define AST_FORMAT_VIDEO_MASK
struct ast_codec_pref prefs
const char * ast_inet_ntoa(struct in_addr ia)
thread-safe replacement for inet_ntoa().
#define ASTOBJ_UNLOCK(object)
Unlock a locked object.
#define ASTOBJ_CONTAINER_FIND(container, namestr)
Find an object in a container.
#define AST_FORMAT_AUDIO_MASK
int ast_rtp_instance_fd(struct ast_rtp_instance *instance, int rtcp)
Get the file descriptor for an RTP session (or RTCP)
static int jingle_action(struct jingle *client, struct jingle_pvt *p, const char *action)
struct ast_rtp_instance * ast_rtp_instance_new(const char *engine_name, struct sched_context *sched, const struct ast_sockaddr *sa, void *data)
Create a new RTP instance.
unsigned int flags
Combination of the AST_JB_ENABLED, AST_JB_FORCED and AST_JB_LOG flags.
static format_t global_capability
structure to hold users read from users.conf
void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address)
Get the local address that we are expecting RTP on.
Structure used to handle boolean flags.
static struct aji_client_container clients
int ast_rtp_instance_destroy(struct ast_rtp_instance *instance)
Destroy an RTP instance.
void ast_channel_set_fd(struct ast_channel *chan, int which, int fd)
void ast_jb_configure(struct ast_channel *chan, const struct ast_jb_conf *conf)
Configures a jitterbuffer on a channel.
static int jingle_hangup(struct ast_channel *ast)
Hangup a call through the jingle proxy channel.
struct ast_rtp_instance * rtp
static struct sockaddr_in bindaddr
void ast_aji_client_destroy(struct aji_client *obj)
struct hostent * ast_gethostbyname(const char *host, struct ast_hostent *hp)
Thread-safe gethostbyname function to use in Asterisk.
struct sched_context * sched_context_create(void)
New schedule context.
Channels have this property if they can create jitter; i.e. most VoIP channels.
static int jingle_is_answered(struct jingle *client, ikspak *pak)
Standard Command Line Interface.
#define ASTOBJ_RDLOCK(object)
Lock an ASTOBJ for reading.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static struct jingle * find_jingle(char *name, char *connection)
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
static ast_mutex_t jinglelock
int ast_setstate(struct ast_channel *chan, enum ast_channel_state)
Change the state of a channel.
int ast_rtp_glue_unregister(struct ast_rtp_glue *glue)
Unregister RTP glue.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
struct jingle_candidate * ourcandidates
static int jingle_sendtext(struct ast_channel *ast, const char *text)
char * ast_getformatname_multiple(char *buf, size_t size, format_t format)
Get the names of a set of formats.
Data structure associated with a single frame of data.
#define ASTOBJ_CONTAINER_FIND_FULL(container, data, field, hashfunc, hashoffset, comparefunc)
Find an object in a container.
Internal Asterisk hangup causes.
static struct ast_channel * jingle_request(const char *type, format_t format, const struct ast_channel *requestor, void *data, int *cause)
Part of PBX interface.
static struct ast_cli_entry jingle_cli[]
struct aji_client * connection
Channels have this property if they can accept input with jitter; i.e. most VoIP channels.
static int jingle_newcall(struct jingle *client, ikspak *pak)
#define ast_sockaddr_to_sin(addr, sin)
Converts a struct ast_sockaddr to a struct sockaddr_in.
enum ast_frame_type frametype
static void jingle_free_pvt(struct jingle *client, struct jingle_pvt *p)
struct ast_variable * next
#define ast_mutex_init(pmutex)
#define CONFIG_STATUS_FILEINVALID
static char context[AST_MAX_CONTEXT]
static struct ast_channel * jingle_new(struct jingle *client, struct jingle_pvt *i, int state, const char *title, const char *linkedid)
Start new jingle channel.
#define ASTERISK_GPL_KEY
The text the key() function should return.
Pluggable RTP Architecture.
#define ASTOBJ_REF(object)
Increment an object reference count.
Asterisk module definitions.
static struct hostent * hp
static snd_pcm_format_t format
union ast_frame::@172 data
struct ast_channel_tech * tech
static int jingle_digit(struct ast_channel *ast, char digit, unsigned int duration)
unsigned char valid
TRUE if the number information is valid/present.
struct aji_resource * resources
General jitterbuffer configuration.
void ast_rtp_codecs_payloads_set_m_type(struct ast_rtp_codecs *codecs, struct ast_rtp_instance *instance, int payload)
Record payload information that was seen in an m= SDP line.
int inet_aton(const char *cp, struct in_addr *pin)
char exten[AST_MAX_EXTENSION]
#define AST_MUTEX_DEFINE_STATIC(mutex)
Structure for mutex and tracking information.
static char * jingle_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
CLI command "jingle show channels".
void ast_aji_increment_mid(char *mid)
increments the mid field for messages and other events.
int ast_parse_allow_disallow(struct ast_codec_pref *pref, format_t *mask, const char *list, int allowing)
Parse an "allow" or "deny" line in a channel or device configuration and update the capabilities mask...
struct ast_frame * ast_rtp_instance_read(struct ast_rtp_instance *instance, int rtcp)
Receive a frame over RTP.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
#define ast_mutex_unlock(a)
enum ast_bridge_result ast_rtp_instance_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms)
Bridge two channels that use RTP instances.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
struct ast_party_number number
Subscriber phone number.
struct aji_client_container * ast_aji_get_clients(void)
struct io_context * io_context_create(void)
Creates a context Create a context for I/O operations Basically mallocs an IO structure and sets up s...