FS-3794 please test this version

This commit is contained in:
Anthony Minessale 2012-01-26 04:46:48 -06:00
parent 62dc305092
commit b3b33ea995
6 changed files with 545 additions and 365 deletions

View File

@ -4175,7 +4175,7 @@ SWITCH_STANDARD_API(sofia_function)
} }
if (strstr(argv[2], "sla")) { if (strstr(argv[2], "sla")) {
mod_sofia_globals.debug_sla = 1; mod_sofia_globals.debug_sla = 10;
stream->write_function(stream, "+OK Debugging sla\n"); stream->write_function(stream, "+OK Debugging sla\n");
} }

View File

@ -828,6 +828,7 @@ typedef struct {
int network_port; int network_port;
const char *is_nat; const char *is_nat;
int is_auto_nat; int is_auto_nat;
int fs_path;
} sofia_nat_parse_t; } sofia_nat_parse_t;
@ -1140,7 +1141,7 @@ switch_status_t sofia_glue_sdp_map(const char *r_sdp, switch_event_t **fmtp, swi
void sofia_glue_build_vid_refresh_message(switch_core_session_t *session, const char *pl); void sofia_glue_build_vid_refresh_message(switch_core_session_t *session, const char *pl);
void sofia_glue_check_dtmf_type(private_object_t *tech_pvt); void sofia_glue_check_dtmf_type(private_object_t *tech_pvt);
void sofia_glue_parse_rtp_bugs(switch_rtp_bug_flag_t *flag_pole, const char *str); void sofia_glue_parse_rtp_bugs(switch_rtp_bug_flag_t *flag_pole, const char *str);
char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, sofia_dispatch_event_t *de, sofia_nat_parse_t *np); char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, nua_handle_t *nh, sofia_dispatch_event_t *de, sofia_nat_parse_t *np);
void sofia_glue_pause_jitterbuffer(switch_core_session_t *session, switch_bool_t on); void sofia_glue_pause_jitterbuffer(switch_core_session_t *session, switch_bool_t on);
void sofia_process_dispatch_event(sofia_dispatch_event_t **dep); void sofia_process_dispatch_event(sofia_dispatch_event_t **dep);
char *sofia_glue_get_host(const char *str, switch_memory_pool_t *pool); char *sofia_glue_get_host(const char *str, switch_memory_pool_t *pool);

View File

@ -91,7 +91,7 @@ void sofia_handle_sip_r_notify(switch_core_session_t *session, int status,
if (status >= 300 && sip && sip->sip_call_id && (!sofia_private || !sofia_private->is_call)) { if (status >= 300 && sip && sip->sip_call_id && (!sofia_private || !sofia_private->is_call)) {
char *sql; char *sql;
sql = switch_mprintf("update sip_subscriptions set expires=%ld where call_id='%q'", (long) switch_epoch_time_now(NULL), sip->sip_call_id->i_id); sql = switch_mprintf("delete from sip_subscriptions where call_id='%q'", sip->sip_call_id->i_id);
switch_assert(sql != NULL); switch_assert(sql != NULL);
sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE); sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
nua_handle_destroy(nh); nua_handle_destroy(nh);
@ -3686,7 +3686,7 @@ switch_status_t config_sofia(int reload, char *profile_name)
profile->contact_user = SOFIA_DEFAULT_CONTACT_USER; profile->contact_user = SOFIA_DEFAULT_CONTACT_USER;
sofia_set_pflag(profile, PFLAG_PASS_CALLEE_ID); sofia_set_pflag(profile, PFLAG_PASS_CALLEE_ID);
sofia_set_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER); sofia_set_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER);
sofia_set_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER); //sofia_set_pflag(profile, PFLAG_PRESENCE_ON_FIRST_REGISTER);
sofia_set_pflag(profile, PFLAG_SQL_IN_TRANS); sofia_set_pflag(profile, PFLAG_SQL_IN_TRANS);
profile->shutdown_type = "false"; profile->shutdown_type = "false";

View File

@ -5139,6 +5139,14 @@ char *sofia_glue_get_url_from_contact(char *buf, uint8_t to_dup)
{ {
char *url = NULL, *e; char *url = NULL, *e;
while((e = strchr(buf, '"'))) {
buf = e+1;
}
while(*buf == ' ') {
buf++;
}
if ((url = strchr(buf, '<')) && (e = strchr(url, '>'))) { if ((url = strchr(buf, '<')) && (e = strchr(url, '>'))) {
url++; url++;
if (to_dup) { if (to_dup) {
@ -6504,9 +6512,14 @@ switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *use
nua_handle_t *nh; nua_handle_t *nh;
sofia_destination_t *dst = NULL; sofia_destination_t *dst = NULL;
char *contact_str, *contact, *user_via = NULL; char *contact_str, *contact, *user_via = NULL;
char *route_uri = NULL; char *route_uri = NULL, *p;
contact = sofia_glue_get_url_from_contact((char *) o_contact, 1); contact = sofia_glue_get_url_from_contact((char *) o_contact, 1);
if ((p = strstr(contact, ";fs_"))) {
*p = '\0';
}
if (!zstr(network_ip) && sofia_glue_check_nat(profile, network_ip)) { if (!zstr(network_ip) && sofia_glue_check_nat(profile, network_ip)) {
char *ptr = NULL; char *ptr = NULL;
//const char *transport_str = NULL; //const char *transport_str = NULL;
@ -6744,7 +6757,7 @@ void sofia_glue_parse_rtp_bugs(switch_rtp_bug_flag_t *flag_pole, const char *str
} }
} }
char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, sofia_dispatch_event_t *de, sofia_nat_parse_t *np) char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, nua_handle_t *nh, sofia_dispatch_event_t *de, sofia_nat_parse_t *np)
{ {
char *contact_str = NULL; char *contact_str = NULL;
const char *contact_host;//, *contact_user; const char *contact_host;//, *contact_user;
@ -6841,7 +6854,8 @@ char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, sof
np->is_nat = "No contact host"; np->is_nat = "No contact host";
} }
if (np->is_nat) {
if (np->is_nat && !np->fs_path) {
contact_host = np->network_ip; contact_host = np->network_ip;
switch_snprintf(new_port, sizeof(new_port), ":%d", np->network_port); switch_snprintf(new_port, sizeof(new_port), ":%d", np->network_port);
port = NULL; port = NULL;
@ -6853,17 +6867,50 @@ char *sofia_glue_gen_contact_str(sofia_profile_t *profile, sip_t const *sip, sof
} }
ipv6 = strchr(contact_host, ':'); ipv6 = strchr(contact_host, ':');
if (contact->m_url->url_params) {
contact_str = switch_mprintf("%s <sip:%s@%s%s%s%s;%s>%s",
display, contact->m_url->url_user,
ipv6 ? "[" : "",
contact_host, ipv6 ? "]" : "", new_port, contact->m_url->url_params, np->is_nat ? ";fs_nat=yes" : "");
} else {
contact_str = switch_mprintf("%s <sip:%s@%s%s%s%s>%s",
display,
contact->m_url->url_user, ipv6 ? "[" : "", contact_host, ipv6 ? "]" : "", new_port, np->is_nat ? ";fs_nat=yes" : "");
}
if (np->is_nat && np->fs_path) {
char *full_contact = sip_header_as_string(nh->nh_home, (void *) contact);
char *full_contact_dup;
char *path_encoded;
int path_encoded_len;
char *path_val;
const char *tp;
full_contact_dup = sofia_glue_get_url_from_contact(full_contact, 1);
if ((tp = switch_stristr("transport=", full_contact_dup))) {
tp += 10;
}
if (zstr(tp)) {
tp = "udp";
}
path_val = switch_mprintf("sip:%s:%d;transport=%s", np->network_ip, np->network_port, tp);
path_encoded_len = (int)(strlen(path_val) * 3) + 1;
switch_zmalloc(path_encoded, path_encoded_len);
switch_copy_string(path_encoded, ";fs_path=", 10);
switch_url_encode(path_val, path_encoded + 9, path_encoded_len - 9);
contact_str = switch_mprintf("%s <%s;fs_nat=yes%s>", display, full_contact_dup, path_encoded);
free(full_contact_dup);
free(path_encoded);
free(path_val);
} else {
if (contact->m_url->url_params) {
contact_str = switch_mprintf("%s <sip:%s@%s%s%s%s;%s>%s",
display, contact->m_url->url_user,
ipv6 ? "[" : "",
contact_host, ipv6 ? "]" : "", new_port, contact->m_url->url_params, np->is_nat ? ";fs_nat=yes" : "");
} else {
contact_str = switch_mprintf("%s <sip:%s@%s%s%s%s>%s",
display,
contact->m_url->url_user, ipv6 ? "[" : "", contact_host, ipv6 ? "]" : "", new_port, np->is_nat ? ";fs_nat=yes" : "");
}
}
return contact_str; return contact_str;
} }

File diff suppressed because it is too large Load Diff

View File

@ -1521,7 +1521,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
"user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port,sip_username,sip_realm," "user_agent,server_user,server_host,profile_name,hostname,network_ip,network_port,sip_username,sip_realm,"
"mwi_user,mwi_host, orig_server_host, orig_hostname, sub_host) " "mwi_user,mwi_host, orig_server_host, orig_hostname, sub_host) "
"values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q','%q','%q','%q','%q','%q')", "values ('%q','%q', '%q','%q','%q','%q', '%q', %ld, '%q', '%q', '%q', '%q', '%q', '%q', '%q','%q','%q','%q','%q','%q','%q','%q')",
call_id, to_user, reg_host, profile->presence_hosts ? profile->presence_hosts : reg_host, call_id, to_user, reg_host, profile->presence_hosts ? profile->presence_hosts : "",
contact_str, reg_desc, rpid, (long) switch_epoch_time_now(NULL) + (long) exptime + 60, contact_str, reg_desc, rpid, (long) switch_epoch_time_now(NULL) + (long) exptime + 60,
agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname, network_ip, network_port_c, username, realm, agent, from_user, guess_ip4, profile->name, mod_sofia_globals.hostname, network_ip, network_port_c, username, realm,
mwi_user, mwi_host, guess_ip4, mod_sofia_globals.hostname, sub_host); mwi_user, mwi_host, guess_ip4, mod_sofia_globals.hostname, sub_host);
@ -1553,7 +1553,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile-name", profile->name); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "profile-name", profile->name);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "from-user", to_user); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "from-user", to_user);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "from-host", reg_host); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "from-host", reg_host);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "presence-hosts", profile->presence_hosts ? profile->presence_hosts : reg_host); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "presence-hosts", profile->presence_hosts ? profile->presence_hosts : "n/a");
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "contact", contact_str); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "contact", contact_str);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "call-id", call_id); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "call-id", call_id);
switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "rpid", rpid); switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "rpid", rpid);
@ -1576,38 +1576,6 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
"Register:\nFrom: [%s@%s]\nContact: [%s]\nExpires: [%ld]\n", to_user, reg_host, contact_str, (long) exptime); "Register:\nFrom: [%s@%s]\nContact: [%s]\nExpires: [%ld]\n", to_user, reg_host, contact_str, (long) exptime);
} }
#if 0
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", rpid);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", profile->url);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "user-agent",
(sip && sip->sip_user_agent) ? sip->sip_user_agent->g_string : "unknown");
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, sub_host);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", "Registered");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_fire(&event);
}
if (sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER) ||
(reg_count == 1 && sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER))) {
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", "sip");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", profile->url);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", rpid);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", to_user, sub_host);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "to", "%s@%s", to_user, sub_host);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", "Registered");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_subtype", "probe");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_fire(&event);
}
}
#endif
} else { } else {
int send = 1; int send = 1;
@ -1629,18 +1597,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_fire(&event); switch_event_fire(&event);
} }
#if 0
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_OUT) == SWITCH_STATUS_SUCCESS) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", "sip");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", profile->url);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s+%s@%s", SOFIA_CHAT_PROTO, to_user, sub_host);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", "unavailable");
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", rpid);
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
switch_event_fire(&event);
}
#endif
if (multi_reg) { if (multi_reg) {
char *icontact, *p; char *icontact, *p;