Package gov.nist.javax.sip.message

Examples of gov.nist.javax.sip.message.SIPMessage


            public void run() {
                for (int i = 0; i < messages.length; i++) {
                    StringMsgParser smp = new StringMsgParser();
                    try {
                        SIPMessage sipMessage = smp
                                .parseSIPMessage(messages[i].getBytes(), true, false, null);
                        System.out.println(" i = " + i + " branchId = "
                                + sipMessage.getTopmostVia().getBranch());
                        // System.out.println("encoded " +
                        // sipMessage.toString());
                    } catch (ParseException ex) {

                    }
View Full Code Here


            public void run() {
                for (int i = 0; i < messages.length; i++) {
                    StringMsgParser smp = new StringMsgParser();
                    try {
                        SIPMessage sipMessage = smp
                                .parseSIPMessage(messages[i].getBytes(), true, false, null);
                        System.out.println(" i = " + i + " branchId = "
                                + sipMessage.getTopmostVia().getBranch());
                        // System.out.println("encoded " +
                        // sipMessage.toString());
                    } catch (ParseException ex) {

                    }
View Full Code Here

                // Stop the timer that will kill the read.
                this.rawInputStream.stopTimer();
                inputBuffer.append(line2);              
//                smp.setParseExceptionListener(sipMessageListener);
//                smp.setReadBody(false);
                SIPMessage sipMessage = null;

                try {
                    if (Debug.debug) {
                        Debug.println("About to parse : " + inputBuffer.toString());
                    }
                    sipMessage = smp.parseSIPMessage(inputBuffer.toString().getBytes(), false, false, sipMessageListener);
                    if (sipMessage == null) {
                        this.rawInputStream.stopTimer();
                        continue;
                    }
                } catch (ParseException ex) {
                    // Just ignore the parse exception.
                    Debug.logError("Detected a parse error", ex);
                    continue;
                }

                if (Debug.debug) {
                    Debug.println("Completed parsing message");
                }
                ContentLength cl = (ContentLength) sipMessage
                        .getContentLength();
                int contentLength = 0;
                if (cl != null) {
                    contentLength = cl.getContentLength();
                } else {
                    contentLength = 0;
                }

                if (Debug.debug) {
                    Debug.println("contentLength " + contentLength);
                }

                if (contentLength == 0) {
                    sipMessage.removeContent();
                } else if (maxMessageSize == 0
                        || contentLength < this.sizeCounter) {
                    byte[] message_body = new byte[contentLength];
                    int nread = 0;
                    while (nread < contentLength) {
                        // Start my starvation timer.
                        // This ensures that the other end
                        // writes at least some data in
                        // or we will close the pipe from
                        // him. This prevents DOS attack
                        // that takes up all our connections.
                        this.rawInputStream.startTimer();
                        try {

                            int readlength = inputStream.read(message_body,
                                    nread, contentLength - nread);
                            if (readlength > 0) {
                                nread += readlength;
                            } else {
                                break;
                            }
                        } catch (IOException ex) {
                            Debug.logError("Exception Reading Content",ex);
                            break;
                        } finally {
                            // Stop my starvation timer.
                            this.rawInputStream.stopTimer();
                        }
                    }
                    sipMessage.setMessageContent(message_body);
                }
                // Content length too large - process the message and
                // return error from there.
                if (sipMessageListener != null) {
                    try {
View Full Code Here

    byte[] msg = new byte[ rxBuffer.position() ];
    rxBuffer.flip();
    rxBuffer.get( msg );
    rxBuffer.compact();
    try {
      SIPMessage m = parser.parseSIPMessage( msg, true, true, this );
      this.processMessage( m, rxTime );
      rxTime = 0// reset for next message
    } catch (ParseException e) {
      getSIPStack().getStackLogger().logException( e );
      if ( getSIPStack().getStackLogger().isLoggingEnabled( LogWriter.TRACE_DEBUG ) ) {
View Full Code Here

    try {
 
   
      StringMsgParser smp = new StringMsgParser();
 
      SIPMessage message = smp.parseSIPMessage(messageToParse.getBytes("UTF-8"), true, false, null);
     
      System.out.println("Message = " + message);
     
      byte[] bytes = message.encodeAsBytes("UDP");
     
        smp = new StringMsgParser();
     
        message = smp.parseSIPMessage(bytes, true, false, null);
        System.out.println("Message = " + message);
        char[] mybytes = new char[2];
        byte[] sipMessageBytes = new byte[binaryMessage.length()];
       
        for ( int i = 0; i < binaryMessage.length(); i += 2) {
          mybytes[0] = binaryMessage.charAt(i);
          mybytes[1] = binaryMessage.charAt(i+1);
          String byteString = new String(mybytes);
          int val = Integer.parseInt(byteString,16);
          sipMessageBytes[i/2] = (byte)val;
         
        }
        smp = new StringMsgParser();
        SIPMessage reparsed = smp.parseSIPMessage(sipMessageBytes, true, false, null);
       
        System.out.println("Reparsed = " + reparsed);
       
        bytes = message.encodeAsBytes("UDP");
        smp = new StringMsgParser();
View Full Code Here

TOP

Related Classes of gov.nist.javax.sip.message.SIPMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.