sip_stack_init - initializes SIP stack
cc [ flag ... ] file ... -lsip [ library ... ] #include <sip.h> int sip_stack_init(sip_stack_init_t * stack_val);
The sip_stack_init() function is used to initialize the SIP stack. The stack can be initialized by a process only once. Any shared library that is linked with a main program or another library that has already initialized the stack will encounter a failure when trying to initialize the stack.
The initialization structure is given by:
typedef struct sip_stack_init_s { int sip_version; uint32_t sip_stack_flags; sip_io_pointers_t *sip_io_pointers; sip_ulp_pointers_t *sip_ulp_pointers; sip_header_function_t *sip_function_table; };
sip_version
sip_stack_flags
These include callbacks that are invoked to deliver incoming messages or error notification.
The callback functions should not create a thread and invoke a function that could recursively invoke the callback. For example, the callback function for a transition state change notification should not create a thread to send a SIP message that results in a change in the state of the transaction, which would again invoke the callback function.
The registration structure is supplied by:
typedef struct sip_ulp_pointers_s { void (*sip_ulp_recv)(const sip_conn_object_t, sip_msg_t, const sip_dialog_t); uint_t (*sip_ulp_timeout)(void *, void (*func)(void *), struct timeval *); boolean_t (*sip_ulp_untimeout)(uint_t); int (*sip_ulp_trans_error) (sip_transaction_t, int, void *); void (*sip_ulp_dlg_del)(sip_dialog_t, sip_msg_t, void *); void (*sip_ulp_trans_state_cb) (sip_transaction_t, sip_msg_t, int, int); void (*sip_ulp_dlg_state_cb)(sip_dialog_t, sip_msg_t, int, int); }sip_io_pointers_t;
sip_ulp_recv
The SIP message is freed once the function returns. If the application wishes to use the message beyond that, it has to hold a reference on the message using sip_hold_msg(). Similarly, if the application wishes to cache the dialog, it must hold a reference on the dialog using sip_hold_msg().
sip_ulp_timeout
sip_ulp_untimeout
These functions must be registered for single-threaded application. Otherwise, the timer thread provided by the stack could result in invoking a registered callback function.
sip_ulp_trans_error
sip_ulp_dlg_del
sip_ulp_trans_state_cb
sip_ulp_dlg_state_cb
The connection manager interfaces must be registered by the application to provide I/O related functionality to the stack. These interfaces act on a connection object that is defined by the application. The application registers the interfaces for the stack to work with the connection object. The connection object is application defined, but the stack requires that the first member of the connection object is a void *, used by the stack to store connection object specific information which is private to the stack.
The connection manager structure is supplied by:
typedef struct sip_io_pointers_s { int (*sip_conn_send)(const sip_conn_object_t, char *, int); void (*sip_hold_conn_object)(sip_conn_object_t); void (*sip_rel_conn_object)(sip_conn_object_t); boolean_t (*sip_conn_is_stream)(sip_conn_object_t); boolean_t (*sip_conn_is_reliable)(sip_conn_object_t); int (*sip_conn_remote_address)(sip_conn_object_t, struct sockaddr *, socklen_t *); int (*sip_conn_local_address)(sip_conn_object_t, struct sockaddr *, socklen_t *); int (*sip_conn_transport)(sip_conn_object_t); int (*sip_conn_timer1)(sip_conn_object_t); int (*sip_conn_timer2)(sip_conn_object_t); int (*sip_conn_timer4)(sip_conn_object_t); int (*sip_conn_timerd)(sip_conn_object_t); }sip_io_pointers_t;
sip_conn_send
sip_hold_conn_object
sip_rel_conn_object
sip_conn_is_stream
sip_conn_is_reliable
sip_conn_local_address
sip_conn_remote_address
sip_conn_transport
sip_conn_timer1
sip_conn_timer2
sip_conn_timer4
sip_conn_timerd
The interfaces provide the timer values for Timer 1 (RTT estimate - default 500 msec), Timer 2 (maximum retransmit interval for non-INVITE request and INVITE response - default 4 secs), Timer 4 (maximum duration a message will remain in the network - default 5 secs) and Timer D (wait time for response retransmit interval - default 32 secs).
In addition to the SIP headers supported by the stack, an application can optionally provide a table of custom headers and associated parsing functions. The table is an array with an entry for each header. If the table includes headers supported by the stack, parsing functions or other application-specific table entries take precedence over libsip supported headers. The header table structure is supplied by:
typedef struct header_function_table { char *header_name; char *header_short_name; int (*header_parse_func) (struct sip_header *, struct sip_parsed_header **); boolean_t (*header_check_compliance) (struct sip_parsed_header *); boolean_t (*header_is_equal) (struct sip_parsed_header *, struct sip_parsed_header *); void (*header_free) (struct sip_parsed_header *); }
header_name
header_short_name
header_parse_func
header_free
header_check_compliance
header_is_equal
On success sip_stack_init() returns 0. Otherwise, the function returns the error value.
The value of errno is not changed by these calls in the event of an error.
On failure, the sip_stack_init() function returns the following error value:
EINVAL
See attributes(5) for descriptions of the following attributes:
|
libsip(3LIB)
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |