update dingaling
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5005 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
2077f45e96
commit
586ae93cad
|
@ -379,7 +379,7 @@ char *
|
|||
iks_name (iks *x)
|
||||
{
|
||||
if (x) {
|
||||
if (IKS_TAG == x->type)
|
||||
if (IKS_TAG == x->type)
|
||||
return IKS_TAG_NAME (x);
|
||||
else
|
||||
return IKS_ATTRIB_NAME (x);
|
||||
|
|
|
@ -110,8 +110,36 @@ io_recv (void *socket, char *buffer, size_t buf_len, int timeout)
|
|||
tv.tv_sec = timeout;
|
||||
if (timeout != -1) tvptr = &tv; else tvptr = NULL;
|
||||
if (select (sock + 1, &fds, NULL, NULL, tvptr) > 0) {
|
||||
memset(buffer, 0, buf_len);
|
||||
len = recv (sock, buffer, buf_len, 0);
|
||||
if (len > 0) {
|
||||
char *p, *e = NULL, *t = NULL;
|
||||
for (p = buffer; p && *p; p++) {
|
||||
|
||||
if (*p == '>') {
|
||||
e = p;
|
||||
t = p+1;
|
||||
if (*t == '<') {
|
||||
continue;
|
||||
}
|
||||
while(t && *t) {
|
||||
if (*t != ' ' && *t != '<') {
|
||||
t = e = NULL;
|
||||
break;
|
||||
}
|
||||
if (*t == '<') {
|
||||
p = t;
|
||||
*(p-1) = '>';
|
||||
*e = ' ';
|
||||
e = NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
t++;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return len;
|
||||
} else if (len <= 0) {
|
||||
return -1;
|
||||
|
|
|
@ -175,6 +175,7 @@ struct ldl_feature {
|
|||
typedef struct ldl_feature ldl_feature_t;
|
||||
|
||||
#define FEATURE_DISCO "http://jabber.org/protocol/disco"
|
||||
#define FEATURE_DISCO_INFO "http://jabber.org/protocol/disco#info"
|
||||
#define FEATURE_VERSION "jabber:iq:version"
|
||||
#define FEATURE_VCARD "vcard-temp"
|
||||
#define FEATURE_VOICE "http://www.google.com/xmpp/protocol/voice/v1"
|
||||
|
@ -182,6 +183,7 @@ typedef struct ldl_feature ldl_feature_t;
|
|||
|
||||
static ldl_feature_t FEATURES[] = {
|
||||
{ FEATURE_DISCO, on_disco_default },
|
||||
{ FEATURE_DISCO_INFO, on_disco_default },
|
||||
{ FEATURE_VERSION, on_disco_default },
|
||||
{ FEATURE_VCARD, on_vcard},
|
||||
{ FEATURE_VOICE, on_disco_default },
|
||||
|
@ -414,11 +416,11 @@ static ldl_status parse_session_code(ldl_handle_t *handle, char *id, char *from,
|
|||
dl_signal = LDL_SIGNAL_TRANSPORT_ACCEPT;
|
||||
} else if (!strcasecmp(type, "reject")) {
|
||||
dl_signal = LDL_SIGNAL_REJECT;
|
||||
} else if (!strcasecmp(type, "transport-info")) {
|
||||
} else if (!strcasecmp(type, "transport-info") || !strcasecmp(type, "candidates")) {
|
||||
char *tid = iks_find_attrib(xml, "id");
|
||||
dl_signal = LDL_SIGNAL_CANDIDATES;
|
||||
tag = iks_child (xml);
|
||||
|
||||
id = type;
|
||||
if (tag && !strcasecmp(iks_name(tag), "transport")) {
|
||||
tag = iks_child(tag);
|
||||
}
|
||||
|
@ -560,7 +562,7 @@ static int on_disco_default(void *user_data, ikspak *pak)
|
|||
} else if (pak->subtype == IKS_TYPE_GET) {
|
||||
if ((iq = iks_new("iq"))) {
|
||||
int all = 0;
|
||||
|
||||
|
||||
iks_insert_attrib(iq, "from", handle->login);
|
||||
iks_insert_attrib(iq, "to", pak->from->full);
|
||||
iks_insert_attrib(iq, "id", pak->id);
|
||||
|
@ -578,15 +580,32 @@ static int on_disco_default(void *user_data, ikspak *pak)
|
|||
if (!(tag = iks_insert (query, "identity"))) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!strcasecmp(ns, FEATURE_DISCO) && !node) {
|
||||
all++;
|
||||
}
|
||||
|
||||
iks_insert_attrib(tag, "category", "gateway");
|
||||
iks_insert_attrib(tag, "type", "voice");
|
||||
//iks_insert_attrib(tag, "type", "voice");
|
||||
iks_insert_attrib(tag, "name", "LibDingaLing");
|
||||
|
||||
if (!strcasecmp(ns, FEATURE_DISCO_INFO)) {
|
||||
if (!node) {
|
||||
all++;
|
||||
} else {
|
||||
char *p;
|
||||
|
||||
if ((p = strstr(node, "caps#"))) {
|
||||
char *what = p + 5;
|
||||
|
||||
if (!strcasecmp(what, "voice-v1")) {
|
||||
if (!(tag = iks_insert (query, "feature"))) {
|
||||
goto fail;
|
||||
}
|
||||
iks_insert_attrib(tag, "var", FEATURE_VOICE);
|
||||
goto done;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (x = 0; FEATURES[x].name; x++) {
|
||||
if (all || !ns || !strcasecmp(ns, FEATURES[x].name)) {
|
||||
if (!(tag = iks_insert (query, "feature"))) {
|
||||
|
@ -595,6 +614,9 @@ static int on_disco_default(void *user_data, ikspak *pak)
|
|||
iks_insert_attrib(tag, "var", FEATURES[x].name);
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
apr_queue_push(handle->queue, iq);
|
||||
iq = NULL;
|
||||
send = 1;
|
||||
|
@ -625,7 +647,7 @@ static int on_presence(void *user_data, ikspak *pak)
|
|||
char *resource;
|
||||
struct ldl_buffer *buffer;
|
||||
ldl_signal_t dl_signal = LDL_SIGNAL_PRESENCE_IN;
|
||||
|
||||
|
||||
|
||||
|
||||
if (type && *type) {
|
||||
|
@ -661,7 +683,7 @@ static int on_presence(void *user_data, ikspak *pak)
|
|||
}
|
||||
}
|
||||
|
||||
if (resource && strstr(resource, "talk") && (buffer = apr_hash_get(handle->probe_hash, id, APR_HASH_KEY_STRING))) {
|
||||
if (resource && (strstr(resource, "talk") || strstr(resource, "telepathy")) && (buffer = apr_hash_get(handle->probe_hash, id, APR_HASH_KEY_STRING))) {
|
||||
apr_cpystrn(buffer->buf, from, buffer->len);
|
||||
fflush(stderr);
|
||||
buffer->hit = 1;
|
||||
|
@ -1857,7 +1879,7 @@ unsigned int ldl_session_candidates(ldl_session_t *session,
|
|||
iq = NULL;
|
||||
sess = NULL;
|
||||
id = 0;
|
||||
|
||||
|
||||
new_session_iq(session, &iq, &sess, &id, "transport-info");
|
||||
tag = iks_insert(sess, "transport");
|
||||
iks_insert_attrib(tag, "xmlns", "http://www.google.com/transport/p2p");
|
||||
|
|
|
@ -1700,12 +1700,20 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
|
|||
user = ldl_handle_get_login(mdl_profile->handle);
|
||||
} else {
|
||||
if (!user) {
|
||||
if (strchr(outbound_profile->caller_id_number, '@')) {
|
||||
snprintf(ubuf, sizeof(ubuf), "%s/talk", outbound_profile->caller_id_number);
|
||||
char *id_num;
|
||||
|
||||
if (!(id_num = outbound_profile->caller_id_number)) {
|
||||
if (!(id_num = outbound_profile->caller_id_name)) {
|
||||
id_num = "nobody";
|
||||
}
|
||||
}
|
||||
|
||||
if (strchr(id_num, '@')) {
|
||||
snprintf(ubuf, sizeof(ubuf), "%s/talk", id_num);
|
||||
user = ubuf;
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Invalid User!\n");
|
||||
terminate_session(new_session, __LINE__, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
|
||||
snprintf(ubuf, sizeof(ubuf), "%s@%s/talk", id_num, profile_name);
|
||||
user = ubuf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2871,14 +2879,27 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
|||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "candidates %s:%d\n", candidates[x].address, candidates[x].port);
|
||||
|
||||
if (!strcasecmp(candidates[x].protocol, "udp") && (!strcasecmp(candidates[x].type, "local") || !strcasecmp(candidates[x].type, "stun")) && ((profile->lanaddr && lanaddr) || (strncasecmp(candidates[x].address, "10.", 3) && strncasecmp(candidates[x].address, "192.168.", 8) && strncasecmp(candidates[x].address, "127.", 4) && strncasecmp(candidates[x].address, "255.", 4) && strncasecmp(candidates[x].address, "0.", 2) && strncasecmp(candidates[x].address, "1.", 2) && strncasecmp(candidates[x].address, "2.", 2) && strncasecmp(candidates[x].address, "172.16.", 7) && strncasecmp(candidates[x].address, "172.17.", 7) && strncasecmp(candidates[x].address, "172.18.", 7) && strncasecmp(candidates[x].address, "172.19.", 7) && strncasecmp(candidates[x].address, "172.2", 5) && strncasecmp(candidates[x].address, "172.30.", 7) && strncasecmp(candidates[x].address, "172.31.", 7) && strncasecmp(candidates[x].address, "192.0.2.", 8) && // 192.0.0.0 - 192.0.127.255 is marked as reserved, should we filter all of them?
|
||||
strncasecmp
|
||||
(candidates
|
||||
[x].
|
||||
address,
|
||||
"169.254.",
|
||||
8)
|
||||
))) {
|
||||
// 192.0.0.0 - 192.0.127.255 is marked as reserved, should we filter all of them?
|
||||
if (!strcasecmp(candidates[x].protocol, "udp") &&
|
||||
(!strcasecmp(candidates[x].type, "local") || !strcasecmp(candidates[x].type, "stun")) &&
|
||||
((profile->lanaddr &&
|
||||
lanaddr) || (strncasecmp(candidates[x].address, "10.", 3) &&
|
||||
strncasecmp(candidates[x].address, "192.168.", 8) &&
|
||||
strncasecmp(candidates[x].address, "127.", 4) &&
|
||||
strncasecmp(candidates[x].address, "255.", 4) &&
|
||||
strncasecmp(candidates[x].address, "0.", 2) &&
|
||||
strncasecmp(candidates[x].address, "1.", 2) &&
|
||||
strncasecmp(candidates[x].address, "2.", 2) &&
|
||||
strncasecmp(candidates[x].address, "172.16.", 7) &&
|
||||
strncasecmp(candidates[x].address, "172.17.", 7) &&
|
||||
strncasecmp(candidates[x].address, "172.18.", 7) &&
|
||||
strncasecmp(candidates[x].address, "172.19.", 7) &&
|
||||
strncasecmp(candidates[x].address, "172.2", 5) &&
|
||||
strncasecmp(candidates[x].address, "172.30.", 7) &&
|
||||
strncasecmp(candidates[x].address, "172.31.", 7) &&
|
||||
strncasecmp(candidates[x].address, "192.0.2.", 8) &&
|
||||
strncasecmp(candidates[x].address, "169.254.", 8)
|
||||
))) {
|
||||
ldl_payload_t payloads[5];
|
||||
|
||||
memset(payloads, 0, sizeof(payloads));
|
||||
|
@ -2890,6 +2911,11 @@ static ldl_status handle_signalling(ldl_handle_t * handle, ldl_session_t * dlses
|
|||
ldl_session_accept_candidate(dlsession, &candidates[x]);
|
||||
}
|
||||
|
||||
if (!strcasecmp(subject, "candidates")) {
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT_ACCEPT);
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_ANSWER);
|
||||
}
|
||||
|
||||
if (lanaddr) {
|
||||
switch_set_flag_locked(tech_pvt, TFLAG_LANADDR);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue