* Builds a replicated message */
| 297 | * Builds a replicated message |
| 298 | */ |
| 299 | static bin_packet_t *tm_replicate_packet(struct sip_msg *msg, int type) |
| 300 | { |
| 301 | static bin_packet_t packet; |
| 302 | str tmp; |
| 303 | int port; |
| 304 | |
| 305 | /* XXX: could estimate better here, but let's assume we need msg->len */ |
| 306 | if (bin_init(&packet, &tm_repl_cap, type, TM_CLUSTER_VERSION, |
| 307 | msg->len + 128) < 0) { |
| 308 | LM_ERR("cannot initiate bin reply buffer\n"); |
| 309 | return NULL; |
| 310 | } |
| 311 | |
| 312 | TM_BIN_PUSH(int, msg->rcv.proto, "proto"); |
| 313 | if (msg->rcv.bind_address->tag.len) { |
| 314 | /* send interface tag if it exists, instead of hostname and port */ |
| 315 | tmp = msg->rcv.bind_address->tag; |
| 316 | port = 0; |
| 317 | } else { |
| 318 | tmp = msg->rcv.bind_address->name; |
| 319 | port = msg->rcv.bind_address->port_no; |
| 320 | } |
| 321 | TM_BIN_PUSH(str, &tmp, "dst host"); |
| 322 | TM_BIN_PUSH(int, port, "dst port"); |
| 323 | tmp.s = (char *)&msg->rcv.src_ip; |
| 324 | tmp.len = sizeof(struct ip_addr); |
| 325 | TM_BIN_PUSH(str, &tmp, "src host"); |
| 326 | TM_BIN_PUSH(int, msg->rcv.src_port, "src port"); |
| 327 | tmp.s = msg->buf; |
| 328 | tmp.len = msg->len + 1; /* XXX: add '\0' terminator - receive_msg expects it */ |
| 329 | TM_BIN_PUSH(str, &tmp, "message"); |
| 330 | |
| 331 | return &packet; |
| 332 | } |
| 333 | |
| 334 | /** |
| 335 | * Replicates an auto-CANCEL message to all nodes |
no outgoing calls
no test coverage detected