There is a good article "An Introduction to the JAIN SIP API"
which can be used as first step guide for development of "IP active" component.
SIP parser application (IP passive) implementation.
However we need to use JainSIP for parsing SIP as well.
This topic is not covered in the article. But it is enough easy.
First, we need to create and initialize SipFactory and MessageFactory instances:
sipFactory = SipFactory.getInstance();
sipFactory.setPathName("gov.nist");
messageFactory = sipFactory.createMessageFactory();
Second, we need to get instance of SIPRequest or SIPResponse and initialize them by input buffer with a real SIP message.
SIPRequest sipRequest = (SIPRequest)messageFactory.createRequest(sipMessage);
How to understand if the income message request or response:
if ( sipMessage.startsWith( SIPConstants.SIP_VERSION_STRING ) ){
processResponse( sipMessage );
}
else {
processRequest( sipMessage );
}
Now we can get any information from the SIP message.
ListIterator<String> itHeaders = sipRequest.getHeaderNames();
String requestMethod = sipRequest.getMethod();
Detailed description of JainSIP API can be found here.