Add a TELNET server to the webserver project, which currently can list active TCP...
[pub/USBasp.git] / Projects / Webserver / Lib / uIPManagement.c
index e207d9c..a2cadd6 100644 (file)
@@ -58,10 +58,11 @@ void uIPManagement_Init(void)
        /* uIP Stack Initialization */\r
        uip_init();\r
        uip_arp_init();\r
        /* uIP Stack Initialization */\r
        uip_init();\r
        uip_arp_init();\r
+       uip_setethaddr(MACAddress);\r
 \r
        /* DHCP/Server IP Settings Initialization */\r
        #if defined(ENABLE_DHCP)\r
 \r
        /* DHCP/Server IP Settings Initialization */\r
        #if defined(ENABLE_DHCP)\r
-       DHCPApp_Init();\r
+       DHCPClientApp_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
        #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
@@ -71,11 +72,12 @@ void uIPManagement_Init(void)
        uip_setnetmask(&Netmask);\r
        uip_setdraddr(&GatewayIPAddress);\r
        #endif\r
        uip_setnetmask(&Netmask);\r
        uip_setdraddr(&GatewayIPAddress);\r
        #endif\r
-\r
-       uip_setethaddr(MACAddress);\r
        \r
        /* HTTP Webserver Initialization */\r
        HTTPServerApp_Init();\r
        \r
        /* HTTP Webserver Initialization */\r
        HTTPServerApp_Init();\r
+       \r
+       /* TELNET Server Initialization */\r
+       TELNETServerApp_Init();\r
 }\r
 \r
 /** uIP Management function. This function manages the uIP stack when called while an RNDIS device has been\r
 }\r
 \r
 /** uIP Management function. This function manages the uIP stack when called while an RNDIS device has been\r
@@ -90,6 +92,37 @@ void uIPManagement_ManageNetwork(void)
        }\r
 }\r
 \r
        }\r
 }\r
 \r
+/** uIP TCP/IP network stack callback function for the processing of a given TCP connection. This routine dispatches\r
+ *  to the appropriate TCP protocol application based on the connection's listen port number.\r
+ */\r
+void uIPManagement_TCPCallback(void)\r
+{\r
+       /* Call the correct TCP application based on the port number the connection is listening on */\r
+       switch (uip_conn->lport)\r
+       {\r
+               case HTONS(HTTP_SERVER_PORT):\r
+                       HTTPServerApp_Callback();\r
+                       break;\r
+               case HTONS(TELNET_SERVER_PORT):\r
+                       TELNETServerApp_Callback();\r
+                       break;\r
+       }\r
+}\r
+\r
+/** uIP TCP/IP network stack callback function for the processing of a given UDP connection. This routine dispatches\r
+ *  to the appropriate UDP protocol application based on the connection's listen port number.\r
+ */\r
+void uIPManagement_UDPCallback(void)\r
+{\r
+       /* Call the correct UDP application based on the port number the connection is listening on */\r
+       switch (uip_udp_conn->lport)\r
+       {\r
+               case HTONS(DHCPC_CLIENT_PORT):\r
+                       DHCPClientApp_Callback();\r
+                       break;\r
+       }\r
+}\r
+\r
 /** Processes incomming packets to the server from the connected RNDIS device, creating responses as needed. */\r
 static void uIPManagement_ProcessIncommingPacket(void)\r
 {\r
 /** Processes incomming packets to the server from the connected RNDIS device, creating responses as needed. */\r
 static void uIPManagement_ProcessIncommingPacket(void)\r
 {\r