mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
Improve support for multipart messages. Code by gasparz, changes
by me (mostly formatting). Thanks, gasparz! Closes issue #10947 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@89280 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -4799,6 +4799,8 @@ static int find_sdp(struct sip_request *req)
|
||||
char *boundary;
|
||||
unsigned int x;
|
||||
int boundaryisquoted = FALSE;
|
||||
int found_application_sdp = FALSE;
|
||||
int found_end_of_headers = FALSE;
|
||||
|
||||
content_type = get_header(req, "Content-Type");
|
||||
|
||||
@@ -4831,31 +4833,36 @@ static int find_sdp(struct sip_request *req)
|
||||
at the beginning */
|
||||
boundary = ast_strdupa(search - 2);
|
||||
boundary[0] = boundary[1] = '-';
|
||||
|
||||
/* Remove final quote */
|
||||
if (boundaryisquoted)
|
||||
boundary[strlen(boundary) - 1] = '\0';
|
||||
|
||||
/* search for the boundary marker, but stop when there are not enough
|
||||
lines left for it, the Content-Type header and at least one line of
|
||||
body */
|
||||
for (x = 0; x < (req->lines - 2); x++) {
|
||||
if (!strncasecmp(req->line[x], boundary, strlen(boundary)) &&
|
||||
!strcasecmp(req->line[x + 1], "Content-Type: application/sdp")) {
|
||||
x += 2;
|
||||
req->sdp_start = x;
|
||||
/* search for the boundary marker, the empty line delimiting headers from
|
||||
sdp part and the end boundry if it exists */
|
||||
|
||||
/* search for the end of the body part */
|
||||
for ( ; x < req->lines; x++) {
|
||||
if (!strncasecmp(req->line[x], boundary, strlen(boundary)))
|
||||
break;
|
||||
for (x = 0; x < (req->lines ); x++) {
|
||||
if(!strncasecmp(req->line[x], boundary, strlen(boundary))){
|
||||
if(found_application_sdp && found_end_of_headers){
|
||||
req->sdp_end = x-1;
|
||||
return 1;
|
||||
}
|
||||
found_application_sdp = FALSE;
|
||||
}
|
||||
if(!strcasecmp(req->line[x], "Content-Type: application/sdp"))
|
||||
found_application_sdp = TRUE;
|
||||
|
||||
if(strlen(req->line[x]) == 0 ){
|
||||
if(found_application_sdp && !found_end_of_headers){
|
||||
req->sdp_start = x;
|
||||
found_end_of_headers = TRUE;
|
||||
}
|
||||
req->sdp_end = x;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
if(found_application_sdp && found_end_of_headers) {
|
||||
req->sdp_end = x;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*! \brief Change hold state for a call */
|
||||
|
Reference in New Issue
Block a user