From 4f691d88123784c2b405816925f1a1aef69d18c1 Mon Sep 17 00:00:00 2001 From: Ben Hilburn Date: Tue, 4 Feb 2014 11:10:07 -0800 Subject: Un-doing firmware change regarding ICMP packate handling. Reverting "x300: ICMP_DUR handler fixed. Supposedly closes #256." This reverts commit 69317629f353734d5ac21dc78be105b2f0164497. Resolved Conflicts: firmware/x300/x300/x300_main.c --- firmware/x300/x300/x300_main.c | 78 ++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 44 deletions(-) (limited to 'firmware') diff --git a/firmware/x300/x300/x300_main.c b/firmware/x300/x300/x300_main.c index a15afd196..7d6771bc7 100644 --- a/firmware/x300/x300/x300_main.c +++ b/firmware/x300/x300/x300_main.c @@ -66,14 +66,8 @@ void handle_udp_prog_framer( const void *buff, const size_t num_bytes ) { - if (buff == NULL) { - /* We got here from ICMP_DUR undeliverable packet */ - /* Future space for hooks to tear down streaming radios etc */ - } - else { const uint32_t sid = ((const uint32_t *)buff)[1]; program_udp_framer(ethno, sid, src, src_port, dst_port); - } } /*********************************************************************** @@ -86,42 +80,42 @@ void handle_udp_fw_comms( const void *buff, const size_t num_bytes ) { - if (buff == NULL) { - /* We got here from ICMP_DUR undeliverable packet */ - /* Future space for hooks to tear down streaming radios etc */ - } else { - const x300_fw_comms_t *request = (const x300_fw_comms_t *)buff; - x300_fw_comms_t reply; memcpy(&reply, buff, sizeof(reply)); + const x300_fw_comms_t *request = (const x300_fw_comms_t *)buff; + x300_fw_comms_t reply; memcpy(&reply, buff, sizeof(reply)); - //check for error and set error flag - if (num_bytes < sizeof(x300_fw_comms_t)) { - reply.flags |= X300_FW_COMMS_FLAGS_ERROR; - } - //otherwise, run the actions set by the flags - else { - if (request->flags & X300_FW_COMMS_FLAGS_PEEK32) - { - if (request->addr & 0x00100000) { - chinch_peek32(request->addr & 0x000FFFFF, &reply.data); - } else { - reply.data = wb_peek32(request->addr); - } - } - if (request->flags & X300_FW_COMMS_FLAGS_POKE32) - { - if (request->addr & 0x00100000) { - chinch_poke32(request->addr & 0x000FFFFF, request->data); - } else { - wb_poke32(request->addr, request->data); - } + //check for error and set error flag + if (num_bytes < sizeof(x300_fw_comms_t)) + { + reply.flags |= X300_FW_COMMS_FLAGS_ERROR; + } + + //otherwise, run the actions set by the flags + else + { + if (request->flags & X300_FW_COMMS_FLAGS_PEEK32) + { + if (request->addr & 0x00100000) { + chinch_peek32(request->addr & 0x000FFFFF, &reply.data); + } else { + reply.data = wb_peek32(request->addr); } } - //send a reply if ack requested - if (request->flags & X300_FW_COMMS_FLAGS_ACK) { - u3_net_stack_send_udp_pkt(ethno, src, dst_port, src_port, &reply, sizeof(reply)); + if (request->flags & X300_FW_COMMS_FLAGS_POKE32) + { + if (request->addr & 0x00100000) { + chinch_poke32(request->addr & 0x000FFFFF, request->data); + } else { + wb_poke32(request->addr, request->data); + } } } + + //send a reply if ack requested + if (request->flags & X300_FW_COMMS_FLAGS_ACK) + { + u3_net_stack_send_udp_pkt(ethno, src, dst_port, src_port, &reply, sizeof(reply)); + } } /*********************************************************************** @@ -138,9 +132,7 @@ void handle_udp_fpga_prog( x300_fpga_prog_flags_t reply = {0}; bool status = true; - if (buff == NULL) { - return; - } else if (num_bytes < offsetof(x300_fpga_prog_t, data)) { + if (num_bytes < offsetof(x300_fpga_prog_t, data)) { reply.flags |= X300_FPGA_PROG_FLAGS_ERROR; } else { if (request->flags & X300_FPGA_PROG_FLAGS_INIT) { @@ -191,7 +183,7 @@ void handle_udp_fpga_prog( /*********************************************************************** * Handler for MTU detection **********************************************************************/ -void handle_udp_mtu_detect( +void handle_mtu_detect( const uint8_t ethno, const struct ip_addr *src, const struct ip_addr *dst, const uint16_t src_port, const uint16_t dst_port, @@ -201,9 +193,7 @@ void handle_udp_mtu_detect( const x300_mtu_t *request = (const x300_mtu_t *) buff; x300_mtu_t reply; - if (buff == NULL) { - return; - } else if (!(request->flags & X300_MTU_DETECT_ECHO_REQUEST)) { + if (!(request->flags & X300_MTU_DETECT_ECHO_REQUEST)) { printf("DEBUG: MTU detect got unknown request\n"); reply.flags |= X300_MTU_DETECT_ERROR; } @@ -426,7 +416,7 @@ int main(void) u3_net_stack_register_udp_handler(X300_FW_COMMS_UDP_PORT, &handle_udp_fw_comms); u3_net_stack_register_udp_handler(X300_VITA_UDP_PORT, &handle_udp_prog_framer); u3_net_stack_register_udp_handler(X300_FPGA_PROG_UDP_PORT, &handle_udp_fpga_prog); - u3_net_stack_register_udp_handler(X300_MTU_DETECT_UDP_PORT, &handle_udp_mtu_detect); + u3_net_stack_register_udp_handler(X300_MTU_DETECT_UDP_PORT, &handle_mtu_detect); uint32_t last_cronjob = 0; -- cgit v1.2.3