/* * returns the CSeq injected packet * @out: packet in error case */ private String setCSeq(String packet, int cseq) { if (packet == null) return null; if (packet.indexOf(SIP_CSEQ) == -1) return packet; int indexStart = packet.indexOf(SIP_CSEQ) + SIP_CSEQ.length(); int indexEnd = packet.indexOf(" ", indexStart); if (indexEnd >= indexStart) { String cseqString = new Integer(cseq).toString(); return packet.substring(0, indexStart) + cseqString + packet.substring(indexEnd); } else return packet; } // setCSeq
/* * returns the CSeq from a given packet * @param packet data to be analyse * @return <code>-1<code> error case * @return <code>0<code> success */ private int getCSeq(String packet) { if (packet == null) return -1; if (packet.indexOf(SIP_CSEQ) == -1) return -1; int indexStart = packet.indexOf(SIP_CSEQ) + SIP_CSEQ.length(); // indexStart = packet.indexOf(" ", indexStart); int indexEnd = packet.indexOf(" ", indexStart); if (indexEnd >= indexStart) { if (m_verbose) System.out.println("SipStack.getCSeq: CSeq is " + packet.substring(indexStart, indexEnd)); return new Integer(packet.substring(indexStart, indexEnd)).intValue(); } else return -1; } // getCSeq