Skip to content

Commit

Permalink
Upload lwip-network-interface-integration 1.1.1.255 [365]
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlab-runner committed Dec 22, 2022
1 parent e6ef4e4 commit 7d8e49c
Show file tree
Hide file tree
Showing 5 changed files with 2,326 additions and 2,291 deletions.
4 changes: 4 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ See the [README.md](./README.md) for a complete description of the [lwIP network

## Changelog

### v1.1.1

- Minor bug fixes

### v1.1.0

- Added support for KIT-XMC72-EVK kit
Expand Down
44 changes: 30 additions & 14 deletions source/cy_ethernetif.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,24 +266,40 @@ __WEAK void ETH_LWIP_Error (ETH_LWIP_ERROR_t error_code)
{
switch (error_code)
{
case ETH_LWIP_ERROR_PHY_DEVICE_ID:
/* Incorrect PHY address configured in the ETH_LWIP APP network interface.
* Because the connect PHY does not match the configuration or the PHYADR is incorrect*/
break;
case ETH_LWIP_ERROR_PHY_DEVICE_ID:
{
/* Incorrect PHY address configured in the ETH_LWIP APP network interface.
* Because the connect PHY does not match the configuration or the PHYADR is incorrect*/
cm_cy_log_msg( CYLF_MIDDLEWARE, CY_LOG_ERR, "%s(): Wrong PHY ID used \n", __FUNCTION__ );
break;
}

case ETH_LWIP_ERROR_PHY_TIMEOUT:
/* PHY did not respond.*/
break;
case ETH_LWIP_ERROR_PHY_TIMEOUT:
{
/* PHY did not respond.*/
cm_cy_log_msg( CYLF_MIDDLEWARE, CY_LOG_ERR, "%s(): PHY read failed \n", __FUNCTION__ );
break;
}

case ETH_LWIP_ERROR_PHY_ERROR:
/*PHY register update failed.*/
break;
case ETH_LWIP_ERROR_PHY_ERROR:
{
/*PHY register update failed.*/
cm_cy_log_msg( CYLF_MIDDLEWARE, CY_LOG_ERR, "%s(): PHY status error \n", __FUNCTION__ );
break;
}

default:
break;
case ETH_LWIP_ERROR_PHY_BUSY:
{
cm_cy_log_msg( CYLF_MIDDLEWARE, CY_LOG_ERR, "%s(): PHY is busy \n", __FUNCTION__ );
break;
}
default:
{
cm_cy_log_msg( CYLF_MIDDLEWARE, CY_LOG_ERR, "%s(): Generic PHY error \n", __FUNCTION__ );
break;
}
}

for (;;);
return;
}

#if LWIP_NETIF_LINK_CALLBACK == 1
Expand Down
18 changes: 13 additions & 5 deletions source/cy_lwip_dhcp_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,16 @@ static void cy_dhcp_thread_func(cy_thread_arg_t thread_input)
uint32_t ip_mask;
uint32_t subnet;
uint32_t netmask_htobe;
uint32_t server_ip_addr_htobe;
char *option_ptr;
cy_lwip_dhcp_server_t *server = (cy_lwip_dhcp_server_t*)thread_input;
uint8_t subnet_mask_option_buff[] = { DHCP_SUBNETMASK_OPTION_CODE, 4, 0, 0, 0, 0 };
uint8_t server_ip_addr_option_buff[] = { DHCP_SERVER_IDENTIFIER_OPTION_CODE, 4, 0, 0, 0, 0 };
uint32_t *server_ip_addr_ptr = (uint32_t*)&server_ip_addr_option_buff[2];
uint8_t wpad_option_buff[ 2 + sizeof(WPAD_SAMPLE_URL)-1 ] = { DHCP_WPAD_OPTION_CODE, sizeof(WPAD_SAMPLE_URL)-1 };
cy_lwip_ip_address_t broadcast_addr;

memset(&local_ip_address, 0x00, sizeof(cy_lwip_ip_address_t));

SET_IPV4_ADDRESS(broadcast_addr, MAKE_IPV4_ADDRESS(255, 255, 255, 255));
/* Save the local IP address to be sent in DHCP packets */

Expand All @@ -317,7 +319,9 @@ static void cy_dhcp_thread_func(cy_thread_arg_t thread_input)
local_ip_address.ip.v4 = ntohl(net_interface->ip_addr.addr);
#endif

*server_ip_addr_ptr = htobe32(GET_IPV4_ADDRESS(local_ip_address));
server_ip_addr_htobe = htobe32(GET_IPV4_ADDRESS(local_ip_address));
memcpy(&server_ip_addr_option_buff[2], &server_ip_addr_htobe, 4);

/* Save the current netmask to be sent in DHCP packets as the 'subnet mask option' */
netmask.version = CY_LWIP_IP_VER_V4;
#if LWIP_IPV4 && LWIP_IPV6
Expand All @@ -335,7 +339,7 @@ static void cy_dhcp_thread_func(cy_thread_arg_t thread_input)

/* Prepare the web proxy auto-discovery URL */
memcpy(&wpad_option_buff[2], WPAD_SAMPLE_URL, sizeof(WPAD_SAMPLE_URL)-1);
ipv4_to_string( (char*)&wpad_option_buff[2 + 7], *server_ip_addr_ptr);
ipv4_to_string((char*)&wpad_option_buff[2 + 7], server_ip_addr_option_buff[2]);

/* Loop endlessly */
while ( server->quit == false )
Expand Down Expand Up @@ -482,10 +486,14 @@ static void cy_dhcp_thread_func(cy_thread_arg_t thread_input)

/* Copy the DHCP header content from the received request packet into the reply packet */
memcpy( reply_header, request_header, sizeof(dhcp_header_t) - sizeof(reply_header->options) );


/* Initialize requested address*/
memset( &requested_ip_address, 0, sizeof(requested_ip_address));

/* Record the client MAC address */
memcpy( &client_mac_address, request_header->client_hardware_addr, sizeof( client_mac_address ) );


/* Locate the requested address in the options and keep the requested address */
requested_ip_address.version = CY_LWIP_IP_VER_V4;
find_option_ptr = find_option( request_header, DHCP_REQUESTED_IP_ADDRESS_OPTION_CODE );
Expand Down Expand Up @@ -789,7 +797,7 @@ static cy_rslt_t udp_create_socket(cy_lwip_udp_socket_t *socket, uint16_t port,

static cy_rslt_t udp_delete_socket(cy_lwip_udp_socket_t *socket)
{
cm_cy_log_msg( CYLF_MIDDLEWARE, CY_LOG_DEBUG, "%s(): START \n", __FUNCTION__ );
cm_cy_log_msg( CYLF_MIDDLEWARE, CY_LOG_DEBUG, "%s(): START \n", __FUNCTION__ );
if (socket->conn_handler == NULL)
{
cm_cy_log_msg(CYLF_MIDDLEWARE, CY_LOG_ERR, "Error : Socket deletion failed due to invalid socket \n");
Expand Down
Loading

0 comments on commit 7d8e49c

Please sign in to comment.