parse_via.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. #ifndef PARSE_VIA_H
  28. #define PARSE_VIA_H
  29. #include "../str.h"
  30. /* via param types
  31. * WARNING: keep in sync w/ FIN_*, GEN_PARAM and PARAM_ERROR from via_parse.c
  32. */
  33. enum {
  34. PARAM_HIDDEN=230, PARAM_TTL, PARAM_BRANCH,
  35. PARAM_MADDR, PARAM_RECEIVED, GEN_PARAM,
  36. PARAM_ERROR
  37. };
  38. struct via_param {
  39. int type; /* Type of the parameter */
  40. str name; /* Name of the parameter */
  41. str value; /* Value of the parameter */
  42. int size; /* total size*/
  43. struct via_param* next; /* Next parameter in the list */
  44. };
  45. /* Format: name/version/transport host:port;params comment */
  46. struct via_body {
  47. int error;
  48. str hdr; /* Contains "Via" or "v" */
  49. str name;
  50. str version;
  51. str transport;
  52. int proto; /* transport */
  53. str host;
  54. int port;
  55. str port_str;
  56. str params;
  57. str comment;
  58. int bsize; /* body size, not including hdr */
  59. struct via_param* param_lst; /* list of parameters*/
  60. struct via_param* last_param; /*last via parameter, internal use*/
  61. /* shortcuts to "important" params*/
  62. struct via_param* branch;
  63. str tid; /* transaction id, part of branch */
  64. struct via_param* received;
  65. struct via_body* next; /* pointer to next via body string if
  66. compact via or null */
  67. };
  68. /*
  69. * Main Via header field parser
  70. */
  71. char* parse_via(char* buffer, char* end, struct via_body *vb);
  72. /*
  73. * Free allocated memory
  74. */
  75. void free_via_list(struct via_body *vb);
  76. #endif /* PARSE_VIA_H */