continue;
}
- (void)knot_tcp_reply_data(rl, ctx->tcp_table, ans->wire, ans->size);
+ (void)knot_tcp_reply_data(rl, ctx->tcp_table, false, ans->wire, ans->size);
// ignore unprobable ENOMEM here
}
_public_
int knot_tcp_reply_data(knot_tcp_relay_t *relay, knot_tcp_table_t *tcp_table,
- uint8_t *data, size_t len)
+ bool ignore_lastbyte, uint8_t *data, size_t len)
{
if (relay == NULL || tcp_table == NULL || relay->conn == NULL) {
return KNOT_EINVAL;
}
- int ret = tcp_outbufs_add(&relay->conn->outbufs, data, len,
+ int ret = tcp_outbufs_add(&relay->conn->outbufs, data, len, ignore_lastbyte,
relay->conn->mss, &tcp_table->outbufs_total);
if (tcp_table->next_obuf == NULL && tcp_outbufs_usage(&relay->conn->outbufs) > 0) {
*
* \param relay Relay with active connection.
* \param tcp_table TCP table.
+ * \param ignore_lastbyte Evil mode: drop last byte of the payload.
* \param data Data payload, possibly > MSS and > window.
* \param len Payload length, < 64k.
*
* \return KNOT_E*
*/
int knot_tcp_reply_data(knot_tcp_relay_t *relay, knot_tcp_table_t *tcp_table,
- uint8_t *data, size_t len);
+ bool ignore_lastbyte, uint8_t *data, size_t len);
/*!
* \brief Send TCP packets.
}
int tcp_outbufs_add(struct tcp_outbufs *ob, uint8_t *data, size_t len,
- uint32_t mss, size_t *outbufs_total)
+ bool ignore_lastbyte, uint32_t mss, size_t *outbufs_total)
{
if (len > UINT16_MAX) {
return KNOT_ELIMIT;
}
*outbufs_total += sizeof(*newob) + newlen;
newob->len = newlen;
+ if (ignore_lastbyte) {
+ newob->len--;
+ }
memcpy(newob->bytes, &prefix, prefix_len);
memcpy(newob->bytes + prefix_len, data, newlen - prefix_len);
* \param ob Output buffers to be updated.
* \param data Payload to be sent.
* \param len Payload length.
+ * \param ignore_lastbyte Evil mode: drop last byte of the payload.
* \param mss Connection outgoing MSS.
* \param outbufs_total In/out: total outbuf statistic to be updated.
*
* \return KNOT_E*
*/
int tcp_outbufs_add(struct tcp_outbufs *ob, uint8_t *data, size_t len,
- uint32_t mss, size_t *outbufs_total);
+ bool ignore_lastbyte, uint32_t mss, size_t *outbufs_total);
/*!
* \brief Remove+free acked data from output buffers.
break;
}
put_dns_payload(&payl, true, ctx, &payload_ptr);
- if (ctx->ignore1 & KXDPGUN_IGNORE_LASTBYTE) {
- payl.iov_len--;
- }
- ret = knot_tcp_reply_data(rl, tcp_table, payl.iov_base, payl.iov_len);
+ ret = knot_tcp_reply_data(rl, tcp_table,
+ (ctx->ignore1 & KXDPGUN_IGNORE_LASTBYTE),
+ payl.iov_base, payl.iov_len);
if (ret != KNOT_EOK) {
errors++;
}
rl.conn->window_size = 65536;
send2_mss = TEST_MSS;
- int ret = knot_tcp_reply_data(&rl, test_table, data, DATA_LEN), i = 0;
+ int ret = knot_tcp_reply_data(&rl, test_table, false, data, DATA_LEN), i = 0;
is_int(KNOT_EOK, ret, "obufs: fill with data");
for (struct tcp_outbuf *ob = rl.conn->outbufs.bufs; ob != NULL; ob = ob->next, i++) {
if (ob->next == NULL) {