From e7b1b0b3c0a6a220b075d7ab826d81ca7108e9cc Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 19 Feb 2019 10:48:44 +0100 Subject: [PATCH] Set UDP dest port and not src port --- src/algo_naive.c | 3 ++- src/packet.c | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/algo_naive.c b/src/algo_naive.c index d1fc775..b238efd 100644 --- a/src/algo_naive.c +++ b/src/algo_naive.c @@ -165,7 +165,7 @@ void on_tcp_read(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) { // 3. A whole packet has been read, we will find someone to write it sprintf(url, "udp:write:127.0.0.1:%d", bp->ip.ap.str.port); - printf("wil forwared to: %s\n", url); + printf("wil be forwarded to: %s\n", url); to_fdinfo = evt_core_get_from_url (ctx, url); if (to_fdinfo == NULL) goto co_error; @@ -216,6 +216,7 @@ void on_udp_read(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) { if ((bp = get_read_buffer(app_ctx, fdinfo)) == NULL) return; // 2. Read packet from socket + bp->ip.ap.str.port = url_get_port_int (fdinfo->url); read_res = read_packet_from_udp (fdinfo->fd, bp); if (read_res == FDS_ERR) goto co_error; if (bp->mode != BP_WRITING) return; diff --git a/src/packet.c b/src/packet.c index 676c7ab..86a7852 100644 --- a/src/packet.c +++ b/src/packet.c @@ -94,7 +94,6 @@ enum FD_STATE read_packet_from_udp (int fd, struct buffer_packet* bp) { if (nread == -1 && errno == EAGAIN) return FDS_AGAIN; if (nread == -1) return FDS_ERR; - bp->ip.ap.str.port = ntohs(addr.sin_port); bp->ip.ap.str.size = nread + pkt_header_size; bp->mode = BP_WRITING;