ip over slip outgoing works

This commit is contained in:
Ulrich Mohr 2023-09-22 16:38:05 +02:00
parent 2b6a8a501b
commit 69e14e14cf
4 changed files with 58 additions and 45 deletions

View File

@ -37,7 +37,7 @@
#else /* LWIP_OPTTEST_FILE */
#define LWIP_IPV4 1
#define LWIP_IPV6 1
#define LWIP_IPV6 0
#define NO_SYS 0
#define LWIP_SOCKET (NO_SYS==0)
@ -74,27 +74,29 @@
#define LWIP_NETIF_STATUS_CALLBACK 1
#define LWIP_NETIF_EXT_STATUS_CALLBACK 1
#define LWIP_DEBUG
#ifdef LWIP_DEBUG
#define LWIP_DBG_MIN_LEVEL 0
#define PPP_DEBUG LWIP_DBG_OFF
#define MEM_DEBUG LWIP_DBG_OFF
#define MEMP_DEBUG LWIP_DBG_OFF
#define PBUF_DEBUG LWIP_DBG_OFF
#define API_LIB_DEBUG LWIP_DBG_OFF
#define API_MSG_DEBUG LWIP_DBG_OFF
#define TCPIP_DEBUG LWIP_DBG_OFF
#define NETIF_DEBUG LWIP_DBG_OFF
#define SOCKETS_DEBUG LWIP_DBG_OFF
#define DNS_DEBUG LWIP_DBG_OFF
#define AUTOIP_DEBUG LWIP_DBG_OFF
#define DHCP_DEBUG LWIP_DBG_OFF
#define IP_DEBUG LWIP_DBG_OFF
#define IP_REASS_DEBUG LWIP_DBG_OFF
#define ICMP_DEBUG LWIP_DBG_OFF
#define IGMP_DEBUG LWIP_DBG_OFF
#define UDP_DEBUG LWIP_DBG_OFF
#define TCP_DEBUG LWIP_DBG_OFF
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL
#define PPP_DEBUG LWIP_DBG_ON
#define MEM_DEBUG LWIP_DBG_ON
#define MEMP_DEBUG LWIP_DBG_ON
#define PBUF_DEBUG LWIP_DBG_ON
#define API_LIB_DEBUG LWIP_DBG_ON
#define API_MSG_DEBUG LWIP_DBG_ON
#define TCPIP_DEBUG LWIP_DBG_ON
#define NETIF_DEBUG LWIP_DBG_ON
#define SOCKETS_DEBUG LWIP_DBG_ON
#define DNS_DEBUG LWIP_DBG_ON
#define AUTOIP_DEBUG LWIP_DBG_ON
#define DHCP_DEBUG LWIP_DBG_ON
#define IP_DEBUG LWIP_DBG_ON
#define IP_REASS_DEBUG LWIP_DBG_ON
#define ICMP_DEBUG LWIP_DBG_ON
#define IGMP_DEBUG LWIP_DBG_ON
#define UDP_DEBUG LWIP_DBG_ON
#define TCP_DEBUG LWIP_DBG_ON
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
#define TCP_RTO_DEBUG LWIP_DBG_OFF
@ -155,7 +157,7 @@ a lot of data that needs to be copied, this should be set high. */
#define MEMP_NUM_TCPIP_MSG_API 16
#define MEMP_NUM_TCPIP_MSG_INPKT 16
#define TCPIP_THREAD_STACKSIZE 1024
#define TCPIP_THREAD_STACKSIZE 10240
/* Enable all socket operations */
#define LWIP_TCP_KEEPALIVE 1

View File

@ -15,5 +15,5 @@ void outbyte(char c);
#endif
void outbyte(char c) {
XUartPs_SendByte(STDOUT_BASEADDRESS, c);
//XUartPs_SendByte(STDOUT_BASEADDRESS, c);
}

View File

@ -160,7 +160,7 @@ int main(void) {
mission, /* The function that implements the task. */
"init", /* The text name assigned to the task - for debug only as it is not used by the
kernel. */
1024, /* The size of the stack to allocate to the task. */
10240, /* The size of the stack to allocate to the task. */
&taskParameters, /* The parameter passed to the task - not used in this simple case. */
1, /* The priority assigned to the task. */
nullptr); /* The task handle is not required, so NULL is passed. */

View File

@ -1,16 +1,48 @@
#include "FreeRTOS.h"
#include "lwip/sio.h"
#include "task.h"
#include <arpa/inet.h>
#include <cstring>
#include <lwip/ip_addr.h>
#include <lwip/tcpip.h>
#include <lwip/netifapi.h>
#include <netif/slipif.h>
#include <sys/socket.h>
#include <xuartps.h>
extern "C" {
void myInitDone(void *arg) {
puts("init done");
}
}
uint32_t sio_data;
sio_fd_t sio_open(u8_t devnum) { return &sio_data; }
void sio_send(u8_t c, sio_fd_t fd) { XUartPs_SendByte(STDOUT_BASEADDRESS, c); }
void testIp() {
tcpip_init(myInitDone, nullptr);
ip_addr_t slip_addr = IPADDR4_INIT_BYTES(10, 0, 0, 32),
slip_mask = IPADDR4_INIT_BYTES(255, 255, 255, 0),
slip_gw = IPADDR4_INIT_BYTES(10, 25, 0, 1);
struct netif netif;
netifapi_netif_add(&netif, &slip_addr, &slip_mask, &slip_gw, NULL, slipif_init,
netif_input);
netifapi_netif_set_default(&netif);
//should be done by driver, which does not do it, so we do it here
netifapi_netif_set_link_up(&netif);
netifapi_netif_set_up(&netif);
vTaskDelay(pdMS_TO_TICKS(2000));
puts("socket");
@ -24,7 +56,7 @@ void myInitDone(void *arg) {
memset(&serverAddr, 0, sizeof(serverAddr));
serverAddr.sin_family = AF_INET6;
serverAddr.sin_family = AF_INET;
serverAddr.sin_port = htons(0xcafe);
serverAddr.sin_addr.s_addr = inet_addr("10.0.0.13");
@ -34,25 +66,4 @@ void myInitDone(void *arg) {
sendto(serverSocket, data, sizeof(data), 0, (sockaddr *)&serverAddr,
sizeof(serverAddr));
}
}
sio_fd_t sio_open(u8_t devnum) { return 0; }
void sio_send(u8_t c, sio_fd_t fd) { XUartPs_SendByte(STDOUT_BASEADDRESS, c); }
void testIp() {
struct netif netif;
tcpip_init(myInitDone, nullptr);
ip_addr_t slip_addr = IPADDR4_INIT_BYTES(10, 0, 0, 32),
slip_mask = IPADDR4_INIT_BYTES(255, 255, 255, 0),
slip_gw = IPADDR4_INIT_BYTES(255, 255, 255, 0);
netif_add(&netif, &slip_addr.u_addr.ip4, &slip_mask.u_addr.ip4,
&slip_gw.u_addr.ip4, NULL, slipif_init, netif_input);
netif_set_default(&netif);
netif_set_up(&netif);
}