• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • Directories
  • File List
  • Globals

tags.h

00001 /*
00002  * $Id$
00003  *
00004  * - utility for generating to-tags
00005  *   in SER, to-tags consist of two parts: a fixed part
00006  *   which is bound to server instance and variable part
00007  *   which is bound to request -- that helps to recognize,
00008  *   who generated the to-tag in loops through the same
00009  *   server -- in such cases, fixed part is constant, but
00010  *   the variable part varies because it depends on 
00011  *   via
00012  *   
00013  * Copyright (C) 2001-2003 FhG Fokus
00014  *
00015  * This file is part of ser, a free SIP server.
00016  *
00017  * ser is free software; you can redistribute it and/or modify
00018  * it under the terms of the GNU General Public License as published by
00019  * the Free Software Foundation; either version 2 of the License, or
00020  * (at your option) any later version
00021  *
00022  * For a license to use the ser software under conditions
00023  * other than those described here, or to purchase support for this
00024  * software, please contact iptel.org by e-mail at the following addresses:
00025  *    info@iptel.org
00026  *
00027  * ser is distributed in the hope that it will be useful,
00028  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00029  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00030  * GNU General Public License for more details.
00031  *
00032  * You should have received a copy of the GNU General Public License 
00033  * along with this program; if not, write to the Free Software 
00034  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00035  */
00036 /*
00037  * History:
00038  * --------
00039  *  2003-02-18  changed TOTAG_LEN into TOTAG_VALUE_LEN, to solve
00040  *               redefinition conflict with tm/t_msgbuilder.h (andrei)
00041  */
00042 
00043 
00044 #ifndef _TAGS_H
00045 #define _TAGS_H
00046 
00047 #include "parser/msg_parser.h"
00048 #include "globals.h"
00049 #include "crc.h"
00050 #include "str.h"
00051 #include "socket_info.h"
00052 
00053 #define TOTAG_VALUE_LEN (MD5_LEN+CRC16_LEN+1)
00054 
00055 /* generate variable part of to-tag for a request;
00056  * it will have length of CRC16_LEN, sufficiently
00057  * long buffer must be passed to the function */
00058 static inline void calc_crc_suffix( struct sip_msg *msg, char *tag_suffix)
00059 {
00060         int ss_nr;
00061         str suffix_source[3];
00062 
00063         ss_nr=2;
00064         if (msg->via1==0) return; /* no via, bad message */
00065         suffix_source[0]=msg->via1->host;
00066         suffix_source[1]=msg->via1->port_str;
00067         if (msg->via1->branch)
00068                 suffix_source[ss_nr++]=msg->via1->branch->value;
00069         crcitt_string_array( tag_suffix, suffix_source, ss_nr );
00070 }
00071 
00072 static void inline init_tags( char *tag, char **suffix, 
00073                 char *signature, char separator )
00074 {
00075         str src[3];
00076         struct socket_info* si;
00077         
00078         si=get_first_socket();
00079         src[0].s=signature; src[0].len=strlen(signature);
00080         /* if we are not listening on anything we shouldn't be here */
00081         src[1].s=si?si->address_str.s:"";
00082         src[1].len=si?si->address_str.len:0;
00083         src[2].s=si?si->port_no_str.s:"";
00084         src[2].len=si?si->port_no_str.len:0;
00085 
00086         MD5StringArray( tag, src, 3 );
00087 
00088         tag[MD5_LEN]=separator;
00089         *suffix=tag+MD5_LEN+1;
00090 }
00091 
00092 
00093 #endif

Generated on Tue May 22 2012 13:10:16 for SIP Router by  doxygen 1.7.1