aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-05-02 02:18:41 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-05-02 02:18:41 +0000
commitbb84291b28d29490b62d1f9494a8d4838ae05c1d (patch)
tree3f497f2d1875fb99a821f761b2f7f0ab4827a2da /channels
parent3bf9b6caa222ab47eca1fc5e7992e5466077e998 (diff)
Parse first line parts when copying initreq's.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@949 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels')
-rwxr-xr-xchannels/chan_sip.c122
1 files changed, 63 insertions, 59 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 429d22411..4a5270d37 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -2273,6 +2273,65 @@ static int transmit_response_with_sdp(struct sip_pvt *p, char *msg, struct sip_r
return send_response(p, &resp, retrans, seqno);
}
+static int determine_firstline_parts( struct sip_request *req ) {
+
+ char *e, *cmd;
+ int len;
+
+ cmd= req->header[0];
+ while(*cmd && (*cmd < 33)) {
+ cmd++;
+ }
+ if (!*cmd) {
+ return -1;
+ }
+ e= cmd;
+ while(*e && (*e > 32)) {
+ e++;
+ }
+ /* Get the command */
+ if (*e) {
+ *e = '\0';
+ e++;
+ }
+ req->rlPart1= cmd;
+ while( *e && ( *e < 33 ) ) {
+ e++;
+ }
+ if( !*e ) {
+ return -1;
+ }
+
+ if ( !strcasecmp(cmd, "SIP/2.0") ) {
+ /* We have a response */
+ req->rlPart2= e;
+ len= strlen( req->rlPart2 );
+ if( len < 2 ) { return -1; }
+ e+= len - 1;
+ while( *e && *e<33 ) {
+ e--;
+ }
+ *(++e)= '\0';
+ } else {
+ /* We have a request */
+ if( *e == '<' ) {
+ e++;
+ if( !*e ) { return -1; }
+ }
+ req->rlPart2= e;
+ if( ( e= strrchr( req->rlPart2, 'S' ) ) == NULL ) {
+ return -1;
+ }
+ while( isspace( *(--e) ) ) {}
+ if( *e == '>' ) {
+ *e= '\0';
+ } else {
+ *(++e)= '\0';
+ }
+ }
+ return 1;
+}
+
static int transmit_reinvite_with_sdp(struct sip_pvt *p, struct ast_rtp *rtp)
{
struct sip_request req;
@@ -2284,6 +2343,7 @@ static int transmit_reinvite_with_sdp(struct sip_pvt *p, struct ast_rtp *rtp)
/* Use this as the basis */
copy_request(&p->initreq, &req);
parse(&p->initreq);
+ determine_firstline_parts(&p->initreq);
p->lastinvite = p->ocseq;
p->outgoing = 1;
return send_request(p, &req, 1, p->ocseq);
@@ -2379,6 +2439,7 @@ static int transmit_invite(struct sip_pvt *p, char *cmd, int sdp, char *auth, ch
/* Use this as the basis */
copy_request(&p->initreq, &req);
parse(&p->initreq);
+ determine_firstline_parts(&p->initreq);
}
p->lastinvite = p->ocseq;
return send_request(p, &req, 1, p->ocseq);
@@ -2491,6 +2552,7 @@ static int transmit_notify(struct sip_pvt *p, int newmsgs, int oldmsgs)
/* Use this as the basis */
copy_request(&p->initreq, &req);
parse(&p->initreq);
+ determine_firstline_parts(&p->initreq);
}
return send_request(p, &req, 1, p->ocseq);
@@ -2624,6 +2686,7 @@ static int transmit_register(struct sip_registry *r, char *cmd, char *auth)
add_blank_header(&req);
copy_request(&p->initreq, &req);
parse(&p->initreq);
+ determine_firstline_parts(&p->initreq);
r->regstate=auth?REG_STATE_AUTHSENT:REG_STATE_REGSENT;
return send_request(p, &req, 1, p->ocseq);
}
@@ -4033,65 +4096,6 @@ static void handle_response(struct sip_pvt *p, int resp, char *rest, struct sip_
}
}
-static int determine_firstline_parts( struct sip_request *req ) {
-
- char *e, *cmd;
- int len;
-
- cmd= req->header[0];
- while(*cmd && (*cmd < 33)) {
- cmd++;
- }
- if (!*cmd) {
- return -1;
- }
- e= cmd;
- while(*e && (*e > 32)) {
- e++;
- }
- /* Get the command */
- if (*e) {
- *e = '\0';
- e++;
- }
- req->rlPart1= cmd;
- while( *e && ( *e < 33 ) ) {
- e++;
- }
- if( !*e ) {
- return -1;
- }
-
- if ( !strcasecmp(cmd, "SIP/2.0") ) {
- /* We have a response */
- req->rlPart2= e;
- len= strlen( req->rlPart2 );
- if( len < 2 ) { return -1; }
- e+= len - 1;
- while( *e && *e<33 ) {
- e--;
- }
- *(++e)= '\0';
- } else {
- /* We have a request */
- if( *e == '<' ) {
- e++;
- if( !*e ) { return -1; }
- }
- req->rlPart2= e;
- if( ( e= strrchr( req->rlPart2, 'S' ) ) == NULL ) {
- return -1;
- }
- while( isspace( *(--e) ) ) {}
- if( *e == '>' ) {
- *e= '\0';
- } else {
- *(++e)= '\0';
- }
- }
- return 1;
-}
-
static int attempt_transfer(struct sip_pvt *p1, struct sip_pvt *p2)
{
if (!p1->owner || !p2->owner) {