} else {
sipStack.getStackLogger().logDebug("Not sending ping back");
}
return;
}
Via topMostVia = sipMessage.getTopmostVia();
// Check for the required headers.
if (sipMessage.getFrom() == null || sipMessage.getTo() == null
|| sipMessage.getCallId() == null
|| sipMessage.getCSeq() == null
|| topMostVia == null) {
String badmsg = new String(msgBytes);
if (sipStack.isLoggingEnabled()) {
this.sipStack.getStackLogger().logError("bad message " + badmsg);
this.sipStack.getStackLogger().logError(">>> Dropped Bad Msg "
+ "From = " + sipMessage.getFrom() + "To = "
+ sipMessage.getTo() + "CallId = "
+ sipMessage.getCallId() + "CSeq = "
+ sipMessage.getCSeq() + "Via = "
+ sipMessage.getViaHeaders());
}
return;
}
// For a request first via header tells where the message
// is coming from.
// For response, just get the port from the packet.
if (sipMessage instanceof SIPRequest) {
Hop hop = sipStack.addressResolver.resolveAddress(topMostVia.getHop());
this.peerPort = hop.getPort();
this.peerProtocol = topMostVia.getTransport();
this.peerPacketSourceAddress = packet.getAddress();
this.peerPacketSourcePort = packet.getPort();
try {
this.peerAddress = packet.getAddress();
// Check to see if the received parameter matches
// the peer address and tag it appropriately.
boolean hasRPort = topMostVia.hasParameter(Via.RPORT);
if (hasRPort
|| !hop.getHost().equals(
this.peerAddress.getHostAddress())) {
topMostVia.setParameter(Via.RECEIVED, this.peerAddress
.getHostAddress());
}
if (hasRPort) {
topMostVia.setParameter(Via.RPORT, Integer
.toString(this.peerPacketSourcePort));
}
} catch (java.text.ParseException ex1) {
InternalErrorHandler.handleException(ex1);
}
} else {
this.peerPacketSourceAddress = packet.getAddress();
this.peerPacketSourcePort = packet.getPort();
this.peerAddress = packet.getAddress();
this.peerPort = packet.getPort();
this.peerProtocol = topMostVia.getTransport();
}
this.processMessage(sipMessage);
}