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

Function tm_replicate_cancel

modules/tm/cluster.c:337–392  ·  view source on GitHub ↗

* Replicates an auto-CANCEL message to all nodes */

Source from the content-addressed store, hash-verified

335 * Replicates an auto-CANCEL message to all nodes
336 */
337static void *tm_replicate_cancel(struct sip_msg *msg)
338{
339 int rc;
340 str reason;
341 static bin_packet_t *pckt, packet;
342
343 /* initially we build a similar packet */
344 pckt = tm_replicate_packet(msg, TM_CLUSTER_AUTO_CANCEL);
345 if (!pckt)
346 return NULL;
347 packet = *pckt;
348
349 /* send offset of the via information */
350 if (msg->via1->branch) {
351 TM_BIN_PUSH(int, msg->via1->branch->value.s - msg->buf, "via branch offset");
352 TM_BIN_PUSH(int, msg->via1->branch->value.len, "via branch length");
353 } else
354 TM_BIN_PUSH(int, 0, "via branch offset");
355 if (msg->via1->host.s) {
356 TM_BIN_PUSH(int, msg->via1->host.s - msg->buf, "via host offset");
357 TM_BIN_PUSH(int, msg->via1->host.len, "via host length");
358 } else
359 TM_BIN_PUSH(int, 0, "via host offset");
360 if (msg->via1->transport.s) {
361 TM_BIN_PUSH(int, msg->via1->transport.s - msg->buf, "via transport offset");
362 TM_BIN_PUSH(int, msg->via1->transport.len, "via transport length");
363 } else
364 TM_BIN_PUSH(int, 0, "via transport offset");
365 TM_BIN_PUSH(int, msg->via1->port, "via port");
366 /* cancel reason */
367 get_cancel_reason(msg, T_CANCEL_REASON_FLAG, &reason);
368 TM_BIN_PUSH(str, &reason, "cancel reason");
369 /* message hash */
370 TM_BIN_PUSH(int, msg->hash_index, "hash index");
371
372 rc = cluster_api.send_all(&packet, tm_repl_cluster);
373 switch (rc) {
374 case CLUSTERER_CURR_DISABLED:
375 LM_INFO("Current node is disabled in cluster: %d\n",
376 tm_repl_cluster);
377 break;
378 case CLUSTERER_DEST_DOWN:
379 LM_INFO("All nodes are disabled in cluster: %d\n",
380 tm_repl_cluster);
381 break;
382 case CLUSTERER_SEND_ERR:
383 LM_ERR("Error sending message to cluster: %d\n",
384 tm_repl_cluster);
385 break;
386 case CLUSTERER_SEND_SUCCESS:
387 if_update_stat(tm_enable_stats, tm_cluster_cancel_tx , 1);
388 break;
389 }
390 bin_free_packet(&packet);
391 return NULL; /* dummy return to comply with TM_BIN_PUSH() */
392}
393#undef TM_BIN_PUSH
394/**

Callers 2

tm_anycast_replicateFunction · 0.85
tm_anycast_cancelFunction · 0.85

Calls 3

tm_replicate_packetFunction · 0.85
get_cancel_reasonFunction · 0.85
bin_free_packetFunction · 0.85

Tested by

no test coverage detected