Via header updates (issues:9,21,109,111,147,149)

5 views
Skip to first unread message

Bryan

unread,
Oct 11, 2009, 5:54:01 PM10/11/09
to Sipdroid Developers
Hi,

This is a bit different from the thread about authenticating with the
localhost ip, so I'm starting a new thread. Initiating with localhost,
though misleading, isn't the real issue.

I think I've nearly solved the issues (9,21,109,111,147,149)
surrounding the branch not being updated and the received and rport
values being ignored in the via header.

I think that the SipProvider.via_addr, SipProvider.host_port, branch,
and via header should all be updated in:
org.zoolu.sip.provider.SipProvider.processReceivedMessage. The problem
that I'm running into is that the listeners are tracked using a
transaction id that is built off of those values, so changing them
breaks the callbacks to the listeners from the sip_provider.

Here's what I'm looking at, but how do I fix the callbacks to the
listeners?

<snippet>
protected void processReceivedMessage(Message msg) {
try { // logs
</snippet>
...
<snippet>
if (msg.isRequest()) {
ViaHeader vh = msg.getViaHeader();
boolean via_changed = false;
String src_addr = msg.getRemoteAddress();
int src_port = msg.getRemotePort();
String via_addr = vh.getHost();
int via_port = vh.getPort();
if (via_port <= 0)
via_port = SipStack.default_port;
if (!via_addr.equals(src_addr)) {
vh.setReceived(src_addr);
via_changed = true;
}
if (vh.hasRport()) {
vh.setRport(src_port);
via_changed = true;
} else {
if (force_rport && via_port != src_port) {
vh.setRport(src_port);
via_changed = true;
}
}
if (via_changed) {
msg.removeViaHeader();
msg.addViaHeader(vh);
}
}
// my new code starts here
// handle "received" and "rport" parameters FOR RESPONSES TOO!
// pick a new branch (RFC3261), and handle received and rport
values
(RFC3581)
else {
ViaHeader vh = msg.getViaHeader();
String received_addr = vh.getReceived();
int via_port = vh.getRport();
if (received_addr != null)
via_addr = received_addr;
if (via_port > 0)
host_port = via_port;
// start a new transaction
vh = new ViaHeader(vh.getProtocol(), via_addr,
host_port);
if (rport)
vh.setRport();
vh.setBranch(pickBranch(msg));
msg.removeViaHeader();
msg.addViaHeader(vh);
// there's no listener keyed on the new transactionId
}
</snippet>
...

Any help would be really great. Thank you!

Bryan
Reply all
Reply to author
Forward
0 new messages