/* This function initializes applications */ static void apps_init() { #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 #endif /* LWIP_TCPECHO_APP && LWIP_NETCONN */ #if LWIP_UDPECHO_APP && LWIP_NETCONN udpecho_init(); #endif /* LWIP_UDPECHO_APP && LWIP_NETCONN */ #if LWIP_SOCKET_EXAMPLES_APP && LWIP_SOCKET socket_examples_init(); #endif /* LWIP_SOCKET_EXAMPLES_APP && LWIP_SOCKET */ #ifdef LWIP_APP_INIT LWIP_APP_INIT(); #endif }
/*! * @brief main function */ int main(void) { struct netif fsl_netif0; ip_addr_t fsl_netif0_ipaddr, fsl_netif0_netmask, fsl_netif0_gw; app_low_level_init(); OSA_Init(); lwip_init(); IP4_ADDR(&fsl_netif0_ipaddr, 192,168,2,102); IP4_ADDR(&fsl_netif0_netmask, 255,255,255,0); IP4_ADDR(&fsl_netif0_gw, 192,168,2,100); netif_add(&fsl_netif0, &fsl_netif0_ipaddr, &fsl_netif0_netmask, &fsl_netif0_gw, NULL, ethernetif_init, ethernet_input); netif_set_default(&fsl_netif0); netif_set_up(&fsl_netif0); echo_init(); #if !ENET_RECEIVE_ALL_INTERRUPT uint32_t devNumber = 0; enet_dev_if_t * enetIfPtr; #if LWIP_HAVE_LOOPIF devNumber = fsl_netif0.num - 1; #else devNumber = fsl_netif0.num; #endif enetIfPtr = (enet_dev_if_t *)&enetDevIf[devNumber]; #endif while(1) { #if !ENET_RECEIVE_ALL_INTERRUPT ENET_receive(enetIfPtr); #endif sys_check_timeouts(); } }
void effect_init() { echo_init(&effect.echo); stereo_init(&effect.stereo); voice_init(&effect.voice); normal_init(&effect.normal); eq_init(&effect.eq); }
static int core_plugins(struct agent_core_t *core) { vping_init(core); logger_init(core); vadmin_init(core); httpd_init(core); echo_init(core); vstatus_init(core); vcl_init(core); html_init(core); vparams_init(core); vban_init(core); vstat_init(core); vlog_init(core); vcurl_init(core); vac_register_init(core); return 1; }
/** * @brief main routine for example_lwip_tcpecho_sa_18xx43xx * @return Function should not exit. */ int main(void) { uint32_t physts; ip_addr_t ipaddr, netmask, gw; prvSetupHardware(); /* Initialize LWIP */ lwip_init(); LWIP_DEBUGF(LWIP_DBG_ON, ("Starting LWIP TCP echo server...\n")); /* Static IP assignment */ #if LWIP_DHCP IP4_ADDR(&gw, 0, 0, 0, 0); IP4_ADDR(&ipaddr, 0, 0, 0, 0); IP4_ADDR(&netmask, 0, 0, 0, 0); #else IP4_ADDR(&gw, 10, 1, 10, 1); IP4_ADDR(&ipaddr, 10, 1, 10, 234); IP4_ADDR(&netmask, 255, 255, 255, 0); APP_PRINT_IP(&ipaddr); #endif /* Add netif interface for lpc17xx_8x */ netif_add(&lpc_netif, &ipaddr, &netmask, &gw, NULL, lpc_enetif_init, ethernet_input); netif_set_default(&lpc_netif); netif_set_up(&lpc_netif); #if LWIP_DHCP dhcp_start(&lpc_netif); #endif /* Initialize and start application */ echo_init(); /* This could be done in the sysTick ISR, but may stay in IRQ context too long, so do this stuff with a background loop. */ while (1) { /* Handle packets as part of this loop, not in the IRQ handler */ lpc_enetif_input(&lpc_netif); /* lpc_rx_queue will re-qeueu receive buffers. This normally occurs automatically, but in systems were memory is constrained, pbufs may not always be able to get allocated, so this function can be optionally enabled to re-queue receive buffers. */ #if 0 while (lpc_rx_queue(&lpc_netif)) {} #endif /* Free TX buffers that are done sending */ lpc_tx_reclaim(&lpc_netif); /* LWIP timers - ARP, DHCP, TCP, etc. */ sys_check_timeouts(); /* Call the PHY status update state machine once in a while to keep the link status up-to-date */ physts = lpcPHYStsPoll(); /* Only check for connection state when the PHY status has changed */ if (physts & PHY_LINK_CHANGED) { if (physts & PHY_LINK_CONNECTED) { Board_LED_Set(0, true); /* Set interface speed and duplex */ if (physts & PHY_LINK_SPEED100) { Chip_ENET_SetSpeed(LPC_ETHERNET, 1); NETIF_INIT_SNMP(&lpc_netif, snmp_ifType_ethernet_csmacd, 100000000); } else { Chip_ENET_SetSpeed(LPC_ETHERNET, 0); NETIF_INIT_SNMP(&lpc_netif, snmp_ifType_ethernet_csmacd, 10000000); } if (physts & PHY_LINK_FULLDUPLX) { Chip_ENET_SetDuplex(LPC_ETHERNET, true); } else { Chip_ENET_SetDuplex(LPC_ETHERNET, false); } netif_set_link_up(&lpc_netif); } else { Board_LED_Set(0, false); netif_set_link_down(&lpc_netif); } DEBUGOUT("Link connect status: %d\r\n", ((physts & PHY_LINK_CONNECTED) != 0)); } } /* Never returns, for warning only */ return 0; }
/* ** The main function */ int main(void) { unsigned int ipAddr; LWIP_IF lwipIfPort1, lwipIfPort2; MMUConfigAndEnable(); #ifdef LWIP_CACHE_ENABLED CacheEnable(CACHE_ALL); #endif CPSWPinMuxSetup(); CPSWClkEnable(); /* Initialize console for communication with the Host Machine */ ConsoleUtilsInit(); /* Select the console type based on compile time check */ ConsoleUtilsSetType(CONSOLE_UART); /* Chip configuration RGMII selection */ EVMPortMIIModeSelect(); /* Get the MAC address */ EVMMACAddrGet(0, lwipIfPort1.macArray); EVMMACAddrGet(1, lwipIfPort2.macArray); AintcCPSWIntrSetUp(); //DelayTimerSetup(); ConsoleUtilsPrintf("\n\rStarterWare Ethernet Echo Application. \n\r\n\r" ); ConsoleUtilsPrintf("Acquiring IP Address for Port 1... \n\r" ); #if STATIC_IP_ADDRESS_PORT1 lwipIfPort1.instNum = 0; lwipIfPort1.slvPortNum = 1; lwipIfPort1.ipAddr = STATIC_IP_ADDRESS_PORT1; lwipIfPort1.netMask = 0; lwipIfPort1.gwAddr = 0; lwipIfPort1.ipMode = IPADDR_USE_STATIC; ipAddr = lwIPInit(&lwipIfPort1); #else lwipIfPort1.instNum = 0; lwipIfPort1.slvPortNum = 1; lwipIfPort1.ipAddr = 0; lwipIfPort1.netMask = 0; lwipIfPort1.gwAddr = 0; lwipIfPort1.ipMode = IPADDR_USE_DHCP; ipAddr = lwIPInit(&lwipIfPort1); #endif if(ipAddr) { ConsoleUtilsPrintf("\n\r\n\rPort 1 IP Address Assigned: "); IpAddrDisplay(ipAddr); } else { ConsoleUtilsPrintf("\n\r\n\rPort 1 IP Address Acquisition Failed."); } /* Initialize the sample httpd server. */ echo_init(); /* Loop forever. All the work is done in interrupt handlers. */ while(1) { ; /* Perform nothing */ } }
int main(int argc, char **argv) { struct netif netif; sigset_t mask, oldmask, empty; int ch; char ip_str[16] = {0}, nm_str[16] = {0}, gw_str[16] = {0}; /* startup defaults (may be overridden by one or more opts) */ IP4_ADDR(&gw, 192,168,0,1); IP4_ADDR(&ipaddr, 192,168,0,2); IP4_ADDR(&netmask, 255,255,255,0); trap_flag = 0; /* use debug flags defined by debug.h */ debug_flags = LWIP_DBG_OFF; while ((ch = getopt_long(argc, argv, "dhg:i:m:t:", longopts, NULL)) != -1) { switch (ch) { case 'd': debug_flags |= (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT); break; case 'h': usage(); exit(0); break; case 'g': ipaddr_aton(optarg, &gw); break; case 'i': ipaddr_aton(optarg, &ipaddr); break; case 'm': ipaddr_aton(optarg, &netmask); break; case 't': trap_flag = !0; /* @todo: remove this authentraps tweak when we have proper SET & non-volatile mem */ snmpauthentraps_set = 1; ipaddr_aton(optarg, &trap_addr); strncpy(ip_str, ipaddr_ntoa(&trap_addr),sizeof(ip_str)); printf("SNMP trap destination %s\n", ip_str); break; default: usage(); break; } } argc -= optind; argv += optind; strncpy(ip_str, ipaddr_ntoa(&ipaddr), sizeof(ip_str)); strncpy(nm_str, ipaddr_ntoa(&netmask), sizeof(nm_str)); strncpy(gw_str, ipaddr_ntoa(&gw), sizeof(gw_str)); printf("Host at %s mask %s gateway %s\n", ip_str, nm_str, gw_str); #ifdef PERF perf_init("/tmp/minimal.perf"); #endif /* PERF */ lwip_init(); printf("TCP/IP initialized.\n"); netif_add(&netif, &ipaddr, &netmask, &gw, NULL, mintapif_init, ethernet_input); netif_set_default(&netif); netif_set_up(&netif); #if SNMP_PRIVATE_MIB != 0 /* initialize our private example MIB */ lwip_privmib_init(); #endif snmp_trap_dst_ip_set(0,&trap_addr); snmp_trap_dst_enable(0,trap_flag); snmp_set_syscontact(syscontact_str,&syscontact_len); snmp_set_syslocation(syslocation_str,&syslocation_len); snmp_set_snmpenableauthentraps(&snmpauthentraps_set); snmp_init(); echo_init(); timer_init(); timer_set_interval(TIMER_EVT_ETHARPTMR, ARP_TMR_INTERVAL / 10); timer_set_interval(TIMER_EVT_TCPTMR, TCP_TMR_INTERVAL / 10); #if IP_REASSEMBLY timer_set_interval(TIMER_EVT_IPREASSTMR, IP_TMR_INTERVAL / 10); #endif printf("Applications started.\n"); while (1) { /* poll for input packet and ensure select() or read() arn't interrupted */ sigemptyset(&mask); sigaddset(&mask, SIGALRM); sigprocmask(SIG_BLOCK, &mask, &oldmask); /* start of critical section, poll netif, pass packet to lwIP */ if (mintapif_select(&netif) > 0) { /* work, immediatly end critical section hoping lwIP ended quickly ... */ sigprocmask(SIG_SETMASK, &oldmask, NULL); } else { /* no work, wait a little (10 msec) for SIGALRM */ sigemptyset(&empty); sigsuspend(&empty); /* ... end critical section */ sigprocmask(SIG_SETMASK, &oldmask, NULL); } if(timer_testclr_evt(TIMER_EVT_TCPTMR)) { tcp_tmr(); } #if IP_REASSEMBLY if(timer_testclr_evt(TIMER_EVT_IPREASSTMR)) { ip_reass_tmr(); } #endif if(timer_testclr_evt(TIMER_EVT_ETHARPTMR)) { etharp_tmr(); } } return 0; }