From 219bcb1af4a84010f3349acb5f352fa3ce3f76d7 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 13 Dec 2010 15:54:56 -0800 Subject: packet_router: reject icmp dest unreachable when port does not match --- firmware/microblaze/lib/net_common.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'firmware/microblaze/lib/net_common.c') diff --git a/firmware/microblaze/lib/net_common.c b/firmware/microblaze/lib/net_common.c index 947f41dae..a34ca615b 100644 --- a/firmware/microblaze/lib/net_common.c +++ b/firmware/microblaze/lib/net_common.c @@ -41,6 +41,9 @@ static const bool debug = false; static const eth_mac_addr_t BCAST_MAC_ADDR = {{0xff, 0xff, 0xff, 0xff, 0xff, 0xff}}; +//used in the top level application... +struct socket_address fp_socket_src, fp_socket_dst; + // ------------------------------------------------------------------------ static eth_mac_addr_t _local_mac_addr; @@ -265,6 +268,11 @@ handle_icmp_packet(struct ip_addr src, struct ip_addr dst, if (icmp->code == ICMP_DUR_PORT){ // port unreachable //handle destination port unreachable (the host ctrl+c'd the app): + //filter out non udp data response + struct ip_hdr *ip = (struct ip_hdr *)(((uint8_t*)icmp) + sizeof(struct icmp_echo_hdr)); + struct udp_hdr *udp = (struct udp_hdr *)(((char *)ip) + IP_HLEN); + if (IPH_PROTO(ip) != IP_PROTO_UDP || udp->dest != fp_socket_dst.port) return; + //end async update packets per second sr_tx_ctrl->cyc_per_up = 0; -- cgit v1.2.3