if (sipMessage instanceof SipRequest) {
SipRequest sipRequest = (SipRequest)sipMessage;
SipHeaderFieldValue topVia = Utils.getTopVia(sipRequest);
String sentBy =
topVia.getParam(new SipHeaderParamName(RFC3261.PARAM_SENTBY));
if (sentBy != null) {
int colonPos = sentBy.indexOf(RFC3261.TRANSPORT_PORT_SEP);
if (colonPos < 0) {
colonPos = sentBy.length();
}
sentBy = sentBy.substring(0, colonPos);
if (!InetAddress.getByName(sentBy).equals(sourceIp)) {
topVia.addParam(new SipHeaderParamName(
RFC3261.PARAM_RECEIVED),
sourceIp.getHostAddress());
}
}
//RFC3581
//TODO check rport configuration
SipHeaderParamName rportName = new SipHeaderParamName(
RFC3261.PARAM_RPORT);
String rport = topVia.getParam(rportName);
if (rport != null && "".equals(rport)) {
topVia.removeParam(rportName);
topVia.addParam(rportName, String.valueOf(sourcePort));
}
ServerTransaction serverTransaction =
transactionManager.getServerTransaction(sipRequest);
if (serverTransaction == null) {