/** ARP timer, to retain the time elapsed since the ARP cache was last updated. */\r
struct timer ARPTimer;\r
\r
+/** MAC address of the RNDIS device, when enumerated */\r
+struct uip_eth_addr MACAddress;\r
\r
/** Main program entry point. This routine configures the hardware required by the application, then\r
* enters a loop to run the application tasks in sequence.\r
break;\r
}\r
\r
- struct uip_eth_addr MACAddress;\r
if (RNDIS_Host_QueryRNDISProperty(&Ethernet_RNDIS_Interface, OID_802_3_CURRENT_ADDRESS,\r
&MACAddress, sizeof(MACAddress)) != HOST_SENDCONTROL_Successful)\r
{\r
\r
for (uint8_t i = 0; i < UIP_CONNS; i++)\r
{\r
- /* Run periodic connection management for each connection */\r
+ /* Run periodic connection management for each TCP connection */\r
uip_periodic(i);\r
\r
/* If a response was generated, send it */\r
if (uip_len > 0)\r
- RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, &uip_buf[0], uip_len);\r
+ {\r
+ /* Add destination MAC to outgoing packet */\r
+ uip_arp_out();\r
+\r
+ RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, &uip_buf[0], uip_len);\r
+ }\r
}\r
\r
+ #if defined(ENABLE_DHCP)\r
+ for (uint8_t i = 0; i < UIP_UDP_CONNS; i++)\r
+ {\r
+ /* Run periodic connection management for each UDP connection */\r
+ uip_udp_periodic(i);\r
+\r
+ /* If a response was generated, send it */\r
+ if (uip_len > 0)\r
+ {\r
+ /* Add destination MAC to outgoing packet */\r
+ uip_arp_out();\r
+\r
+ RNDIS_Host_SendPacket(&Ethernet_RNDIS_Interface, &uip_buf[0], uip_len);\r
+ }\r
+ }\r
+ #endif\r
+\r
LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
}\r
\r
\r
/* uIP Stack Initialization */\r
uip_init();\r
+\r
+ /* DHCP/Server IP Settings Initialization */\r
+ #if defined(ENABLE_DHCP)\r
+ DHCPApp_Init();\r
+ #else\r
uip_ipaddr_t IPAddress, Netmask, GatewayIPAddress;\r
- uip_ipaddr(&IPAddress, DEVICE_IP_ADDRESS[0], DEVICE_IP_ADDRESS[1], DEVICE_IP_ADDRESS[2], DEVICE_IP_ADDRESS[3]);\r
- uip_ipaddr(&Netmask, DEVICE_NETMASK[0], DEVICE_NETMASK[1], DEVICE_NETMASK[2], DEVICE_NETMASK[3]);\r
- uip_ipaddr(&GatewayIPAddress, DEVICE_GATEWAY[0], DEVICE_GATEWAY[1], DEVICE_GATEWAY[2], DEVICE_GATEWAY[3]);\r
+ uip_ipaddr(&IPAddress, DEVICE_IP_ADDRESS[0], DEVICE_IP_ADDRESS[1], DEVICE_IP_ADDRESS[2], DEVICE_IP_ADDRESS[3]);\r
+ uip_ipaddr(&Netmask, DEVICE_NETMASK[0], DEVICE_NETMASK[1], DEVICE_NETMASK[2], DEVICE_NETMASK[3]);\r
+ uip_ipaddr(&GatewayIPAddress, DEVICE_GATEWAY[0], DEVICE_GATEWAY[1], DEVICE_GATEWAY[2], DEVICE_GATEWAY[3]);\r
uip_sethostaddr(&IPAddress);\r
uip_setnetmask(&Netmask);\r
uip_setdraddr(&GatewayIPAddress);\r
- \r
+ #endif\r
+ \r
/* HTTP Webserver Initialization */\r
WebserverApp_Init();\r
}\r