parse_via.h 3.6 KB

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