parse_fline.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 :: SIP first line parsing automaton
  27. *
  28. * \ingroup parser
  29. */
  30. #ifndef PARSE_FLINE_H
  31. #define PARSE_FLINE_H
  32. #include "../str.h"
  33. /* Message is request */
  34. #define SIP_REQUEST 1
  35. /* Message is reply */
  36. #define SIP_REPLY 2
  37. /* Invalid message */
  38. #define SIP_INVALID 0
  39. #define SIP_VERSION "SIP/2.0"
  40. #define SIP_VERSION_LEN 7
  41. #define HTTP_VERSION "HTTP/1."
  42. #define HTTP_VERSION_LEN (sizeof(HTTP_VERSION)-1)
  43. #define CANCEL "CANCEL"
  44. #define ACK "ACK"
  45. #define INVITE "INVITE"
  46. #define INVITE_LEN 6
  47. #define CANCEL_LEN 6
  48. #define ACK_LEN 3
  49. #define BYE_LEN 3
  50. #define INFO_LEN 4
  51. #define REGISTER_LEN 8
  52. #define SUBSCRIBE_LEN 9
  53. #define NOTIFY_LEN 6
  54. #define MESSAGE_LEN 7
  55. #define OPTIONS_LEN 7
  56. #define PRACK_LEN 5
  57. #define UPDATE_LEN 6
  58. #define REFER_LEN 5
  59. #define PUBLISH_LEN 7
  60. struct msg_start {
  61. int type; /*!< Type of the Message - Request/Response */
  62. int len; /*!< length including delimiter */
  63. union {
  64. struct {
  65. str method; /*!< Method string */
  66. str uri; /*!< Request URI */
  67. str version; /*!< SIP version */
  68. int method_value;
  69. } request;
  70. struct {
  71. str version; /*!< SIP version */
  72. str status; /*!< Reply status */
  73. str reason; /*!< Reply reason phrase */
  74. unsigned int /*!< statusclass,*/ statuscode;
  75. } reply;
  76. }u;
  77. };
  78. char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl);
  79. char* parse_fline(char* buffer, char* end, struct msg_start* fl);
  80. #endif /* PARSE_FLINE_H */