diff --git a/fnet_doc/doxygen/fnet_doc.dox b/fnet_doc/doxygen/fnet_doc.dox index d5086109..258b6502 100644 --- a/fnet_doc/doxygen/fnet_doc.dox +++ b/fnet_doc/doxygen/fnet_doc.dox @@ -2361,6 +2361,10 @@ Press any key to continue . . . FNET public releases: +- Version 4.7.1 + - Broadcast a DHCP DECLINE message, instead of unicasting. + - Randomize TCP initial sequence number. + - Version 4.7.0 - Fix possible out of bounds read on a received malformed LLMNR, mDNS or IPv6 packet. - Add null termination check for the input-name parameter of the LLMNR, mDNS and DNS services. diff --git a/fnet_doc/doxygen/fnet_gen_doc.in b/fnet_doc/doxygen/fnet_gen_doc.in index e8abc875..65feea52 100644 --- a/fnet_doc/doxygen/fnet_gen_doc.in +++ b/fnet_doc/doxygen/fnet_gen_doc.in @@ -38,7 +38,7 @@ PROJECT_NAME = "Embedded TCP/IP stack" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 4.7.0 +PROJECT_NUMBER = 4.7.1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/fnet_doc/doxygen/fnet_gen_doc_chm.in b/fnet_doc/doxygen/fnet_gen_doc_chm.in index 912ab256..01dfb3b6 100644 --- a/fnet_doc/doxygen/fnet_gen_doc_chm.in +++ b/fnet_doc/doxygen/fnet_gen_doc_chm.in @@ -38,7 +38,7 @@ PROJECT_NAME = "Embedded TCP/IP stack" # could be handy for archiving the generated documentation or if some version # control system is used. -PROJECT_NUMBER = 4.7.0 +PROJECT_NUMBER = 4.7.1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer a diff --git a/fnet_doc/fnet_user_manual.chm b/fnet_doc/fnet_user_manual.chm index 651fc321..c8492812 100644 Binary files a/fnet_doc/fnet_user_manual.chm and b/fnet_doc/fnet_user_manual.chm differ diff --git a/fnet_stack/fnet.h b/fnet_stack/fnet.h index e35b375c..538579ca 100644 --- a/fnet_stack/fnet.h +++ b/fnet_stack/fnet.h @@ -73,7 +73,7 @@ * string. * @showinitializer ******************************************************************************/ -#define FNET_VERSION "4.7.0" +#define FNET_VERSION "4.7.1" /*! @} */ diff --git a/fnet_stack/service/dhcp/fnet_dhcp_cln.c b/fnet_stack/service/dhcp/fnet_dhcp_cln.c index be9bcead..5d558a43 100644 --- a/fnet_stack/service/dhcp/fnet_dhcp_cln.c +++ b/fnet_stack/service/dhcp/fnet_dhcp_cln.c @@ -475,7 +475,7 @@ static void _fnet_dhcp_cln_send_message( fnet_dhcp_cln_if_t *dhcp ) message_type = FNET_DHCP_OPTION_MSG_TYPE_REQUEST; break; case FNET_DHCP_CLN_STATE_PROBING: - ip_address = dhcp->current_options.public_options.dhcp_server; /* Send REQUEST to leasing server*/ + ip_address.s_addr = INADDR_BROADCAST; /* As the client does not have a valid network address, the client must broadcast the DHCPDECLINE message. */ message->header.ciaddr = dhcp->current_options.public_options.ip_address.s_addr; message_type = FNET_DHCP_OPTION_MSG_TYPE_DECLINE; /* DHCPDECLINE - Client to server indicating network address is already in use.*/ break; diff --git a/fnet_stack/stack/fnet_tcp.c b/fnet_stack/stack/fnet_tcp.c index e093f090..29ec88d8 100644 --- a/fnet_stack/stack/fnet_tcp.c +++ b/fnet_stack/stack/fnet_tcp.c @@ -110,6 +110,7 @@ static fnet_return_t _fnet_tcp_setsockopt( fnet_socket_if_t *sk, fnet_protocol_t static fnet_return_t _fnet_tcp_getsockopt( fnet_socket_if_t *sk, fnet_protocol_t level, fnet_socket_options_t optname, void *optval, fnet_size_t *optlen ); static fnet_return_t _fnet_tcp_listen( fnet_socket_if_t *sk, fnet_size_t backlog ); static void _fnet_tcp_drain( void ); +static void _fnet_tcp_initial_seq_number_update( void ); #if FNET_CFG_DEBUG_TRACE_TCP && FNET_CFG_DEBUG_TRACE void _fnet_tcp_trace(fnet_uint8_t *str, fnet_tcp_header_t *tcp_hdr); @@ -127,8 +128,8 @@ static void _fnet_tcp_drain( void ); /* Initial Sequence Number * tcpcb_isntime is changed by STEPISN every 0.5 sec. * Additionaly, each time a connection is established, - * tcpcb_isntime is also incremented by FNET_TCP_INITIAL_SEQ_NUMBER_STEP */ -static fnet_uint32_t _fnet_tcp_initial_seq_number = 1u; + * tcpcb_isntime is also incremented by FNET_TCP_INITIAL_SEQ_NUMBER_STEP + random value */ +static fnet_uint32_t _fnet_tcp_initial_seq_number; /* Timers.*/ static fnet_timer_desc_t fnet_tcp_fasttimer; @@ -174,7 +175,7 @@ fnet_prot_if_t fnet_tcp_prot_if = *************************************************************************/ static fnet_return_t _fnet_tcp_init( void ) { - /* Create the slow timer.*/ + /* Create the fast timer.*/ fnet_tcp_fasttimer = _fnet_timer_new(FNET_TCP_FAST_TIMER_PERIOD_MS, _fnet_tcp_fasttimo, 0u); if(!fnet_tcp_fasttimer) @@ -182,7 +183,7 @@ static fnet_return_t _fnet_tcp_init( void ) return FNET_ERR; } - /* Create the fast timer.*/ + /* Create the slow timer.*/ fnet_tcp_slowtimer = _fnet_timer_new(FNET_TCP_SLOW_TIMER_PERIOD_MS, _fnet_tcp_slowtimo, 0u); if(!fnet_tcp_slowtimer) @@ -192,6 +193,9 @@ static fnet_return_t _fnet_tcp_init( void ) return FNET_ERR; } + /* Initialize ISN */ + _fnet_tcp_initial_seq_number_update(); + return FNET_OK; } @@ -437,6 +441,14 @@ static fnet_return_t _fnet_tcp_attach( fnet_socket_if_t *sk ) return FNET_OK; } +/************************************************************************ +* DESCRIPTION: This function updates TCP ISN. +*************************************************************************/ +static void _fnet_tcp_initial_seq_number_update( void ) +{ + /* Increase Initial Sequence Number. */ + _fnet_tcp_initial_seq_number += FNET_TCP_INITIAL_SEQ_NUMBER_STEP + fnet_rand() & 0xFF; +} /************************************************************************ * DESCRIPTION: This function performs the connection termination. * @@ -591,7 +603,7 @@ static fnet_return_t _fnet_tcp_connect( fnet_socket_if_t *sk, struct fnet_sockad sk->state = SS_CONNECTING; /* Increase Initial Sequence Number.*/ - _fnet_tcp_initial_seq_number += FNET_TCP_INITIAL_SEQ_NUMBER_STEP; + _fnet_tcp_initial_seq_number_update(); /* Initialize Abort Timer.*/ cb->tcpcb_timers.retransmission = cb->tcpcb_rto; @@ -1790,7 +1802,7 @@ static fnet_bool_t _fnet_tcp_inputsk( fnet_socket_if_t *sk, fnet_netbuf_t *inseg _fnet_tcp_send_headseg(psk, FNET_TCP_SGT_SYN | FNET_TCP_SGT_ACK, options, optionlen); /* Increase ISN (Initial Sequence Number).*/ - _fnet_tcp_initial_seq_number += FNET_TCP_INITIAL_SEQ_NUMBER_STEP; + _fnet_tcp_initial_seq_number_update(); /* Initialization the connection timer.*/ pcb->tcpcb_timers.connection = FNET_TCP_ABORT_INTERVAL_CON; @@ -2745,7 +2757,7 @@ static void _fnet_tcp_slowtimo(fnet_uint32_t cookie) sk = nextsk; } - _fnet_tcp_initial_seq_number += FNET_TCP_INITIAL_SEQ_NUMBER_STEP; + _fnet_tcp_initial_seq_number_update(); fnet_isr_unlock(); } diff --git a/readme.txt b/readme.txt index e052e5df..0d8014da 100644 --- a/readme.txt +++ b/readme.txt @@ -17,7 +17,7 @@ The stack provides following protocols and services: - QCA4002 (GT202-GC3013-FRDM4-KIT board). - QCA4004 (SX-ULPAN-2401-SHIELD board). - Supported Compilers: - - IAR: Embedded Workbench for ARM, version 8.50 + - IAR: Embedded Workbench for ARM, version 8.22 - GCC: Kinetis Design Studio, version 3.2 - Bare-metal TCP/IP stack. No underlying RTOS is required, although it can be used with it. FreeRTOS example is provided. - Certified logos for: