⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainpage.docs

📁 Sofia SIP is an open-source SIP User-Agent library, compliant with the IETF RFC3261 specification.
💻 DOCS
📖 第 1 页 / 共 2 页
字号:
/* -*- text -*- *//**@mainpage Sofia SIP User Agent Library - sofia-sip-ua@section IntroductionThis document contains automatically generated reference documentationfor Sofia-SIP components. Some introductory material andpointers to the example code are also included.For a list of module specific pages, see @ref subdirs "source tree structure" or direct links to submodules:<br><a href="nua/index.html">nua</a> <a href="su/index.html">su</a> <a href="features/index.html">features</a> <a href="soa/index.html">soa</a> <a href="sdp/index.html">sdp</a> <a href="nta/index.html">nta</a> <a href="tport/index.html">tport</a> <a href="sresolv/index.html">sresolv</a> <a href="sip/index.html">sip</a> <a href="msg/index.html">msg</a> <a href="url/index.html">url</a> <a href="stun/index.html">stun</a> <a href="iptsec/index.html">iptsec</a> <a href="nea/index.html">nea</a> <a href="nth/index.html">nth</a> <a href="http/index.html">http</a> <a href="bnf/index.html">bnf</a> <a href="ipt/index.html">ipt</a> @section who Contact InformationYou can download latest Sofia SIP from the project <a href="http://sofia-sip.sf.net">home page</a> at <a href="sf.net">Sourceforge.net</a>.Please contact us if you have questions regarding this software:<ul> <li>Pekka Pessi <Pekka.Pessi@nokia.com></li><li>Kai Vehmanen <Kai.Vehmanen@nokia.com></li></ul> Or post to the Sofia-SIP mailing list:<ul><li>mailto:sofia-sip-devel@lists.sourceforge.net</li><li>http://lists.sourceforge.net/lists/listinfo/sofia-sip-devel</li></ul>*//**@page building Source Tree Structure@section subdirs Directory StructureIn libsofia-sip-ua, there are subdirectories for different modules listedbelow.Terminal and high-level libraries used for both signaling and media:Common runtime library: - <a href="su/index.html">"su" - sockets, memory management, threads</a> - <a href="sresolv/index.html">"sresolv" - Asynchronous DNS resolver</a> - <a href="ipt/index.html">"ipt" - IPT utility library</a>SIP Signaling: - <a href="nua/index.html">"nua" - SIP User Agent library</a> - <a href="nea/index.html">"nea" - SIP Event API</a> - <a href="iptsec/index.html">"iptsec" -     Digest authentication for HTTP and SIP</a> - <a href="nta/index.html">"nta" - SIP transaction engine</a> - <a href="tport/index.html">"tport" - Message transport</a> - <a href="sip/index.html">"sip" - SIP messages and headers</a> - <a href="msg/index.html">"msg" - Message handling </a> - <a href="url/index.html">"url" - URL handling</a> - <a href="bnf/index.html">"url" - low level parsing</a>HTTP subsystem: - <a href="nth/index.html">"nth" - HTTP protocol engine</a> - <a href="http/index.html">"http" - HTTP messages and headers</a>SDP processing: - <a href="soa/index.html">"soa" - SDP Offer/Answer engine for SIP</a> - <a href="sdp/index.html">"sdp" - SDP parser</a>Other: - <a href="stun/index.html">"stun" - STUN library</a>Features provided by Sofia-SIP library: - <a href="features/index.html">"features" - Features provided by Sofia SIP</a>Documentation: - "docs" - Doxygen reference documentation*//**@page styleguide C Style GuideThis document gives general guidelines on generic C style and codeformatting within Sofia-SIP. The guidelines include identifier namingconventions, indenting convention, and tool usage directions.Please note that C style is always a matter of taste. @section naming Naming ConventionsGenerally, identifiers within each module are prefixed with the name ofthat module. For instance, the functions within http parser module @b httphave prefix @c http_. Identifiers composed of multiple words have anunderscore "_" between the words, the words themselves are in lowercase. For instance, http_request_create().Macros should be in upper case. File names should be in lower case usingunderscore as delimiter if needed.Normal typedefs have suffix @c _t, however, function types have suffix @c_f. The enum names also sometimes have @c _e, struct names have @c _s andunion names @c _u.It is recommended that type itself is typedef'ed, not a pointer to thetype. It should be clear from variable declaration if the variable is apointer or not.@codetypedef struct foo_s foo_t;typedef int f_fun(foo_t *f, char const *s);@endcodeStruct and union members should have common prefix. For instance,@codestruct foo_s {  int    f_len;  char  *f_name;  fun_f *f_fun;};@endcodeThis prefix makes it easier to find where members are used.@section formatting Indenting and Formatting codeIndentation in Sofia-SIP C code generally follows the @e K&R style with indentof 2 characters (so you can use the default "GNU" c-style in Emacs). Themaximum line length should be 80 characters.For example,@codevoid kluge(int foo){  if (foo) {    bar();  }  else {    switch (baz()) {    case a:      eeny();      break;    case b:      meeny();      break;    default:      moe();      break;    }  }}@endcodeThe default indentation can be achieved with GNU indent with options@code-nbad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci2 -cli0 -cp33 -cs-d0 -di1 -nfc1 -nfca -hnl -i2 -ip0 -l79 -lp -npcs -nprs -npsl -saf -sai-saw -nsc -nsob -nss@endcodeLoops without condition use @c for @c (;;) instead of @c while @c (1). @code  for (;;) {    foo();    if (bar())      break;    baz();  }@endcodeThere should be whitespace on both sides of infix operators, except<code>.</code> or <code>-></code>, which require no space, or<code>,</code> (comma) which requires space only after). There should bewhitespace between a keyword and parenthesis following it, but nowhitespace between an identifier and parenthesis following it. E.g.,@code  while (i++ < n)    baz();  for (;;) {    x->x_foo();    if (bar())      break;    z.z_baz++;  }  return (13 * i);@endcode *//**@page programming Programming Guide@section porting Writing Portable CodeMost of Sofia-SIP software is written as portable. All core modules are(or at least should be) written in ANSI C 89 with some ANSI C 99features. If there are platform specific parts, they are collected toseparate C files and isolated from the rest of the software with awrapper interface.SU module handles abstraction to OS specific functionality such asmemory management, sockets, threads and time functions. @subsection ansi_99 ANSI C 99 featuresThe following ANSI C 99 features are to be used in Sofia-SIP software:- Integer types- functions va_copy() and snprintf()The following ANSI C 99 features shall not be used in Sofia-SIP software:- definition of a variable in the middle of function code.  (so always define your variables in the beginning of the block)@subsection port_ints Integer TypesAs you should know, the length of native storage size depends on hardware,OS and compiler. This means in practice that the length of int or long isnot necessarily 32 bits. As a consequence, you need to make sure that thevalue you intend to store in the int, can actually fit in int on differentplatforms. As a rule of thumb, if the integer value can exceed 8 bits, youshould use types that have a defined length.Nevertheless its OK to use native integer types if you bear in mindwhat was said above. The original reason for having only nativedata type was performance. The int type is always stored in thefastest (and usually biggest size) possible.Never assume anything on the length of the type. Alway use sizeof()operator to find out the length.C 99 standard defines the following fixed length data types:- int64_t- uint64_t- int32_t- uint32_t- int16_t- uint16_t- int8_t- uint8_tTo use these data types you must include the <sofia-sip/su_types.h> header, whichtakes care of including correct file. If @b su includes are not available,you must include the following code segment to each file where you plan touse them:@code#if HAVE_STDINT_H#include <stdint.h>#elif HAVE_INTTYPES_H#include <inttypes.h>#else#error Define HAVE_STDINT_H as 1 if you have <stdint.h>, \ or HAVE_INTTYPES_H if you have <inttypes.h>#endif@endcode@subsection port_byte_sex Byte orderThe host byte order on different platforms vary. When you do onlylocal processing, need not to worry about the byte order. But assoon as you start writing code that send or receives anything tothe network, you need to start worrying.If you wish to convert the byte order, it is simply done by callingone the following functions:The htonl() function converts the unsigned integer hostlong fromhost byte order to network byte order.The htons() function converts the unsigned short integer hostshortfrom host byte order to network byte order.The ntohl() function converts the unsigned integer netlong fromnetwork byte order to host byte order.The ntohs() function converts the unsigned short integer netshortfrom network byte order to host byte order.You need to include <netinet/in.h> or <sofia-sip/su.h> to use these functions.@subsection port_struct Packing structuresBy default, compilers usually arrange structures so that they arequick to access. This means that most fields in the structure startat the 32 bit boundary. If you need to conserve memory, you may usestructure packing.To tell the compiler that you only need certain amount of bits tostore a variable, you can use bit-fields. Compiler may or may notpack the bit-fields.@codestruct foo {  unsigned bar:5;  unsigned foo:2;  unsigned :0;  int      something;}@endcodeIf compiler decides to pack this structure, this code generates astructure that has @a bar and @a foo in the first seven bits, and then@a something beginning from the next 32 bit boundary. One problem arises when using packed bit-fields: on ARM it isgenerally not possible to access a 32 bit field that does not start fromthe 32-bit boundary. Hence the example has the :0 padding member in thestructure. Seems handy but beware: initialization of this structure failson some ARM gcc compilers. (Ask Kai Vehmanen for details).A way to force packing of a structure is to use preprocessordirective @c @#pragma(pack). This directive is compiler specific, so ifyou plan to write truly portable code, you cannot use it. We haveused it in some parts of the Sofia-SIP though. Only alternative is towrite functions that fetch the desired bits from a 32 bit fieldwith bit operations; not very handy and error prone.The same aligment problem also arises if you cast for example charbuffer to a int32_t. You can only read int32_t from the 32bit boundaryon ARM platform. So be careful.As a conclusion, when using bit-fields and stucture packing, bewareof the pitfalls. If you don't really need to use them (as in parsingbinary protocols), don't use them.@section file_organization File and Directory StructureA Sofia-SIP library module can be defined as a subdirectory under thelibsofia-sip-ua directory hierarchy that contains a file \<modulename\>.docs (where the \<modulename\> of course referes to the actual name of the module). In case you like to start developing a new module, pleasecontact Sofia-SIP development team so that they can help you to set upthe basic module for you.An overview of the contents of a module directory:  - file \<modulename\>.docs \n    Main documentation file for the module. See @ref module_docs    for more information  - subdirectory pictures \n    Contains any pictures/images    that are needed by the module documentation. The    file formats to use are GIF (for html pages) and    EPS (for latex). If some program (e.g. MS Visio) is     used to create the pictures, also the original    files must be stored here.\n    (Note that old modules may have "images" subdirectory instead of    "pictures")

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -