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;