📄 group__howto0__initialize.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>libosip: How-To initialize libosip2.</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.3.8 --><div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related Pages</a></div><h1>How-To initialize libosip2.<br><small>[<a class="el" href="group__libosip2.html">The GNU oSIP stack</a>]</small></h1><table border=0 cellpadding=0 cellspacing=0><tr><td></td></tr></table>When using osip, your first task is to initialize the parser and the state machine. This must be done prior to any use of libosip2.<p><pre> #include <sys/time.h> #include <osip2/osip.h></pre><p><pre> int i; osip_t *osip; i=osip_init(&osip); if (i!=0) return -1;</pre><p>In case you want to use the state machines (transaction management), the second step will be to set a few callbacks which will inform you of any change in the state of a SIP transaction.<p>Most of the following callbacks are optional. The following ones are usefull.<p><pre> // callback called when a SIP message must be sent. osip_set_cb_send_message(osip, &cb_udp_snd_message);</pre><p><pre> // callback called when a SIP transaction is TERMINATED. osip_set_kill_transaction_callback(osip ,OSIP_ICT_KILL_TRANSACTION, &cb_ict_kill_transaction); osip_set_kill_transaction_callback(osip ,OSIP_NIST_KILL_TRANSACTION, &cb_ist_kill_transaction); osip_set_kill_transaction_callback(osip ,OSIP_NICT_KILL_TRANSACTION, &cb_nict_kill_transaction); osip_set_kill_transaction_callback(osip ,OSIP_NIST_KILL_TRANSACTION, &cb_nist_kill_transaction);</pre><p><pre> // callback called when the callback to send message have failed. osip_set_transport_error_callback(osip ,OSIP_ICT_TRANSPORT_ERROR, &cb_transport_error); osip_set_transport_error_callback(osip ,OSIP_IST_TRANSPORT_ERROR, &cb_transport_error); osip_set_transport_error_callback(osip ,OSIP_NICT_TRANSPORT_ERROR, &cb_transport_error); osip_set_transport_error_callback(osip ,OSIP_NIST_TRANSPORT_ERROR, &cb_transport_error);</pre><p><pre> // callback called when a received answer has been accepted by the transaction. osip_set_message_callback(osip ,OSIP_ICT_STATUS_1XX_RECEIVED, &cb_rcv1xx); osip_set_message_callback(osip ,OSIP_ICT_STATUS_2XX_RECEIVED, &cb_rcv2xx); osip_set_message_callback(osip ,OSIP_ICT_STATUS_3XX_RECEIVED, &cb_rcv3456xx); osip_set_message_callback(osip ,OSIP_ICT_STATUS_4XX_RECEIVED, &cb_rcv3456xx); osip_set_message_callback(osip ,OSIP_ICT_STATUS_5XX_RECEIVED, &cb_rcv3456xx); osip_set_message_callback(osip ,OSIP_ICT_STATUS_6XX_RECEIVED, &cb_rcv3456xx);</pre><p><pre> // callback called when a received answer has been accepted by the transaction. osip_set_message_callback(osip ,OSIP_NICT_STATUS_1XX_RECEIVED, &cb_rcv1xx); osip_set_message_callback(osip ,OSIP_NICT_STATUS_2XX_RECEIVED, &cb_rcv2xx); osip_set_message_callback(osip ,OSIP_NICT_STATUS_3XX_RECEIVED, &cb_rcv3456xx); osip_set_message_callback(osip ,OSIP_NICT_STATUS_4XX_RECEIVED, &cb_rcv3456xx); osip_set_message_callback(osip ,OSIP_NICT_STATUS_5XX_RECEIVED, &cb_rcv3456xx); osip_set_message_callback(osip ,OSIP_NICT_STATUS_6XX_RECEIVED, &cb_rcv3456xx);</pre><p><pre> // callback called when a received request has been accepted by the transaction. osip_set_message_callback(osip ,OSIP_IST_INVITE_RECEIVED, &cb_rcvreq); osip_set_message_callback(osip ,OSIP_IST_ACK_RECEIVED, &cb_rcvreq); osip_set_message_callback(osip ,OSIP_NIST_REGISTER_RECEIVED, &cb_rcvreq); osip_set_message_callback(osip ,OSIP_NIST_BYE_RECEIVED, &cb_rcvreq); osip_set_message_callback(osip ,OSIP_NIST_CANCEL_RECEIVED, &cb_rcvreq); osip_set_message_callback(osip ,OSIP_NIST_INFO_RECEIVED, &cb_rcvreq); osip_set_message_callback(osip ,OSIP_NIST_OPTIONS_RECEIVED, &cb_rcvreq); osip_set_message_callback(osip ,OSIP_NIST_SUBSCRIBE_RECEIVED, &cb_rcvreq); osip_set_message_callback(osip ,OSIP_NIST_NOTIFY_RECEIVED, &cb_rcvreq); osip_set_message_callback(osip ,OSIP_NIST_UNKNOWN_REQUEST_RECEIVED, &cb_rcvreq);</pre><p><pre> // other callbacks exists... They are optionnal.</pre> <hr size="1"><address style="align: right;"><small>Generated on Tue Sep 7 15:08:00 2004 for libosip by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.8 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -