New IPC interface, lwip sends data to rndis

This commit is contained in:
songyanguang
2024-08-13 14:43:22 +08:00
parent 84ab3dff35
commit aaceb82386
11 changed files with 129 additions and 15 deletions
@@ -53,10 +53,12 @@ arch_usyscall = $(KERNEL_ROOT)/services/app/arch_usyscall.o
session = $(KERNEL_ROOT)/services/app/session.o
libipc = $(KERNEL_ROOT)/services/app/libipc.o
libsem = $(KERNEL_ROOT)/services/app/libsemaphore.o
librndis = $(KERNEL_ROOT)/services/net/net_server/rndis_service.o
lwip: COMPILER lwip_server.o | bin
@${ld} ${user_ldflags} -e main -o $@ ${sys} ${api} ${core} ${ipv4} ${netif} lwip_server.o ${libserial} ${printf} ${libmem} ${usyscall} ${arch_usyscall} ${session} ${libipc} ${libsem} ${board_specs}
@${ld} ${user_ldflags} -e main -o $@ ${librndis} ${sys} ${api} ${core} ${ipv4} ${netif} lwip_server.o ${libserial} ${printf} ${libmem} ${usyscall} ${arch_usyscall} ${session} ${libipc} ${libsem} ${board_specs}
@${objdump} -S $@ > $@.asm
@$(ar) -r liblwip.a ${sys} ${api} ${core} ${ipv4} ${netif}
@$(ar) -r liblwip.a ${librndis} ${sys} ${api} ${core} ${ipv4} ${netif}
@mv *.o bin
@mv $@ $(KERNEL_ROOT)/services/app
@mv $@.asm $(KERNEL_ROOT)/services/app
@@ -1,5 +1,6 @@
include $(KERNEL_ROOT)/services/net/net_server/lwip.mk
objs += sys_arch.o ethernetif.o
objs += $(KERNEL_ROOT)/services/drivers/usb/usb_service/rndis_service.o
arch: ${objs}
@@ -20,10 +20,15 @@
#include "lwip/ethip6.h"
#include "lwip/etharp.h"
#include "libserial.h"
#include "rndis_service.h"
/* Define those to better describe your network interface. */
#define IFNAME0 'e'
#define IFNAME1 'n'
/* IPC rndis client */
struct Session *g_session_rndis = NULL;
/**
* In this function, the hardware should be initialized.
* Called from ethernetif_init().
@@ -80,6 +85,21 @@ void print_packet_data(const char *packet_data, int length) {
}
}
}
/**
* This function should do the actual transmission of the packet.
*
* @param dataptr pointer to the actual data in the buffer
* @param tot_len the length of this buffer
* @return ERR_OK if the send is success
* any other err_t on error
*/
int usbh_rndis_eth_tx(void *dataptr, size_t tot_len)
{
struct Session* session = g_session_rndis;
return ipc_usbh_rndis_eth_tx(session, dataptr, tot_len);;
}
/**
* This function should do the actual transmission of the packet. The packet is
* contained in the pbuf that is passed to the function. This pbuf
@@ -104,8 +124,11 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p)
#endif
pbuf_copy_partial(p, buf, p->tot_len, 0);
print_packet_data(buf, p->tot_len);
usbh_rndis_eth_tx(buf, p->tot_len);
return ERR_OK;
}
@@ -149,6 +172,26 @@ void ethernetif_input(struct netif *netif)
}
}
/**
* In this function, get session info.
* Called from ethernetif_init().
*
* @return lwIP error code
*/
int ipc_rndis_client_init(void)
{
struct Session *session;
session = mem_malloc(sizeof(struct Session));
if(connect_session(session, "RndisServer", 4096) < 0) {
printf("connect session failed\n");
return ERR_IF;
}
g_session_rndis = session;
return ERR_OK;
}
/**
* Should be called at the beginning of the program to set up the
* network interface. It calls the function low_level_init() to do the
@@ -190,6 +233,7 @@ err_t ethernetif_init(struct netif *netif)
/* initialize the hardware */
low_level_init(netif);
ipc_rndis_client_init();
return ERR_OK;
}
@@ -41,4 +41,5 @@ INC_DIR = -I$(KERNEL_ROOT)/services/net/libnet \
-I$(KERNEL_ROOT)/services/lib/serial \
-I$(KERNEL_ROOT)/services/lib/usyscall \
-I$(KERNEL_ROOT)/services/boards/$(BOARD) \
-I$(KERNEL_ROOT)/services/app
-I$(KERNEL_ROOT)/services/app \
-I$(KERNEL_ROOT)/services/drivers/usb/usb_service