[asterisk-commits] mmichelson: branch group/issue8824 r143533 - /team/group/issue8824/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Sep 18 16:54:28 CDT 2008
Author: mmichelson
Date: Thu Sep 18 16:54:27 2008
New Revision: 143533
URL: http://svn.digium.com/view/asterisk?view=rev&rev=143533
Log:
All redirecting information except the reason is updated
properly now when appropriate.
I will work on reason stuff next and should have it done
soonly.
Modified:
team/group/issue8824/channels/chan_sip.c
Modified: team/group/issue8824/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/issue8824/channels/chan_sip.c?view=diff&rev=143533&r1=143532&r2=143533
==============================================================================
--- team/group/issue8824/channels/chan_sip.c (original)
+++ team/group/issue8824/channels/chan_sip.c Thu Sep 18 16:54:27 2008
@@ -15204,8 +15204,51 @@
};
/*XXX TODO Write this*/
-static int read_ruri_parts(struct sip_pvt *p, struct sip_request *req, char **name, char **number)
-{
+static int read_to_parts(struct sip_pvt *p, struct sip_request *req, char **name, char **number)
+{
+
+ char to_header[256];
+ char *to_name = NULL;
+ char *to_number = NULL;
+ char *separator;
+
+ ast_copy_string(to_header, get_header(req, "To"), sizeof(to_header));
+
+ /* Let's get that number first! */
+ to_number = get_in_brackets(to_header);
+
+ if (!strncasecmp(to_number, "sip:", 4)) {
+ to_number += 4;
+ } else if (!strncasecmp(to_number, "sips:", 5)) {
+ to_number += 5;
+ } else {
+ ast_log(LOG_WARNING, "Not a SIP URI? (%s)!\n", to_number);
+ return -1;
+ }
+
+ /* Remove the host and such since we just want the number */
+ if ((separator = strchr(to_number, '@'))) {
+ *separator = '\0';
+ }
+
+ /* We have the number. Let's get the name now. */
+
+ if (*to_header == '\"') {
+ to_name = to_header + 1;
+ if (!(separator = (char *)find_closing_quote(to_name, NULL))) {
+ ast_log(LOG_NOTICE, "No closing quote in name section of To: header (%s)\n", to_header);
+ return -1;
+ }
+ *separator = '\0';
+ }
+
+ if (number) {
+ *number = ast_strdup(to_number);
+ }
+ if (name && !ast_strlen_zero(to_name)) {
+ *name = ast_strdup(to_name);
+ }
+
return 0;
}
@@ -15224,7 +15267,7 @@
res = get_rdnis(p, req, &redirecting_from_name, &redirecting_from_number);
if (res == -1) {
if (is_response) {
- read_ruri_parts(p, req, &redirecting_from_name, &redirecting_from_number);
+ read_to_parts(p, req, &redirecting_from_name, &redirecting_from_number);
} else {
return;
}
@@ -15237,7 +15280,7 @@
if (is_response) {
parse_moved_contact(p, req, &redirecting_to_name, &redirecting_to_number);
} else {
- read_ruri_parts(p, req, &redirecting_to_name, &redirecting_to_number);
+ read_to_parts(p, req, &redirecting_to_name, &redirecting_to_number);
}
/* This check could probably moved up higher so we don't do any unnecessary
@@ -15254,24 +15297,28 @@
if (p->owner->cid.cid_rdnis) {
ast_free(p->owner->cid.cid_rdnis);
}
- p->owner->cid.cid_rdnis = ast_strdup(redirecting_from_number);
+ ast_debug(3, "Got redirecting from number %s\n", redirecting_from_number);
+ p->owner->cid.cid_rdnis = redirecting_from_number;
}
if (!ast_strlen_zero(redirecting_from_name)) {
if (p->owner->redirecting.from.name) {
ast_free(p->owner->redirecting.from.name);
}
- p->owner->redirecting.from.name = ast_strdup(redirecting_from_name);
+ ast_debug(3, LOG_NOTICE, "Got redirecting from name %s\n", redirecting_from_name);
+ p->owner->redirecting.from.name = redirecting_from_name;
}
if (!ast_strlen_zero(redirecting_to_number)) {
if (p->owner->redirecting.to.number) {
ast_free(p->owner->redirecting.to.number);
}
+ ast_debug(3, LOG_NOTICE, "Got redirecting to number %s\n", redirecting_to_number);
p->owner->redirecting.to.number = redirecting_to_number;
}
if (!ast_strlen_zero(redirecting_to_name)) {
if (p->owner->redirecting.to.name) {
ast_free(p->owner->redirecting.to.name);
}
+ ast_debug(3, LOG_NOTICE, "Got redirecting to name %s\n", redirecting_from_number);
p->owner->redirecting.to.name = redirecting_to_name;
}
}
@@ -15367,9 +15414,10 @@
if (*contact == '\"') {
contact_name = contact + 1;
- if ((separator = strchr(contact_name, '\"'))) {
- *separator = '\0';
- }
+ if (!(separator = (char *)find_closing_quote(contact_name, NULL))) {
+ ast_log(LOG_NOTICE, "No closing quote on name in Contact header? %s\n", contact);
+ }
+ *separator = '\0';
}
if (name && !ast_strlen_zero(contact_name)) {
More information about the asterisk-commits
mailing list