MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / receive_tm_repl

Function receive_tm_repl

modules/tm/cluster.c:165–232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165static void receive_tm_repl(bin_packet_t *packet)
166{
167 int proto;
168 int port;
169 str tmp;
170 struct receive_info ri;
171
172 memset(&ri, 0, sizeof ri);
173 LM_DBG("received %d packet from %d in cluster %d\n",
174 packet->type, packet->src_id, tm_repl_cluster);
175
176 if (packet->type != TM_CLUSTER_REPLY &&
177 packet->type != TM_CLUSTER_REQUEST &&
178 packet->type != TM_CLUSTER_AUTO_CANCEL) {
179 LM_WARN("Invalid tm binary packet command: %d (from node: %d in cluster: %d)\n",
180 packet->type, packet->src_id, tm_repl_cluster);
181 return;
182 }
183
184 /* first part is common to all messages */
185 TM_BIN_POP(int, &proto, "proto");
186 TM_BIN_POP(str, &tmp, "dst host");
187 TM_BIN_POP(int, &port, "dst port");
188
189 ri.bind_address = grep_internal_sock_info(&tmp, port, proto);
190 if (!ri.bind_address) {
191 LM_WARN("received replicated message for an interface"
192 " we don't know %s:%.*s:%d; discarding...\n",
193 proto2a(proto), tmp.len, tmp.s, port);
194 return;
195 }
196 if (!(ri.bind_address->flags & SI_IS_ANYCAST)) {
197 LM_WARN("received replicated message for a non-anycast interface"
198 " %s:%.*s:%d\n",
199 proto2a(proto), tmp.len, tmp.s, port);
200 }
201 ri.dst_port = ri.bind_address->port_no;
202 ri.dst_ip = ri.bind_address->address;
203 ri.proto = proto;
204 /* XXX: do we care about this? Only UDP should work with anycast */
205 ri.proto_reserved1 = ri.proto_reserved2 = 0;
206
207 TM_BIN_POP(str, &tmp, "src host");
208 memcpy((char *)&ri.src_ip, tmp.s, tmp.len);
209 TM_BIN_POP(int, &ri.src_port, "src port");
210 TM_BIN_POP(str, &tmp, "message");
211 /* we need to substract the '\0' termination from message len */
212 tmp.len--;
213
214 /* only auto-CANCEL is treated differently */
215 switch (packet->type) {
216 case TM_CLUSTER_AUTO_CANCEL:
217 if_update_stat(tm_enable_stats, tm_cluster_cancel_rx , 1);
218 if (tm_repl_auto_cancel) {
219 tm_repl_cancel(packet, &tmp, &ri);
220 return;
221 }
222 LM_WARN("auto-CANCEL handling is disabled, but got one auto-CANCEL here!\n");

Callers

nothing calls this directly

Calls 3

proto2aFunction · 0.85
tm_repl_cancelFunction · 0.85
receive_msgFunction · 0.85

Tested by

no test coverage detected