/src/opensips/msg_translator.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (C) 2001-2003 FhG Fokus |
3 | | * |
4 | | * This file is part of opensips, a free SIP server. |
5 | | * |
6 | | * opensips is free software; you can redistribute it and/or modify |
7 | | * it under the terms of the GNU General Public License as published by |
8 | | * the Free Software Foundation; either version 2 of the License, or |
9 | | * (at your option) any later version |
10 | | * |
11 | | * opensips is distributed in the hope that it will be useful, |
12 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | | * GNU General Public License for more details. |
15 | | * |
16 | | * You should have received a copy of the GNU General Public License |
17 | | * along with this program; if not, write to the Free Software |
18 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 | | * |
20 | | * History: |
21 | | * -------- |
22 | | * 2003-03-06 totags in outgoing replies bookmarked to enable |
23 | | * ACK/200 tag matching |
24 | | * 2003-10-08 receive_test function-alized (jiri) |
25 | | */ |
26 | | |
27 | | /*! |
28 | | * \file |
29 | | * \brief Create and translate SIP messages/ message contents |
30 | | * - \ref ViaSpecialParams |
31 | | */ |
32 | | |
33 | | |
34 | | #ifndef _MSG_TRANSLATOR_H |
35 | | #define _MSG_TRANSLATOR_H |
36 | | |
37 | | #define MY_HF_SEP ": " |
38 | | #define MY_HF_SEP_LEN 2 |
39 | | |
40 | 0 | #define BRANCH_SEPARATOR '.' |
41 | | #define WARNING "Warning: 392 " |
42 | | #define WARNING_LEN (sizeof(WARNING)-1) |
43 | | #define WARNING_PHRASE " \"Noisy feedback tells: " |
44 | | #define WARNING_PHRASE_LEN (sizeof(WARNING_PHRASE)-1) |
45 | | |
46 | 12.0k | #define MSG_TRANS_SHM_FLAG (1<<0) |
47 | 12.0k | #define MSG_TRANS_NOVIA_FLAG (1<<1) |
48 | | |
49 | 0 | #define OSS_BOUNDARY "OSS-unique-boundary-42" |
50 | | |
51 | | //#define MAX_CONTENT_LEN_BUF INT2STR_MAX_LEN /* see ut.h/int2str() */ |
52 | | |
53 | | #include "parser/msg_parser.h" |
54 | | #include "ip_addr.h" |
55 | | #include "socket_info.h" |
56 | | #include "context.h" |
57 | | #include "globals.h" |
58 | | |
59 | | /*! \brief point to some remarkable positions in a SIP message */ |
60 | | struct bookmark { |
61 | | str to_tag_val; |
62 | | }; |
63 | | |
64 | | /*! \brief used by via_builder() */ |
65 | | struct hostport { |
66 | | str* host; |
67 | | str* port; |
68 | | }; |
69 | | |
70 | | |
71 | | #define set_hostport(hp, msg) \ |
72 | 12.0k | do { \ |
73 | 12.0k | if (!(msg)) \ |
74 | 12.0k | (hp)->host = NULL; \ |
75 | 12.0k | else { \ |
76 | 12.0k | if (((struct sip_msg *)(msg))->set_global_address.s) \ |
77 | 12.0k | (hp)->host = &(((struct sip_msg *)(msg))->set_global_address); \ |
78 | 12.0k | else \ |
79 | 12.0k | (hp)->host = default_global_address; \ |
80 | 12.0k | } \ |
81 | 12.0k | if (!(msg)) \ |
82 | 12.0k | (hp)->port = NULL; \ |
83 | 12.0k | else { \ |
84 | 12.0k | if (((struct sip_msg *)(msg))->set_global_port.s) \ |
85 | 12.0k | (hp)->port = &(((struct sip_msg *)(msg))->set_global_port); \ |
86 | 12.0k | else \ |
87 | 12.0k | (hp)->port = default_global_port; \ |
88 | 12.0k | } \ |
89 | 12.0k | } while (0) |
90 | | |
91 | | static inline const str *get_adv_host(const struct socket_info *send_sock) |
92 | 12.0k | { |
93 | 12.0k | if(send_sock->adv_name_str.len) |
94 | 0 | return &(send_sock->adv_name_str); |
95 | 12.0k | else if (default_global_address->s) |
96 | 0 | return default_global_address; |
97 | 12.0k | else |
98 | 12.0k | return &(send_sock->address_str); |
99 | 12.0k | } Unexecuted instantiation: action.c:get_adv_host Unexecuted instantiation: forward.c:get_adv_host msg_translator.c:get_adv_host Line | Count | Source | 92 | 12.0k | { | 93 | 12.0k | if(send_sock->adv_name_str.len) | 94 | 0 | return &(send_sock->adv_name_str); | 95 | 12.0k | else if (default_global_address->s) | 96 | 0 | return default_global_address; | 97 | 12.0k | else | 98 | 12.0k | return &(send_sock->address_str); | 99 | 12.0k | } |
Unexecuted instantiation: core_cmds.c:get_adv_host Unexecuted instantiation: fuzz_core_funcs.c:get_adv_host |
100 | | |
101 | | static inline const str *get_adv_port(const struct socket_info *send_sock) |
102 | 12.0k | { |
103 | 12.0k | if(send_sock->adv_port_str.len) |
104 | 0 | return &(send_sock->adv_port_str); |
105 | 12.0k | else if (default_global_port->s) |
106 | 0 | return default_global_port; |
107 | 12.0k | else |
108 | 12.0k | return &(send_sock->port_no_str); |
109 | 12.0k | } Unexecuted instantiation: action.c:get_adv_port Unexecuted instantiation: forward.c:get_adv_port msg_translator.c:get_adv_port Line | Count | Source | 102 | 12.0k | { | 103 | 12.0k | if(send_sock->adv_port_str.len) | 104 | 0 | return &(send_sock->adv_port_str); | 105 | 12.0k | else if (default_global_port->s) | 106 | 0 | return default_global_port; | 107 | 12.0k | else | 108 | 12.0k | return &(send_sock->port_no_str); | 109 | 12.0k | } |
Unexecuted instantiation: core_cmds.c:get_adv_port Unexecuted instantiation: fuzz_core_funcs.c:get_adv_port |
110 | | |
111 | | static inline const str *_get_adv_host(const struct socket_info *send_sock, |
112 | | struct sip_msg *msg) |
113 | 0 | { |
114 | 0 | if (send_sock->adv_name_str.len) |
115 | 0 | return &send_sock->adv_name_str; |
116 | 0 | else if (msg->set_global_address.s) |
117 | 0 | return &msg->set_global_address; |
118 | 0 | else if (default_global_address->s) |
119 | 0 | return default_global_address; |
120 | 0 | else |
121 | 0 | return &send_sock->address_str; |
122 | 0 | } Unexecuted instantiation: action.c:_get_adv_host Unexecuted instantiation: forward.c:_get_adv_host Unexecuted instantiation: msg_translator.c:_get_adv_host Unexecuted instantiation: core_cmds.c:_get_adv_host Unexecuted instantiation: fuzz_core_funcs.c:_get_adv_host |
123 | | |
124 | | static inline const str *_get_adv_port(const struct socket_info *send_sock, |
125 | | struct sip_msg *msg) |
126 | 0 | { |
127 | 0 | if (send_sock->adv_port_str.len) |
128 | 0 | return &send_sock->adv_port_str; |
129 | 0 | else if (msg->set_global_port.s) |
130 | 0 | return &msg->set_global_port; |
131 | 0 | else if (default_global_port->s) |
132 | 0 | return default_global_port; |
133 | 0 | else |
134 | 0 | return &send_sock->port_no_str; |
135 | 0 | } Unexecuted instantiation: action.c:_get_adv_port Unexecuted instantiation: forward.c:_get_adv_port Unexecuted instantiation: msg_translator.c:_get_adv_port Unexecuted instantiation: core_cmds.c:_get_adv_port Unexecuted instantiation: fuzz_core_funcs.c:_get_adv_port |
136 | | |
137 | | char * build_req_buf_from_sip_req ( struct sip_msg* msg, |
138 | | unsigned int *returned_len, const struct socket_info* send_sock, |
139 | | int proto, str *via_params, unsigned int flags); |
140 | | |
141 | | char * build_res_buf_from_sip_res( struct sip_msg* msg, |
142 | | unsigned int *returned_len, const struct socket_info *sock,int flags); |
143 | | |
144 | | |
145 | | char * build_res_buf_from_sip_req( unsigned int code, |
146 | | const str *text, |
147 | | str *new_tag, |
148 | | struct sip_msg* msg, |
149 | | unsigned int *returned_len, |
150 | | struct bookmark *bmark); |
151 | | |
152 | | char* via_builder( unsigned int *len, |
153 | | const struct socket_info* send_sock, |
154 | | str *branch, str* extra_params, int proto, struct hostport *hp ); |
155 | | |
156 | | |
157 | | int branch_builder( unsigned int hash_index, |
158 | | /* only either parameter useful */ |
159 | | unsigned int label, char * char_v, |
160 | | int branch, |
161 | | /* output value: string and actual length */ |
162 | | char *branch_str, int *len ); |
163 | | |
164 | | char *contact_builder(const struct socket_info* send_sock, int *ct_len); |
165 | | |
166 | | /* check if IP address in Via != source IP address of signaling */ |
167 | | int received_test( struct sip_msg *msg ); |
168 | | |
169 | | char *construct_uri(str *protocol,str *username,str *domain,str *port, |
170 | | str *params,int *len); |
171 | | |
172 | | void process_lumps( struct sip_msg* msg, struct lump* lumps, char* new_buf, |
173 | | unsigned int* new_buf_offs, unsigned int* orig_offs, |
174 | | const struct socket_info* send_sock, int max_offset); |
175 | | |
176 | | int is_del_via1_lump(struct sip_msg* msg); |
177 | | |
178 | | char* received_builder(struct sip_msg *msg, unsigned int *received_len); |
179 | | |
180 | | char* rport_builder(struct sip_msg *msg, unsigned int *rport_len); |
181 | | |
182 | | unsigned int prep_reassemble_body_parts( struct sip_msg* msg, |
183 | | const struct socket_info* send_sock); |
184 | | |
185 | | void reassemble_body_parts( struct sip_msg* msg, char* new_buf, |
186 | | unsigned int* new_offs, unsigned int* orig_offs, |
187 | | const struct socket_info* send_sock); |
188 | | |
189 | | #endif |