Quellcode durchsuchen

*** empty log message ***

Bogdan-Andrei Iancu vor 23 Jahren
Ursprung
Commit
b13ec1cd9c
6 geänderte Dateien mit 91 neuen und 77 gelöschten Zeilen
  1. 2 3
      Makefile.defs
  2. 67 58
      modules/tm/sip_msg.c
  3. 3 3
      modules/tm/t_lookup.c
  4. 2 1
      msg_parser.c
  5. 1 0
      msg_parser.h
  6. 16 12
      parse_to.c

+ 2 - 3
Makefile.defs

@@ -86,10 +86,9 @@ DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
 	 #-DNOSMP \
 	 #-DNOSMP \
 	 #-DEXTRA_DEBUG 
 	 #-DEXTRA_DEBUG 
 	 #-DVQ_MALLOC  -DDBG_LOCK  #-DSTATS
 	 #-DVQ_MALLOC  -DDBG_LOCK  #-DSTATS
-	 #-DDBG_QM_MALLOC #-DNO_DEBUG
+	 #-DDBG_QM_MALLOC 
 # -DUSE_SHM_MEM
 # -DUSE_SHM_MEM
-#-DNO_DEBUG
-#-DNO_DEBUG#-DSTATS -DNO_DEBUG
+#-DSTATS 
 #-DNO_LOG
 #-DNO_LOG
 
 
 # arh. specific definitions
 # arh. specific definitions

+ 67 - 58
modules/tm/sip_msg.c

@@ -149,29 +149,32 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
       new_msg->first_line.u.reply.reason.s =  translate_pointer( new_msg->buf , org_msg->buf , org_msg->first_line.u.reply.reason.s );
       new_msg->first_line.u.reply.reason.s =  translate_pointer( new_msg->buf , org_msg->buf , org_msg->first_line.u.reply.reason.s );
     }
     }
 
 
-   /*headers list*/
-   new_msg->via1=0;
-   new_msg->via2=0;
-   for( hdr=org_msg->headers,last_hdr=0 ; hdr ; hdr=hdr->next )
-   {
-      new_hdr = (struct hdr_field*)p;
-      memcpy(new_hdr, hdr, sizeof(struct hdr_field) );
-      p += ROUND4(sizeof( struct hdr_field));
-      new_hdr->name.s =  translate_pointer( new_msg->buf , org_msg->buf , hdr->name.s );
-      new_hdr->body.s =  translate_pointer( new_msg->buf , org_msg->buf , hdr->body.s );
-
-     switch (hdr->type)
-      {
-         case HDR_VIA:
-                if ( !new_msg->via1 )
-                   {
-                       new_msg->h_via1 = new_hdr;
-                       new_msg->via1 = via_body_cloner_2( new_msg->buf , org_msg->buf , (struct via_body*)hdr->parsed , &p);
-                       new_hdr->parsed  = (void*)new_msg->via1;
-                   if ( new_msg->via1->next )
-                            new_msg->via2 = new_msg->via1->next;
-                   }
-                else if ( !new_msg->via2 && new_msg->via1 )
+	/*headers list*/
+	new_msg->via1=0;
+	new_msg->via2=0;
+	for( hdr=org_msg->headers,last_hdr=0 ; hdr ; hdr=hdr->next )
+	{
+		new_hdr = (struct hdr_field*)p;
+		memcpy(new_hdr, hdr, sizeof(struct hdr_field) );
+		p += ROUND4(sizeof( struct hdr_field));
+		new_hdr->name.s = translate_pointer(new_msg->buf, org_msg->buf,
+			hdr->name.s);
+		new_hdr->body.s = translate_pointer(new_msg->buf, org_msg->buf,
+			hdr->body.s);
+
+		switch (hdr->type)
+		{
+			case HDR_VIA:
+				if ( !new_msg->via1 )
+				{
+					new_msg->h_via1 = new_hdr;
+					new_msg->via1 = via_body_cloner_2(new_msg->buf,
+						org_msg->buf, (struct via_body*)hdr->parsed, &p);
+					new_hdr->parsed  = (void*)new_msg->via1;
+					if ( new_msg->via1->next )
+						new_msg->via2 = new_msg->via1->next;
+				}
+				else if ( !new_msg->via2 && new_msg->via1 )
                    {
                    {
                        new_msg->h_via2 = new_hdr;
                        new_msg->h_via2 = new_hdr;
                        if ( new_msg->via1->next )
                        if ( new_msg->via1->next )
@@ -181,35 +184,41 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
                            new_hdr->parsed  = (void*)new_msg->via2;
                            new_hdr->parsed  = (void*)new_msg->via2;
                        }
                        }
                    }
                    }
-                else if ( new_msg->via2 && new_msg->via1 )
+				else if ( new_msg->via2 && new_msg->via1 )
                    {
                    {
                        new_hdr->parsed  = new_msg->via1 = via_body_cloner_2( new_msg->buf , org_msg->buf , (struct via_body*)hdr->parsed , &p);
                        new_hdr->parsed  = new_msg->via1 = via_body_cloner_2( new_msg->buf , org_msg->buf , (struct via_body*)hdr->parsed , &p);
                    }
                    }
                    break;
                    break;
-         case HDR_CSEQ:
-                   new_hdr->parsed = p;
-                   p +=ROUND4(sizeof(struct cseq_body));
-                   memcpy( new_hdr->parsed , hdr->parsed , sizeof(struct cseq_body) );
-                   ((struct cseq_body*)new_hdr->parsed)->number.s =  translate_pointer( new_msg->buf , org_msg->buf , ((struct cseq_body*)hdr->parsed)->number.s );
-                   ((struct cseq_body*)new_hdr->parsed)->method.s =  translate_pointer( new_msg->buf , org_msg->buf , ((struct cseq_body*)hdr->parsed)->method.s );
-                   new_msg->cseq = new_hdr;
-                   break;
-         case HDR_TO:
-                   new_hdr->parsed = p;
-                   p +=ROUND4(sizeof(struct to_body));
-                   memcpy( new_hdr->parsed , hdr->parsed ,
-                    sizeof(struct to_body) );
-                   ((struct to_body*)new_hdr->parsed)->body.s =
-                        translate_pointer( new_msg->buf , org_msg->buf ,
-                        ((struct to_body*)hdr->parsed)->body.s );
-                   if ( ((struct to_body*)hdr->parsed)->tag_value.s )
-                         ((struct to_body*)new_hdr->parsed)->tag_value.s
-                         = translate_pointer( new_msg->buf , org_msg->buf ,
-                            ((struct to_body*)hdr->parsed)->tag_value.s );
-                    /*to params*/
-                   to_prm = ((struct to_body*)(hdr->parsed))->param_lst;
-                   for(;to_prm;to_prm=to_prm->next)
-                   {
+			case HDR_CSEQ:
+				new_hdr->parsed = p;
+				p +=ROUND4(sizeof(struct cseq_body));
+				memcpy(new_hdr->parsed, hdr->parsed, sizeof(struct cseq_body));
+				((struct cseq_body*)new_hdr->parsed)->number.s =
+					translate_pointer(new_msg->buf ,org_msg->buf,
+					((struct cseq_body*)hdr->parsed)->number.s );
+				((struct cseq_body*)new_hdr->parsed)->method.s =
+					translate_pointer(new_msg->buf ,org_msg->buf,
+					((struct cseq_body*)hdr->parsed)->method.s );
+				new_msg->cseq = new_hdr;
+				break;
+			case HDR_TO:
+				new_hdr->parsed = p;
+				p +=ROUND4(sizeof(struct to_body));
+				memcpy(new_hdr->parsed, hdr->parsed, sizeof(struct to_body));
+				((struct to_body*)new_hdr->parsed)->body.s =
+					translate_pointer( new_msg->buf , org_msg->buf ,
+					((struct to_body*)hdr->parsed)->body.s );
+				((struct to_body*)new_hdr->parsed)->uri.s =
+					translate_pointer( new_msg->buf , org_msg->buf ,
+					((struct to_body*)hdr->parsed)->uri.s );
+				if ( ((struct to_body*)hdr->parsed)->tag_value.s )
+					((struct to_body*)new_hdr->parsed)->tag_value.s =
+						translate_pointer( new_msg->buf , org_msg->buf ,
+						((struct to_body*)hdr->parsed)->tag_value.s );
+				/*to params*/
+				to_prm = ((struct to_body*)(hdr->parsed))->param_lst;
+				for(;to_prm;to_prm=to_prm->next)
+				{
                       /*alloc*/
                       /*alloc*/
                       new_to_prm = (struct to_param*)p;
                       new_to_prm = (struct to_param*)p;
                       p +=ROUND4(sizeof(struct to_param ));
                       p +=ROUND4(sizeof(struct to_param ));
@@ -229,22 +238,22 @@ struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg )
                             = new_to_prm;
                             = new_to_prm;
                       ((struct to_body*)new_hdr->parsed)->last_param
                       ((struct to_body*)new_hdr->parsed)->last_param
                          = new_to_prm;
                          = new_to_prm;
-                   }
-                   new_msg->to = new_hdr;
-                   break;
-         case HDR_CALLID:
-                   new_msg->callid = new_hdr;
-                   break;
-         case HDR_FROM:
+				}
+				new_msg->to = new_hdr;
+				break;
+			case HDR_CALLID:
+				new_msg->callid = new_hdr;
+				break;
+			case HDR_FROM:
                    new_msg->from = new_hdr;
                    new_msg->from = new_hdr;
                    break;
                    break;
-         case HDR_CONTACT:
+			case HDR_CONTACT:
                    new_msg->contact = new_hdr;
                    new_msg->contact = new_hdr;
                    break;
                    break;
-         case HDR_MAXFORWARDS :
+			case HDR_MAXFORWARDS :
                   new_msg->maxforwards = new_hdr;
                   new_msg->maxforwards = new_hdr;
                break;
                break;
-        case HDR_ROUTE :
+			case HDR_ROUTE :
                   new_msg->route = new_hdr;
                   new_msg->route = new_hdr;
                break;
                break;
       }
       }

+ 3 - 3
modules/tm/t_lookup.c

@@ -133,7 +133,7 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked )
 			&& /*callid length*/ EQ_LEN(callid)
 			&& /*callid length*/ EQ_LEN(callid)
 			&& get_cseq(t_msg)->number.len==get_cseq(p_msg)->number.len
 			&& get_cseq(t_msg)->number.len==get_cseq(p_msg)->number.len
 			&& /*from length*/ EQ_LEN(from)
 			&& /*from length*/ EQ_LEN(from)
-			&& /*to body*/get_to(t_msg)->body.len==get_to(p_msg)->body.len
+			&& /*to uri*/get_to(t_msg)->uri.len==get_to(p_msg)->uri.len
 			&& /*to tag*/p_cell->tag->len==get_to(p_msg)->tag_value.len
 			&& /*to tag*/p_cell->tag->len==get_to(p_msg)->tag_value.len
 			&& /*req URI*/(p_cell->status==200 || EQ_REQ_URI_LEN )
 			&& /*req URI*/(p_cell->status==200 || EQ_REQ_URI_LEN )
 			&& /*VIA*/(p_cell->status==200 || EQ_VIA_LEN(via1)) )
 			&& /*VIA*/(p_cell->status==200 || EQ_VIA_LEN(via1)) )
@@ -144,8 +144,8 @@ int t_lookup_request( struct sip_msg* p_msg , int leave_new_locked )
 				&& /*cseq nr*/!memcmp(get_cseq(t_msg)->number.s,
 				&& /*cseq nr*/!memcmp(get_cseq(t_msg)->number.s,
 					get_cseq(p_msg)->number.s,get_cseq(p_msg)->number.len)
 					get_cseq(p_msg)->number.s,get_cseq(p_msg)->number.len)
 				&& /*from*/EQ_STR(from)
 				&& /*from*/EQ_STR(from)
-				&& /*to body*/!memcmp(get_to(t_msg)->body.s,
-					get_to(p_msg)->body.s,get_to(t_msg)->body.len)
+				&& /*to uri*/!memcmp(get_to(t_msg)->uri.s,
+					get_to(p_msg)->uri.s,get_to(t_msg)->uri.len)
 				&& /*to tag*/!memcmp(p_cell->tag->s,
 				&& /*to tag*/!memcmp(p_cell->tag->s,
 					get_to(p_msg)->tag_value.s,p_cell->tag->len)
 					get_to(p_msg)->tag_value.s,p_cell->tag->len)
 				&& /*req URI*/(p_cell->status==200 || EQ_REQ_URI_STR)
 				&& /*req URI*/(p_cell->status==200 || EQ_REQ_URI_STR)

+ 2 - 1
msg_parser.c

@@ -264,7 +264,8 @@ char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
 			hdr->parsed=to_b;
 			hdr->parsed=to_b;
 			hdr->body.len=tmp-hdr->body.s;
 			hdr->body.len=tmp-hdr->body.s;
 			DBG("get_hdr_field: <%s> [%d]; <%s>.len = %d \n",
 			DBG("get_hdr_field: <%s> [%d]; <%s>.len = %d \n",
-				hdr->name.s, hdr->body.len, to_b->body.s,to_b->body.len);
+				hdr->name.s, hdr->body.len, to_b->uri.s,to_b->uri.len);
+			DBG("to <%s>.len=%d\n",to_b->body.s,to_b->body.len);
 			break;
 			break;
 		case HDR_FROM:
 		case HDR_FROM:
 		case HDR_CALLID:
 		case HDR_CALLID:

+ 1 - 0
msg_parser.h

@@ -156,6 +156,7 @@ struct to_param{
 struct to_body{
 struct to_body{
 	int error;
 	int error;
 	str body;
 	str body;
+	str uri;
 	str tag_value;
 	str tag_value;
 	struct to_param *param_lst;
 	struct to_param *param_lst;
 	struct to_param *last_param;
 	struct to_param *last_param;

+ 16 - 12
parse_to.c

@@ -409,8 +409,8 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 						status=saved_status;
 						status=saved_status;
 						break;
 						break;
 					case URI_ENCLOSED:
 					case URI_ENCLOSED:
-						to_b->body.len = tmp - to_b->body.s;
-						*tmp = 0;
+						to_b->uri.len = tmp - to_b->uri.s;
+						//*tmp = 0;
 						status = E_URI_ENCLOSED;
 						status = E_URI_ENCLOSED;
 						break;
 						break;
 					case URI_OR_TOKEN:
 					case URI_OR_TOKEN:
@@ -490,6 +490,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 				switch (status)
 				switch (status)
 				{
 				{
 					case START_TO:
 					case START_TO:
+						to_b->body.s=tmp;
 						status = S_URI_ENCLOSED;
 						status = S_URI_ENCLOSED;
 						break;
 						break;
 					case DISPLAY_QUOTED:
 					case DISPLAY_QUOTED:
@@ -517,9 +518,9 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 					case DISPLAY_QUOTED:
 					case DISPLAY_QUOTED:
 						break;
 						break;
 					case URI_ENCLOSED:
 					case URI_ENCLOSED:
-						*tmp = 0;
+						//*tmp = 0;
 					case E_URI_ENCLOSED:
 					case E_URI_ENCLOSED:
-						to_b->body.len = tmp - to_b->body.s;
+						to_b->uri.len = tmp - to_b->uri.s;
 						status = END;
 						status = END;
 						foo = 0;
 						foo = 0;
 						break;
 						break;
@@ -538,6 +539,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 				switch (status)
 				switch (status)
 				{
 				{
 					case START_TO:
 					case START_TO:
+						to_b->body.s = tmp;
 						status = DISPLAY_QUOTED;
 						status = DISPLAY_QUOTED;
 						break;
 						break;
 					case DISPLAY_QUOTED:
 					case DISPLAY_QUOTED:
@@ -563,10 +565,11 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 					case URI_OR_TOKEN:
 					case URI_OR_TOKEN:
 						foo = tmp;
 						foo = tmp;
 					case MAYBE_URI_END:
 					case MAYBE_URI_END:
-						to_b->body.len = foo - to_b->body.s;
+						to_b->uri.len = foo - to_b->uri.s;
 					case END:
 					case END:
+						to_b->body.len = tmp-to_b->body.s;
 						tmp = parse_to_param(tmp,end,to_b,&saved_status);
 						tmp = parse_to_param(tmp,end,to_b,&saved_status);
-						if (foo) *foo=0;
+						//if (foo) *foo=0;
 						goto endofheader;
 						goto endofheader;
 					case F_CRLF:
 					case F_CRLF:
 					case F_LF:
 					case F_LF:
@@ -583,11 +586,11 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 				switch (status)
 				switch (status)
 				{
 				{
 					case START_TO:
 					case START_TO:
-						to_b->body.s=tmp;
+						to_b->uri.s = to_b->body.s = tmp;
 						status = URI_OR_TOKEN;;
 						status = URI_OR_TOKEN;;
 						break;
 						break;
 					case S_URI_ENCLOSED:
 					case S_URI_ENCLOSED:
-						to_b->body.s=tmp;
+						to_b->uri.s=tmp;
 						status=URI_ENCLOSED;
 						status=URI_ENCLOSED;
 						break;
 						break;
 					case MAYBE_URI_END:
 					case MAYBE_URI_END:
@@ -603,7 +606,7 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 						/*previous=crlf and now !=' '*/
 						/*previous=crlf and now !=' '*/
 						goto endofheader;
 						goto endofheader;
 					default:
 					default:
-						DBG("DEBUG: parse_to: spitting out [%c] in status %d\n",
+						DBG("DEBUG:parse_to: spitting out [%c] in status %d\n",
 						*tmp,status );
 						*tmp,status );
 						goto error;
 						goto error;
 				}
 				}
@@ -617,10 +620,11 @@ endofheader:
 	/* check if error*/
 	/* check if error*/
 	switch(status){
 	switch(status){
 		case MAYBE_URI_END:
 		case MAYBE_URI_END:
-			*foo=0;
-			to_b->body.len = foo - to_b->body.s;
+			//*foo=0;
+			to_b->uri.len = foo - to_b->uri.s;
 		case END:
 		case END:
-		case E_PARA_VALUE:
+			to_b->body.len = tmp - to_b->body.s;
+	case E_PARA_VALUE:
 			*(tmp-1)=0;
 			*(tmp-1)=0;
 			break;
 			break;
 		default:
 		default: