$Revision$ $Date$ The SIP Message Parser In this section we will discuss internals of the SIP message header parser implemented in the server. Message parsing is very important and one of the most time consuming operations of a SIP server. We have been trying to make the parser as fast as possible. A header field parser can be either in the server core or in a module. By convention, parser that is needed by the core itself or is needed by at least two modules will be in the core. Parsers contained in modules will be not described in this section. There is a parser subdirectory that contains all the parsers and related stuff. The following parsers can be found under parser subdirectory:
Structure of a <acronym>SIP</acronym> Message A SIP message consists of message header and optional message body. The header is separated from the body with an empty line (containing CRLF only). Message header consists of the first line and one or more header fields. The first line determines type of the message. Header fields provide additional information that is needed by clients and servers to be able to process the message. Each header field consists of header field name and header field body. Header field name is delimited from header field body by a colon (":"). For example, "Server: SIP Express Router" - in this case "Server" is header field name and "SIP Express Router" is header field body.
Parser Structure The server implements what we call incremental parsing. It means that a header field will be not parsed unless it is really needed. There is a minimal set of header that will be parsed every time. The set includes: The first line - the server must know if the message is request or response Via header field - Via will be needed for sure. We must add ourself to Via list when forwarding the message.