/** * Timer callback function that calls etharp_tmr() and reschedules itself. * * @param arg unused argument */ static void arp_timer(void *arg) { LWIP_UNUSED_ARG(arg); LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip: etharp_tmr()\n")); etharp_tmr(); sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL); }
/** * Timer callback function that calls igmp_tmr() and reschedules itself. * * @param arg unused argument */ static void igmp_timer(void *arg) { LWIP_UNUSED_ARG(arg); LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: igmp_tmr()\n")); igmp_tmr(); sys_timeout(IGMP_TMR_INTERVAL, igmp_timer, NULL); }
/*-----------------------------------------------------------------------------------*/ static void tcp_timeout(void *data) { #if TCP_DEBUG tcp_debug_print_pcbs(); #endif /* TCP_DEBUG */ sys_timeout(5000, tcp_timeout, NULL); }
/** * Timer callback function that calls etharp_tmr() and reschedules itself. * * @param arg unused argument */ static void ICACHE_FLASH_ATTR arp_timer(void *arg) { LWIP_UNUSED_ARG(arg); LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: etharp_tmr()\n")); etharp_tmr(); sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL); }
static void ICACHE_FLASH_ATTR tcp_timer_coarse(void *arg) { LWIP_UNUSED_ARG(arg); LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: tcp_tmr()\n")); tcp_tmr(); sys_timeout(TCP_TMR_INTERVAL, tcp_timer_coarse, NULL); }
/** * Timer callback function that calls ip_reass_tmr() and reschedules itself. * * @param arg unused argument */ static void ICACHE_FLASH_ATTR ip_reass_timer(void *arg) { LWIP_UNUSED_ARG(arg); LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: ip_reass_tmr()\n")); ip_reass_tmr(); sys_timeout(IP_TMR_INTERVAL, ip_reass_timer, NULL); }
/** * Timer callback function that calls dns_tmr() and reschedules itself. * * @param arg unused argument */ static void dns_timer(void *arg) { LWIP_UNUSED_ARG(arg); LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: dns_tmr()\n")); dns_tmr(); sys_timeout(DNS_TMR_INTERVAL, dns_timer, NULL); }
/** * Timer callback function that calls autoip_tmr() and reschedules itself. * * @param arg unused argument */ static void autoip_timer(void *arg) { LWIP_UNUSED_ARG(arg); LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: autoip_tmr()\n")); autoip_tmr(); sys_timeout(AUTOIP_TMR_INTERVAL, autoip_timer, NULL); }
/** * Timer callback function that calls dhcp_fine_tmr() and reschedules itself. * * @param arg unused argument */ static void dhcp_timer_fine(void *arg) { LWIP_UNUSED_ARG(arg); LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: dhcp_fine_tmr()\n")); dhcp_fine_tmr(); sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL); }
/** * Timer callback function that calls dhcp_coarse_tmr() and reschedules itself. * * @param arg unused argument */ static void dhcp_timer_coarse(void *arg) { LWIP_UNUSED_ARG(arg); LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: dhcp_coarse_tmr()\r\n")); dhcp_coarse_tmr(); sys_timeout(DHCP_COARSE_TIMER_MSECS, dhcp_timer_coarse, NULL); }
/** * Timer callback function that calls mld6_tmr() and reschedules itself. * * @param arg unused argument */ static void mld6_timer(void *arg) { LWIP_UNUSED_ARG(arg); LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: mld6_tmr()\n")); mld6_tmr(); sys_timeout(MLD6_TMR_INTERVAL, mld6_timer, NULL); }
/** * Timer callback function that calls ip6_reass_tmr() and reschedules itself. * * @param arg unused argument */ static void ip6_reass_timer(void *arg) { LWIP_UNUSED_ARG(arg); LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: ip6_reass_tmr()\n")); ip6_reass_tmr(); sys_timeout(IP6_REASS_TMR_INTERVAL, ip6_reass_timer, NULL); }
/** Initialize this module */ void sys_timeouts_init(void) { #if IP_REASSEMBLY sys_timeout(IP_TMR_INTERVAL, ip_reass_timer, NULL); #endif /* IP_REASSEMBLY */ #if LWIP_ARP sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL); #endif /* LWIP_ARP */ #if LWIP_DHCP sys_timeout(DHCP_COARSE_TIMER_MSECS, dhcp_timer_coarse, NULL); sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL); #endif /* LWIP_DHCP */ #if LWIP_AUTOIP sys_timeout(AUTOIP_TMR_INTERVAL, autoip_timer, NULL); #endif /* LWIP_AUTOIP */ #if LWIP_IGMP sys_timeout(IGMP_TMR_INTERVAL, igmp_timer, NULL); #endif /* LWIP_IGMP */ #if LWIP_DNS sys_timeout(DNS_TMR_INTERVAL, dns_timer, NULL); #endif /* LWIP_DNS */ #if NO_SYS /* Initialise timestamp for sys_check_timeouts */ timeouts_last_time = sys_now(); #endif }
static void tcp_debug_timeout(void *data) { LWIP_UNUSED_ARG(data); #if TCP_DEBUG tcp_debug_print_pcbs(); #endif /* TCP_DEBUG */ sys_timeout(5000, tcp_debug_timeout, NULL); }
static void ping_raw_init(void) { ping_pcb = raw_new(IP_PROTO_ICMP); LWIP_ASSERT("ping_pcb != NULL", ping_pcb != NULL); raw_recv(ping_pcb, ping_recv, NULL); raw_bind(ping_pcb, IP_ADDR_ANY); sys_timeout(PING_DELAY, ping_timeout, ping_pcb); }
void lwip_dhcp_start(void *pParameter) { struct netif *pNetif = (struct netif *)pParameter; dhcp_start(pNetif); sys_timeout(2000, lwip_dhcp_stop, pNetif); uprintf(UPRINT_INFO, UPRINT_BLK_NET, "LWIP DHCP started\n"); }
/** * Called from TCP_REG when registering a new PCB: * the reason is to have the TCP timer only running when * there are active (or time-wait) PCBs. */ void tcp_timer_needed(void) { /* timer is off but needed again? */ if (!tcpip_tcp_timer_active && (tcp_active_pcbs || tcp_tw_pcbs)) { /* enable and start timer */ tcpip_tcp_timer_active = 1; sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL); } }
void udp_proxy_timer_needed(void) { /* timer is off but needed again? */ if (!proxy_udp_timer_active && udp_proxy_pcbs) { /* enable and start timer */ proxy_udp_timer_active = 1; sys_timeout(UDP_PROXY_TMR_INTERVAL, proxy_udp_timer, NULL); } }
/** * Timer callback function that calls mld6_tmr() and reschedules itself. * * @param arg unused argument */ static void cyclic_timer(void *arg) { const struct lwip_cyclic_timer* cyclic = (const struct lwip_cyclic_timer*)arg; #if LWIP_DEBUG_TIMERNAMES LWIP_DEBUGF(TIMERS_DEBUG, ("tcpip: %s()\n", cyclic->handler_name)); #endif cyclic->handler(); sys_timeout(cyclic->interval_ms, cyclic_timer, arg); }
/* Reassembly timer */ static void ip_reass_timer(void *arg) { (void)arg; if (ip_reasstmr > 1) { ip_reasstmr--; sys_timeout(IP_REASS_TMO, ip_reass_timer, NULL); } else if (ip_reasstmr == 1) ip_reasstmr = 0; }
static void ping_timeout(void *arg) { struct raw_pcb *pcb = (struct raw_pcb*)arg; ip_addr_t ping_target = PING_TARGET; LWIP_ASSERT("ping_timeout: no pcb given!", pcb != NULL); ping_send(pcb, &ping_target); sys_timeout(PING_DELAY, ping_timeout, pcb); }
/*-----------------------------------------------------------------------------------*/ static void delif_output_timeout(void *arg) { struct netif *netif; struct delif *delif; struct delif_pbuf *dp; unsigned int timeout, now; timeout = DELIF_TIMEOUT; netif = (struct netif*)arg; delif = (struct delif*)netif->state; /* Check if there is anything on the output list. */ dp = output_list; while (dp != NULL) { now = sys_now(); if (dp->time <= now) { LWIP_DEBUGF(DELIF_DEBUG, ("delif_output_timeout: now %u dp->time %u\n", now, dp->time)); #if LWIP_IPV4 if(!IP_IS_V6_VAL(dp->ipaddr)) { delif->netif->output(delif->netif, dp->p, ip_2_ip4(&dp->ipaddr)); } #endif /* LWIP_IPV4 */ #if LWIP_IPV6 if(IP_IS_V6_VAL(dp->ipaddr)) { delif->netif->output_ip6(delif->netif, dp->p, ip_2_ip6(&dp->ipaddr)); } #endif /* LWIP_IPV6 */ if (dp->next != NULL) { if (dp->next->time > now) { timeout = dp->next->time - now; } else { timeout = 0; } LWIP_DEBUGF(DELIF_DEBUG, ("delif_output_timeout: timeout %u.\n", timeout)); } pbuf_free(dp->p); output_list = dp->next; free(dp); dp = output_list; } else { dp = dp->next; } } sys_timeout(timeout, delif_output_timeout, arg); }
static void timeout_fn ( void * arg) { int i, j = (int)arg; // diag_printf("Timeout #%d called\n", (int)arg); for (i = 0; i < j; i++) diag_printf(" "); diag_printf("%d\n", j); // sys_timeout( intervals[j], timers[j], arg); sys_timeout( 1000, timers[j], arg); }
static void tcpip_thread(void *arg) { struct tcpip_msg *msg; (void)arg; ip_init(); #if LWIP_UDP udp_init(); #endif #if LWIP_TCP tcp_init(); #endif #if IP_REASSEMBLY sys_timeout(1000, ip_timer, NULL); #endif if (tcpip_init_done != NULL) { tcpip_init_done(tcpip_init_done_arg); } while (1) { /* MAIN Loop */ sys_mbox_fetch(mbox, (void *)&msg); switch (msg->type) { case TCPIP_MSG_API: LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: API message %p\n", (void *)msg)); api_msg_input(msg->msg.apimsg); break; case TCPIP_MSG_INPUT: LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: IP packet %p\n", (void *)msg)); ip_input(msg->msg.inp.p, msg->msg.inp.netif); break; case TCPIP_MSG_CALLBACK: LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK %p\n", (void *)msg)); msg->msg.cb.f(msg->msg.cb.ctx); break; default: break; } #ifdef VBOX if (msg->type == TCPIP_MSG_TERM) { memp_free(MEMP_TCPIP_MSG, msg); break; } #endif memp_free(MEMP_TCPIP_MSG, msg); } #ifdef VBOX if (tcpip_init_done != NULL) { tcpip_init_done(tcpip_init_done_arg); } #endif }
/** Actually send an sntp request to a server. * * @param server_addr resolved IP address of the SNTP server */ void sntp_send_request(ip_addr_t *server_addr) { struct pbuf* p; p = pbuf_alloc(PBUF_TRANSPORT, SNTP_MSG_LEN, PBUF_RAM); if (p != NULL) { struct sntp_msg *sntpmsg = (struct sntp_msg *)p->payload; LWIP_DEBUGF(SNTP_DEBUG_STATE, ("sntp_send_request: Sending request to server\n")); /* os_sprintf(deb,"sntp_send_request: Sending request to server\n"); uart0_sendStr(deb);*/ /* initialize request message */ sntp_initialize_request(sntpmsg); /* send request */ udp_sendto(sntp_pcb, p, server_addr, SNTP_PORT); /* os_sprintf(deb,"sntp_send_request: Sent request to server\n"); uart0_sendStr(deb);*/ /* free the pbuf after sending it */ pbuf_free(p); /* os_sprintf(deb,"sntp_send_request: freed request\n"); uart0_sendStr(deb);*/ /* set up receive timeout: try next server or retry on timeout */ sys_timeout((u32_t)SNTP_RECV_TIMEOUT, sntp_try_next_server, NULL); #if SNTP_CHECK_RESPONSE >= 1 /* save server address to verify it in sntp_recv */ ip_addr_set(&sntp_last_server_address, server_addr); #endif /* SNTP_CHECK_RESPONSE >= 1 */ } else { LWIP_DEBUGF(SNTP_DEBUG_SERIOUS, "sntp_send_request: Out of memory, trying again in %"U32_F" ms\n", (u32_t)SNTP_RETRY_TIMEOUT); /* os_sprintf(deb,"sntp_send_request: Out of memory, trying again in %"U32_F" ms\n",(u32_t)SNTP_RETRY_TIMEOUT); uart0_sendStr(deb);*/ /* out of memory: set up a timer to send a retry */ sys_timeout((u32_t)SNTP_RETRY_TIMEOUT, sntp_request, NULL); } /*os_sprintf(deb,"sntp_send_request: finished\n"); uart0_sendStr(deb);*/ }
static bool ICACHE_FLASH_ATTR ping_raw_init(struct ping_msg *pingmsg) { if (pingmsg == NULL) return false; ip_addr_t ping_target; pingmsg->ping_pcb = raw_new(IP_PROTO_ICMP); LWIP_ASSERT("ping_pcb != NULL", pingmsg->ping_pcb != NULL); raw_recv(pingmsg->ping_pcb, ping_recv, pingmsg); raw_bind(pingmsg->ping_pcb, IP_ADDR_ANY); ping_target.addr = pingmsg->ping_opt->ip; pingmsg ->ping_sent = system_get_time(); ping_send(pingmsg->ping_pcb, &ping_target); sys_timeout(PING_TIMEOUT_MS, ping_timeout, pingmsg); sys_timeout(pingmsg->coarse_time, ping_coarse_tmr, pingmsg); return true; }
/** * @brief Initializes the lwIP stack * @param None * @retval None */ void lwip_sys_init(void) { struct ip_addr ipaddr; struct ip_addr netmask; struct ip_addr gw; uprintf_set_enable(UPRINT_INFO, UPRINT_BLK_NET, 1); uprintf_set_enable(UPRINT_DEBUG, UPRINT_BLK_NET, 0); /* Create tcp_ip stack thread */ tcpip_init( NULL, NULL ); /* IP address setting & display on STM32_evalboard LCD*/ #ifdef USE_DHCP ipaddr.addr = 0; netmask.addr = 0; gw.addr = 0; /* create a timer to start dhcp */ sys_timeout(2000, lwip_dhcp_start, &xnetif); #else IP4_ADDR(&ipaddr, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3); IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1 , NETMASK_ADDR2, NETMASK_ADDR3); IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3); uprintf(UPRINT_INFO, UPRINT_BLK_NET, "LWIP eth0 IP: %d.%d.%d.%d\n", IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3); #endif /* - netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask, struct ip_addr *gw, void *state, err_t (* init)(struct netif *netif), err_t (* input)(struct pbuf *p, struct netif *netif)) Adds your network interface to the netif_list. Allocate a struct netif and pass a pointer to this structure as the first argument. Give pointers to cleared ip_addr structures when using DHCP, or fill them with sane numbers otherwise. The state pointer may be NULL. The init function pointer must point to a initialization function for your ethernet netif interface. The following code illustrates it's use.*/ netif_add(&xnetif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, &tcpip_input); /* Registers the default network interface. */ netif_set_default(&xnetif); /* When the netif is fully configured this function must be called.*/ netif_set_up(&xnetif); /* attach ethernet isr */ bsp_isr_attach(16+ETH_IRQn, ethernetif_isr); bsp_irq_unmask(16+ETH_IRQn); }
void LWIP::tcpip_thread_callback(void *ptr) { lwip_callback *cb = static_cast<lwip_callback *>(ptr); if (cb->delay) { sys_timeout(cb->delay, LWIP::tcpip_thread_callback, ptr); cb->delay = 0; } else { cb->callback(); delete cb; } }
/*-----------------------------------------------------------------------------------*/ static void tcpip_tcp_timer(void *arg) { (void)arg; tcp_tmr(); if (tcp_active_pcbs || tcp_tw_pcbs) { sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL); } else { tcpip_tcp_timer_active = 0; } }
/** Initialize this module */ void sys_timeouts_init(void) { //we don't support ipreassembly // ip_reass_waiter = sys_timeout(IP_TMR_INTERVAL, ip_reass_timer, ip_reass_waiter); #if 0 #if LWIP_ARP sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL); #endif /* LWIP_ARP */ #if LWIP_DHCP sys_timeout(DHCP_COARSE_TIMER_MSECS, dhcp_timer_coarse, NULL); sys_timeout(DHCP_FINE_TIMER_MSECS, dhcp_timer_fine, NULL); #endif /* LWIP_DHCP */ #if LWIP_AUTOIP sys_timeout(AUTOIP_TMR_INTERVAL, autoip_timer, NULL); #endif /* LWIP_AUTOIP */ #if LWIP_IGMP sys_timeout(IGMP_TMR_INTERVAL, igmp_timer, NULL); #endif /* LWIP_IGMP */ #if LWIP_DNS sys_timeout(DNS_TMR_INTERVAL, dns_timer, NULL); #endif /* LWIP_DNS */ */ #endif }