git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3415 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2006-11-19 20:08:16 +00:00
parent da2397d006
commit 24456954f7

View File

@ -4120,6 +4120,8 @@ static void sip_r_register(int status,
char const *scheme = NULL; char const *scheme = NULL;
int index; int index;
char *cur; char *cur;
char authentication[256] = "";
int ss_state;
if (session) { if (session) {
private_object_t *tech_pvt; private_object_t *tech_pvt;
@ -4129,6 +4131,15 @@ static void sip_r_register(int status,
} }
} }
if (sofia_private && sofia_private->oreg) {
oreg = sofia_private->oreg;
if (oreg && status == 200) {
oreg->state = REG_STATE_REGISTER;
return;
}
}
if (status == 401 || status == 407) { if (status == 401 || status == 407) {
if (sip->sip_www_authenticate) { if (sip->sip_www_authenticate) {
authenticate = sip->sip_www_authenticate; authenticate = sip->sip_www_authenticate;
@ -4152,13 +4163,8 @@ static void sip_r_register(int status,
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No scheme and realm!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No scheme and realm!\n");
return; return;
} }
}
if (profile) {
if (sofia_private) {
if (sofia_private->oreg) {
oreg = sofia_private->oreg;
} else if (profile) {
outbound_reg_t *oregp; outbound_reg_t *oregp;
if ((duprealm = strdup(realm))) { if ((duprealm = strdup(realm))) {
@ -4167,6 +4173,7 @@ static void sip_r_register(int status,
while(*qrealm && *qrealm == '"') { while(*qrealm && *qrealm == '"') {
qrealm++; qrealm++;
} }
if ((p = strchr(qrealm, '"'))) { if ((p = strchr(qrealm, '"'))) {
*p = '\0'; *p = '\0';
} }
@ -4186,19 +4193,7 @@ static void sip_r_register(int status,
return; return;
} }
} }
}
if (!oreg) {
return;
}
if (status == 200) {
oreg->state = REG_STATE_REGISTER;
} else if (authenticate) {
char authentication[256] = "";
int ss_state;
if (realm) {
snprintf(authentication, sizeof(authentication), "%s:%s:%s:%s", scheme, realm, snprintf(authentication, sizeof(authentication), "%s:%s:%s:%s", scheme, realm,
oreg->register_username, oreg->register_username,
oreg->register_password); oreg->register_password);
@ -4214,12 +4209,9 @@ static void sip_r_register(int status,
SIPTAG_WWW_AUTHENTICATE_REF(authenticate), SIPTAG_WWW_AUTHENTICATE_REF(authenticate),
TAG_END()); TAG_END());
nua_authenticate(nh, SIPTAG_EXPIRES_STR(oreg->expires_str), NUTAG_AUTH(authentication), TAG_END()); nua_authenticate(nh, SIPTAG_EXPIRES_STR(oreg->expires_str), NUTAG_AUTH(authentication), TAG_END());
} }
} }
}
static void event_callback(nua_event_t event, static void event_callback(nua_event_t event,
int status, int status,