parse_via.h

Go to the documentation of this file.
00001 /*
00002  * $Id: parse_via.h 4720 2008-08-23 10:56:15Z henningw $
00003  *
00004  * Copyright (C) 2001-2003 FhG Fokus
00005  *
00006  * This file is part of Kamailio, a free SIP server.
00007  *
00008  * Kamailio is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * Kamailio is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License 
00019  * along with this program; if not, write to the Free Software 
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  */
00022 
00023 /*
00024  *  2003-01-21  added rport parsing code, contributed by
00025  *               Maxim Sobolev  <sobomax@FreeBSD.org>
00026  *  2003-01-21  added extra via param parsing code (i=...), used
00027  *               by tcp to identify the sending socket, by andrei
00028  *  2003-01-27  added a new member (start) to via_param, by andrei
00029  *  2003-10-27  added alias to via && PARAM_ALIAS (andrei)
00030  */
00031 
00032 /*!
00033  * \file
00034  * \brief VIA parsing automaton
00035  * \ingroup parser
00036  */
00037 
00038 
00039 #ifndef PARSE_VIA_H
00040 #define PARSE_VIA_H
00041 
00042 #include "../str.h"
00043 
00044 /*! via param types
00045  * \warning WARNING: keep in sync with parse_via.c FIN_HIDDEN and with tm/sip_msg.c via_body_cloner
00046  */
00047 enum {
00048    PARAM_HIDDEN=230, PARAM_TTL, PARAM_BRANCH, 
00049    PARAM_MADDR, PARAM_RECEIVED, PARAM_RPORT, PARAM_I, PARAM_ALIAS,
00050    GEN_PARAM,
00051    PARAM_ERROR
00052 };
00053 
00054 
00055 
00056 struct via_param {
00057    int type;               /* Type of the parameter */
00058    str name;               /* Name of the parameter */
00059    str value;              /* Value of the parameter */
00060    char* start;            /* Pointer to param start, just after ';',
00061                       * (it can be diff. from name.s!) */
00062    int size;               /* total size, including preceding and trailing
00063                       * white space */
00064    struct via_param* next; /* Next parameter in the list */
00065 };
00066 
00067 
00068 /*! Format: name/version/transport host:port;params comment
00069  * \warning keep in sync with tm/sip_msg.c via_body_cloner */
00070 struct via_body { 
00071    int error;
00072    str hdr;   /*!< Contains "Via" or "v" */
00073    str name;
00074    str version;
00075    str transport;
00076    str host;
00077    unsigned short proto; /*!< transport */
00078    unsigned short port;
00079    str port_str;
00080    str params;
00081    str comment;
00082    unsigned int bsize;           /*!< body size, not including hdr */
00083    struct via_param* param_lst;  /*!< list of parameters*/
00084    struct via_param* last_param; /*!< last via parameter, internal use*/
00085 
00086    /* shortcuts to "important" params*/
00087    struct via_param* branch;
00088    str tid; /*!< transaction id, part of branch */
00089    struct via_param* received;
00090    struct via_param* rport;
00091    struct via_param* i;
00092    struct via_param* alias; /*!< alias see draft-ietf-sip-connect-reuse-00 */
00093    struct via_param* maddr;
00094    struct via_body* next; /*!< pointer to next via body string if
00095               compact via or null */
00096 };
00097 
00098 
00099 /*!
00100  * Main Via header field parser
00101  */
00102 char* parse_via(char* buffer, char* end, struct via_body *vb);
00103 
00104 
00105 /*!
00106  * Free allocated memory
00107  */
00108 void free_via_list(struct via_body *vb);
00109 
00110 
00111 #endif /* PARSE_VIA_H */

Generated on Thu May 24 00:00:28 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6