Hello,
I am trying to add a function to SER, in order to only alter the host part
of the Contact URI.
To do that, I'm trying to draw inspiration from the existing
fix_nated_contact_f function written in nathelper.c
Problem is there are various points I just don't seem to understand.
If anyone can help me answer these questions, I would sure appreciate it!!
1- the parameters declared for the fix_nated_contact_f function are (struct
sip_msg* msg, char* str1, char* str2)
But the code itself only exploits the first parameter, if I am not mistaken.
If that is the case, what are the others here for?
2- the lines:
if (uri.port.len==0)
uri.port.s = uri.host.s + uri.host.len;
What I understand from this is the following: If there isn't a port
specified in the original message (the port pointer is not pointing to
anything), set the pointer's value (the pointer in the port part of the URI
structure) to point to the memory location right after where the host part
in the URI ends.
Is that correct? And, if so, is that done in order to prepare for an
eventual insertion of a port when going through the NAT?
3- the line:
offset = c->uri.s - msg->buf;
I won't even venture a guess here. A total mystery to me.
4- the line:
len = c->uri.len + strlen(cp) + 6 /* :port */ - (uri.port.s +
uri.port.len - uri.host.s) + 1;
What I gather here is that we're computing the relative difference in size
(length) between the already existing ip:port field in the message, and the
one we're about to replace it with (source address of the packet), is that
right?
5- the part:
temp[0] = uri.host.s[0];
temp[1] = c->uri.s[c->uri.len];
Euh!! Is he taking just the first and last characters from the URI host
string, putting them in a "safe place" (to be later restored) and putting
'\0' characters instead to "delimit" something or other? Or am I totally
off
mark???
6- the line:
len1 = snprintf(buf, len, "%s%s:%d%s", c->uri.s, cp,
msg->rcv.src_port,uri.port.s + uri.port.len);
Here, len1 will hold the size of the memory size (buffer) needed to insert
the new data, right?
7- the condition:
if (len1 < len)
len = len1;
You'll have to enlighten me on that one, cause I don't see it...
I'm sorry to bother you with such a long mail, but I need the help!
And if someone has a better approach to my original problem(cf. first line
of the mail) please do not hesitate :-)
Thank you in advance
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/