This package contains the classes for building a SIP stack. The NIST-SIP
stack uses the NIST-SIP parser. An incoming message is passed through the
parser and generates a SIPServerRequestImp or SIPServerResponseImpl. These
are interfaces that are implemented by the application (see the example
directory for an example of how to use this stack). This stack is
quite simple and stripped down in its goals (for example, it does
not provide any transaction support). It is essentially a messaging
layer that utilizes the nist-sip parser and defines abstractions for
message processing and I/O handling. The transaction layer is provided
in a package gov.nist.sip.stack.transaction. The security package
gov.nist.sip.stack.security. Provides an abstraction for authentication
methods the package gov.nist.sip.stack.security has implementations
of Basic and Digest authentication methods. The stack provides the
following functions:
- IO - Read and write messages from the "wire" via a socket and provide
an abstraction to the application for IO (the stack handles both
TCP and UDP sockets). The stack reads input from a specified TCP
and UDP port. The default is to enable UDP only on port 5060.
- Message Formatting : Generate message strings.
- Message logging.
An application extends the SIPStack class in this package and is expected
to implement the SIPMessageFactory, SIPServerRequest and SIPServerResponse
interfaces. The message factory implementation is registered with the
SIPStack class on initialization. When a message comes in, the stack
calls the NIST-SIP message parser to process the request and then calls
the Message Factory Implementation to create a new SIPServerRequest or
SIPServerResponse (depending on whether the message was a request or
response) and then calls processRequest on the created SIPServerRequest
or SIPServerResponse.
Here is pseudo-code that illustrates the flow of processing messages
(for UDP):
while (true) {
String messageString = messageChannel.read_incoming_message();
SIPMessage parsed_message =
sipMessageParser.parseSIPMesage(messageString);
sipMessageFactoryImpl.newSIPServerRequest(parsed_message);
}
The actual code implements the SIPMessageListener interface which has
a callback method for erroneous messages. TCP Processing is a bit more
complex because of the stream oriented nature of TCP.
There is an architected means for dealing with extension headers by an
application implementing the ExtensionParser interface that is part of
this package. Such extension parsers are registered with the stack by
using the SIPStack.registerExtensionParser method which specifies the
extension header name and the parser for the extnsion header. If the
header parses correctly, the application returns a class that subclasses
SIPHeader and that specific to the extension header and if it does not
parse correctly, the extension parser may throw a SIPParse exception.
Extensions headers that are not recognized by the parser are stored
in a list and can be retrieved by the application by calling the
getExtensionHeaders method that returns a list of extension headers.
Unparseable SIP headers and SDP Fields (headers that are not extension
headers and that failed to parse correctly) are stored in another list
and can be retrieved using the getBadHeaders and getBadSDPFields methods
respectively.
Requests routing is handled by the SIPServerRequest handler. A routing
algorithm may be specified by implementing the Route interface. A default
routing algorithm that just forwards to a hard-coded proxy address is
implemented in the DefaultRouter class.
The stack supports logging of messages into a log file that can be specified
on start-up. The log file is accessable remotely via RMI. The format of the
log file is specified in XML. This facility is to be exploited for log
file visualization. See tools.traceviewerapp for a visualization tool for log
records.