HP-UX C SIP Stack Programmer's Guide (Novembery 2007)
308 HP-UX C SIP Stack Programmer’s Guide
Server Connection Reuse
Both the client and the server take part in the connection reuse mechanism.
CLIENT SIDE The client opens new connections with the server. The client should indicate to
the server if a specific opened connection can be reused by the server for new
requests. This indication is carried as a new parameter called “alias” that is
added to the Via header of a request sent on this connection.
For example:
Via: SIP/2.0/TLS 10.54.32.1:5061;branch=z9hG4bKa7;alias
The alias parameter indicates that the server should handle this connection as a
connection that came from the address of the sent-by portion in the Via header
(10.54.32.1:5061) and not the real destination address (that includes an
ephemeral port). The sent-by part of the Via header is referred to as the
“advertised address” of this connection.
Another example is of a request that arrived over a connection from IP
10.54.32.1 and port 8241. The top Via is:
Via: SIP/2.0/TLS proxy-farm-example.com; branch=z9hG4bK7;alias
The connection alias is “proxy-farm-example.com”. A server that wants to
send a request to this host (
proxy-farm-example.com) can use this
connection, with no need to make a DNS resolution.
A client application that wishes to enable a connection for server reuse may add
the alias in the RvSipXXXFinalDestResolvedEv() callback function.
Sample Code
In the code example below, a client enables a connection for server reuse in
RvSipTranscFinalDestResolvedEv() by doing the following:
1. Updating the top Via header—only in requests.
2. Setting an alias parameter (“;alias”).
3. Setting the “advertised address” of the alias parameter (which
is the host string) to be “
alias.xxx”.
4. Removing the port number.
/*==================================================================================*/
RvStatus RVCALLCONV AppTranscFinalDestResolvedEv (
IN RvSipTranscHandle hTransc,
IN RvSipTranscOwnerHandle hLuaTransc,
IN RvSipMsgHandle hMsgToSend)
{
RvSipViaHeaderHandle hVia;