瀏覽代碼

parse param to fixed

Bogdan-Andrei Iancu 23 年之前
父節點
當前提交
e65823ce9b
共有 3 個文件被更改,包括 43 次插入37 次删除
  1. 3 3
      msg_parser.c
  2. 37 31
      parse_to.c
  3. 3 3
      test/th-uri.cfg

+ 3 - 3
msg_parser.c

@@ -275,9 +275,9 @@ 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",
-				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);
+			DBG("DEBUG: get_hdr_field: <%s> [%d]; uri=[%.*s] \n",
+				hdr->name.s, hdr->body.len, to_b->uri.len,to_b->uri.s);
+			DBG("DEBUG: to body [%.*s]\n",to_b->body.len,to_b->body.s);
 			break;
 			break;
 		case HDR_FROM:
 		case HDR_FROM:
 		case HDR_CALLID:
 		case HDR_CALLID:

+ 37 - 31
parse_to.c

@@ -22,6 +22,8 @@ enum{ S_PARA_NAME=20, PARA_NAME, S_EQUAL, S_PARA_VALUE, TAG1, TAG2, TAG3
 
 
 #define add_param( _param , _body ) \
 #define add_param( _param , _body ) \
 	do{\
 	do{\
+		DBG("DEBUG: add_param: %.*s=%.*s\n",param->name.len,param->name.s,\
+			param->value.len,param->value.s);\
 		if (!(_body)->param_lst)  (_body)->param_lst=(_param);\
 		if (!(_body)->param_lst)  (_body)->param_lst=(_param);\
 		else (_body)->last_param->next=(_param);\
 		else (_body)->last_param->next=(_param);\
 		(_body)->last_param =(_param);\
 		(_body)->last_param =(_param);\
@@ -112,7 +114,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
 						goto endofheader;
 						goto endofheader;
 					default:
 					default:
 						LOG( L_ERR , "ERROR: parse_to_param : "
 						LOG( L_ERR , "ERROR: parse_to_param : "
-						"unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
+							"unexpected char [%c] in status %d: <<%.*s>> .\n",
+							*tmp,status, tmp-buffer, buffer);
 				}
 				}
 				break;
 				break;
 			case '\r':
 			case '\r':
@@ -149,8 +152,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
 						goto endofheader;
 						goto endofheader;
 					default:
 					default:
 						LOG( L_ERR , "ERROR: parse_to_param : "
 						LOG( L_ERR , "ERROR: parse_to_param : "
-						"unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
-						/* "unexpected char [%c] in status %d .\n",*tmp,status); */
+							"unexpected char [%c] in status %d: <<%.*s>> .\n",
+							*tmp,status, tmp-buffer, buffer);
 						goto error;
 						goto error;
 				}
 				}
 				break;
 				break;
@@ -168,8 +171,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
 						}
 						}
 					default:
 					default:
 						LOG( L_ERR , "ERROR: parse_to_param : "
 						LOG( L_ERR , "ERROR: parse_to_param : "
-						"unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
-						/* "unexpected char [%c] in status %d .\n",*tmp,status); */
+							"unexpected char [%c] in status %d: <<%.*s>> .\n",
+							*tmp,status, tmp-buffer, buffer);
 						goto error;
 						goto error;
 				}
 				}
 				break;
 				break;
@@ -193,8 +196,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
 						goto endofheader;
 						goto endofheader;
 					default:
 					default:
 						LOG( L_ERR , "ERROR: parse_to_param :"
 						LOG( L_ERR , "ERROR: parse_to_param :"
-						"unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
-						/* "unexpected char [%c] in status %d .\n",*tmp,status); */
+							"unexpected char [%c] in status %d: <<%.*s>> .\n",
+							*tmp,status, tmp-buffer, buffer);
 						goto error;
 						goto error;
 				}
 				}
 				break;
 				break;
@@ -203,6 +206,9 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
 				{
 				{
 					case PARA_VALUE_QUOTED:
 					case PARA_VALUE_QUOTED:
 						break;
 						break;
+					case PARA_VALUE_TOKEN:
+						param->value.len=tmp-param->value.s-1;
+						add_param(param,to_b);
 					case PARA_START:
 					case PARA_START:
 						*tmp=0;
 						*tmp=0;
 					case E_PARA_VALUE:
 					case E_PARA_VALUE:
@@ -224,8 +230,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
 						goto endofheader;
 						goto endofheader;
 					default:
 					default:
 						LOG( L_ERR , "ERROR: parse_to_param :"
 						LOG( L_ERR , "ERROR: parse_to_param :"
-						"unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
-						/* "unexpected char [%c] in status %d .\n",*tmp,status); */
+							"unexpected char [%c] in status %d: <<%.*s>> .\n",
+							*tmp,status, tmp-buffer, buffer);
 						goto error;
 						goto error;
 				}
 				}
 				break;
 				break;
@@ -257,8 +263,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
 						goto endofheader;
 						goto endofheader;
 					default:
 					default:
 						LOG( L_ERR , "ERROR: parse_to_param :"
 						LOG( L_ERR , "ERROR: parse_to_param :"
-						"unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
-						/* " unexpected char [%c] in status %d .\n",*tmp,status); */
+							"unexpected char [%c] in status %d: <<%.*s>> .\n",
+							*tmp,status, tmp-buffer, buffer);
 						goto error;
 						goto error;
 				}
 				}
 				break;
 				break;
@@ -292,8 +298,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
 						goto endofheader;
 						goto endofheader;
 					default:
 					default:
 						LOG( L_ERR , "ERROR: parse_to_param : "
 						LOG( L_ERR , "ERROR: parse_to_param : "
-						"unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
-						/* "unexpected char [%c] in status %d .\n",*tmp,status); */
+							"unexpected char [%c] in status %d: <<%.*s>> .\n",
+							*tmp,status, tmp-buffer, buffer);
 						goto error;
 						goto error;
 				}
 				}
 				break;
 				break;
@@ -327,8 +333,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
 						goto endofheader;
 						goto endofheader;
 					default:
 					default:
 						LOG( L_ERR , "ERROR: parse_to_param : "
 						LOG( L_ERR , "ERROR: parse_to_param : "
-						"unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
-						/* "unexpected char [%c] in status %d .\n",*tmp,status); */
+							"unexpected char [%c] in status %d: <<%.*s>> .\n",
+							*tmp,status, tmp-buffer, buffer);
 						goto error;
 						goto error;
 				}
 				}
 				break;
 				break;
@@ -356,8 +362,8 @@ char* parse_to_param(char *buffer, char *end, struct to_body *to_b,
 						goto endofheader;
 						goto endofheader;
 					default:
 					default:
 						LOG( L_ERR , "ERROR: parse_to_param : "
 						LOG( L_ERR , "ERROR: parse_to_param : "
-						"unexpected char [%c] in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
-						/* "unexpected char [%c] in status %d .\n",*tmp,status); */
+							"unexpected char [%c] in status %d: <<%.*s>> .\n",
+							*tmp,status, tmp-buffer, buffer);
 						goto error;
 						goto error;
 				}
 				}
 				break;
 				break;
@@ -460,8 +466,8 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 						goto endofheader;
 						goto endofheader;
 					default:
 					default:
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
-						"in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
-						/* "in status %d .\n",*tmp,status); */
+							"in status %d: <<%.*s>> .\n",
+							*tmp,status, tmp-buffer, buffer);
 				}
 				}
 				break;
 				break;
 			case '\r':
 			case '\r':
@@ -484,8 +490,8 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 						goto endofheader;
 						goto endofheader;
 					default:
 					default:
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
-						"in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
-						/* "in status %d .\n",*tmp,status); */
+							"in status %d: <<%.*s>> .\n",
+							*tmp,status, tmp-buffer, buffer);
 						goto error;
 						goto error;
 				}
 				}
 				break;
 				break;
@@ -503,8 +509,8 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 						}
 						}
 					default:
 					default:
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
-						"in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
-						/* "in status %d .\n",*tmp,status); */
+							"in status %d: <<%.*s>> .\n",
+							*tmp,status, tmp-buffer, buffer);
 						goto error;
 						goto error;
 				}
 				}
 				break;
 				break;
@@ -530,8 +536,8 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 						goto endofheader;
 						goto endofheader;
 					default:
 					default:
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
-						"in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
-						/* "in status %d .\n",*tmp,status); */
+							"in status %d: <<%.*s>> .\n",
+							*tmp,status, tmp-buffer, buffer);
 						goto error;
 						goto error;
 				}
 				}
 				break;
 				break;
@@ -554,8 +560,8 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 						goto endofheader;
 						goto endofheader;
 					default:
 					default:
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
-						"in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
-						/* "in status %d .\n",*tmp,status); */
+							"in status %d: <<%.*s>> .\n",
+							*tmp,status, tmp-buffer, buffer);
 						goto error;
 						goto error;
 				}
 				}
 				break;
 				break;
@@ -576,8 +582,8 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 						goto endofheader;
 						goto endofheader;
 					default:
 					default:
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
-						"in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
-						/* "in status %d .\n",*tmp,status); */
+							"in status %d: <<%.*s>> .\n",
+							*tmp,status, tmp-buffer, buffer);
 						goto error;
 						goto error;
 				}
 				}
 				break;
 				break;
@@ -603,8 +609,8 @@ char* parse_to(char* buffer, char *end, struct to_body *to_b)
 						goto endofheader;
 						goto endofheader;
 					default:
 					default:
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
 						LOG( L_ERR , "ERROR: parse_to : unexpected char [%c] "
-						"in status %d: <<%.*s>> .\n",*tmp,status, tmp-buffer, buffer);
-						/* "in status %d .\n",*tmp,status); */
+							"in status %d: <<%.*s>> .\n",
+							*tmp,status, tmp-buffer, buffer);
 						goto error;
 						goto error;
 				}
 				}
 				break;
 				break;

+ 3 - 3
test/th-uri.cfg

@@ -64,9 +64,9 @@ route{
 	t_clear_forks();
 	t_clear_forks();
 /*	if (method=="INVITE")
 /*	if (method=="INVITE")
 	{
 	{
-		#t_fork_to("195.37.78.143","5060");
+		t_fork_to("195.37.78.125","5060");
 		#t_fork_to("195.37.78.246","5060");
 		#t_fork_to("195.37.78.246","5060");
-	};
-*/	
+	};*/
+	
 	t_relay();
 	t_relay();
 }
 }