parse_content.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * $Id$
  3. *
  4. *
  5. * Copyright (C) 2001-2003 FhG Fokus
  6. *
  7. * This file is part of ser, a free SIP server.
  8. *
  9. * ser is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version
  13. *
  14. * ser is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. /*! \file
  24. * \brief Parser :: Content
  25. *
  26. * \ingroup parser
  27. */
  28. #ifndef _PARSE_CONTENT_H
  29. #define _PARSE_CONTENT_H
  30. #include "msg_parser.h"
  31. struct mime_type {
  32. unsigned short type;
  33. unsigned short subtype;
  34. };
  35. /*! \name MimeTypes
  36. * Mimes types/subtypes that are recognized
  37. */
  38. /*@{ */
  39. #define TYPE_TEXT 1
  40. #define TYPE_MESSAGE 2
  41. #define TYPE_APPLICATION 3
  42. #define TYPE_MULTIPART 4
  43. #define TYPE_ALL 0xfe
  44. #define TYPE_UNKNOWN 0xff
  45. #define SUBTYPE_PLAIN 1
  46. #define SUBTYPE_CPIM 2
  47. #define SUBTYPE_SDP 3
  48. #define SUBTYPE_CPLXML 4
  49. #define SUBTYPE_PIDFXML 5
  50. #define SUBTYPE_RLMIXML 6
  51. #define SUBTYPE_RELATED 7
  52. #define SUBTYPE_LPIDFXML 8
  53. #define SUBTYPE_XPIDFXML 9
  54. #define SUBTYPE_WATCHERINFOXML 10
  55. #define SUBTYPE_EXTERNAL_BODY 11
  56. #define SUBTYPE_XML_MSRTC_PIDF 12
  57. #define SUBTYPE_CPIM_PIDFXML 13
  58. #define SUBTYPE_MIXED 14
  59. #define SUBTYPE_ALL 0xfe
  60. #define SUBTYPE_UNKNOWN 0xff
  61. /*@} */
  62. /*! \brief taken from PA module - will be useful here */
  63. #define MIMETYPE(x_,y_) ((TYPE_##x_ << 16) | (SUBTYPE_##y_))
  64. /*! \brief
  65. * Maximum number of mimes allowed in Accept header
  66. */
  67. #define MAX_MIMES_NR 128
  68. /*! \brief
  69. * returns the content-length value of a sip_msg as an integer
  70. */
  71. #define get_content_length(_msg_) ((long)((_msg_)->content_length->parsed))
  72. /*! \brief
  73. * returns the content-type value of a sip_msg as an integer
  74. */
  75. #define get_content_type(_msg_) ((int)(long)((_msg_)->content_type->parsed))
  76. /*! \brief
  77. * returns the accept values of a sip_msg as an null-terminated array
  78. * of integer
  79. */
  80. #define get_accept(_msg_) ((int*)((_msg_)->accept->parsed))
  81. /*! \brief
  82. * parse the body of the Content-Type header. It's value is also converted
  83. * as int.
  84. * Returns: n (n>0) : the found type
  85. * 0 : hdr not found
  86. * -1 : error (parse error )
  87. */
  88. int parse_content_type_hdr( struct sip_msg *msg);
  89. int parse_accept_body(struct hdr_field *hdr);
  90. /*! \brief
  91. * parse the body of the Accept header. It's values are also converted
  92. * as an null-terminated array of ints.
  93. * Returns: 1 : OK
  94. * 0 : hdr not found
  95. * -1 : error (parse error)
  96. */
  97. int parse_accept_hdr( struct sip_msg *msg );
  98. /*! \brief
  99. * parse the body of a Content_-Length header. Also tries to recognize the
  100. * type specified by this header (see th above defines).
  101. * Returns the first chr after the end of the header.
  102. */
  103. char* parse_content_length( char* buffer, char* end, int* len);
  104. /*! \brief
  105. * Sets the mime type from the body of a Content-Type header
  106. */
  107. char* decode_mime_type(char *start, char *end, unsigned int *mime_type);
  108. #endif