use of gov.nist.javax.sip.header.RAck in project XobotOS by xamarin.
the class SIPDialog method createPrack.
/*
* (non-Javadoc) Retransmissions of the reliable provisional response cease when a matching
* PRACK is received by the UA core. PRACK is like any other request within a dialog, and the
* UAS core processes it according to the procedures of Sections 8.2 and 12.2.2 of RFC 3261. A
* matching PRACK is defined as one within the same dialog as the response, and whose method,
* CSeq-num, and response-num in the RAck header field match, respectively, the method from
* the CSeq, the sequence number from the CSeq, and the sequence number from the RSeq of the
* reliable provisional response.
*
* @see javax.sip.Dialog#createPrack(javax.sip.message.Response)
*/
public Request createPrack(Response relResponse) throws DialogDoesNotExistException, SipException {
if (this.getState() == null || this.getState().equals(DialogState.TERMINATED))
throw new DialogDoesNotExistException("Dialog not initialized or terminated");
if ((RSeq) relResponse.getHeader(RSeqHeader.NAME) == null) {
throw new SipException("Missing RSeq Header");
}
try {
SIPResponse sipResponse = (SIPResponse) relResponse;
SIPRequest sipRequest = (SIPRequest) this.createRequest(Request.PRACK, (SIPResponse) relResponse);
String toHeaderTag = sipResponse.getTo().getTag();
sipRequest.setToTag(toHeaderTag);
RAck rack = new RAck();
RSeq rseq = (RSeq) relResponse.getHeader(RSeqHeader.NAME);
rack.setMethod(sipResponse.getCSeq().getMethod());
rack.setCSequenceNumber((int) sipResponse.getCSeq().getSeqNumber());
rack.setRSequenceNumber(rseq.getSeqNumber());
sipRequest.setHeader(rack);
return (Request) sipRequest;
} catch (Exception ex) {
InternalErrorHandler.handleException(ex);
return null;
}
}
use of gov.nist.javax.sip.header.RAck in project XobotOS by xamarin.
the class SIPDialog method handlePrack.
/**
* Do the processing necessary for the PRACK
*
* @param prackRequest
* @return true if this is the first time the tx has seen the prack ( and hence needs to be
* passed up to the TU)
*/
public boolean handlePrack(SIPRequest prackRequest) {
/*
* The RAck header is sent in a PRACK request to support reliability of provisional
* responses. It contains two numbers and a method tag. The first number is the value from
* the RSeq header in the provisional response that is being acknowledged. The next
* number, and the method, are copied from the CSeq in the response that is being
* acknowledged. The method name in the RAck header is case sensitive.
*/
if (!this.isServer()) {
if (sipStack.isLoggingEnabled())
sipStack.getStackLogger().logDebug("Dropping Prack -- not a server Dialog");
return false;
}
SIPServerTransaction sipServerTransaction = (SIPServerTransaction) this.getFirstTransaction();
SIPResponse sipResponse = sipServerTransaction.getReliableProvisionalResponse();
if (sipResponse == null) {
if (sipStack.isLoggingEnabled())
sipStack.getStackLogger().logDebug("Dropping Prack -- ReliableResponse not found");
return false;
}
RAck rack = (RAck) prackRequest.getHeader(RAckHeader.NAME);
if (rack == null) {
if (sipStack.isLoggingEnabled())
sipStack.getStackLogger().logDebug("Dropping Prack -- rack header not found");
return false;
}
CSeq cseq = (CSeq) sipResponse.getCSeq();
if (!rack.getMethod().equals(cseq.getMethod())) {
if (sipStack.isLoggingEnabled())
sipStack.getStackLogger().logDebug("Dropping Prack -- CSeq Header does not match PRACK");
return false;
}
if (rack.getCSeqNumberLong() != cseq.getSeqNumber()) {
if (sipStack.isLoggingEnabled())
sipStack.getStackLogger().logDebug("Dropping Prack -- CSeq Header does not match PRACK");
return false;
}
RSeq rseq = (RSeq) sipResponse.getHeader(RSeqHeader.NAME);
if (rack.getRSequenceNumber() != rseq.getSeqNumber()) {
if (sipStack.isLoggingEnabled())
sipStack.getStackLogger().logDebug("Dropping Prack -- RSeq Header does not match PRACK");
return false;
}
return sipServerTransaction.prackRecieved();
}
Aggregations