2 .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH SIP_STACK_INIT 3SIP "Jan 23, 2007"
8 sip_stack_init \- initializes SIP stack
12 \fBcc\fR [ \fIflag\fR ... ] \fIfile\fR ... -lsip [ \fIlibrary\fR ... ]
15 \fBint\fR \fIsip_stack_init\fR(\fBsip_stack_init_t *\fR \fIstack_val\fR);
20 The \fBsip_stack_init()\fR function is used to initialize the \fBSIP\fR stack.
21 The stack can be initialized by a process only once. Any shared library that is
22 linked with a main program or another library that has already initialized the
23 stack will encounter a failure when trying to initialize the stack.
26 The initialization structure is given by:
30 typedef struct sip_stack_init_s {
32 uint32_t sip_stack_flags;
33 sip_io_pointers_t *sip_io_pointers;
34 sip_ulp_pointers_t *sip_ulp_pointers;
35 sip_header_function_t *sip_function_table;
46 This must be set to \fBSIP_STACK_VERSION\fR.
55 If the application wants the \fBSIP\fR stack to maintain dialogs, this flag
56 must be set to \fBSIP_STACK_DIALOGS\fR. Otherwise, it must be set to \fB0\fR.
57 If \fBSIP_STACK_DIALOGS\fR is not set, the stack does not deal with dialogs at
61 .SS "Upper Layer Registrations"
63 These include callbacks that are invoked to deliver incoming messages or error
67 The callback functions should not create a thread and invoke a function that
68 could recursively invoke the callback. For example, the callback function for a
69 transition state change notification should not create a thread to send a
70 \fBSIP\fR message that results in a change in the state of the transaction,
71 which would again invoke the callback function.
74 The registration structure is supplied by:
78 typedef struct sip_ulp_pointers_s {
79 void (*sip_ulp_recv)(const sip_conn_object_t,
80 sip_msg_t, const sip_dialog_t);
81 uint_t (*sip_ulp_timeout)(void *,
84 boolean_t (*sip_ulp_untimeout)(uint_t);
85 int (*sip_ulp_trans_error)
86 (sip_transaction_t, int, void *);
87 void (*sip_ulp_dlg_del)(sip_dialog_t,
89 void (*sip_ulp_trans_state_cb)
90 (sip_transaction_t, sip_msg_t,
92 void (*sip_ulp_dlg_state_cb)(sip_dialog_t,
104 This is a mandatory routine that the application registers for the stack to
105 deliver an inbound \fBSIP\fR message. The \fBSIP\fR stack invokes the function
106 with the connection object on which the message arrived, the \fBSIP\fR message,
107 and any associated dialog.
109 The \fBSIP\fR message is freed once the function returns. If the application
110 wishes to use the message beyond that, it has to hold a reference on the
111 message using \fBsip_hold_msg()\fR. Similarly, if the application wishes to
112 cache the dialog, it must hold a reference on the dialog using
113 \fBsip_hold_msg()\fR.
119 \fBsip_ulp_timeout\fR
123 \fBsip_ulp_untimeout\fR
126 An application can register these two routines to implement its own routines
127 for the stack timers. Typically, an application should allow the stack to use
128 its own built-in timer routines. The built-in timer routines are used only by
129 the stack and are not available to applications. If the application registers
130 one routine, it must also register the other.
132 These functions must be registered for single-threaded application. Otherwise,
133 the timer thread provided by the stack could result in invoking a registered
140 \fBsip_ulp_trans_error\fR
143 The application can register this routine to be notified of a transaction
144 error. An error can occur when the transaction layer tries to send a message
145 using a cached connection object which results in a failure. If this routine is
146 not registered the transaction is terminated on such a failure. The final
147 argument is for future use. It is always set to \fBNULL\fR.
153 \fBsip_ulp_dlg_del\fR
156 An application can register this routine to be notified when a dialog is
157 deleted. The dialog to be deleted is passed along with the \fBSIP\fR message
158 which caused the dialog to be deleted. The final argument is for future use. It
159 is always set to \fBNULL\fR.
165 \fBsip_ulp_trans_state_cb\fR
169 \fBsip_ulp_dlg_state_cb\fR
172 If these callback routines are registered, the stack invokes
173 \fBsip_ulp_trans_state_cb\fR when a transaction changes states and
174 \fBsip_ulp_dlg_state_cb\fR when a dialog changes states.
177 .SS "Connection Manager Interface"
179 The connection manager interfaces must be registered by the application to
180 provide I/O related functionality to the stack. These interfaces act on a
181 connection object that is defined by the application. The application registers
182 the interfaces for the stack to work with the connection object. The connection
183 object is application defined, but the stack requires that the first member of
184 the connection object is a void *, used by the stack to store connection object
185 specific information which is private to the stack.
188 The connection manager structure is supplied by:
192 typedef struct sip_io_pointers_s {
193 int (*sip_conn_send)(const sip_conn_object_t, char *, int);
194 void (*sip_hold_conn_object)(sip_conn_object_t);
195 void (*sip_rel_conn_object)(sip_conn_object_t);
196 boolean_t (*sip_conn_is_stream)(sip_conn_object_t);
197 boolean_t (*sip_conn_is_reliable)(sip_conn_object_t);
198 int (*sip_conn_remote_address)(sip_conn_object_t, struct sockaddr *,
200 int (*sip_conn_local_address)(sip_conn_object_t, struct sockaddr *,
202 int (*sip_conn_transport)(sip_conn_object_t);
203 int (*sip_conn_timer1)(sip_conn_object_t);
204 int (*sip_conn_timer2)(sip_conn_object_t);
205 int (*sip_conn_timer4)(sip_conn_object_t);
206 int (*sip_conn_timerd)(sip_conn_object_t);
217 This function is invoked by the stack after processing an outbound \fBSIP\fR
218 message. This function is responsible for sending the \fBSIP\fR message to the
219 peer. A return of \fB0\fR indicates success. The \fBSIP\fR message is passed to
220 the function as a string, along with the length information and the associated
227 \fBsip_hold_conn_object\fR
231 \fBsip_rel_conn_object\fR
234 The application provides a mechanism for the stack to indicate that a
235 connection object is in use by the stack and must not be freed. The stack uses
236 \fBsip_hold_conn_object\fR to indicate that the connection object is in use and
237 \fBsip_rel_conn_object\fR to indicate that it has been released. The connection
238 object is passed as the argument to these functions. The stack expects that the
239 application will not free the connection object if it is in use by the stack.
245 \fBsip_conn_is_stream\fR
248 The stack uses this to determine whether the connection object, passed as the
249 argument, is byte-stream oriented. Byte-stream protocols include \fBTCP\fR
250 while message-based protocols include \fBSCTP\fR and \fBUDP\fR.
256 \fBsip_conn_is_reliable\fR
259 The stack uses this to determine whether the connection object, passed as the
260 argument, is reliable. Reliable protocols include \fBTCP\fR and \fBSCTP\fR.
261 Unreliable protocols include \fBUDP\fR.
267 \fBsip_conn_local_address\fR
271 \fBsip_conn_remote_address\fR
274 These two interfaces are used by the stack to obtain endpoint information for a
275 connection object. The \fBsip_conn_local_address\fR provides the local
276 address/port information. The \fBsip_conn_remote_address\fR provides the
277 address/port information of the peer. The caller allocates the buffer and
278 passes its associated length along with it. On return, the length is updated to
279 reflect the actual length.
285 \fBsip_conn_transport\fR
288 The stack uses this to determine the transport used by the connection object,
289 passed as the argument. The transport could be \fBTCP\fR, \fBUDP\fR,
296 \fBsip_conn_timer1\fR
300 \fBsip_conn_timer2\fR
304 \fBsip_conn_timer4\fR
308 \fBsip_conn_timerd\fR
311 These four interfaces may be registered by an application to provide connection
312 object specific timer information. If these are not registered the stack uses
315 The interfaces provide the timer values for \fBTimer 1\fR (\fBRTT\fR estimate -
316 default \fB500\fR \fBmsec\fR), \fBTimer 2\fR (maximum retransmit interval for
317 non-\fBINVITE\fR request and \fBINVITE\fR response - default \fB4\fR
318 \fBsecs\fR), \fBTimer 4\fR (maximum duration a message will remain in the
319 network - default \fB5\fR \fBsecs\fR) and \fBTimer D\fR (wait time for response
320 retransmit interval - default \fB32\fR \fBsecs\fR).
323 .SS "Custom \fBSIP\fR headers"
325 In addition to the \fBSIP\fR headers supported by the stack, an application can
326 optionally provide a table of custom headers and associated parsing functions.
327 The table is an array with an entry for each header. If the table includes
328 headers supported by the stack, parsing functions or other application-specific
329 table entries take precedence over \fBlibsip\fR supported headers. The header
330 table structure is supplied by:
334 typedef struct header_function_table {
336 char *header_short_name;
337 int (*header_parse_func)
338 (struct sip_header *,
339 struct sip_parsed_header **);
340 boolean_t (*header_check_compliance)
341 (struct sip_parsed_header *);
342 boolean_t (*header_is_equal)
343 (struct sip_parsed_header *,
344 struct sip_parsed_header *);
346 (struct sip_parsed_header *);
357 The full name of the header. The application must ensure that he name does not
358 conflict with existing headers. If it does, the one registered by the
359 application takes precedence.
365 \fBheader_short_name\fR
368 Compact name, if any, for the header.
374 \fBheader_parse_func\fR
377 The parsing function for the header. The parser will set the second argument to
378 the resulting parsed structure. A return value of \fB0\fR indicates success.
387 The function that frees the parsed header
393 \fBheader_check_compliance\fR
396 An application can optionally provide this function that will check if the
397 header is compliant or not. The compliance for a custom header will be defined
404 \fBheader_is_equal\fR
407 An application can optionally provide this function to determine whether two
408 input headers are equivalent. The equivalence criteria is defined by the
414 On success \fBsip_stack_init()\fR returns \fB0\fR. Otherwise, the function
415 returns the error value.
418 The value of \fBerrno\fR is not changed by these calls in the event of an
422 On failure, the \fBsip_stack_init()\fR function returns the following error
430 If the stack version is incorrect, or if any of the mandatory functions is
436 See \fBattributes\fR(5) for descriptions of the following attributes:
444 ATTRIBUTE TYPE ATTRIBUTE VALUE
446 Interface Stability Committed
453 \fBlibsip\fR(3LIB), \fBsockaddr\fR(3SOCKET)