1 /* 2 * Copyright (C) 2001-2003 FhG Fokus 3 * 4 * This file is part of Kamailio, a free SIP server. 5 * 6 * Kamailio 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 Kamailio 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 * info@iptel.org 15 * 16 * Kamailio 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 26 /*! \file 27 * \brief Parser :: SIP first line parsing automaton 28 * 29 * \ingroup parser 30 */ 31 32 #ifndef PARSE_FLINE_H 33 #define PARSE_FLINE_H 34 35 #include "../str.h" 36 37 /* Message is request */ 38 #define SIP_REQUEST 1 39 40 /* Message is reply */ 41 #define SIP_REPLY 2 42 43 /* Invalid message */ 44 #define SIP_INVALID 0 45 46 #define SIP_VERSION "SIP/2.0" 47 #define SIP_VERSION_LEN 7 48 49 #define HTTP_VERSION "HTTP/1." 50 #define HTTP_VERSION_LEN (sizeof(HTTP_VERSION)-1) 51 52 #define HTTP2_VERSION "HTTP/2" 53 #define HTTP2_VERSION_LEN (sizeof(HTTP2_VERSION)-1) 54 55 #define CANCEL "CANCEL" 56 #define ACK "ACK" 57 #define INVITE "INVITE" 58 59 #define INVITE_LEN 6 60 #define CANCEL_LEN 6 61 #define ACK_LEN 3 62 #define BYE_LEN 3 63 #define INFO_LEN 4 64 #define REGISTER_LEN 8 65 #define SUBSCRIBE_LEN 9 66 #define NOTIFY_LEN 6 67 #define MESSAGE_LEN 7 68 #define OPTIONS_LEN 7 69 #define PRACK_LEN 5 70 #define UPDATE_LEN 6 71 #define REFER_LEN 5 72 #define PUBLISH_LEN 7 73 #define KDMQ_LEN 4 74 #define GET_LEN 3 75 #define POST_LEN 4 76 #define PUT_LEN 3 77 #define DELETE_LEN 6 78 79 typedef struct msg_start { 80 short type; /*!< Type of the message - request/response */ 81 short flags; /*!< First line flags */ 82 int len; /*!< length including delimiter */ 83 union { 84 struct { 85 str method; /*!< Method string */ 86 str uri; /*!< Request URI */ 87 str version; /*!< SIP version */ 88 int method_value; 89 } request; 90 struct { 91 str version; /*!< SIP version */ 92 str status; /*!< Reply status */ 93 str reason; /*!< Reply reason phrase */ 94 unsigned int statuscode; /*!< Reply status code */ 95 } reply; 96 }u; 97 } msg_start_t; 98 99 char* parse_first_line(char* buffer, unsigned int len, struct msg_start * fl); 100 101 char* parse_fline(char* buffer, char* end, struct msg_start* fl); 102 103 #endif /* PARSE_FLINE_H */ 104