Retransmits the last sent inbound reply. * input: p_msg==request for which I want to retransmit an associated reply * Returns -1 - error * 1 - OK */
| 1100 | * 1 - OK |
| 1101 | */ |
| 1102 | int t_retransmit_reply( struct cell *t ) |
| 1103 | { |
| 1104 | static char b[BUF_SIZE]; |
| 1105 | int len; |
| 1106 | str cb_s; |
| 1107 | |
| 1108 | /* we need to lock the transaction as messages from |
| 1109 | upstream may change it continuously */ |
| 1110 | LOCK_REPLIES( t ); |
| 1111 | |
| 1112 | if (!t->uas.response.buffer.s) { |
| 1113 | LM_DBG("nothing to retransmit\n"); |
| 1114 | goto error; |
| 1115 | } |
| 1116 | |
| 1117 | /* response.dst.send_sock should be valid all the time now, as it's taken |
| 1118 | from original request -bogdan */ |
| 1119 | if (t->uas.response.dst.send_sock==0) { |
| 1120 | LM_CRIT("something to retransmit, but send_sock is NULL\n"); |
| 1121 | goto error; |
| 1122 | } |
| 1123 | |
| 1124 | len=t->uas.response.buffer.len; |
| 1125 | if ( len==0 || len>BUF_SIZE ) { |
| 1126 | LM_DBG("zero length or too big to retransmit: %d\n", len); |
| 1127 | goto error; |
| 1128 | } |
| 1129 | memcpy( b, t->uas.response.buffer.s, len ); |
| 1130 | UNLOCK_REPLIES( t ); |
| 1131 | |
| 1132 | /* send the buffer out */ |
| 1133 | if (t->uas.request && t->uas.request->flags & tcp_no_new_conn_rplflag) |
| 1134 | tcp_no_new_conn = 1; |
| 1135 | |
| 1136 | if (SEND_PR_BUFFER( & t->uas.response, b, len )==0) { |
| 1137 | /* success */ |
| 1138 | LM_DBG("buf=%p: %.9s..., shmem=%p: %.9s\n",b, b, |
| 1139 | t->uas.response.buffer.s, t->uas.response.buffer.s ); |
| 1140 | if (has_tran_tmcbs( t, TMCB_MSG_SENT_OUT) ) { |
| 1141 | cb_s.s = b; |
| 1142 | cb_s.len = len; |
| 1143 | set_extra_tmcb_params( &cb_s, &t->uas.response.dst); |
| 1144 | run_trans_callbacks( TMCB_MSG_SENT_OUT, t, |
| 1145 | NULL, FAKED_REPLY, t->uas.status); |
| 1146 | } |
| 1147 | } |
| 1148 | |
| 1149 | tcp_no_new_conn = 0; |
| 1150 | |
| 1151 | return 1; |
| 1152 | |
| 1153 | error: |
| 1154 | UNLOCK_REPLIES(t); |
| 1155 | return -1; |
| 1156 | } |
| 1157 | |
| 1158 | |
| 1159 | int t_reply( struct cell *t, struct sip_msg* p_msg, unsigned int code, |
no test coverage detected