public SipRequest getSipRequest(SipMessage sipMessage) {
if (sipMessage instanceof SipRequest) {
return (SipRequest) sipMessage;
} else if (sipMessage instanceof SipResponse) {
SipResponse sipResponse = (SipResponse) sipMessage;
Transaction transaction = (Transaction)transactionManager
.getClientTransaction(sipResponse);
if (transaction == null) {
transaction = (Transaction)transactionManager
.getServerTransaction(sipResponse);
}
if (transaction == null) {
return null;
}
return transaction.getRequest();
} else {
return null;
}
}