parse_via.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. * Copyright (C) 2001-2003 FhG Fokus
  3. *
  4. * This file is part of ser, a free SIP server.
  5. *
  6. * ser is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version
  10. *
  11. * For a license to use the ser software under conditions
  12. * other than those described here, or to purchase support for this
  13. * software, please contact iptel.org by e-mail at the following addresses:
  14. * [email protected]
  15. *
  16. * ser is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. */
  25. /** @file
  26. * @brief Parser :: Via parsing automation
  27. *
  28. * @ingroup parser
  29. */
  30. /*
  31. * 2003-01-21 added rport parsing code, contributed by
  32. * Maxim Sobolev <[email protected]>
  33. * 2003-01-21 added extra via param parsing code (i=...), used
  34. * by tcp to identify the sending socket, by andrei
  35. * 2003-01-27 added a new member (start) to via_param, by andrei
  36. * 2003-10-27 added alias to via && PARAM_ALIAS (andrei)
  37. * 2006-02-24 added comp/PARAM_COMP support (andrei)
  38. */
  39. #ifndef PARSE_VIA_H
  40. #define PARSE_VIA_H
  41. #include "../str.h"
  42. struct sip_msg;
  43. /* via param types
  44. * WARNING: keep in sync with parse_via.c FIN_HIDDEN...
  45. * and with tm/sip_msg.c via_body_cloner
  46. */
  47. enum {
  48. PARAM_HIDDEN=230, PARAM_TTL, PARAM_BRANCH,
  49. PARAM_MADDR, PARAM_RECEIVED, PARAM_RPORT, PARAM_I, PARAM_ALIAS,
  50. #ifdef USE_COMP
  51. PARAM_COMP,
  52. #endif
  53. GEN_PARAM=253,
  54. PARAM_ERROR
  55. };
  56. struct via_param {
  57. int type; /* Type of the parameter */
  58. str name; /* Name of the parameter */
  59. str value; /* Value of the parameter */
  60. char* start; /* Pointer to param start, just after ';',
  61. * (it can be diff. from name.s!) */
  62. int size; /* total size, including preceding and trailing
  63. * white space */
  64. struct via_param* next; /* Next parameter in the list */
  65. };
  66. /* Format: name/version/transport host:port;params comment */
  67. /* WARNING: keep in sync with tm/sip_msg.c via_body_cloner */
  68. struct via_body {
  69. int error;
  70. str hdr; /* Contains "Via" or "v" */
  71. str name;
  72. str version;
  73. str transport;
  74. str host;
  75. short proto; /* transport */
  76. unsigned short port;
  77. #ifdef USE_COMP
  78. short comp_no;
  79. #endif
  80. str port_str;
  81. str params;
  82. str comment;
  83. int bsize; /* body size, not including hdr */
  84. struct via_param* param_lst; /* list of parameters*/
  85. struct via_param* last_param; /*last via parameter, internal use*/
  86. /* shortcuts to "important" params*/
  87. struct via_param* branch;
  88. str tid; /* transaction id, part of branch */
  89. struct via_param* received;
  90. struct via_param* rport;
  91. struct via_param* i;
  92. struct via_param* alias; /* alias see draft-ietf-sip-connect-reuse-00 */
  93. #ifdef USE_COMP
  94. struct via_param* comp; /* see rfc3486 */
  95. #endif
  96. struct via_body* next; /* pointer to next via body string if
  97. compact via or null */
  98. };
  99. /*
  100. * Main Via header field parser
  101. */
  102. char* parse_via(char* buffer, const char* const end, struct via_body* const vbody);
  103. /*
  104. * Free allocated memory
  105. */
  106. void free_via_list(struct via_body *vb);
  107. /*
  108. * Get one Via header
  109. */
  110. int parse_via_header( struct sip_msg *msg, int n, struct via_body** q);
  111. #endif /* PARSE_VIA_H */