| 46 | } while(0) |
| 47 | |
| 48 | static void tm_repl_cancel(bin_packet_t *packet, str *buf, struct receive_info *ri) |
| 49 | { |
| 50 | int itmp; |
| 51 | char *tmp; |
| 52 | str stmp; |
| 53 | struct cell *t; |
| 54 | /* build a nice static message, exactly how t_lookupOriginalT() expects */ |
| 55 | struct sip_msg msg; |
| 56 | struct via_body via; |
| 57 | struct via_param branch; |
| 58 | |
| 59 | /* cleanup the structure */ |
| 60 | memset(&msg, 0, sizeof(msg)); |
| 61 | |
| 62 | branch.value.s = NULL; |
| 63 | branch.value.len = 0; |
| 64 | |
| 65 | TM_BIN_POP(int, &itmp, "via branch offset"); |
| 66 | if (itmp != 0) { |
| 67 | TM_BIN_POP(int, &branch.value.len, "via branch length"); |
| 68 | |
| 69 | if (branch.value.len > MCOOKIE_LEN && |
| 70 | !memcmp(buf->s + itmp, MCOOKIE,MCOOKIE_LEN)) |
| 71 | branch.value.s = buf->s + itmp; |
| 72 | } |
| 73 | |
| 74 | if (!branch.value.s) { |
| 75 | /* if there is no RFC3261 magic cookie in the branch param, we do the message |
| 76 | * parsing here, as we will need several headers for matching anyway */ |
| 77 | msg.buf = buf->s; |
| 78 | msg.len = buf->len; |
| 79 | msg.rcv=*ri; |
| 80 | msg.ruri_q = Q_UNSPECIFIED; |
| 81 | msg.id=get_next_msg_no(); |
| 82 | |
| 83 | if (parse_msg(buf->s, buf->len, &msg) != 0) { |
| 84 | tmp = ip_addr2a(&(ri->src_ip)); |
| 85 | LM_ERR("Unable to parse replicated CANCEL received from [%s:%d]\n", |
| 86 | tmp, ri->src_port); |
| 87 | return; |
| 88 | } |
| 89 | |
| 90 | TM_BIN_POP(int, &itmp, "via host offset"); |
| 91 | if (itmp != 0) |
| 92 | TM_BIN_POP(int, &itmp, "via host length"); |
| 93 | TM_BIN_POP(int, &itmp, "via transport offset"); |
| 94 | if (itmp != 0) |
| 95 | TM_BIN_POP(int, &msg.via1->transport.len, "via transport length"); |
| 96 | TM_BIN_POP(int, &itmp, "via port"); |
| 97 | } else { |
| 98 | msg.REQ_METHOD = METHOD_CANCEL; |
| 99 | msg.via1 = &via; |
| 100 | msg.via1->branch = &branch; |
| 101 | |
| 102 | TM_BIN_POP(int, &itmp, "via host offset"); |
| 103 | if (itmp != 0) { |
| 104 | msg.via1->host.s = buf->s + itmp; |
| 105 | TM_BIN_POP(int, &msg.via1->host.len, "via host length"); |
no test coverage detected