private static int generateNcFromMessage(Message message) { int nc = 1; CSeqHeader cseq = (CSeqHeader) message.getHeader(CSeqHeader.NAME); if (cseq != null) { nc = (int) (cseq.getSeqNumber() % Integer.MAX_VALUE); } return nc; }
/** * Compare two cseq headers for equality. * @param other Object to compare against. * @return true if the two cseq headers are equals, false * otherwise. */ public boolean equals(Object other) { if (other instanceof CSeqHeader) { final CSeqHeader o = (CSeqHeader) other; return this.getSeqNumber() == o.getSeqNumber() && this.getMethod().equals( o.getMethod() ); } return false; }
/** * Return true if this request can be consumed by the dialog. * * @param dialogRequest * is the request to check with the dialog. * @return true if the dialogRequest sequence number matches the next * consumable seqno. */ public synchronized boolean isRequestConsumable(SIPRequest dialogRequest) { // have not yet set remote seqno - this is a fresh if (dialogRequest.getMethod().equals(Request.ACK)) throw new RuntimeException("Illegal method"); // For loose validation this function is delegated to the application if (!this.isSequenceNumberValidation()) { return true; } // JvB: Acceptable iff remoteCSeq < cseq. remoteCSeq==-1 // when not defined yet, so that works too return remoteSequenceNumber < dialogRequest.getCSeq().getSeqNumber(); }
public void setOriginalRequest(MobicentsSipServletRequest originalRequest) { // Determine the direction of the request. Either it's from the dialog initiator (the caller) // or from the callee if(storeTerminationInfo) { if(((MessageExt)originalRequest.getMessage()).getFromHeader().getTag().equals(callerFromTag)) { terminationInfo.setCallerCSeq((((MessageExt)originalRequest.getMessage()).getCSeqHeader().getSeqNumber())); } else { // If it's from the callee we should send it in the other direction terminationInfo.setCalleeCSeq((((MessageExt)originalRequest.getMessage()).getCSeqHeader().getSeqNumber())); } } this.originalRequest = (SipServletRequestImpl) originalRequest; }
if(logger.isDebugEnabled()) { logger.debug("trying to cleanup message "+ sipServletMessage + " and related dialog app data " + dialogAppData); logger.debug("is dialog established " + (Request.INVITE.equalsIgnoreCase(sipServletMessage.getMethod()) && isAckReceived(((MessageExt)sipServletMessage.getMessage()).getCSeqHeader().getSeqNumber()))); logger.debug("is dialog creating method " + JainSipUtils.DIALOG_CREATING_METHODS.contains(sipServletMessage.getMethod())); logger.debug("is dialog terminating method " + JainSipUtils.DIALOG_TERMINATING_METHODS.contains(sipServletMessage.getMethod())); if((Request.INVITE.equalsIgnoreCase(sipServletMessage.getMethod()) && isAckReceived(((MessageExt)sipServletMessage.getMessage()).getCSeqHeader().getSeqNumber()))) { if(logger.isDebugEnabled()) { logger.debug("cleaning INVITE and ack received for it for dialog "+ sessionCreatingDialog);
public boolean validateCSeq(MobicentsSipServletRequest sipServletRequest) { final Request request = (Request) sipServletRequest.getMessage(); final long localCseq = cseq; final long remoteCSeq = ((CSeqHeader) request.getHeader(CSeqHeader.NAME)).getSeqNumber(); final String method = request.getMethod(); final boolean isAck = Request.ACK.equalsIgnoreCase(method);
final SipServletMessageImpl sipServletMessage = transactionApplicationData.getSipServletMessage(); if(sipServletMessage != null && sipServletMessage instanceof SipServletRequestImpl && ((MessageExt)request.getMessage()).getCSeqHeader().getSeqNumber() == ((MessageExt)sipServletMessage.getMessage()).getCSeqHeader().getSeqNumber() && ((MessageExt)request.getMessage()).getCallIdHeader().getCallId().equals(((MessageExt)sipServletMessage.getMessage()).getCallIdHeader().getCallId())) { return (SipServletRequestImpl)sipServletMessage;
public void checkRetransmissionForForking(SIPResponse response) { final int statusCode = response.getStatusCode(); final String responseMethod = response.getCSeqHeader().getMethod(); final long responseCSeqNumber = response.getCSeq().getSeqNumber(); boolean isRetransmission = !responsesReceivedInForkingCase.add(statusCode + "/" + responseCSeqNumber + "/" + responseMethod); response.setRetransmission(isRetransmission); if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) { logger.logDebug( "marking response as retransmission " + isRetransmission + " for dialog " + this); } }
/** * Return true if ACK was sent ( for client tx ). For server tx, this is a * NO-OP ( we dont send ACK). */ public boolean isAckSent(long cseqNo) { if (this.getLastTransaction() == null) return true; if (this.getLastTransaction() instanceof ClientTransaction) { if (this.getLastAckSent() == null) { return false; } else { return cseqNo <= ((SIPRequest) this.getLastAckSent()).getCSeq() .getSeqNumber(); } } else { return true; } }
public void on2xxResponse(ResponseEvent event, ActivityContextInterface aci) { final CSeqHeader cseq = (CSeqHeader) event.getResponse().getHeader( CSeqHeader.NAME); if (cseq.getMethod().equals(Request.INVITE)) { // lets ack it ourselves to avoid UAS retransmissions due to // forwarding of this response and further UAC Ack // note that the app does not handles UAC ACKs try { final Request ack = event.getDialog().createAck( cseq.getSeqNumber()); event.getDialog().sendAck(ack); } catch (Exception e) { tracer.severe("Unable to ack INVITE's 200 ok from UAS", e); } } else if (cseq.getMethod().equals(Request.BYE) || cseq.getMethod().equals(Request.CANCEL)) { // not forwarded to the other dialog return; } processResponse(event, aci); }
logger.debug("dialog to create the ack Request " + dialog); Request ackRequest = dialog.createAck(cSeqHeader.getSeqNumber());
((MessageExt)((MobicentsSipServletRequest)proxiedResponse.getRequest()).getMessage()).getCSeqHeader().getSeqNumber());
cSeq.setSeqNumber(cSeq.getSeqNumber() + 1l); } catch (InvalidArgumentException ex) { throw new SipException("Invalid CSeq -- could not increment : " + cSeq.getSeqNumber());
setLocalSequenceNumber(sipRequest.getCSeq().getSeqNumber()); this.originalLocalSequenceNumber = getLocalSeqNumber(); this.setLocalTag(sipRequest.getFrom().getTag()); setRemoteSequenceNumber(sipRequest.getCSeq().getSeqNumber()); long lastReferCSeq = ((SIPRequest) transaction.getRequest()).getCSeq().getSeqNumber(); this.eventHeader = new Event(); this.eventHeader.setEventType("refer");
final long cSeq = ((CSeqHeader)request.getHeader(CSeqHeader.NAME)).getSeqNumber(); sipSessionImpl.setCseq(cSeq);
/** * create a sip dialog with a response ( no tx) */ public SIPDialog(SipProviderImpl sipProvider, SIPResponse sipResponse) { this(sipProvider); this.sipStack = (SIPTransactionStack) sipProvider.getSipStack(); this.setLastResponse(null, sipResponse); this.localSequenceNumber = sipResponse.getCSeq().getSeqNumber(); this.originalLocalSequenceNumber = localSequenceNumber; this.localParty = sipResponse.getFrom().getAddress(); this.remoteParty = sipResponse.getTo().getAddress(); this.method = sipResponse.getCSeq().getMethod(); this.callIdHeader = sipResponse.getCallId(); this.serverTransactionFlag = false; this.setLocalTag(sipResponse.getFrom().getTag()); this.setRemoteTag(sipResponse.getTo().getTag()); if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) { logger.logDebug("Creating a dialog : " + this); logger.logStackTrace(); } this.isBackToBackUserAgent = sipStack.isBackToBackUserAgent; addEventListener(sipStack); releaseReferencesStrategy = sipStack.getReleaseReferencesStrategy(); }
localSequenceNumber = subscribeTx.getCSeq(); SIPRequest not = (SIPRequest) notifyST.getRequest(); remoteSequenceNumber = not.getCSeq().getSeqNumber(); setDialogId(not.getDialogId(true)); setLocalTag(not.getToTag());
sipDialog.doDeferredDeleteIfNoAckSent(sipResponse.getCSeq().getSeqNumber());
long cseqNo = ((SIPRequest) request).getCSeq().getSeqNumber(); if (!this.isAckSent(cseqNo)) { releaseAckSem = true; this.highestSequenceNumberAcknowledged = Math.max( this.highestSequenceNumberAcknowledged, ((SIPRequest) ackRequest).getCSeq().getSeqNumber()); if (releaseAckSem && this.isBackToBackUserAgent) { this.releaseAckSem();
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 = this.createRequest(Request.PRACK, sipResponse.getTopmostVia().getTransport()); 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); if (this.proxyAuthorizationHeader != null) { sipRequest.addHeader(proxyAuthorizationHeader); } return (Request) sipRequest; } catch (Exception ex) { InternalErrorHandler.handleException(ex); return null; } }