// first via header tells where the message is coming from.
// For response, this has already been recorded in the outgoing
// message.
if (sipMessage instanceof SIPRequest) {
Via v = (Via) viaList.getFirst();
Hop hop = sipStack.addressResolver.resolveAddress(v.getHop());
this.peerProtocol = v.getTransport();
try {
if(mySock != null) { // selfrouting makes socket = null
this.peerAddress = mySock.getInetAddress();
}
// Check to see if the received parameter matches
// the peer address and tag it appropriately.
// JvB: dont do this. It is both costly and incorrect
// Must set received also when it is a FQDN, regardless
// whether
// it resolves to the correct IP address
// InetAddress sentByAddress =
// InetAddress.getByName(hop.getHost());
// JvB: if sender added 'rport', must always set received
if (v.hasParameter(Via.RPORT)
|| !hop.getHost().equals(this.peerAddress.getHostAddress())) {
v.setParameter(Via.RECEIVED, this.peerAddress.getHostAddress());
}
// @@@ hagai
// JvB: technically, may only do this when Via already
// contains