4 * Copyright (C) 2001-2003 FhG Fokus
6 * This file is part of ser, a free SIP server.
8 * ser is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version
13 * For a license to use the ser software under conditions
14 * other than those described here, or to purchase support for this
15 * software, please contact iptel.org by e-mail at the following addresses:
18 * ser is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 * 2003-03-06 totags in outgoing replies bookmarked to enable
30 * ACK/200 tag matching
32 * 2003-03-01 VOICE_MAIL defs removed (jiri)
33 * 2003-10-08 receive_test function-alized (jiri)
37 #ifndef _MSG_TRANSLATOR_H
38 #define _MSG_TRANSLATOR_H
40 #define MY_HF_SEP ": "
41 #define MY_HF_SEP_LEN 2
43 #define BRANCH_SEPARATOR '.'
44 #define WARNING "Warning: 392 "
45 #define WARNING_LEN (sizeof(WARNING)-1)
46 #define WARNING_PHRASE " \"Noisy feedback tells: "
47 #define WARNING_PHRASE_LEN (sizeof(WARNING_PHRASE)-1)
49 /*#define MAX_CONTENT_LEN_BUF INT2STR_MAX_LEN *//* see ut.h/int2str() */
51 #include "parser/msg_parser.h"
54 /* point to some remarkable positions in a SIP message */
59 /* used by via_builder */
66 #define set_hostport(hp, msg) \
68 if ((msg) && ((struct sip_msg*)(msg))->set_global_address.len) \
69 (hp)->host=&(((struct sip_msg*)(msg))->set_global_address); \
71 (hp)->host=&default_global_address; \
72 if ((msg) && ((struct sip_msg*)(msg))->set_global_port.len) \
73 (hp)->port=&(((struct sip_msg*)(msg))->set_global_port); \
75 (hp)->port=&default_global_port; \
78 char * build_req_buf_from_sip_req ( struct sip_msg* msg,
79 unsigned int *returned_len, struct dest_info* send_info);
81 char * build_res_buf_from_sip_res( struct sip_msg* msg,
82 unsigned int *returned_len);
85 char * build_res_buf_from_sip_req( unsigned int code ,
89 unsigned int *returned_len,
90 struct bookmark *bmark);
92 char * build_res_buf_with_body_from_sip_req( unsigned int code ,
95 unsigned int new_tag_len ,
97 unsigned int body_len,
99 unsigned int content_type_len,
101 unsigned int *returned_len,
102 struct bookmark *bmark);
104 char* via_builder( unsigned int *len,
105 struct dest_info* send_info,
106 str *branch, str* extra_params, struct hostport *hp );
109 int branch_builder( unsigned int hash_index,
110 /* only either parameter useful */
111 unsigned int label, char * char_v,
113 /* output value: string and actual length */
114 char *branch_str, int *len );
116 char* id_builder(struct sip_msg* msg, unsigned int *id_len);
118 /* check if IP address in Via != source IP address of signaling */
119 int received_test( struct sip_msg *msg );
121 /* builds a char* buffer from message headers without body
122 * first line is excluded in case of skip_first_line=1
124 char * build_only_headers( struct sip_msg* msg, int skip_first_line,
125 unsigned int *returned_len,
127 struct dest_info* send_info);
129 /* builds a char* buffer from message body
130 * error is set -1 if the memory allocation failes
132 char * build_body( struct sip_msg* msg,
133 unsigned int *returned_len,
135 struct dest_info* send_info);
137 /* builds a char* buffer from SIP message including body
138 * The function adjusts the Content-Length HF according
139 * to body lumps in case of adjust_clen=1.
141 char * build_all( struct sip_msg* msg, int adjust_clen,
142 unsigned int *returned_len,
144 struct dest_info* send_info);