diff options
Diffstat (limited to 'src/sip/sip.c')
-rw-r--r-- | src/sip/sip.c | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/src/sip/sip.c b/src/sip/sip.c index bda9261..2ced743 100644 --- a/src/sip/sip.c +++ b/src/sip/sip.c @@ -456,7 +456,7 @@ static void setup_req(call_t *call, osmo_cc_msg_t *msg) const char *sdp = sdp; int rc; - if (!call->sip_ep->remote_peer[0]) { + if (!call->sip_ep->remote_peer || !call->sip_ep->remote_peer[0]) { PDEBUG(DSIP, DEBUG_NOTICE, "No remote peer set or no peer has registered to us.\n"); release_and_destroy(call, OSMO_CC_ISDN_CAUSE_DEST_OOO, 0, 0, 0, ""); return; @@ -862,16 +862,29 @@ static void ep_i_register(sip_endpoint_t *sip_ep, int status, nua_t *nua, nua_ha nua_save_event(nua, saved); nua_event_data_t const *data = nua_event_data(saved); sip_authorization_t const *authorization; - char contact[255] = ""; + char contact_user[256] = "", contact_peer[256] = ""; const char *auth_text = NULL; char auth_str[256] = ""; + if (!sip->sip_contact || !sip->sip_contact->m_url || !sip->sip_contact->m_url->url_host) { + PDEBUG(DSIP, DEBUG_NOTICE, "Not found, because we don't have a contact line"); + PDEBUG(DSIP, DEBUG_INFO, "Sending REGISTER response: %d %s (registration)\n", SIP_404_NOT_FOUND); + nua_respond(nh, SIP_403_FORBIDDEN, NUTAG_WITH_THIS_MSG(data->e_msg), TAG_END()); + nua_destroy_event(saved); + PDEBUG(DSIP, DEBUG_DEBUG, "destroying nua_handle %p (register)\n", nh); + nua_handle_destroy(nh); + sip_ep->register_handle = NULL; + return; + } + + if (sip->sip_contact->m_url->url_user) + strcpy(contact_user, sip->sip_contact->m_url->url_user); if (sip->sip_contact->m_url->url_host) { // FIXME: unstable/might not work with IPv6 - strcpy(contact, sip->sip_contact->m_url->url_host); + strcpy(contact_peer, sip->sip_contact->m_url->url_host); if (sip->sip_contact->m_url->url_port && sip->sip_contact->m_url->url_port[0]) { - strcat(contact, ":"); - strcat(contact, sip->sip_contact->m_url->url_port); + strcat(contact_peer, ":"); + strcat(contact_peer, sip->sip_contact->m_url->url_port); } } @@ -886,7 +899,7 @@ static void ep_i_register(sip_endpoint_t *sip_ep, int status, nua_t *nua, nua_ha return; } - PDEBUG(DSIP, DEBUG_DEBUG, " -> contact %s\n", contact); + PDEBUG(DSIP, DEBUG_DEBUG, " -> contact %s@%s\n", contact_user, contact_peer); if (sip_ep->authenticate_local && sip_ep->auth_realm[0]) { authorization = sip->sip_authorization; @@ -903,10 +916,11 @@ static void ep_i_register(sip_endpoint_t *sip_ep, int status, nua_t *nua, nua_ha PDEBUG(DSIP, DEBUG_DEBUG, " -> Authentication: %d %s\n", status, auth_text); if (status == 200) { - strncpy(sip_ep->remote_contact, contact, sizeof(sip_ep->remote_contact) - 1); - sip_ep->remote_peer = sip_ep->remote_contact; + strncpy(sip_ep->remote_contact_user, contact_user, sizeof(sip_ep->remote_contact_user) - 1); + strncpy(sip_ep->remote_contact_peer, contact_peer, sizeof(sip_ep->remote_contact_peer) - 1); + sip_ep->remote_user = sip_ep->remote_contact_user; + sip_ep->remote_peer = sip_ep->remote_contact_peer; sip_ep->register_nonce[0] = '\0'; - PDEBUG(DSIP, DEBUG_DEBUG, "remote contact '%s'\n", sip_ep->remote_peer); } PDEBUG(DSIP, DEBUG_INFO, "Sending REGISTER response: %d %s (registration)\n", status, auth_text); |