diff options
author | Josh Blum <josh@joshknows.com> | 2010-12-13 15:54:56 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-12-13 15:54:56 -0800 |
commit | 219bcb1af4a84010f3349acb5f352fa3ce3f76d7 (patch) | |
tree | 1c40a7e99208f8dc3691fb847d14b7bf743fbe76 /firmware/microblaze | |
parent | 096405b9291d1d3b3ac37d9768232cca43a37db6 (diff) | |
download | uhd-219bcb1af4a84010f3349acb5f352fa3ce3f76d7.tar.gz uhd-219bcb1af4a84010f3349acb5f352fa3ce3f76d7.tar.bz2 uhd-219bcb1af4a84010f3349acb5f352fa3ce3f76d7.zip |
packet_router: reject icmp dest unreachable when port does not match
Diffstat (limited to 'firmware/microblaze')
-rw-r--r-- | firmware/microblaze/apps/txrx_uhd.c | 2 | ||||
-rw-r--r-- | firmware/microblaze/lib/net_common.c | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/firmware/microblaze/apps/txrx_uhd.c b/firmware/microblaze/apps/txrx_uhd.c index dc41e56c4..e9c98c26e 100644 --- a/firmware/microblaze/apps/txrx_uhd.c +++ b/firmware/microblaze/apps/txrx_uhd.c @@ -53,7 +53,7 @@ static void setup_network(void); // the fast-path setup global variables // ---------------------------------------------------------------- static eth_mac_addr_t fp_mac_addr_src, fp_mac_addr_dst; -static struct socket_address fp_socket_src, fp_socket_dst; +extern struct socket_address fp_socket_src, fp_socket_dst; void handle_udp_data_packet( struct socket_address src, struct socket_address dst, 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; |