Ejemplo n.º 1
0
 /**
  * Helper function that checks whether or not the data could be a SIP message. It is a very basic
  * check but if it doesn't go through it definitely is not a SIP message.
  *
  * @param data
  * @return
  */
 public static boolean couldBeSipMessage(final Buffer data) throws IOException {
   final byte a = data.getByte(0);
   final byte b = data.getByte(1);
   final byte c = data.getByte(2);
   return a == 'S' && b == 'I' && c == 'P'
       || // response
       a == 'I' && b == 'N' && c == 'V'
       || // INVITE
       a == 'A' && b == 'C' && c == 'K'
       || // ACK
       a == 'B' && b == 'Y' && c == 'E'
       || // BYE
       a == 'O' && b == 'P' && c == 'T'
       || // OPTIONS
       a == 'C' && b == 'A' && c == 'N'
       || // CANCEL
       a == 'M' && b == 'E' && c == 'S'
       || // MESSAGE
       a == 'R' && b == 'E' && c == 'G'
       || // REGISTER
       a == 'I' && b == 'N' && c == 'F'
       || // INFO
       a == 'P' && b == 'R' && c == 'A'
       || // PRACK
       a == 'S' && b == 'U' && c == 'B'
       || // SUBSCRIBE
       a == 'N' && b == 'O' && c == 'T'
       || // NOTIFY
       a == 'U' && b == 'P' && c == 'D'
       || // UPDATE
       a == 'R' && b == 'E' && c == 'F'
       || // REFER
       a == 'P' && b == 'U' && c == 'B'; // PUBLISH
 }
Ejemplo n.º 2
0
 /**
  * Convenience method for determining whether the method of this message is an ACK or not. Hence,
  * this is NOT to the method to determine whether this is an ACK Request or not!
  *
  * @return true if the method of this message is a ACK, false otherwise.
  * @throws SipParseException in case the method could not be parsed out of the underlying buffer.
  */
 default boolean isAck() throws SipParseException {
   final Buffer m = getMethod();
   try {
     return m.getByte(0) == 'A' && m.getByte(1) == 'C' && m.getByte(2) == 'K';
   } catch (final IOException e) {
     throw new SipParseException(
         0, UNABLE_TO_PARSE_OUT_THE_METHOD_DUE_TO_UNDERLYING_IO_EXCEPTION, e);
   }
 }
Ejemplo n.º 3
0
 @Override
 public RouteHeader clone() {
   final Buffer value = getValue();
   final Address address = getAddress();
   final Buffer params = getRawParams();
   // TODO: once Buffer is truly immutable we don't actually have to clone, like we don't have to
   // do for Address anymore
   return new RouteHeaderImpl(value.clone(), address, params.clone());
 }
Ejemplo n.º 4
0
 /**
  * Convenience method for determining whether the method of this message is a OPTIONS or not.
  * Hence, this is NOT to the method to determine whether this is an OPTIONS Request or not!
  *
  * @return true if the method of this message is a OPTIONS, false otherwise.
  * @throws SipParseException in case the method could not be parsed out of the underlying buffer.
  */
 default boolean isOptions() throws SipParseException {
   final Buffer m = getMethod();
   try {
     return m.getByte(0) == 'O'
         && m.getByte(1) == 'P'
         && m.getByte(2) == 'T'
         && m.getByte(3) == 'I'
         && m.getByte(4) == 'O'
         && m.getByte(5) == 'N'
         && m.getByte(6) == 'S';
   } catch (final IOException e) {
     throw new SipParseException(
         0, UNABLE_TO_PARSE_OUT_THE_METHOD_DUE_TO_UNDERLYING_IO_EXCEPTION, e);
   }
 }