forked from xuos/xiuos
23/07/27 1.Add netdev module and for edu-arm32, fit Lwip to it; 2.Fit Webnet to edu-arm32;
This commit is contained in:
@@ -19,48 +19,45 @@
|
||||
*/
|
||||
|
||||
#include <board.h>
|
||||
#include <sys_arch.h>
|
||||
#include <shell.h>
|
||||
#include <sys.h>
|
||||
#include <string.h>
|
||||
#include <sys.h>
|
||||
#include <sys_arch.h>
|
||||
#include <xs_kdbg.h>
|
||||
|
||||
#include <netdev.h>
|
||||
|
||||
/******************************************************************************/
|
||||
uint8_t enet_id = 0;
|
||||
static void LwipSetIPTask(void *param)
|
||||
static void LwipSetIPTask(void* param)
|
||||
{
|
||||
uint8_t enet_port = *(uint8_t *)param; ///< test enet port
|
||||
uint8_t enet_port = *(uint8_t*)param; ///< test enet port
|
||||
printf("lw: [%s] config netport id[%d]\n", __func__, enet_port);
|
||||
// lwip_config_net(enet_port, lwip_ipaddr, lwip_netmask, lwip_gwaddr);
|
||||
lwip_config_tcp(enet_port, lwip_ipaddr, lwip_netmask, lwip_gwaddr);
|
||||
}
|
||||
|
||||
void LwipSetIPTest(int argc, char *argv[])
|
||||
void LwipSetIPTest(int argc, char* argv[])
|
||||
{
|
||||
if(argc >= 4)
|
||||
{
|
||||
if (argc >= 4) {
|
||||
printf("lw: [%s] ip %s mask %s gw %s netport %s\n", __func__, argv[1], argv[2], argv[3], argv[4]);
|
||||
sscanf(argv[1], "%d.%d.%d.%d", &lwip_ipaddr[0], &lwip_ipaddr[1], &lwip_ipaddr[2], &lwip_ipaddr[3]);
|
||||
sscanf(argv[2], "%d.%d.%d.%d", &lwip_netmask[0], &lwip_netmask[1], &lwip_netmask[2], &lwip_netmask[3]);
|
||||
sscanf(argv[3], "%d.%d.%d.%d", &lwip_gwaddr[0], &lwip_gwaddr[1], &lwip_gwaddr[2], &lwip_gwaddr[3]);
|
||||
sscanf(argv[4], "%d", &enet_id);
|
||||
|
||||
if(0 == enet_id)
|
||||
{
|
||||
if (0 == enet_id) {
|
||||
printf("save eth0 info\n");
|
||||
memcpy(lwip_eth0_ipaddr, lwip_ipaddr, 20);
|
||||
memcpy(lwip_eth0_netmask, lwip_netmask, 20);
|
||||
memcpy(lwip_eth0_gwaddr, lwip_gwaddr, 20);
|
||||
}
|
||||
else if(1 == enet_id)
|
||||
{
|
||||
} else if (1 == enet_id) {
|
||||
printf("save eth1 info\n");
|
||||
memcpy(lwip_eth1_ipaddr, lwip_ipaddr, 20);
|
||||
memcpy(lwip_eth1_netmask, lwip_netmask, 20);
|
||||
memcpy(lwip_eth1_gwaddr, lwip_gwaddr, 20);
|
||||
}
|
||||
}
|
||||
else if(argc == 2)
|
||||
{
|
||||
} else if (argc == 2) {
|
||||
printf("lw: [%s] set eth0 ipaddr %s \n", __func__, argv[1]);
|
||||
sscanf(argv[1], "%d.%d.%d.%d", &lwip_ipaddr[0], &lwip_ipaddr[1], &lwip_ipaddr[2], &lwip_ipaddr[3]);
|
||||
memcpy(lwip_eth0_ipaddr, lwip_ipaddr, strlen(lwip_ipaddr));
|
||||
@@ -70,39 +67,56 @@ void LwipSetIPTest(int argc, char *argv[])
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(5),
|
||||
setip, LwipSetIPTest, setip [IP] [Netmask] [Gateway] [port]);
|
||||
setip, LwipSetIPTest, setip[IP][Netmask][Gateway][port]);
|
||||
|
||||
|
||||
void LwipShowIPTask(int argc, char *argv[])
|
||||
void LwipShowIPTask(int argc, char* argv[])
|
||||
{
|
||||
#ifdef configMAC_ADDR
|
||||
char mac_addr0[] = configMAC_ADDR;
|
||||
#endif
|
||||
|
||||
// find default netdev
|
||||
struct netdev* netdev = netdev_get_by_name("en\0");
|
||||
if (netdev == NULL) {
|
||||
lw_notice("[%s] Netdev not found by name en\n");
|
||||
struct netdev* default_netdev = NETDEV_DEFAULT;
|
||||
}
|
||||
|
||||
lw_notice("\r\n************************************************\r\n");
|
||||
lw_notice(" Network Configuration\r\n");
|
||||
lw_notice("************************************************\r\n");
|
||||
lw_notice(" ETH0 IPv4 Address : %u.%u.%u.%u\r\n", ((u8_t *)&lwip_eth0_ipaddr)[0], ((u8_t *)&lwip_eth0_ipaddr)[1],
|
||||
((u8_t *)&lwip_eth0_ipaddr)[2], ((u8_t *)&lwip_eth0_ipaddr)[3]);
|
||||
lw_notice(" ETH0 IPv4 Subnet mask : %u.%u.%u.%u\r\n", ((u8_t *)&lwip_eth0_netmask)[0], ((u8_t *)&lwip_eth0_netmask)[1],
|
||||
((u8_t *)&lwip_eth0_netmask)[2], ((u8_t *)&lwip_eth0_netmask)[3]);
|
||||
lw_notice(" ETH0 IPv4 Gateway : %u.%u.%u.%u\r\n", ((u8_t *)&lwip_gwaddr)[0], ((u8_t *)&lwip_eth0_gwaddr)[1],
|
||||
((u8_t *)&lwip_eth0_gwaddr)[2], ((u8_t *)&lwip_eth0_gwaddr)[3]);
|
||||
// lw_notice(" ETH0 IPv4 Address : %u.%u.%u.%u\r\n", ((u8_t*)&lwip_eth0_ipaddr)[0], ((u8_t*)&lwip_eth0_ipaddr)[1],
|
||||
// ((u8_t*)&lwip_eth0_ipaddr)[2], ((u8_t*)&lwip_eth0_ipaddr)[3]);
|
||||
// lw_notice(" ETH0 IPv4 Subnet mask : %u.%u.%u.%u\r\n", ((u8_t*)&lwip_eth0_netmask)[0], ((u8_t*)&lwip_eth0_netmask)[1],
|
||||
// ((u8_t*)&lwip_eth0_netmask)[2], ((u8_t*)&lwip_eth0_netmask)[3]);
|
||||
// lw_notice(" ETH0 IPv4 Gateway : %u.%u.%u.%u\r\n", ((u8_t*)&lwip_gwaddr)[0], ((u8_t*)&lwip_eth0_gwaddr)[1],
|
||||
// ((u8_t*)&lwip_eth0_gwaddr)[2], ((u8_t*)&lwip_eth0_gwaddr)[3]);
|
||||
// #ifdef configMAC_ADDR
|
||||
// lw_notice(" ETH0 MAC Address : %x:%x:%x:%x:%x:%x\r\n", mac_addr0[0], mac_addr0[1], mac_addr0[2],
|
||||
// mac_addr0[3], mac_addr0[4], mac_addr0[5]);
|
||||
// #endif
|
||||
|
||||
lw_notice(" ETH0 IPv4 Address : %u.%u.%u.%u\r\n", ((u8_t*)&lwip_eth0_ipaddr)[0], ((u8_t*)&lwip_eth0_ipaddr)[1],
|
||||
((u8_t*)&lwip_eth0_ipaddr)[2], ((u8_t*)&lwip_eth0_ipaddr)[3]);
|
||||
lw_notice(" ETH0 IPv4 Subnet mask : %u.%u.%u.%u\r\n", ((u8_t*)&lwip_eth0_netmask)[0], ((u8_t*)&lwip_eth0_netmask)[1],
|
||||
((u8_t*)&lwip_eth0_netmask)[2], ((u8_t*)&lwip_eth0_netmask)[3]);
|
||||
lw_notice(" ETH0 IPv4 Gateway : %u.%u.%u.%u\r\n", ((u8_t*)&lwip_gwaddr)[0], ((u8_t*)&lwip_eth0_gwaddr)[1],
|
||||
((u8_t*)&lwip_eth0_gwaddr)[2], ((u8_t*)&lwip_eth0_gwaddr)[3]);
|
||||
#ifdef configMAC_ADDR
|
||||
lw_notice(" ETH0 MAC Address : %x:%x:%x:%x:%x:%x\r\n", mac_addr0[0], mac_addr0[1], mac_addr0[2],
|
||||
mac_addr0[3], mac_addr0[4], mac_addr0[5]);
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_NET_COUNT
|
||||
if(BOARD_NET_COUNT > 1)
|
||||
{
|
||||
if (BOARD_NET_COUNT > 1) {
|
||||
char mac_addr1[] = configMAC_ADDR_ETH1;
|
||||
lw_notice("\r\n");
|
||||
lw_notice(" ETH1 IPv4 Address : %u.%u.%u.%u\r\n", ((u8_t *)&lwip_eth1_ipaddr)[0], ((u8_t *)&lwip_eth1_ipaddr)[1],
|
||||
((u8_t *)&lwip_eth1_ipaddr)[2], ((u8_t *)&lwip_eth1_ipaddr)[3]);
|
||||
lw_notice(" ETH1 IPv4 Subnet mask : %u.%u.%u.%u\r\n", ((u8_t *)&lwip_eth1_netmask)[0], ((u8_t *)&lwip_eth1_netmask)[1],
|
||||
((u8_t *)&lwip_eth1_netmask)[2], ((u8_t *)&lwip_eth1_netmask)[3]);
|
||||
lw_notice(" ETH1 IPv4 Gateway : %u.%u.%u.%u\r\n", ((u8_t *)&lwip_eth1_gwaddr)[0], ((u8_t *)&lwip_eth1_gwaddr)[1],
|
||||
((u8_t *)&lwip_eth1_gwaddr)[2], ((u8_t *)&lwip_eth1_gwaddr)[3]);
|
||||
lw_notice(" ETH1 IPv4 Address : %u.%u.%u.%u\r\n", ((u8_t*)&lwip_eth1_ipaddr)[0], ((u8_t*)&lwip_eth1_ipaddr)[1],
|
||||
((u8_t*)&lwip_eth1_ipaddr)[2], ((u8_t*)&lwip_eth1_ipaddr)[3]);
|
||||
lw_notice(" ETH1 IPv4 Subnet mask : %u.%u.%u.%u\r\n", ((u8_t*)&lwip_eth1_netmask)[0], ((u8_t*)&lwip_eth1_netmask)[1],
|
||||
((u8_t*)&lwip_eth1_netmask)[2], ((u8_t*)&lwip_eth1_netmask)[3]);
|
||||
lw_notice(" ETH1 IPv4 Gateway : %u.%u.%u.%u\r\n", ((u8_t*)&lwip_eth1_gwaddr)[0], ((u8_t*)&lwip_eth1_gwaddr)[1],
|
||||
((u8_t*)&lwip_eth1_gwaddr)[2], ((u8_t*)&lwip_eth1_gwaddr)[3]);
|
||||
lw_notice(" ETH1 MAC Address : %x:%x:%x:%x:%x:%x\r\n", mac_addr1[0], mac_addr1[1], mac_addr1[2],
|
||||
mac_addr1[3], mac_addr1[4], mac_addr1[5]);
|
||||
}
|
||||
@@ -111,5 +125,4 @@ void LwipShowIPTask(int argc, char *argv[])
|
||||
}
|
||||
|
||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN) | SHELL_CMD_PARAM_NUM(0),
|
||||
showip, LwipShowIPTask, GetIp [IP] [Netmask] [Gateway]);
|
||||
|
||||
showip, LwipShowIPTask, GetIp[IP][Netmask][Gateway]);
|
||||
|
||||
Reference in New Issue
Block a user