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 * Kamailio is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 /** @file 22 * @brief Parser :: Via parsing automation 23 * 24 * @ingroup parser 25 */ 26 27 #ifndef PARSE_VIA_H 28 #define PARSE_VIA_H 29 30 #include "../str.h" 31 32 struct sip_msg; 33 34 /* via param types 35 * WARNING: keep in sync with parse_via.c FIN_HIDDEN... 36 * and with tm/sip_msg.c via_body_cloner 37 */ 38 enum { 39 PARAM_HIDDEN=230, PARAM_TTL, PARAM_BRANCH, 40 PARAM_MADDR, PARAM_RECEIVED, PARAM_RPORT, PARAM_I, PARAM_ALIAS, 41 #ifdef USE_COMP 42 PARAM_COMP, 43 #endif 44 GEN_PARAM=253, 45 PARAM_ERROR 46 }; 47 48 49 50 typedef struct via_param { 51 int type; /* Type of the parameter */ 52 str name; /* Name of the parameter */ 53 str value; /* Value of the parameter */ 54 char* start; /* Pointer to param start, just after ';', 55 * (it can be diff. from name.s!) */ 56 int size; /* total size, including preceding and trailing 57 * white space */ 58 struct via_param* next; /* Next parameter in the list */ 59 } via_param_t; 60 61 62 /* Format: name/version/transport host:port;params comment */ 63 /* WARNING: keep in sync with tm/sip_msg.c via_body_cloner */ 64 typedef struct via_body { 65 int error; 66 str hdr; /* Contains "Via" or "v" */ 67 str name; 68 str version; 69 str transport; 70 str host; 71 short proto; /* transport */ 72 unsigned short port; 73 #ifdef USE_COMP 74 short comp_no; 75 #endif 76 str port_str; 77 str params; 78 str comment; 79 int bsize; /* body size, not including hdr */ 80 struct via_param* param_lst; /* list of parameters*/ 81 struct via_param* last_param; /*last via parameter, internal use*/ 82 83 /* shortcuts to "important" params*/ 84 struct via_param* branch; 85 str tid; /* transaction id, part of branch */ 86 struct via_param* received; 87 struct via_param* rport; 88 struct via_param* i; 89 struct via_param* alias; /* alias see draft-ietf-sip-connect-reuse-00 */ 90 #ifdef USE_COMP 91 struct via_param* comp; /* see rfc3486 */ 92 #endif 93 struct via_body* next; /* pointer to next via body string if 94 compact via or null */ 95 } via_body_t; 96 97 98 /* 99 * Main Via header field parser 100 */ 101 char* parse_via(char* buffer, const char* const end, struct via_body* const vbody); 102 103 104 /* 105 * Free allocated memory 106 */ 107 void free_via_list(struct via_body *vb); 108 109 110 /* 111 * Get one Via header 112 */ 113 int parse_via_header( struct sip_msg *msg, int n, struct via_body** q); 114 115 116 #endif /* PARSE_VIA_H */ 117