Subject: [Iptel] how to add a route header

From: zaghouani hamdi <[email-masked]>
Date: Thu, 1 Dec 2005 15:34:46 +0100 (CET)

hi,

I m using SER server.

the architecture : SipPhone -- server_1 --- server2

I want to create a fonction that allow me to add a new
header. I want to add a new route header, containing
the sip address of server_2, in the message received
by server_1 from SipPhone.

I  write the fonction below and it works(the route
header is added to the sip message). to test my sip
servers(small network), I m using SipPhone to
regester. 

the problem is that after registering and
de-registering many times (random  number)the server
is shutting down (children process killed). ( for
exemple , in the 7th registration the server shut
down). I think that the problem is due to this
fonction because when I dont put a " Route header" or
I use the fonction "append_fh" in ser.cfg file instead
of mine to add the header , I dont get this problem.

My fonction is :
  
int add_hf(struct sip_msg *msg, char* prefix, char*
content, char* suffix) {
	char* hf;
	struct lump* anchor;
	int len = strlen(content);

	if (prefix != NULL)
		len += strlen(prefix);
	if (suffix != NULL)
		len += strlen(suffix);

	hf = (char*)malloc(len * sizeof(char) + 1);

	if (prefix != NULL)
		strcat(hf, prefix);
	strcat(hf, content);
	if (suffix != NULL)
		strcat(hf, suffix);
	hf[len+1] = '\0';
	
	parse_headers(msg, HDR_EOH, 0);
	anchor = anchor_lump(msg , msg->headers->name.s -
msg->buf, 0, 0);
	insert_new_lump_before(anchor, hf, len, 0);

	return 1;
}

thinks a lot 

Hamdi

		
___________________________________________________________________________ 
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger 
Téléchargez cette version sur http://fr.messenger.yahoo.com

_______________________________________________
Iptel mailing list
[email-masked]
https://www1.ietf.org/mailman/listinfo/iptel