if (sipStack.isLoggingEnabled()) {
this.sipStack.getStackLogger().logDebug("Rejecting message ! + Null message parsed.");
}
return;
}
ViaList viaList = sipMessage.getViaHeaders();
// Check for the required headers.
if (sipMessage.getFrom() == null || sipMessage.getTo() == null
|| sipMessage.getCallId() == null
|| sipMessage.getCSeq() == null
|| sipMessage.getViaHeaders() == 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());
}
sipStack.getStackLogger().logError("BAD MESSAGE!");
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) {
Via v = (Via) viaList.getFirst();
Hop hop = sipStack.addressResolver.resolveAddress(v.getHop());
this.peerPort = hop.getPort();
this.peerProtocol = v.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 = v.hasParameter(Via.RPORT);
if (hasRPort
|| !hop.getHost().equals(
this.peerAddress.getHostAddress())) {
v.setParameter(Via.RECEIVED, this.peerAddress
.getHostAddress());
}
if (hasRPort) {
v.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 = ((Via) viaList.getFirst()).getTransport();
}
this.processMessage(sipMessage);
}