Przeglądaj źródła

- small fixes/cosmetic changes

Andrei Pelinescu-Onciul 24 lat temu
rodzic
commit
ac79e819a1
2 zmienionych plików z 14 dodań i 15 usunięć
  1. 9 9
      forward.c
  2. 5 6
      msg_parser.h

+ 9 - 9
forward.c

@@ -41,10 +41,10 @@
 int forward_request( struct sip_msg* msg, struct proxy_l * p)
 {
 	unsigned int len;
-	char* buf=NULL;
-	struct sockaddr_in* to=NULL;
-
+	char* buf;
+	struct sockaddr_in* to;
 
+	to=0;
 	buf = build_req_buf_from_sip_req( msg, &len);
 	if (!buf){
 		LOG(L_ERR, "ERROR: forward_reply: building failed\n");
@@ -58,7 +58,7 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p)
 	}
 
 	 /* send it! */
-	DBG("Sending:", buf);
+	DBG("Sending:\n%s.\n", buf);
 	DBG("orig. len=%d, new_len=%d\n", msg->len, len );
 
 	to->sin_family = AF_INET;
@@ -102,6 +102,7 @@ error:
 int update_sock_struct_from_via( struct sockaddr_in* to,  struct via_body* via )
 {
 	int err;
+	struct hostent* he;
 
 	to->sin_family = AF_INET;
 	to->sin_port = (via->port)?htons(via->port): htons(SIP_PORT);
@@ -111,7 +112,6 @@ int update_sock_struct_from_via( struct sockaddr_in* to,  struct via_body* via )
 	if (err)
 #endif
 	{
-		struct hostent* he;
 		/* fork? gethostbyname will probably block... */
 		he=gethostbyname(via->host.s);
 		if (he==0){
@@ -129,9 +129,8 @@ int update_sock_struct_from_via( struct sockaddr_in* to,  struct via_body* via )
 int forward_reply(struct sip_msg* msg)
 {
 	int  r;
-	char* new_buf=NULL;
-	struct hostent* he=NULL;
-	struct sockaddr_in* to=NULL;
+	char* new_buf;
+	struct sockaddr_in* to;
 	unsigned int new_len;
 	struct sr_module *mod;
 #ifdef DNS_IP_HACK
@@ -140,6 +139,8 @@ int forward_reply(struct sip_msg* msg)
 
 
 
+	to=0;
+	new_buf=0;
 	/*check if first via host = us */
 	if (check_via){
 		for (r=0; r<addresses_no; r++)
@@ -162,7 +163,6 @@ int forward_reply(struct sip_msg* msg)
 		}
 	}
 	
-	to=0;
 	to=(struct sockaddr_in*)malloc(sizeof(struct sockaddr));
 	if (to==0){
 		LOG(L_ERR, "ERROR: forward_reply: out of memory\n");

+ 5 - 6
msg_parser.h

@@ -227,20 +227,19 @@ void free_sip_msg(struct sip_msg* msg);
    parsed; return 0 if those HFs can't be found
  */
 
-/*
 #define check_transaction_quadruple(msg ) \
-	(parse_headers(msg, HDR_FROM|HDR_TO|HDR_CALLID|HDR_CSEQ)!=-1 && \
-	 msg->from && msg->to && msg->callid && msg->cseq)
-*/
+	(parse_headers((msg), HDR_FROM|HDR_TO|HDR_CALLID|HDR_CSEQ)!=-1 && \
+	(msg)->from && (msg)->to && (msg)->callid && (msg)->cseq)
 
 /* restored to the original double-check and put macro params
    in parenthesses  -jiri */
-
+/* re-reverted to the shorter version -andrei 
 #define check_transaction_quadruple(msg ) \
    ( ((msg)->from || (parse_headers( (msg), HDR_FROM)!=-1 && (msg)->from)) && 	\
    ((msg)->to|| (parse_headers( (msg), HDR_TO)!=-1 && (msg)->to)) &&		\
    ((msg)->callid|| (parse_headers( (msg), HDR_CALLID)!=-1 && (msg)->callid)) &&\
    ((msg)->cseq|| (parse_headers( (msg), HDR_CSEQ)!=-1 && (msg)->cseq)) && \
    ((msg)->via1|| (parse_headers( (msg), HDR_VIA)!=-1 && (msg)->via1)) ) 
-
+*/
+	
 #endif