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

msg_translator.h

00001 /*$Id$
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 #define BUILD_NO_LOCAL_VIA              (1<<0)
00052 #define BUILD_NO_VIA1_UPDATE    (1<<1)
00053 #define BUILD_NO_PATH                   (1<<2)
00054 #define BUILD_IN_SHM                    (1<<7)
00055 
00056 #include "parser/msg_parser.h"
00057 #include "ip_addr.h"
00058 
00059 /* point to some remarkable positions in a SIP message */
00060 struct bookmark {
00061         str to_tag_val;
00062 };
00063 
00064 /* used by via_builder */
00065 struct hostport {
00066         str* host;
00067         str* port;
00068 };
00069 
00070 
00071 #define set_hostport(hp, msg) \
00072         do{ \
00073                 if ((msg) && ((struct sip_msg*)(msg))->set_global_address.len) \
00074                         (hp)->host=&(((struct sip_msg*)(msg))->set_global_address); \
00075                 else \
00076                         (hp)->host=&default_global_address; \
00077                 if ((msg) && ((struct sip_msg*)(msg))->set_global_port.len) \
00078                         (hp)->port=&(((struct sip_msg*)(msg))->set_global_port); \
00079                 else \
00080                         (hp)->port=&default_global_port; \
00081         }while(0)
00082 
00083 char * build_req_buf_from_sip_req(struct sip_msg* msg, 
00084                                 unsigned int *returned_len, struct dest_info* send_info,
00085                                 unsigned int mode);
00086 
00087 char * build_res_buf_from_sip_res(struct sip_msg* msg,
00088                                 unsigned int *returned_len);
00089 
00090 
00091 char * build_res_buf_from_sip_req(unsigned int code,
00092                                 str *text,
00093                                 str *new_tag,
00094                                 struct sip_msg* msg,
00095                                 unsigned int *returned_len,
00096                                 struct bookmark *bmark);
00097 /*
00098 char * build_res_buf_with_body_from_sip_req(    unsigned int code ,
00099                                 char *text ,
00100                                 char *new_tag ,
00101                                 unsigned int new_tag_len ,
00102                                 char *body ,
00103                                 unsigned int body_len,
00104                                 char *content_type,
00105                                 unsigned int content_type_len,
00106                                 struct sip_msg* msg,
00107                                 unsigned int *returned_len,
00108                                 struct bookmark *bmark);
00109 */
00110 char* via_builder( unsigned int *len,
00111         struct dest_info* send_info,
00112         str *branch, str* extra_params, struct hostport *hp );
00113 
00114 /* creates a via header honoring the protocol of the incomming socket
00115  * msg is an optional parameter */
00116 char* create_via_hf( unsigned int *len,
00117         struct sip_msg *msg,
00118         struct dest_info* send_info /* where to send the reply */,
00119         str* branch);
00120 
00121 int branch_builder( unsigned int hash_index, 
00122         /* only either parameter useful */
00123         unsigned int label, char * char_v,
00124         int branch,
00125         /* output value: string and actual length */
00126         char *branch_str, int *len );
00127 
00128 char* id_builder(struct sip_msg* msg, unsigned int *id_len);
00129 
00130 /* check if IP address in Via != source IP address of signaling */
00131 int received_test( struct sip_msg *msg );
00132 
00133 /* builds a char* buffer from message headers without body
00134  * first line is excluded in case of skip_first_line=1
00135  */
00136 char * build_only_headers( struct sip_msg* msg, int skip_first_line,
00137                                 unsigned int *returned_len,
00138                                 int *error,
00139                                 struct dest_info* send_info);
00140 
00141 /* builds a char* buffer from message body
00142  * error is set -1 if the memory allocation failes
00143  */
00144 char * build_body( struct sip_msg* msg,
00145                         unsigned int *returned_len,
00146                         int *error,
00147                         struct dest_info* send_info);
00148 
00149 /* builds a char* buffer from SIP message including body
00150  * The function adjusts the Content-Length HF according
00151  * to body lumps in case of adjust_clen=1.
00152  */
00153 char * build_all( struct sip_msg* msg, int adjust_clen,
00154                         unsigned int *returned_len,
00155                         int *error,
00156                         struct dest_info* send_info);
00157 
00159 void fix_global_req_flags(str* gname, str* name);
00160 
00161 int build_sip_msg_from_buf(struct sip_msg *msg, char *buf, int len,
00162                 unsigned int id);
00163 #endif

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