/** * Perform Sanity check of user-configurable values, and initialize all modules. */ void lwip_init(void) { /* Sanity check user-configurable values */ lwip_sanity_check(); /* Modules initialization */ stats_init(); #if !NO_SYS sys_init(); #endif /* !NO_SYS */ mem_init(); memp_init(); pbuf_init(); netif_init(); #if LWIP_SOCKET lwip_socket_init(); #endif /* LWIP_SOCKET */ ip_init(); #if LWIP_ARP etharp_init(); #endif /* LWIP_ARP */ #if LWIP_RAW raw_init(); #endif /* LWIP_RAW */ #if LWIP_UDP udp_init(); #endif /* LWIP_UDP */ #if LWIP_TCP tcp_init(); #endif /* LWIP_TCP */ #if LWIP_SNMP snmp_init(); #endif /* LWIP_SNMP */ #if LWIP_AUTOIP autoip_init(); #endif /* LWIP_AUTOIP */ #if LWIP_IGMP igmp_init(); #endif /* LWIP_IGMP */ #if LWIP_DNS dns_init(); #endif /* LWIP_DNS */ #if LWIP_TIMERS sys_timeouts_init(); #endif /* LWIP_TIMERS */ #if !NO_SYS /* in the Xilinx lwIP 1.2.0 port, lwip_init() was added as a convenience utility function to initialize all the lwIP layers. lwIP 1.3.0 introduced lwip_init() in the base lwIP itself. However a user cannot use lwip_init() regardless of whether it is raw or socket modes. The following call to lwip_sock_init() is made to make sure that lwIP is properly initialized in both raw & socket modes with just a call to lwip_init(). */ lwip_sock_init(); #endif }
/** * Perform Sanity check of user-configurable values, and initialize all modules. */ void lwip_init(void) { /*++ Changed by Espressif ++*/ MEMP_NUM_TCP_PCB = 5; TCP_WND = (4 * TCP_MSS); TCP_MAXRTX = 3; TCP_SYNMAXRTX = 6; /*-- --*/ /* Modules initialization */ stats_init(); #if !NO_SYS sys_init(); #endif /* !NO_SYS */ /*++ Changed by Espressif ++*/ #if 0 mem_init(&_bss_end); #endif /*-- --*/ memp_init(); pbuf_init(); netif_init(); #if LWIP_SOCKET lwip_socket_init(); #endif /* LWIP_SOCKET */ ip_init(); #if LWIP_ARP etharp_init(); #endif /* LWIP_ARP */ #if LWIP_RAW raw_init(); #endif /* LWIP_RAW */ #if LWIP_UDP udp_init(); #endif /* LWIP_UDP */ #if LWIP_TCP tcp_init(); #endif /* LWIP_TCP */ #if LWIP_SNMP snmp_init(); #endif /* LWIP_SNMP */ #if LWIP_AUTOIP autoip_init(); #endif /* LWIP_AUTOIP */ #if LWIP_IGMP igmp_init(); #endif /* LWIP_IGMP */ #if LWIP_DNS dns_init(); #endif /* LWIP_DNS */ #if LWIP_TIMERS sys_timeouts_init(); #endif /* LWIP_TIMERS */ }
int luaopen_net( lua_State *L ) { igmp_init(); luaL_rometatable(L, NET_TABLE_TCP_SERVER, (void *)net_tcpserver_map); luaL_rometatable(L, NET_TABLE_TCP_CLIENT, (void *)net_tcpsocket_map); luaL_rometatable(L, NET_TABLE_UDP_SOCKET, (void *)net_udpsocket_map); return 0; }
/** * Perform Sanity check of user-configurable values, and initialize all modules. */ void lwip_init(void) { esp_ms_timer_init(); // espressif /* Modules initialization */ stats_init(); #if !NO_SYS sys_init(); #endif /* !NO_SYS */ mem_init(); memp_init(); pbuf_init(); netif_init(); #if LWIP_IPV4 ip_init(); #if LWIP_ARP etharp_init(); #endif /* LWIP_ARP */ #endif /* LWIP_IPV4 */ #if LWIP_RAW raw_init(); #endif /* LWIP_RAW */ #if LWIP_UDP udp_init(); #endif /* LWIP_UDP */ #if LWIP_TCP tcp_init(); #endif /* LWIP_TCP */ #if LWIP_SNMP snmp_init(); #endif /* LWIP_SNMP */ #if LWIP_AUTOIP autoip_init(); #endif /* LWIP_AUTOIP */ #if LWIP_IGMP igmp_init(); #endif /* LWIP_IGMP */ #if LWIP_DNS dns_init(); #endif /* LWIP_DNS */ #if LWIP_IPV6 ip6_init(); nd6_init(); #if LWIP_IPV6_MLD mld6_init(); #endif /* LWIP_IPV6_MLD */ #endif /* LWIP_IPV6 */ #if PPP_SUPPORT ppp_init(); #endif #if LWIP_TIMERS sys_timeouts_init(); #endif /* LWIP_TIMERS */ }
/** * Perform Sanity check of user-configurable values, and initialize all modules. */ void ICACHE_FLASH_ATTR lwip_init(void) { /* Modules initialization */ stats_init(); #if !NO_SYS sys_init(); #endif /* !NO_SYS */ mem_init(); memp_init(); pbuf_init(); netif_init(); #if LWIP_SOCKET lwip_socket_init(); #endif /* LWIP_SOCKET */ ip_init(); #if LWIP_ARP etharp_init(); #endif /* LWIP_ARP */ #if LWIP_RAW raw_init(); #endif /* LWIP_RAW */ #if LWIP_UDP udp_init(); #endif /* LWIP_UDP */ #if LWIP_TCP tcp_init(); #endif /* LWIP_TCP */ #if LWIP_SNMP snmp_init(); #endif /* LWIP_SNMP */ #if LWIP_AUTOIP autoip_init(); #endif /* LWIP_AUTOIP */ #if LWIP_IGMP igmp_init(); #endif /* LWIP_IGMP */ #if LWIP_DNS dns_init(); #endif /* LWIP_DNS */ #if LWIP_IPV6 ip6_init(); nd6_init(); #if LWIP_IPV6_MLD mld6_init(); #endif /* LWIP_IPV6_MLD */ #endif /* LWIP_IPV6 */ #if LWIP_TIMERS sys_timeouts_init(); #endif /* LWIP_TIMERS */ }
void uip_server_init(chanend xtcp[], int num_xtcp, xtcp_ipconfig_t* ipconfig, unsigned char mac_address[6]) { if (ipconfig != NULL) memcpy(&uip_static_ipconfig, ipconfig, sizeof(xtcp_ipconfig_t)); memcpy(&uip_ethaddr, mac_address, 6); uip_init(); #if UIP_IGMP igmp_init(); #endif if (ipconfig != NULL && (*((int*)ipconfig->ipaddr) != 0)) { uip_static_ip = 1; } if (ipconfig == NULL) { uip_ipaddr_t ipaddr; uip_ipaddr(ipaddr, 0, 0, 0, 0); uip_sethostaddr(ipaddr); uip_setdraddr(ipaddr); uip_setnetmask(ipaddr); uip_setsubnetaddr(); } else { uip_sethostaddr(ipconfig->ipaddr); uip_setdraddr(ipconfig->gateway); uip_setnetmask(ipconfig->netmask); uip_setsubnetaddr(); #ifdef XTCP_VERBOSE_DEBUG printstr("Address: ");uip_printip4(uip_hostaddr);printstr("\n"); printstr("Gateway: ");uip_printip4(uip_draddr);printstr("\n"); printstr("Netmask: ");uip_printip4(uip_netmask);printstr("\n"); #endif } { #if UIP_USE_AUTOIP int hwsum = mac_address[0] + mac_address[1] + mac_address[2] + mac_address[3] + mac_address[4] + mac_address[5]; autoip_init(hwsum + (hwsum << 16) + (hwsum << 24)); #endif #if UIP_USE_DHCP dhcpc_init(uip_ethaddr.addr, 6); #endif xtcpd_init(xtcp, num_xtcp); } }
/** * Perform Sanity check of user-configurable values, and initialize all modules. */ void lwip_init(void) { /* Sanity check user-configurable values */ lwip_sanity_check(); /* Modules initialization */ stats_init(); #if !NO_SYS sys_init(); #endif /* !NO_SYS */ mem_init(); memp_init(); pbuf_init(); netif_init(); #if LWIP_SOCKET lwip_socket_init(); #endif /* LWIP_SOCKET */ ip_init(); #if LWIP_ARP etharp_init(); #endif /* LWIP_ARP */ #if LWIP_RAW raw_init(); #endif /* LWIP_RAW */ #if LWIP_UDP udp_init(); #endif /* LWIP_UDP */ #if LWIP_TCP tcp_init(); #endif /* LWIP_TCP */ #if LWIP_SNMP snmp_init(); #endif /* LWIP_SNMP */ #if LWIP_AUTOIP autoip_init(); #endif /* LWIP_AUTOIP */ #if LWIP_IGMP igmp_init(); #endif /* LWIP_IGMP */ #if LWIP_DNS dns_init(); #endif /* LWIP_DNS */ #if LWIP_TIMERS sys_timeouts_init(); #endif /* LWIP_TIMERS */ }
/** * Perform Sanity check of user-configurable values, and initialize all modules. */ void lwip_init(void) { lwip_init_globals(); /* Sanity check user-configurable values */ lwip_sanity_check(); /* Modules initialization */ stats_init(); sys_init(); mem_init(); memp_init(); pbuf_init(); netif_init(); #if LWIP_SOCKET lwip_socket_init(); #endif /* LWIP_SOCKET */ ip_init(); #if LWIP_ARP etharp_init(); #endif /* LWIP_ARP */ #if LWIP_RAW raw_init(); #endif /* LWIP_RAW */ #if LWIP_UDP udp_init(); #endif /* LWIP_UDP */ #if LWIP_TCP /* Initialize the network stack */ // [MS_CHANGE] - tcpip_init() is a no-op. This method actually initializes the tcpip stack. tcpip_init(NULL,NULL); #endif /* LWIP_TCP */ #if LWIP_SNMP snmp_init(); #endif /* LWIP_SNMP */ #if LWIP_AUTOIP autoip_init(); #endif /* LWIP_AUTOIP */ #if LWIP_IGMP igmp_init(); #endif /* LWIP_IGMP */ #if LWIP_DNS dns_init(); #endif /* LWIP_DNS */ }
static void remaining_lwip_initialization(char *card_name, uint64_t queueid) { nb = netbench_alloc("app", RECORDED_EVENTS_COUNT); //asq: connect to the NIC driver, before doing anything else idc_connect_to_driver(card_name, queueid); DEBUGPRINTPS("Connected to driver [%s]\n", card_name); stats_init(); sys_init(); DEBUGPRINTPS("remaining_lwip_init: allocating pbuf memory\n"); #ifdef CONFIG_QEMU_NETWORK printf("#### Networking with small amount of memory #####\n"); #endif // CONFIG_QEMU_NETWORK printf("#### [%u:%"PRIuDOMAINID":%s] [%s] [%d] MEM_SIZE[%d], " "PBUF_POOL_SIZE[%d], MEMP_MAX[%d], RECEIVE_BUFFERS[%d] qid[%"PRIu64"]####\n", disp_get_core_id(), disp_get_domain_id(), disp_name(), MEM_CONF_LOC, is_ctl, MEM_SIZE, PBUF_POOL_SIZE, MEMP_MAX, RECEIVE_BUFFERS, queueid); memp_init(); // 0'st buffer DEBUGPRINTPS("remaining_lwip_init: allocating memory for sending\n"); mem_init(); // 1'th buffer DEBUGPRINTPS("remaining_lwip_init: done with memroy allocation\n"); DEBUGPRINTPS("LWIP: lwip_starting\n"); netif_init(); #if LWIP_SOCKET lwip_socket_init(); #endif /* LWIP_SOCKET */ ip_init(); DEBUGPRINTPS("r_lwip_init: done ip_init\n"); #if LWIP_ARP etharp_init(); #endif /* LWIP_ARP */ #if LWIP_RAW raw_init(); #endif /* LWIP_RAW */ #if LWIP_UDP udp_init(); DEBUGPRINTPS("r_lwip_init: done udp_init\n"); #endif /* LWIP_UDP */ #if LWIP_TCP tcp_init(); DEBUGPRINTPS("r_lwip_init: done tcp_init\n"); #endif /* LWIP_TCP */ #if LWIP_SNMP snmp_init(); DEBUGPRINTPS("r_lwip_init: done snmp_init\n"); #endif /* LWIP_SNMP */ #if LWIP_AUTOIP autoip_init(); DEBUGPRINTPS("r_lwip_init: done autoip_init\n"); #endif /* LWIP_AUTOIP */ #if LWIP_IGMP igmp_init(); DEBUGPRINTPS("r_lwip_init: done igmp_init\n"); #endif /* LWIP_IGMP */ DEBUGPRINTPS("r_lwip_init: done2 igmp_init\n"); #if LWIP_DNS DEBUGPRINTPS("r_lwip_init: starting DNS_init\n"); dns_init(); DEBUGPRINTPS("r_lwip_init: done DNS_init\n"); #endif /* LWIP_DNS */ DEBUGPRINTPS("LWIP: lwip_started\n"); }
PACK_STRUCT_END #ifdef PACK_STRUCT_USE_INCLUDES # include "arch/epstruct.h" #endif #define PACKED_STRUCT_TEST_EXPECTED_SIZE 5 #endif /* Compile-time sanity checks for configuration errors. * These can be done independently of LWIP_DEBUG, without penalty. */ #ifndef BYTE_ORDER #error "BYTE_ORDER is not defined, you have to define it in your cc.h" #endif #if (!IP_SOF_BROADCAST && IP_SOF_BROADCAST_RECV) #error "If you want to use broadcast filter per pcb on recv operations, you have to define IP_SOF_BROADCAST=1 in your lwipopts.h" #endif #if (!LWIP_UDP && LWIP_UDPLITE) #error "If you want to use UDP Lite, you have to define LWIP_UDP=1 in your lwipopts.h" #endif #if (!LWIP_UDP && LWIP_DHCP) #error "If you want to use DHCP, you have to define LWIP_UDP=1 in your lwipopts.h" #endif #if (!LWIP_UDP && LWIP_MULTICAST_TX_OPTIONS) #error "If you want to use IGMP/LWIP_MULTICAST_TX_OPTIONS, you have to define LWIP_UDP=1 in your lwipopts.h" #endif #if (!LWIP_UDP && LWIP_DNS) #error "If you want to use DNS, you have to define LWIP_UDP=1 in your lwipopts.h" #endif #if !MEMP_MEM_MALLOC /* MEMP_NUM_* checks are disabled when not using the pool allocator */ #if (LWIP_ARP && ARP_QUEUEING && (MEMP_NUM_ARP_QUEUE<=0)) #error "If you want to use ARP Queueing, you have to define MEMP_NUM_ARP_QUEUE>=1 in your lwipopts.h" #endif #if (LWIP_RAW && (MEMP_NUM_RAW_PCB<=0)) #error "If you want to use RAW, you have to define MEMP_NUM_RAW_PCB>=1 in your lwipopts.h" #endif #if (LWIP_UDP && (MEMP_NUM_UDP_PCB<=0)) #error "If you want to use UDP, you have to define MEMP_NUM_UDP_PCB>=1 in your lwipopts.h" #endif #if (LWIP_TCP && (MEMP_NUM_TCP_PCB<=0)) #error "If you want to use TCP, you have to define MEMP_NUM_TCP_PCB>=1 in your lwipopts.h" #endif #if (LWIP_IGMP && (MEMP_NUM_IGMP_GROUP<=1)) #error "If you want to use IGMP, you have to define MEMP_NUM_IGMP_GROUP>1 in your lwipopts.h" #endif #if (LWIP_IGMP && !LWIP_MULTICAST_TX_OPTIONS) #error "If you want to use IGMP, you have to define LWIP_MULTICAST_TX_OPTIONS==1 in your lwipopts.h" #endif #if (LWIP_IGMP && !LWIP_IPV4) #error "IGMP needs LWIP_IPV4 enabled in your lwipopts.h" #endif #if (LWIP_MULTICAST_TX_OPTIONS && !LWIP_IPV4) #error "LWIP_MULTICAST_TX_OPTIONS needs LWIP_IPV4 enabled in your lwipopts.h" #endif #if ((LWIP_NETCONN || LWIP_SOCKET) && (MEMP_NUM_TCPIP_MSG_API<=0)) #error "If you want to use Sequential API, you have to define MEMP_NUM_TCPIP_MSG_API>=1 in your lwipopts.h" #endif /* There must be sufficient timeouts, taking into account requirements of the subsystems. */ #if LWIP_TIMERS && (MEMP_NUM_SYS_TIMEOUT < (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_SUPPORT + (LWIP_IPV6 ? (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD) : 0))) #error "MEMP_NUM_SYS_TIMEOUT is too low to accomodate all required timeouts" #endif #if (IP_REASSEMBLY && (MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS)) #error "MEMP_NUM_REASSDATA > IP_REASS_MAX_PBUFS doesn't make sense since each struct ip_reassdata must hold 2 pbufs at least!" #endif #endif /* !MEMP_MEM_MALLOC */ #if LWIP_WND_SCALE #if (LWIP_TCP && (TCP_WND > 0xffffffff)) #error "If you want to use TCP, TCP_WND must fit in an u32_t, so, you have to reduce it in your lwipopts.h" #endif #if (LWIP_TCP && LWIP_WND_SCALE && (TCP_RCV_SCALE > 14)) #error "The maximum valid window scale value is 14!" #endif #if (LWIP_TCP && (TCP_WND > (0xFFFFU << TCP_RCV_SCALE))) #error "TCP_WND is bigger than the configured LWIP_WND_SCALE allows!" #endif #if (LWIP_TCP && ((TCP_WND >> TCP_RCV_SCALE) == 0)) #error "TCP_WND is too small for the configured LWIP_WND_SCALE (results in zero window)!" #endif #else /* LWIP_WND_SCALE */ #if (LWIP_TCP && (TCP_WND > 0xffff)) #error "If you want to use TCP, TCP_WND must fit in an u16_t, so, you have to reduce it in your lwipopts.h (or enable window scaling)" #endif #endif /* LWIP_WND_SCALE */ #if (LWIP_TCP && (TCP_SND_QUEUELEN > 0xffff)) #error "If you want to use TCP, TCP_SND_QUEUELEN must fit in an u16_t, so, you have to reduce it in your lwipopts.h" #endif #if (LWIP_TCP && (TCP_SND_QUEUELEN < 2)) #error "TCP_SND_QUEUELEN must be at least 2 for no-copy TCP writes to work" #endif #if (LWIP_TCP && ((TCP_MAXRTX > 12) || (TCP_SYNMAXRTX > 12))) #error "If you want to use TCP, TCP_MAXRTX and TCP_SYNMAXRTX must less or equal to 12 (due to tcp_backoff table), so, you have to reduce them in your lwipopts.h" #endif #if (LWIP_TCP && TCP_LISTEN_BACKLOG && ((TCP_DEFAULT_LISTEN_BACKLOG < 0) || (TCP_DEFAULT_LISTEN_BACKLOG > 0xff))) #error "If you want to use TCP backlog, TCP_DEFAULT_LISTEN_BACKLOG must fit into an u8_t" #endif #if (LWIP_NETIF_API && (NO_SYS==1)) #error "If you want to use NETIF API, you have to define NO_SYS=0 in your lwipopts.h" #endif #if ((LWIP_SOCKET || LWIP_NETCONN) && (NO_SYS==1)) #error "If you want to use Sequential API, you have to define NO_SYS=0 in your lwipopts.h" #endif #if (LWIP_PPP_API && (NO_SYS==1)) #error "If you want to use PPP API, you have to define NO_SYS=0 in your lwipopts.h" #endif #if (LWIP_PPP_API && (PPP_SUPPORT==0)) #error "If you want to use PPP API, you have to enable PPP_SUPPORT in your lwipopts.h" #endif #if (((!LWIP_DHCP) || (!LWIP_AUTOIP)) && LWIP_DHCP_AUTOIP_COOP) #error "If you want to use DHCP/AUTOIP cooperation mode, you have to define LWIP_DHCP=1 and LWIP_AUTOIP=1 in your lwipopts.h" #endif #if (((!LWIP_DHCP) || (!LWIP_ARP)) && DHCP_DOES_ARP_CHECK) #error "If you want to use DHCP ARP checking, you have to define LWIP_DHCP=1 and LWIP_ARP=1 in your lwipopts.h" #endif #if (!LWIP_ARP && LWIP_AUTOIP) #error "If you want to use AUTOIP, you have to define LWIP_ARP=1 in your lwipopts.h" #endif #if (LWIP_TCP && ((LWIP_EVENT_API && LWIP_CALLBACK_API) || (!LWIP_EVENT_API && !LWIP_CALLBACK_API))) #error "One and exactly one of LWIP_EVENT_API and LWIP_CALLBACK_API has to be enabled in your lwipopts.h" #endif #if (MEM_LIBC_MALLOC && MEM_USE_POOLS) #error "MEM_LIBC_MALLOC and MEM_USE_POOLS may not both be simultaneously enabled in your lwipopts.h" #endif #if (MEM_USE_POOLS && !MEMP_USE_CUSTOM_POOLS) #error "MEM_USE_POOLS requires custom pools (MEMP_USE_CUSTOM_POOLS) to be enabled in your lwipopts.h" #endif #if (PBUF_POOL_BUFSIZE <= MEM_ALIGNMENT) #error "PBUF_POOL_BUFSIZE must be greater than MEM_ALIGNMENT or the offset may take the full first pbuf" #endif #if (DNS_LOCAL_HOSTLIST && !DNS_LOCAL_HOSTLIST_IS_DYNAMIC && !(defined(DNS_LOCAL_HOSTLIST_INIT))) #error "you have to define define DNS_LOCAL_HOSTLIST_INIT {{'host1', 0x123}, {'host2', 0x234}} to initialize DNS_LOCAL_HOSTLIST" #endif #if PPP_SUPPORT && !PPPOS_SUPPORT && !PPPOE_SUPPORT && !PPPOL2TP_SUPPORT #error "PPP_SUPPORT needs at least one of PPPOS_SUPPORT, PPPOE_SUPPORT or PPPOL2TP_SUPPORT turned on" #endif #if PPP_SUPPORT && !PPP_IPV4_SUPPORT && !PPP_IPV6_SUPPORT #error "PPP_SUPPORT needs PPP_IPV4_SUPPORT and/or PPP_IPV6_SUPPORT turned on" #endif #if PPP_SUPPORT && PPP_IPV4_SUPPORT && !LWIP_IPV4 #error "PPP_IPV4_SUPPORT needs LWIP_IPV4 turned on" #endif #if PPP_SUPPORT && PPP_IPV6_SUPPORT && !LWIP_IPV6 #error "PPP_IPV6_SUPPORT needs LWIP_IPV6 turned on" #endif #if !LWIP_ETHERNET && (LWIP_ARP || PPPOE_SUPPORT) #error "LWIP_ETHERNET needs to be turned on for LWIP_ARP or PPPOE_SUPPORT" #endif #if (LWIP_IGMP || LWIP_IPV6) && !defined(LWIP_RAND) #error "When using IGMP or IPv6, LWIP_RAND() needs to be defined to a random-function returning an u32_t random value (in arch/cc.h)" #endif #if LWIP_TCPIP_CORE_LOCKING_INPUT && !LWIP_TCPIP_CORE_LOCKING #error "When using LWIP_TCPIP_CORE_LOCKING_INPUT, LWIP_TCPIP_CORE_LOCKING must be enabled, too" #endif #if LWIP_TCP && LWIP_NETIF_TX_SINGLE_PBUF && !TCP_OVERSIZE #error "LWIP_NETIF_TX_SINGLE_PBUF needs TCP_OVERSIZE enabled to create single-pbuf TCP packets" #endif #if LWIP_NETCONN && LWIP_TCP #if NETCONN_COPY != TCP_WRITE_FLAG_COPY #error "NETCONN_COPY != TCP_WRITE_FLAG_COPY" #endif #if NETCONN_MORE != TCP_WRITE_FLAG_MORE #error "NETCONN_MORE != TCP_WRITE_FLAG_MORE" #endif #endif /* LWIP_NETCONN && LWIP_TCP */ #if LWIP_SOCKET /* Check that the SO_* socket options and SOF_* lwIP-internal flags match */ #if SO_REUSEADDR != SOF_REUSEADDR #error "WARNING: SO_REUSEADDR != SOF_REUSEADDR" #endif #if SO_KEEPALIVE != SOF_KEEPALIVE #error "WARNING: SO_KEEPALIVE != SOF_KEEPALIVE" #endif #if SO_BROADCAST != SOF_BROADCAST #error "WARNING: SO_BROADCAST != SOF_BROADCAST" #endif #endif /* LWIP_SOCKET */ /* Compile-time checks for deprecated options. */ #ifdef MEMP_NUM_TCPIP_MSG #error "MEMP_NUM_TCPIP_MSG option is deprecated. Remove it from your lwipopts.h." #endif #ifdef TCP_REXMIT_DEBUG #error "TCP_REXMIT_DEBUG option is deprecated. Remove it from your lwipopts.h." #endif #ifdef RAW_STATS #error "RAW_STATS option is deprecated. Remove it from your lwipopts.h." #endif #ifdef ETHARP_QUEUE_FIRST #error "ETHARP_QUEUE_FIRST option is deprecated. Remove it from your lwipopts.h." #endif #ifdef ETHARP_ALWAYS_INSERT #error "ETHARP_ALWAYS_INSERT option is deprecated. Remove it from your lwipopts.h." #endif #if !NO_SYS && LWIP_TCPIP_CORE_LOCKING && LWIP_COMPAT_MUTEX && !defined(LWIP_COMPAT_MUTEX_ALLOWED) #error "LWIP_COMPAT_MUTEX cannot prevent priority inversion. It is recommended to implement priority-aware mutexes. (Define LWIP_COMPAT_MUTEX_ALLOWED to disable this error.)" #endif #ifndef LWIP_DISABLE_TCP_SANITY_CHECKS #define LWIP_DISABLE_TCP_SANITY_CHECKS 0 #endif #ifndef LWIP_DISABLE_MEMP_SANITY_CHECKS #define LWIP_DISABLE_MEMP_SANITY_CHECKS 0 #endif /* MEMP sanity checks */ #if MEMP_MEM_MALLOC #if !LWIP_DISABLE_MEMP_SANITY_CHECKS #if LWIP_NETCONN || LWIP_SOCKET #if !MEMP_NUM_NETCONN && LWIP_SOCKET #error "lwip_sanity_check: WARNING: MEMP_NUM_NETCONN cannot be 0 when using sockets!" #endif #else /* MEMP_MEM_MALLOC */ #if MEMP_NUM_NETCONN > (MEMP_NUM_TCP_PCB+MEMP_NUM_TCP_PCB_LISTEN+MEMP_NUM_UDP_PCB+MEMP_NUM_RAW_PCB) #error "lwip_sanity_check: WARNING: MEMP_NUM_NETCONN should be less than the sum of MEMP_NUM_{TCP,RAW,UDP}_PCB+MEMP_NUM_TCP_PCB_LISTEN. If you know what you are doing, define LWIP_DISABLE_MEMP_SANITY_CHECKS to 1 to disable this error." #endif #endif /* LWIP_NETCONN || LWIP_SOCKET */ #endif /* !LWIP_DISABLE_MEMP_SANITY_CHECKS */ #if MEM_USE_POOLS #error "MEMP_MEM_MALLOC and MEM_USE_POOLS cannot be enabled at the same time" #endif #ifdef LWIP_HOOK_MEMP_AVAILABLE #error "LWIP_HOOK_MEMP_AVAILABLE doesn't make sense with MEMP_MEM_MALLOC" #endif #endif /* MEMP_MEM_MALLOC */ /* TCP sanity checks */ #if !LWIP_DISABLE_TCP_SANITY_CHECKS #if LWIP_TCP #if !MEMP_MEM_MALLOC && (MEMP_NUM_TCP_SEG < TCP_SND_QUEUELEN) #error "lwip_sanity_check: WARNING: MEMP_NUM_TCP_SEG should be at least as big as TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #endif #if TCP_SND_BUF < (2 * TCP_MSS) #error "lwip_sanity_check: WARNING: TCP_SND_BUF must be at least as much as (2 * TCP_MSS) for things to work smoothly. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #endif #if TCP_SND_QUEUELEN < (2 * (TCP_SND_BUF / TCP_MSS)) #error "lwip_sanity_check: WARNING: TCP_SND_QUEUELEN must be at least as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #endif #if TCP_SNDLOWAT >= TCP_SND_BUF #error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must be less than TCP_SND_BUF. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #endif #if TCP_SNDLOWAT >= (0xFFFF - (4 * TCP_MSS)) #error "lwip_sanity_check: WARNING: TCP_SNDLOWAT must at least be 4*MSS below u16_t overflow!" #endif #if TCP_SNDQUEUELOWAT >= TCP_SND_QUEUELEN #error "lwip_sanity_check: WARNING: TCP_SNDQUEUELOWAT must be less than TCP_SND_QUEUELEN. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #endif #if !MEMP_MEM_MALLOC && PBUF_POOL_SIZE && (PBUF_POOL_BUFSIZE <= (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)) #error "lwip_sanity_check: WARNING: PBUF_POOL_BUFSIZE does not provide enough space for protocol headers. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #endif #if !MEMP_MEM_MALLOC && PBUF_POOL_SIZE && (TCP_WND > (PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - (PBUF_LINK_ENCAPSULATION_HLEN + PBUF_LINK_HLEN + PBUF_IP_HLEN + PBUF_TRANSPORT_HLEN)))) #error "lwip_sanity_check: WARNING: TCP_WND is larger than space provided by PBUF_POOL_SIZE * (PBUF_POOL_BUFSIZE - protocol headers). If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #endif #if TCP_WND < TCP_MSS #error "lwip_sanity_check: WARNING: TCP_WND is smaller than MSS. If you know what you are doing, define LWIP_DISABLE_TCP_SANITY_CHECKS to 1 to disable this error." #endif #endif /* LWIP_TCP */ #endif /* !LWIP_DISABLE_TCP_SANITY_CHECKS */ /** * @ingroup lwip_nosys * Initialize all modules. * Use this in NO_SYS mode. Use tcpip_init() otherwise. */ void lwip_init(void) { #ifndef LWIP_SKIP_PACKING_CHECK LWIP_ASSERT("Struct packing not implemented correctly. Check your lwIP port.", sizeof(struct packed_struct_test) == PACKED_STRUCT_TEST_EXPECTED_SIZE); #endif /* Modules initialization */ stats_init(); #if !NO_SYS sys_init(); #endif /* !NO_SYS */ mem_init(); memp_init(); pbuf_init(); netif_init(); #if LWIP_IPV4 ip_init(); #if LWIP_ARP etharp_init(); #endif /* LWIP_ARP */ #endif /* LWIP_IPV4 */ #if LWIP_RAW raw_init(); #endif /* LWIP_RAW */ #if LWIP_UDP udp_init(); #endif /* LWIP_UDP */ #if LWIP_TCP tcp_init(); #endif /* LWIP_TCP */ #if LWIP_IGMP igmp_init(); #endif /* LWIP_IGMP */ #if LWIP_DNS dns_init(); #endif /* LWIP_DNS */ #if PPP_SUPPORT ppp_init(); #endif #if LWIP_TIMERS sys_timeouts_init(); #endif /* LWIP_TIMERS */ }
void lwip_init(u8_t* lwip_memory){ sys_sem_t sem; extern u8_t** ADI_TOOLS_ram_ptr; extern u32_t ADI_TOOLS_ram_len; extern u8_t** ADI_TOOLS_memp_ptr; extern u32_t ADI_TOOLS_memp_len; extern u8_t** ADI_TOOLS_pbuf_pool_ptr; extern u32_t ADI_TOOLS_pbuf_pool_len; // caller must ensure that the area of memory supplied as 'lwip_memory' // is at least as long as the sum of the 'len' values *ADI_TOOLS_ram_ptr = lwip_memory; *ADI_TOOLS_memp_ptr = lwip_memory + ADI_TOOLS_ram_len; stats_init(); sys_init(); mem_init(); memp_init(); pbuf_init(); netif_init(); sys_sem_new(&sem,0); tcpip_init(tcpip_init_done, &sem); sys_sem_wait(&sem); sys_sem_free(&sem); #if LWIP_SOCKET lwip_socket_init(); #endif /* LWIP_SOCKET */ ip_init(); #if LWIP_ARP etharp_init(); #endif /* LWIP_ARP */ #if LWIP_RAW raw_init(); #endif /* LWIP_RAW */ #if LWIP_UDP udp_init(); #endif /* LWIP_UDP */ #if LWIP_TCP //tcp_init(); #endif /* LWIP_TCP */ #if LWIP_AUTOIP autoip_init(); #endif /* LWIP_AUTOIP */ #if LWIP_IGMP igmp_init(); #endif /* LWIP_IGMP */ #if LWIP_DNS dns_init(); #endif /* LWIP_DNS */ }
/* 考虑到升级是个非常重要但又较少依赖其他模块的功能,因此即使大部分模块初始化失败,也一样要继续运行,只要组播功能正常即可。 */ void *main_thread() { DEBUG("main thread start...\n"); compile_timeprint(); _wLBM_zyzdmb(13578642); smarthome_gw_sn_init(); if(-1==setting_init()){ DEBUG("setting init failed\n"); //return NULL; } if(-1==push_decoder_buf_init()){ DEBUG("push decoder buf init failed\n"); //return NULL; } chanFilterInit(); smc_init(); if(-1==sqlite_init()){ DEBUG("sqlite init failed\n"); //return NULL; } setting_init_with_database(); maintenance_thread_init(); if(-1==xmlparser_init()){ DEBUG("xmlparser init failed\n"); //return NULL; } // return parse_xml("pushroot/pushinfo/1/ProductDesc.xml", PRODUCTDESC_XML, NULL); if(0!=drm_init()){ DEBUG("drm init failed\n"); //return NULL; } upgrade_info_init(); // 根据首次开机标记"/data/data/com.dbstar/files/flag"决定是否要重置国电网关序列号 smarthome_sn_init_when_network_init(); #if 0 /* 慎用:只有在需要清理已有授权、重新接收授权时使用,正式版本不能调用。 */ DEBUG("\n\nWarning: you call function CDCASTB_FormatBuffer, it is an unnormal action\n\n\n"); CDCASTB_FormatBuffer(); #endif if(-1==mid_push_init(PUSH_CONF)){ DEBUG("push model init with \"%s\" failed\n", PUSH_CONF); //return NULL; } if(-1==igmp_init()){ DEBUG("igmp init failed\n"); //return NULL; } if(-1==softdvb_init()){ DEBUG("dvb init with failed\n"); //return NULL; } smartlife_connect_init(); DEBUG("OK ================================ OK\n"); msg_send2_UI(STATUS_DVBPUSH_INIT_SUCCESS, NULL, 0); int main_running = 1; while(1==main_running) { pthread_mutex_lock(&mtx_main); /* 需要本线程先运行到这里,再在其他非父线程中执行pthread_cond_signal(&cond_push_monitor)才能生效。 */ pthread_cond_wait(&cond_main,&mtx_main); DEBUG("main thread is closed by external call\n"); main_running = 0; pthread_mutex_unlock(&mtx_main); } DEBUG("exit from main thread\n"); return NULL; }
/* ----------------------------------------------------------------------------- * Initialise the uip_server * -------------------------------------------------------------------------- */ void uip_server_init(chanend xtcp[], int num_xtcp, xtcp_ipconfig_t *ipconfig, unsigned char *mac_address) { if (ipconfig != NULL) memcpy(&uip_static_ipconfig, ipconfig, sizeof(xtcp_ipconfig_t)); /* set the mac_adress */ memcpy(&uip_lladdr, mac_address, 6); #if 0 //XXX CHSC: not necessary? Be carefully with erasing the mac address... /* The following line sets the uIP's link-layer address. This must be done * before the tcpip_process is started since in its initialisation * routine the function uip_netif_init() will be called from inside * uip_init()and there the default IPv6 address will be set by combining * the link local prefix (fe80::/64)and the link layer address. */ rimeaddr_copy((rimeaddr_t*) &uip_lladdr.addr, &rimeaddr_node_addr); #endif //TODO chsc: port the rtimer module (if really needed) // /* rtimers needed for radio cycling */ // rtimer_init(); /* Initialise the process module */ process_init(); /* etimers must be started before ctimer_init */ process_start(&etimer_process, NULL); ctimer_init(); /* this calls have to be made before the uip_init * not exactely proved why. CHSC * */ etimer_request_poll(); process_run(); uip_init(); #if UIP_CONF_IPV6 && UIP_CONF_IPV6_RPL rpl_init(); #endif /* UIP_CONF_IPV6_RPL */ #if UIP_IGMP igmp_init(); #endif /* UIP_IGMP */ if (ipconfig != NULL && (*((int*)ipconfig->ipaddr.u8) != 0)) { uip_static_ip = 1; } if (ipconfig == NULL) { uip_ipaddr_t ipaddr; #if UIP_CONF_IPV4 uip_ipaddr(&ipaddr, 0, 0, 0, 0); uip_sethostaddr(&ipaddr); uip_setdraddr(&ipaddr); uip_setnetmask(&ipaddr); #elif UIP_CONF_IPV6 uip_ip6addr(&ipaddr, 0, 0, 0, 0 , 0, 0, 0, 0); #endif /* UIP_CONF_IPVx */ } else { #if UIP_CONF_IPV4 uip_sethostaddr(&ipconfig->ipaddr); uip_setdraddr(&ipconfig->gateway); uip_setnetmask(&ipconfig->netmask); #ifdef XTCP_VERBOSE_DEBUG printf("Address: ");uip_printip4(uip_hostaddr);printf("\n"); printf("Gateway: ");uip_printip4(uip_draddr);printf("\n"); printf("Netmask: ");uip_printip4(uip_netmask);printf("\n"); #endif /* XTCP_VERBOSE_DEBUG */ #elif UIP_CONF_IPV6 #endif /* UIP_CONF_IPVx */ } #if UIP_CONF_IPV4 { #if UIP_USE_AUTOIP int hwsum = mac_address[0] + mac_address[1] + mac_address[2] + mac_address[3] + mac_address[4] + mac_address[5]; autoip_init(hwsum + (hwsum << 16) + (hwsum << 24)); #endif #if UIP_USE_DHCP dhcpc_init(uip_lladdr.addr, 6); #endif } #endif /* UIP_CONF_IPV4 */ xtcpd_init(xtcp, num_xtcp); }