2
0

sip_msg.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
  4. <section id="sip_msg" xmlns:xi="http://www.w3.org/2001/XInclude">
  5. <sectioninfo>
  6. <revhistory>
  7. <revision>
  8. <revnumber>$Revision$</revnumber>
  9. <date>$Date$</date>
  10. </revision>
  11. </revhistory>
  12. </sectioninfo>
  13. <title>Structure <structname>sip_msg</structname></title>
  14. <para>
  15. This is the most important structure in the whole server. This
  16. structure represents a <acronym>SIP</acronym> message. When a message
  17. is received, it is immediately converted into this structure and all
  18. operations are performed over the structure. After the server finished
  19. processing, this structure is converted back to character array buffer
  20. and the buffer is sent out.
  21. </para>
  22. <para>
  23. <emphasis>Structure Declaration:</emphasis>
  24. <programlisting>
  25. struct sip_msg {
  26. unsigned int id; /* message id, unique/process*/
  27. struct msg_start first_line; /* Message first line */
  28. struct via_body* via1; /* The first via */
  29. struct via_body* via2; /* The second via */
  30. struct hdr_field* headers; /* All the parsed headers*/
  31. struct hdr_field* last_header; /* Pointer to the last parsed header*/
  32. int parsed_flag; /* Already parsed header field types */
  33. /* Via, To, CSeq, Call-Id, From, end of header*/
  34. /* first occurrence of it; subsequent occurrences
  35. * saved in 'headers'
  36. */
  37. struct hdr_field* h_via1;
  38. struct hdr_field* h_via2;
  39. struct hdr_field* callid;
  40. struct hdr_field* to;
  41. struct hdr_field* cseq;
  42. struct hdr_field* from;
  43. struct hdr_field* contact;
  44. struct hdr_field* maxforwards;
  45. struct hdr_field* route;
  46. struct hdr_field* record_route;
  47. struct hdr_field* content_type;
  48. struct hdr_field* content_length;
  49. struct hdr_field* authorization;
  50. struct hdr_field* expires;
  51. struct hdr_field* proxy_auth;
  52. struct hdr_field* www_auth;
  53. struct hdr_field* supported;
  54. struct hdr_field* require;
  55. struct hdr_field* proxy_require;
  56. struct hdr_field* unsupported;
  57. struct hdr_field* allow;
  58. struct hdr_field* event;
  59. char* eoh; /* pointer to the end of header (if found) or null */
  60. char* unparsed; /* here we stopped parsing*/
  61. struct ip_addr src_ip;
  62. struct ip_addr dst_ip;
  63. char* orig; /* original message copy */
  64. char* buf; /* scratch pad, holds a modified message,
  65. * via, etc. point into it
  66. */
  67. unsigned int len; /* message len (orig) */
  68. /* modifications */
  69. str new_uri; /* changed first line uri*/
  70. int parsed_uri_ok; /* 1 if parsed_uri is valid, 0 if not */
  71. struct sip_uri parsed_uri; /* speed-up > keep here the parsed uri*/
  72. struct lump* add_rm; /* used for all the forwarded
  73. * requests */
  74. struct lump* repl_add_rm; /* used for all the forwarded replies */
  75. struct lump_rpl *reply_lump; /* only for locally generated replies !!!*/
  76. char add_to_branch_s[MAX_BRANCH_PARAM_LEN];
  77. int add_to_branch_len;
  78. /* index to TM hash table; stored in core to avoid unnecessary calcs */
  79. unsigned int hash_index;
  80. /* allows to set various flags on the message; may be used for
  81. * simple inter-module communication or remembering processing state
  82. * reached
  83. */
  84. flag_t flags;
  85. };
  86. </programlisting>
  87. </para>
  88. <para>
  89. <emphasis>Field Description:</emphasis>
  90. <itemizedlist>
  91. <listitem>
  92. <para>
  93. <structfield>id</structfield> - Unique ID of the message within a process context.
  94. </para>
  95. </listitem>
  96. <listitem>
  97. <para>
  98. <structfield>first_line</structfield> - Parsed first line of the message.
  99. </para>
  100. </listitem>
  101. <listitem>
  102. <para>
  103. <structfield>via1</structfield> - The first Via - parsed.
  104. </para>
  105. </listitem>
  106. <listitem>
  107. <para>
  108. <structfield>via2</structfield> - The second Via - parsed.
  109. </para>
  110. </listitem>
  111. <listitem>
  112. <para>
  113. <structfield>headers</structfield> - Linked list of all parsed headers.
  114. </para>
  115. </listitem>
  116. <listitem>
  117. <para>
  118. <structfield>last_header</structfield> - Pointer to the
  119. last parsed header (parsing is incremental, that means that
  120. the parser will stop if all requested headers were found
  121. and next time it will continue at the place where it
  122. stopped previously. Therefore this field will not point to
  123. the last header of the message if the whole message hasn't
  124. been parsed yet).
  125. </para>
  126. </listitem>
  127. <listitem>
  128. <para>
  129. <structfield>parsed_flag</structfield> - Already parsed header field types (bitwise OR).
  130. </para>
  131. </listitem>
  132. </itemizedlist>
  133. The following fields are set to zero if the corresponding header field
  134. was not found in the message or hasn't been parsed yet. (These fields
  135. are called hooks - they always point to the first occurrence if there
  136. is more than one header field of the same type).
  137. <itemizedlist>
  138. <listitem>
  139. <para>
  140. <structfield>h_via1</structfield> - Pointer to the first Via header field.
  141. </para>
  142. </listitem>
  143. <listitem>
  144. <para>
  145. <structfield>h_via2</structfield> - Pointer to the second Via header field.
  146. </para>
  147. </listitem>
  148. <listitem>
  149. <para>
  150. <structfield>callid</structfield> - Pointer to the first Call-ID header field.
  151. </para>
  152. </listitem>
  153. <listitem>
  154. <para>
  155. <structfield>to</structfield> - Pointer to the first To header field.
  156. </para>
  157. </listitem>
  158. <listitem>
  159. <para>
  160. <structfield>cseq</structfield> - Pointer to the first CSeq header field.
  161. </para>
  162. </listitem>
  163. <listitem>
  164. <para>
  165. <structfield>from</structfield> - Pointer to the first From header field.
  166. </para>
  167. </listitem>
  168. <listitem>
  169. <para>
  170. <structfield>contact</structfield> - Pointer to the first Contact header field.
  171. </para>
  172. </listitem>
  173. <listitem>
  174. <para>
  175. <structfield>maxforwards</structfield> - Pointer to the first Max-Forwards header field.
  176. </para>
  177. </listitem>
  178. <listitem>
  179. <para>
  180. <structfield>route</structfield> - Pointer to the first Route header field.
  181. </para>
  182. </listitem>
  183. <listitem>
  184. <para>
  185. <structfield>record_route</structfield> - Pointer to the first Record-Route header field.
  186. </para>
  187. </listitem>
  188. <listitem>
  189. <para>
  190. <structfield>content_type</structfield> - Pointer to the first Content-Type header field.
  191. </para>
  192. </listitem>
  193. <listitem>
  194. <para>
  195. <structfield>content_length</structfield> - Pointer to the first Content-Length header field.
  196. </para>
  197. </listitem>
  198. <listitem>
  199. <para>
  200. <structfield>authorization</structfield> - Pointer to the first Authorization header field.
  201. </para>
  202. </listitem>
  203. <listitem>
  204. <para>
  205. <structfield>expires</structfield> - Pointer to the first Expires header field.
  206. </para>
  207. </listitem>
  208. <listitem>
  209. <para>
  210. <structfield>proxy_auth</structfield> - Pointer to the first Proxy-Authorize header field.
  211. </para>
  212. </listitem>
  213. <listitem>
  214. <para>
  215. <structfield>www_auth</structfield> - Pointer to the first WWW-Authorize header field.
  216. </para>
  217. </listitem>
  218. <listitem>
  219. <para>
  220. <structfield>supported</structfield> - Pointer to the first Supported header field.
  221. </para>
  222. </listitem>
  223. <listitem>
  224. <para>
  225. <structfield>require</structfield> - Pointer to the first Require header field.
  226. </para>
  227. </listitem>
  228. <listitem>
  229. <para>
  230. <structfield>proxy_require</structfield> - Pointer to the first Proxy-Require header field.
  231. </para>
  232. </listitem>
  233. <listitem>
  234. <para>
  235. <structfield>unsupported</structfield> - Pointer to the first Unsupported header field.
  236. </para>
  237. </listitem>
  238. <listitem>
  239. <para>
  240. <structfield>allow</structfield> - Pointer to the first Allow header field.
  241. </para>
  242. </listitem>
  243. <listitem>
  244. <para>
  245. <structfield>event</structfield> - Pointer to the first Event header field.
  246. </para>
  247. </listitem>
  248. </itemizedlist>
  249. The following fields are mostly used internally by the server and
  250. should be modified through dedicated functions only.
  251. <itemizedlist>
  252. <listitem>
  253. <para>
  254. <structfield>eoh</structfield> - Pointer to the End of
  255. Header or null if not found yet (the field will be set if
  256. and only if the whole message was parsed already).
  257. </para>
  258. </listitem>
  259. <listitem>
  260. <para>
  261. <structfield>unparsed</structfield> - Pointer to the first
  262. unparsed character in the message.
  263. </para>
  264. </listitem>
  265. <listitem>
  266. <para>
  267. <structfield>src_ip</structfield> - Sender's <acronym>IP</acronym> address.
  268. </para>
  269. </listitem>
  270. <listitem>
  271. <para>
  272. <structfield>dst_ip</structfield> - Destination's <acronym>IP</acronym> address.
  273. </para>
  274. </listitem>
  275. <listitem>
  276. <para>
  277. <structfield>orig</structfield> - Original (unmodified)
  278. message copy, this field will hold unmodified copy of the
  279. message during the whole message lifetime.
  280. </para>
  281. </listitem>
  282. <listitem>
  283. <para>
  284. <structfield>buf</structfield> - Message scratch-pad (modified
  285. copy of the message) - All modifications made to the message
  286. will be done here.
  287. </para>
  288. </listitem>
  289. <listitem>
  290. <para>
  291. <structfield>len</structfield> - Length of the message (unmodified).
  292. </para>
  293. </listitem>
  294. </itemizedlist>
  295. <itemizedlist>
  296. <listitem>
  297. <para>
  298. <structfield>new_uri</structfield> - New Request-URI to be used when forwarding the message.
  299. </para>
  300. </listitem>
  301. <listitem>
  302. <para>
  303. <structfield>parsed_uri_ok</structfield> - 1 if <structfield>parsed_uri</structfield> is
  304. valid, 0 if not.
  305. </para>
  306. </listitem>
  307. <listitem>
  308. <para>
  309. <structfield>parsed_uri</structfield> - The original parsed
  310. Request <acronym>URI</acronym>, sometimes it might be
  311. necessary to revert changes made to the Request
  312. <acronym>URI</acronym> and therefore we store the original
  313. <acronym>URI</acronym> here.
  314. </para>
  315. </listitem>
  316. </itemizedlist>
  317. <itemizedlist>
  318. <listitem>
  319. <para>
  320. <structfield>add_rm</structfield> - Linked list describing
  321. all modifications that will be made to
  322. <emphasis>REQUEST</emphasis> before it will be
  323. forwarded. The list will be processed when the request is
  324. being converted to character array (i.e. immediately before
  325. the request will be send out).
  326. </para>
  327. </listitem>
  328. <listitem>
  329. <para>
  330. <structfield>repl_add_rm</structfield> - Linked list
  331. describing all modifications that will be made to
  332. <emphasis>REPLY</emphasis> before it will be forwarded. the
  333. list will be processed when the reply is being converted to
  334. character array (i.e. immediately before the request will
  335. be send out).
  336. </para>
  337. </listitem>
  338. <listitem>
  339. <para>
  340. <structfield>reply_lump</structfield> - This is list of
  341. data chunks that should be appended to locally generated
  342. reply, i.e. when the server is generating local reply out
  343. of the request. A local reply is reply generated by the
  344. server. For example, when processing of a request fails for
  345. some reason, the server might generate an error reply and
  346. send it back to sender.
  347. </para>
  348. </listitem>
  349. </itemizedlist>
  350. <itemizedlist>
  351. <listitem>
  352. <para>
  353. <structfield>add_to_branch_s</structfield> - String to be
  354. appended to branch parameter.
  355. </para>
  356. </listitem>
  357. <listitem>
  358. <para>
  359. <structfield>add_to_branch_len</structfield> - Length of the string.
  360. </para>
  361. </listitem>
  362. </itemizedlist>
  363. <itemizedlist>
  364. <listitem>
  365. <para>
  366. <structfield>hash_index</structfield> - Index to a hash table
  367. in TM module.
  368. </para>
  369. </listitem>
  370. <listitem>
  371. <para>
  372. <structfield>flags</structfield> - Allows to set various flags on the message. May be used
  373. for simple inter-module communication or remembering processing state reached.
  374. </para>
  375. </listitem>
  376. </itemizedlist>
  377. </para>
  378. </section> <!-- sip_msg -->