- Hack to deal with Asterisks broken Alert-Info headers
(Asterisk does include Alert-Info header without '<>')
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
0.6.0
|
||||
=====
|
||||
21-Apr-2007: - Hack to deal with Asterisks broken Alert-Info headers
|
||||
(Asterisk does include Alert-Info header without '<>')
|
||||
19-Feb-2007: - Increased RTP buffer size
|
||||
13-Oct-2006: - Various fixes due to a code review by Andrew Jones
|
||||
05-Oct-2006: - route_determine_nexthop(): don't remove header
|
||||
|
||||
+46
-1
@@ -1097,6 +1097,51 @@ int sip_find_direction(sip_ticket_t *ticket, int *urlidx) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* SIP_FIXUP_ALERT_INFO
|
||||
*
|
||||
* Asterisk Hack.
|
||||
* Asterisk seems to include broken Alert-Info headers (without <>)
|
||||
* that cause parsing to fail (libosip2).
|
||||
* This function does try to guess if we have such a broken SIP
|
||||
* message and does simply remove the offending Alert-Info header.
|
||||
*
|
||||
* RETURNS
|
||||
* STS_SUCCESS on success
|
||||
*/
|
||||
int sip_fixup_asterisk(char *buff, int *buflen) {
|
||||
char *alert_info_ptr=NULL;
|
||||
/*
|
||||
* Check for Asterisk UA string
|
||||
* User-Agent: Asterisk PBX
|
||||
*/
|
||||
if (strstr(buff, "\r\nUser-Agent: Asterisk PBX\r\n")==NULL)
|
||||
return STS_SUCCESS;
|
||||
|
||||
DEBUGC(DBCLASS_SIP, "sip_fixup_alert_info: SIP message is from Asterisk");
|
||||
/*
|
||||
* Look form Alert-Info: header
|
||||
*/
|
||||
alert_info_ptr=strstr(buff, "\r\nAlert-Info: ");
|
||||
if (alert_info_ptr) {
|
||||
char *eol_ptr=NULL;
|
||||
DEBUGC(DBCLASS_SIP, "sip_fixup_alert_info: Asterisk message "
|
||||
"with Alert-Info found");
|
||||
eol_ptr=strstr((alert_info_ptr+2), "\r\n");
|
||||
if (eol_ptr) {
|
||||
int i;
|
||||
// cut the Alert-Info header from the message
|
||||
// (actually move the rest of the message up)
|
||||
DEBUGC(DBCLASS_SIP, "sip_fixup_alert_info: removed malformed "
|
||||
"Alert-Info header");
|
||||
for (i=0; i<(*buflen - (eol_ptr - buff)); i++) {
|
||||
alert_info_ptr[i]=eol_ptr[i];
|
||||
} /* for */
|
||||
|
||||
*buflen=strlen(buff);
|
||||
} /* if */
|
||||
}
|
||||
return STS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -318,6 +318,11 @@ int main (int argc, char *argv[])
|
||||
continue; /* there are no resources to free */
|
||||
}
|
||||
|
||||
/*
|
||||
* Hacks to fix-up some broken headers
|
||||
*/
|
||||
sts=sip_fixup_asterisk(buff, &buflen);
|
||||
|
||||
/*
|
||||
* init sip_msg
|
||||
*/
|
||||
|
||||
@@ -175,6 +175,7 @@ int sip_calculate_branch_id (sip_ticket_t *ticket, char *id); /*X*/
|
||||
int sip_find_outbound_proxy(sip_ticket_t *ticket, struct in_addr *addr,
|
||||
int *port); /*X*/
|
||||
int sip_find_direction(sip_ticket_t *ticket, int *urlidx); /*X*/
|
||||
int sip_fixup_asterisk(char *buff, int *buflen); /*X*/
|
||||
|
||||
/* readconf.c */
|
||||
int read_config(char *name, int search); /*X*/
|
||||
|
||||
Reference in New Issue
Block a user