I have been testing the last changes about the "rport-received" tags, and I have found the next bug:
when using UDP transport, if the IP address and port in the "Via" field differ from the IP address and port of the incoming packet, the "received" and "port" tags added to the Via of the response are correct, but the packet is sent back to the "received" IP address BUT to an incorrect port ( this should be the "rport" port ), that generates an ICMP "Destination unrecheable port".
I have been capturing these packets and I think I have found exactly where is the problem. For example in the next sequence:
1)REQUEST PACKET: ( REGISTER for example ) Source: 192.168.1.2:1667 Destination: 192.168.1.3:5060 "Via: SIP/2.0/UDP 192.168.1.100:6969;rport"
2)RESPONSE PACKET: Source: 192.168.1.3:5060 Destination: 192.168.1.3:33542 <- HERE IS THE PROBLEM, this should be "rport" "Via: SIP/2.0/UDP 192.168.1.100:6969;rport=1667;received=192.168.1.2"<-but this is correct
3)ICMP PACKET: Source 192.168.1.2 Destination: 192.168.1.3 Type:3 "Destination unrecheable" Code:3 "Port unrecheable"
I've been checking other pairs of ports sent and received like 1667-33542, 1507-58117, 1509-58629, 1511-59141 and the second is the network address order of the first ( 1667 = ntohs(33542) ) .
I think that you forget to make a htons() of the port received in host format before sending the packet back to network.
Please, let me know when this issue is solved in the CVS.
Best regards and congratulations for your excellent work.
Sergio.