Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

msg_translator.h

Go to the documentation of this file.
00001 /*$Id: msg_translator.h,v 1.33 2009/03/13 13:59:28 tirpi Exp $
00002  * 
00003  *
00004  * Copyright (C) 2001-2003 FhG Fokus
00005  *
00006  * This file is part of ser, a free SIP server.
00007  *
00008  * ser 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  * For a license to use the ser software under conditions
00014  * other than those described here, or to purchase support for this
00015  * software, please contact iptel.org by e-mail at the following addresses:
00016  *    info@iptel.org
00017  *
00018  * ser is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License 
00024  * along with this program; if not, write to the Free Software 
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  *
00027  * History:
00028  * --------
00029  * 2003-03-06  totags in outgoing replies bookmarked to enable
00030  *             ACK/200 tag matching
00031  *
00032  * 2003-03-01 VOICE_MAIL defs removed (jiri)
00033  * 2003-10-08 receive_test function-alized (jiri)
00034  */
00035 
00036 
00037 #ifndef  _MSG_TRANSLATOR_H
00038 #define _MSG_TRANSLATOR_H
00039 
00040 #define MY_HF_SEP ": "
00041 #define MY_HF_SEP_LEN 2
00042 
00043 #define BRANCH_SEPARATOR '.'
00044 #define WARNING "Warning: 392 "
00045 #define WARNING_LEN (sizeof(WARNING)-1)
00046 #define WARNING_PHRASE " \"Noisy feedback tells: "
00047 #define WARNING_PHRASE_LEN (sizeof(WARNING_PHRASE)-1)
00048 
00049 /*#define MAX_CONTENT_LEN_BUF INT2STR_MAX_LEN *//* see ut.h/int2str() */
00050 
00051 #include "parser/msg_parser.h"
00052 #include "ip_addr.h"
00053 
00054 /* point to some remarkable positions in a SIP message */
00055 struct bookmark {
00056         str to_tag_val;
00057 };
00058 
00059 /* used by via_builder */
00060 struct hostport {
00061         str* host;
00062         str* port;
00063 };
00064 
00065 
00066 #define set_hostport(hp, msg) \
00067         do{ \
00068                 if ((msg) && ((struct sip_msg*)(msg))->set_global_address.len) \
00069                         (hp)->host=&(((struct sip_msg*)(msg))->set_global_address); \
00070                 else \
00071                         (hp)->host=&default_global_address; \
00072                 if ((msg) && ((struct sip_msg*)(msg))->set_global_port.len) \
00073                         (hp)->port=&(((struct sip_msg*)(msg))->set_global_port); \
00074                 else \
00075                         (hp)->port=&default_global_port; \
00076         }while(0)
00077 
00078 char * build_req_buf_from_sip_req (     struct sip_msg* msg, 
00079                                 unsigned int *returned_len, struct dest_info* send_info);
00080 
00081 char * build_res_buf_from_sip_res(      struct sip_msg* msg,
00082                                 unsigned int *returned_len);
00083 
00084 
00085 char * build_res_buf_from_sip_req( unsigned int code ,
00086                                 char *text ,
00087                                 str *new_tag ,
00088                                 struct sip_msg* msg,
00089                                 unsigned int *returned_len,
00090                                 struct bookmark *bmark);
00091 /*
00092 char * build_res_buf_with_body_from_sip_req(    unsigned int code ,
00093                                 char *text ,
00094                                 char *new_tag ,
00095                                 unsigned int new_tag_len ,
00096                                 char *body ,
00097                                 unsigned int body_len,
00098                                 char *content_type,
00099                                 unsigned int content_type_len,
00100                                 struct sip_msg* msg,
00101                                 unsigned int *returned_len,
00102                                 struct bookmark *bmark);
00103 */
00104 char* via_builder( unsigned int *len,
00105         struct dest_info* send_info,
00106         str *branch, str* extra_params, struct hostport *hp );
00107 
00108 /* creates a via header honoring the protocol of the incomming socket
00109  * msg is an optional parameter */
00110 char* create_via_hf( unsigned int *len,
00111         struct sip_msg *msg,
00112         struct dest_info* send_info /* where to send the reply */,
00113         str* branch);
00114 
00115 int branch_builder( unsigned int hash_index, 
00116         /* only either parameter useful */
00117         unsigned int label, char * char_v,
00118         int branch,
00119         /* output value: string and actual length */
00120         char *branch_str, int *len );
00121 
00122 char* id_builder(struct sip_msg* msg, unsigned int *id_len);
00123 
00124 /* check if IP address in Via != source IP address of signaling */
00125 int received_test( struct sip_msg *msg );
00126 
00127 /* builds a char* buffer from message headers without body
00128  * first line is excluded in case of skip_first_line=1
00129  */
00130 char * build_only_headers( struct sip_msg* msg, int skip_first_line,
00131                                 unsigned int *returned_len,
00132                                 int *error,
00133                                 struct dest_info* send_info);
00134 
00135 /* builds a char* buffer from message body
00136  * error is set -1 if the memory allocation failes
00137  */
00138 char * build_body( struct sip_msg* msg,
00139                         unsigned int *returned_len,
00140                         int *error,
00141                         struct dest_info* send_info);
00142 
00143 /* builds a char* buffer from SIP message including body
00144  * The function adjusts the Content-Length HF according
00145  * to body lumps in case of adjust_clen=1.
00146  */
00147 char * build_all( struct sip_msg* msg, int adjust_clen,
00148                         unsigned int *returned_len,
00149                         int *error,
00150                         struct dest_info* send_info);
00151 
00153 void fix_global_req_flags(str* gname, str* name);
00154 
00155 #endif

Generated on Tue Sep 7 04:16:12 2010 for SIPExpressRouter by  doxygen 1.3.9.1