lwip-contrib-mac/ports/mac/test.c

1 line
13 KiB
C
Raw Normal View History

/* * test.c * * * Created by Eric Pooch on 1/4/14. * Copyright 2014 Eric Pooch. All rights reserved. * */ #include <stdlib.h> //#include <stdbool.h> #include <time.h> #include <SegLoad.h> #include <Memory.h> #include <Files.h> #include <Errors.h> #include "arch/macos_debug.h" #include "lwip/sys.h" #include "lwip/sio.h" #include "fs.h" #include "lwip/init.h" #include "lwip/ip.h" #include "lwip/tcp_impl.h" #include "lwip/tcpip.h" #include "lwip/netif.h" #if SER_DEBUG #include <stdarg.h> #endif #include "test.h" #if PPP_SUPPORT #include "netif/ppp/ppp.h" #endif #define MIN_FREE_MEM 28000 #if LWIP_HAVE_SLIPIF #include "netif/slipif.h" #endif //#include "echo.h" #include "httpserver_raw/httpd.h" #if SER_DEBUG sio_fd_t debug_sio; #endif #if PPP_SUPPORT sio_fd_t ppp_sio; struct ppp_pcb_s *ppps; void ppp_link_status_cb(ppp_pcb *pcb, int err_code, void *ctx); void test_intf(void); void ppp_poll(void); void apps_init(void); #if PPP_NOTIFY_PHASE void ppp_notify_phase_cb(ppp_pcb *pcb, u8_t phase, void *ctx); //static u8_t ppp_phase; #endif /*PPP_NOTIFY_PHASE*/ #endif /*PPP_SUPPORT*/ #if LWIP_HAVE_SLIPIF static struct netif slipif; void test_intf(void); /* (manual) host IP configuration */ static ip_addr_t ipaddr, netmask, gw; #endif #if LWIP_HAVE_LOOPIF static struct netif loopif; #endif // lwIP interval timer struct test_timer { u32_t time; // Current time counter in ms u32_t interval; // Interval in ms void (*timed_func)(void); // Function to call }; // List of lwIP interval timers #define PPP_TMR_INTERVAL 16 #define PING_TMR_INTERVAL 1200 static struct test_timer test_timers[] = { #if LWIP_TCP //{ 0, TCP_TMR_INTERVAL, tcp_tmr }, #endif #if LWIP_ARP { 0, ARP_TMR_INTERVAL, etharp_tmr }, #endif #if IP_REASSEMBLY { 0, IP_TMR_INTERVAL, ip_reass_tmr }, #endif #if LWIP_AUTOIP { 0, AUTOIP_TMR_INTERVAL, autoip_tmr }, #endif #if LWIP_IGMP { 0, IGMP_TMR_INTERVAL, igmp_tmr }, #endif #if LWIP_DNS { 0, DNS_TMR_INTERVAL, dns_tmr }, #endif #if PPP_SUPPORT //{ 0, PPP_TMR_INTERVAL, ppp_poll }, { 0, 15000, test_intf }, #endif #ifndef TEST_MAIN_DISABLE { 0, 60000, test_stop }, #endif { 0, 0, NULL } }; static short apps_started; static u32_t last_ticks; #ifndef TEST_MAIN_DISABLE int main(void) { /* Initialize menus Initialize user settings Initialize browser window */ /* initialize the program */ /* Chat with modem/server */ /* Start PPP/SLIP */ test_init(); while (1) { test_poll(); } return 0; } #endif /* This function initializes applications */ void apps_init(void) { #if LWIP_DNS_APP && LWIP_DNS /* wait until the netif is up (for dhcp, autoip or ppp) */ //sys_timeout(5000, dns_dorequest, NULL); #endif /* LWIP_DNS_APP && LWIP_DNS */ #if LWIP_CHARGEN_APP && LWIP_SOCKET chargen_init(); #endif /* LWIP_CHARGEN_APP && LWIP_SOCKET */ #if LWIP_PING_APP && LWIP_RAW && LWIP_ICMP ping_init(); #endif /* LWIP_PING_APP && LWIP_RAW && LWIP_ICMP */ #if LWIP_NETBIOS_APP && LWIP_UDP netbios_init(); #endif /* LWIP_NETBIOS_APP && LWIP_UDP */ #if LWIP_HTTPD_APP && LWIP_TCP #ifdef LWIP_HTTPD_APP_NETCONN http_server_netconn_init(); #else /* LWIP_HTTPD_APP_NETCONN */ httpd_init(); #endif /* LWIP_HTTPD_APP_NETCONN */ #endif /* LWIP_HTTPD_APP && LWIP_TCP */ #if LWIP_NETIO_APP && LWIP_TCP netio_init(); #endif /* LWIP_NETIO_APP && LWIP_TCP */ #if LWIP_RTP_APP && LWIP_SOCKET && LWIP_IGMP rtp_init(); #endif /* LWIP_RTP_APP && LWIP_SOCKET && LWIP_IGMP */ #if LWIP_SNTP_APP && LWIP_SOCKET sntp_init(); #endif /* LWIP_SNTP_APP && LWIP_SOCKET */ #if LWIP_SHELL_APP && LWIP_NETCONN shell_init(); #endif /* LWIP_SHELL_APP && LWIP_NETCONN */ #if LWIP_TCPECHO_APP #if LWIP_NETCONN && defined(LWIP_TCPECHO_APP_NETCONN) tcpecho_init(); #else /* LWIP_NETCONN && defined(LWIP_TCPECHO_APP_NETCONN) */ echo_init(); #endif /* LWIP_TCPECHO_APP && LWIP_NETCONN */ #endif #if LWIP_UDPECHO_APP && LWIP_NETCONN udpecho_init(); #endif /* LWIP_UDPECHO_APP && LWIP_NETCONN */ #if LWIP_SOCKET_EXAMPLES_APP