diff --git a/net/net_tcp.c b/net/net_tcp.c index 24c5f3eec09..db537204a63 100644 --- a/net/net_tcp.c +++ b/net/net_tcp.c @@ -834,6 +834,8 @@ static struct tcp_connection* tcpconn_new(int sock, union sockaddr_union* su, struct socket_info* si, int state, int flags) { struct tcp_connection *c; + union sockaddr_union local_su; + unsigned int su_size; c=(struct tcp_connection*)shm_malloc(sizeof(struct tcp_connection)); if (c==0){ @@ -855,7 +857,9 @@ static struct tcp_connection* tcpconn_new(int sock, union sockaddr_union* su, c->rcv.src_port=su_getport(su); c->rcv.bind_address = si; c->rcv.dst_ip = si->address; - c->rcv.dst_port = si->port_no; + su_size = sockaddru_len(local_su); + getsockname(sock, (struct sockaddr *)&local_su, &su_size); + c->rcv.dst_port = su_getport(&local_su); print_ip("tcpconn_new: new tcp connection to: ", &c->rcv.src_ip, "\n"); LM_DBG("on port %d, proto %d\n", c->rcv.src_port, si->proto); c->id=(*connection_id)++;