/** Configures the uIP stack ready for network traffic processing. */ void uIPManagement_Init(void) { /* uIP Timing Initialization */ clock_init(); timer_set(&ConnectionTimer, CLOCK_SECOND / 2); timer_set(&ARPTimer, CLOCK_SECOND * 10); /* uIP Stack Initialization */ uip_init(); uip_arp_init(); uip_setethaddr(MACAddress); /* DHCP/Server IP Settings Initialization */ #if defined(ENABLE_DHCP_CLIENT) HaveIPConfiguration = false; DHCPClientApp_Init(); #else HaveIPConfiguration = true; uip_ipaddr_t IPAddress, Netmask, GatewayIPAddress; uip_ipaddr(&IPAddress, DEVICE_IP_ADDRESS[0], DEVICE_IP_ADDRESS[1], DEVICE_IP_ADDRESS[2], DEVICE_IP_ADDRESS[3]); uip_ipaddr(&Netmask, DEVICE_NETMASK[0], DEVICE_NETMASK[1], DEVICE_NETMASK[2], DEVICE_NETMASK[3]); uip_ipaddr(&GatewayIPAddress, DEVICE_GATEWAY[0], DEVICE_GATEWAY[1], DEVICE_GATEWAY[2], DEVICE_GATEWAY[3]); uip_sethostaddr(&IPAddress); uip_setnetmask(&Netmask); uip_setdraddr(&GatewayIPAddress); #endif /* HTTP Webserver Initialization */ HTTPServerApp_Init(); /* TELNET Server Initialization */ #if defined(ENABLE_TELNET_SERVER) TELNETServerApp_Init(); #endif }
/** Configures the uIP stack ready for network traffic processing. */ void uIPManagement_Init(void) { /* uIP Timing Initialization */ clock_init(); timer_set(&ConnectionTimer, CLOCK_SECOND / 2); timer_set(&ARPTimer, CLOCK_SECOND * 10); /* uIP Stack Initialization */ uip_init(); uip_arp_init(); /* DHCP/Server IP Settings Initialization */ if (USB_CurrentMode == USB_MODE_Device) { MACAddress.addr[0] = SERVER_MAC_ADDRESS[0]; MACAddress.addr[1] = SERVER_MAC_ADDRESS[1]; MACAddress.addr[2] = SERVER_MAC_ADDRESS[2]; MACAddress.addr[3] = SERVER_MAC_ADDRESS[3]; MACAddress.addr[4] = SERVER_MAC_ADDRESS[4]; MACAddress.addr[5] = SERVER_MAC_ADDRESS[5]; #if defined(ENABLE_DHCP_SERVER) DHCPServerApp_Init(); #endif uip_ipaddr_t IPAddress, Netmask, GatewayIPAddress; uip_ipaddr(&IPAddress, DEVICE_IP_ADDRESS[0], DEVICE_IP_ADDRESS[1], DEVICE_IP_ADDRESS[2], DEVICE_IP_ADDRESS[3]); uip_ipaddr(&Netmask, DEVICE_NETMASK[0], DEVICE_NETMASK[1], DEVICE_NETMASK[2], DEVICE_NETMASK[3]); uip_ipaddr(&GatewayIPAddress, DEVICE_GATEWAY[0], DEVICE_GATEWAY[1], DEVICE_GATEWAY[2], DEVICE_GATEWAY[3]); uip_sethostaddr(&IPAddress); uip_setnetmask(&Netmask); uip_setdraddr(&GatewayIPAddress); } else { #if defined(ENABLE_DHCP_CLIENT) DHCPClientApp_Init(); #else uip_ipaddr_t IPAddress, Netmask, GatewayIPAddress; uip_ipaddr(&IPAddress, DEVICE_IP_ADDRESS[0], DEVICE_IP_ADDRESS[1], DEVICE_IP_ADDRESS[2], DEVICE_IP_ADDRESS[3]); uip_ipaddr(&Netmask, DEVICE_NETMASK[0], DEVICE_NETMASK[1], DEVICE_NETMASK[2], DEVICE_NETMASK[3]); uip_ipaddr(&GatewayIPAddress, DEVICE_GATEWAY[0], DEVICE_GATEWAY[1], DEVICE_GATEWAY[2], DEVICE_GATEWAY[3]); uip_sethostaddr(&IPAddress); uip_setnetmask(&Netmask); uip_setdraddr(&GatewayIPAddress); #endif } /* Virtual Webserver Ethernet Address Configuration */ uip_setethaddr(MACAddress); /* HTTP Webserver Initialization */ HTTPServerApp_Init(); /* TELNET Server Initialization */ #if defined(ENABLE_TELNET_SERVER) TELNETServerApp_Init(); #endif }