示例#1
0
文件: main.c 项目: Masa55/BT_DROID
void bt_init ( void )
{
	sys_init();
	mem_init();
	memp_init();
	pbuf_init();
	UART2PrintString("mem mgmt initialized\r\n");
	lwbt_memp_init();

	phybusif_init("");

	cb = malloc(sizeof(struct phybusif_cb));
	phybusif_reset(cb);

	if(hci_init() != ERR_OK) {
		UART2PrintString("HCI initialization failed!\r\n");
		return;
	}
	l2cap_init();
	sdp_init();
	rfcomm_init();
	UART2PrintString("Bluetooth initialized.\r\n");

	bt_spp_start();
	UART2PrintString("Applications started.\r\n");
}
示例#2
0
void rest_sys_mem(void)
{
    mem_init();
    /* Initializes the memory pools defined by MEMP_NUM_x.*/
    memp_init();    
    pbuf_init();	
}
示例#3
0
文件: init.c 项目: GiannisRambo/lwip
/**
 * 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
}
示例#4
0
文件: init.c 项目: sdelavega/smart.js
/**
 * 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 */
}
示例#5
0
文件: network.c 项目: CJP1973/xell
void network_init()
{
	struct ip_addr ipaddr, netmask, gw;

	printf("trying to initialize network...\n");

#ifdef STATS
	stats_init();
#endif /* STATS */

	mem_init();
	memp_init();
	pbuf_init(); 
	netif_init();
	ip_init();
	udp_init();
	tcp_init();
	etharp_init();
	printf("ok now the NIC\n");
	
	if (!netif_add(&netif, &ipaddr, &netmask, &gw, NULL, enet_init, ip_input))
	{
		printf("netif_add failed!\n");
		return;
	}
	
	netif_set_default(&netif);
	
	dhcp_start(&netif);
	
	mftb(&last_tcp);
	mftb(&last_dhcp);
	
	printf("\nWaiting for DHCP");

	int i;	
	for (i=0; i<10; i++) {
		mdelay(500);
		network_poll();
		
		printf(".");
		
		if (netif.ip_addr.addr)
			break;
	}
	
	if (netif.ip_addr.addr) {
		printf("%u.%u.%u.%u\n",	
			(netif.ip_addr.addr >> 24) & 0xFF,
			(netif.ip_addr.addr >> 16) & 0xFF,
			(netif.ip_addr.addr >>  8) & 0xFF,
			(netif.ip_addr.addr >>  0) & 0xFF);
			
		printf("\n");
	} else {
示例#6
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 */
}
示例#7
0
static int sr_lwip_transport_startup(void)
{
    sys_init();
    mem_init();
    memp_init();
    pbuf_init();

    transport_subsys_init(0, 0);

    return 0;
} /* -- sr_lwip_transport_startup -- */
示例#8
0
文件: BasicWEB.c 项目: Eclo/FreeRTOS
void vlwIPInit( void )
{
    /* Initialize lwIP and its interface layer. */
	sys_init();
	mem_init();
	memp_init();
	pbuf_init();
	netif_init();
	ip_init();
	tcpip_init( NULL, NULL );
}
示例#9
0
文件: network.c 项目: gz/aos10
void
network_init(void)
{
    printf("\nStarting %s\n", __FUNCTION__);

    // Initialise the nslu2 hardware
    ixOsalOemInit(); 

    /* Initialise lwIP */
    mem_init();
    memp_init();
    pbuf_init();
    netif_init();
    udp_init();
    etharp_init();

    /* Setup the network interface */
    struct ip_addr netmask, ipaddr, gw;
    IP4_ADDR(&netmask, 255, 255, 255, 0);	// Standard net mask
    IP4_ADDR(&gw,      192, 168, 0, 1);		// Your host system
    IP4_ADDR(&ipaddr,  192, 168, 0, 2);		// The Slug's IP address

    struct netif *netif = netif_add(&ipaddr,&netmask,&gw, sosIfInit, ip_input);
    netif_set_default(netif);

    // Generate an arp entry for our gateway
    // We should only need to do this once, but Linux seems to love ignoring
    // ARP queries (why??!), so we keep trying until we get a response
    struct pbuf *p = etharp_query(netif, &netif->gw, NULL);
    do {
        (*netif_default->linkoutput)(netif, p);	// Direct output
        sos_usleep(100000);	// Wait a while for a reply
    } while (!etharp_entry_present(&netif->gw));
    pbuf_free(p);

    // Finish the initialisation of the nslu2 hardware
    ixOsalOSServicesFinaliseInit();


    /* Initialise NFS */
    int r = nfs_init(gw); assert(!r);

    mnt_get_export_list();	// Print out the exports on this server

    const char *msg;
    if (mnt_mount(NFS_DIR, &mnt_point))		// Mount aos_nfs
	msg = "%s: Error mounting path '%s'!\n";
    else
	msg = "Successfully mounted '%s'\n";
    printf(msg, __FUNCTION__, NFS_DIR);

    printf("Finished %s\n\n", __FUNCTION__);
}
示例#10
0
/**
 * 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 */
}
示例#11
0
void vlwIPInit( void )
{
    /* Initialize lwIP and its interface layer. */
	sys_init();
	mem_init();								
	memp_init();
	pbuf_init();
	netif_init();
	ip_init();
	sys_set_state(( signed char * ) "lwIP", lwipTCP_STACK_SIZE);
	tcpip_init( NULL, NULL );	
	sys_set_default_state();
}
示例#12
0
文件: main.c 项目: 1573472562/netfpga
int main(int argc,char **argv)
{
    sys_init();
    mem_init();
    memp_init();
    pbuf_init();


    sys_thread_new((void *)(main_thread), NULL);
    pause();

    return 0;
}
示例#13
0
int csp_can_init(uint8_t mode, struct csp_can_config *conf) {

	int ret;
	uint32_t mask;

	/* Initialize packet buffer */
	if (pbuf_init() != 0) {
		csp_log_error("Failed to initialize CAN packet buffers\r\n");
		return CSP_ERR_NOMEM;
	}

	/* Initialize CFP identifier */
	if (id_init() != 0) {
		csp_log_error("Failed to initialize CAN identification number\r\n");
		return CSP_ERR_NOMEM;
	}

	if (mode == CSP_CAN_MASKED) {
		mask = CFP_MAKE_DST((1 << CFP_HOST_SIZE) - 1);
	} else if (mode == CSP_CAN_PROMISC) {
		mask = 0;
		csp_if_can.promisc = 1;
	} else {
		csp_log_error("Unknown CAN mode\r\n");
		return CSP_ERR_INVAL;
	}

	can_rx_queue = csp_queue_create(CSP_CAN_RX_QUEUE_SIZE, sizeof(can_frame_t));
	if (can_rx_queue == NULL) {
		csp_log_error("Failed to create CAN RX queue\r\n");
		return CSP_ERR_NOMEM;
	}

	ret = csp_thread_create(csp_can_rx_task, (signed char *) "CANRX",2048, NULL, 3, &can_rx_task);
	if (ret != 0) {
		csp_log_error("Failed to init CAN RX task\r\n");
		return CSP_ERR_NOMEM;
	}

	/* Initialize CAN driver */
	if (can_init(CFP_MAKE_DST(my_address), mask, csp_tx_callback, csp_rx_callback, conf) != 0) {
		csp_log_error("Failed to initialize CAN driver\r\n");
		return CSP_ERR_DRIVER;
	}

	/* Regsiter interface */
	csp_route_add_if(&csp_if_can);

	return CSP_ERR_NONE;

}
//*------------------------------------------------------------------------------------------------
//* 函数名称 : __ilvInitLwIP
//* 功能描述 : 完成LwIP最基本的初始化工作
//* 入口参数 : 无
//* 出口参数 : 无
//*------------------------------------------------------------------------------------------------
__inline void __ilvInitLwIP(void)
{
	sys_init();
	
	mem_init();
	
	memp_init();
	
	pbuf_init();
	
	/*	下面的这个函数有一定的问题 在接受消息的时候一直不堵塞,因为按照要求在没有消息的时候 应该是堵塞的,但是现在一直没有堵塞*/
	/*	这个函数是对前面的函数的封装,里面创建了一个接受的进程	*/
	tcpip_init(NULL, NULL);
}
示例#15
0
文件: init.c 项目: 0x00dec0de/Rovnix
/**
 * 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 */
}
示例#16
0
/**
 * 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 */
}
示例#17
0
/**
* @brief Init_lwIP initialize the LwIP
*/
void Init_lwIP(void)
{
	struct ip_addr ipaddr;
	struct ip_addr netmask;
	struct ip_addr gw;
	struct ip_addr dnsserver;
	long *cfg_ip=(long *)wireless_ip;
	//  sys_init();	 
	/* Initializes the dynamic memory heap defined by MEM_SIZE.*/
	mem_init();
	/* Initializes the memory pools defined by MEMP_NUM_x.*/
	memp_init();	
	pbuf_init();	
	netif_init();
	printf("TCP/IP initializing...\n");
	if(*cfg_ip==0){//no ip addr,use DHCP
		/* 启用DHCP服务器 */
		ipaddr.addr = 0;
		netmask.addr = 0;
		gw.addr = 0;
		printf("using dhcp!\n");
		netif_add(&netif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &ethernet_input);
		netif_set_default(&netif);
		netif_set_up(&netif);
		dhcp_start(&netif);
	}
	else{
		printf("using static ip!\n");
		/* 启用静态IP */
		IP4_ADDR(&ipaddr,wireless_ip[0], wireless_ip[1],
		wireless_ip[2], wireless_ip[3]);
		IP4_ADDR(&netmask, wireless_mask[0], wireless_mask[1], 
						wireless_mask[2], wireless_mask[3]);
		IP4_ADDR(&gw, wireless_gw[0], wireless_gw[1],
					wireless_gw[2], wireless_gw[3]);
		IP4_ADDR(&dnsserver, wireless_dns[0], wireless_dns[1],
					wireless_dns[2], wireless_dns[3]);
		dns_init();
		dns_setserver(0, &dnsserver);//set dns server addr	
		netif_add(&netif, &ipaddr, &netmask, &gw, NULL, &ethernetif_init, &ethernet_input);
		netif_set_default(&netif);
		netif_set_up(&netif);
	}
	timerbase_config();
	printf("TCP/IP initialized.\n");
}
int main(void)
{
	SysInit();
	sys_init();
	mem_init();
	memp_init();
	pbuf_init();
	tcpip_init( NULL, NULL );
/* Start the tasks defined within this file/specific to this demo. */
	xTaskCreate( vGSM_GPRS_Task, "GSM_GPRS_TASK", 256 , NULL,tskIDLE_PRIORITY + 1 , NULL );
  xTaskCreate( vAmpmNetTestTask, "ampm net test", 128 , "\r\nThienhaiblue->",tskIDLE_PRIORITY + 1 , NULL );
	xTaskCreate( vAmpmNetTestTask1, "ampm net test1", 128 , "\r\nTony->",tskIDLE_PRIORITY + 1 , NULL );
	/* Start the scheduler. */
	vTaskStartScheduler();
	while(1)
	{
		
		
	}
	return 0;
}
示例#19
0
文件: ps2ip.c 项目: AzagraMac/PS2_SDK
int
_start(int argc,char** argv)
{
	sys_sem_t	Sema;
	int			iRet;

	dbgprintf("PS2IP: Module Loaded.\n");

	if ((iRet=RegisterLibraryEntries(&_exp_ps2ip))!=0)
	{
		printf("PS2IP: RegisterLibraryEntries returned: %d\n",iRet);
	}

	sys_init();
	mem_init();
	memp_init();
	pbuf_init();

	dbgprintf("PS2IP: sys_init, mem_init, memp_init, pbuf_init called\n");

	netif_init();

	dbgprintf("PS2IP: netif_init called\n");

	Sema=sys_sem_new(0);
	dbgprintf("PS2IP: Calling tcpip_init\n");
	tcpip_init(InitDone,&Sema);

	sys_arch_sem_wait(Sema,0);
	sys_sem_free(Sema);

	dbgprintf("PS2IP: tcpip_init called\n");

	AddLoopIF();
	InitTimer();

	dbgprintf("PS2IP: System Initialised\n");

	return	iRet; 
}
示例#20
0
文件: simhost.c 项目: kingcope/LikeOS
/*-----------------------------------------------------------------------------------*/
int
main(int argc, char **argv)
{
#ifdef PERF
  perf_init("/tmp/simhost.perf");
#endif /* PERF */
#ifdef STATS
  stats_init();
#endif /* STATS */
  sys_init();
  mem_init();
  memp_init();
  pbuf_init();

  tcpdump_init();

  
  printf("System initialized.\n");
    
  sys_thread_new((void *)(main_thread), NULL);
  pause();
  return 0;
}
示例#21
0
/*-----------------------------------------------------------------------------------*/
int
main(int argc, char **argv)
{
#ifdef PERF
  perf_init("/tmp/simhost.perf");
#endif /* PERF */
#if LWIP_STATS
  stats_init();
#endif /* STATS */
  sys_init();
  mem_init();
  memp_init();
  pbuf_init();
#ifdef LWIP_TCPDUMP
  tcpdump_init();
#endif
  
  printf("System initialized.\n");
    
  sys_thread_new(main_thread, NULL, DEFAULT_THREAD_PRIO);
  pause();
  return 0;
}
示例#22
0
/*
--------------------------------------------------------------------------------
  Function name : void WiFiInit(void)
  Author        : 
  Description   : 
                  
  Input         : 
  Return        : 

  History:     <author>         <time>         <version>
               
  desc:         ORG
--------------------------------------------------------------------------------
*/
void WiFiInit(void *pArg)
{
    //系统初始化
    WifiLDOBak = ScuLDOSet(SCU_LDO_30);
    PMU_EnterModule(PMU_MAX);

    //SDIO初始化
    ModuleOverlay(MODULE_ID_WIFI_SCAN, MODULE_OVERLAY_ALL);
    
    __user_initial_stackheap();  
    if (SDIO_Module_Init())
	{
        SendMsg(MSG_WIFI_SCAN_ERR);
        SendMsg(MSG_WIFI_SDIO_ERR);
        return;
	}
    
    //WIFI驱动初始化    
 	ClearMsg(MSG_WIFI_SCAN);
	bss_descriptor_info_init();
	SetScanEventOpen(TRUE);//set dirver enable receive the scan result event.
    SendMsg(MSG_WIFI_SCAN_START);  
    pbuf_init();
}
示例#23
0
文件: main.c 项目: 1847123212/lwBT
/*-----------------------------------------------------------------------------------*/
int
main(int argc, char **argv)
{
  struct phybusif_cb *cb;
  struct timeval tcptv, bttv, now;
  struct timezone tz;
  u8_t btiptmr = 0;
  
#ifdef PERF
  perf_init("/tmp/minimal.perf");
#endif /* PERF */
#ifdef STATS
  stats_init();
#endif /* STATS */

  mem_init();
  memp_init();
  pbuf_init(); 
  netif_init();
  ip_init();
  //udp_init();
  tcp_init();
  printf("TCP/IP initialized.\n");
  lwbt_memp_init();
  phybusif_init();
  if(hci_init() != ERR_OK) {
    printf("HCI initialization failed!");
    exit(-1);
  }
  l2cap_init();
  sdp_init();
  rfcomm_init();
  ppp_init();
  printf("Bluetooth initialized.\n");

  //echo_init();
  httpd_init();
  printf("Applications started.\n");

  cb = malloc(sizeof(struct phybusif_cb));
  phybusif_reset(cb);

  gettimeofday(&bttv, &tz); /* Initialize Bluetooth timer (1s) */
  gettimeofday(&tcptv, &tz); /* Initialize TCP timer (TCP_TMR_INTERVAL) */

  /* Host controller initialization for DTs according to LAN access point (LAP) and dial up networking (DUN) profile */
  bt_ip_start(NULL);

  while(1) {
    phybusif_input(cb); /* Check for input */

    gettimeofday(&now, &tz); /* Get current time */

    /* Check if TCP timer  should be called */
    if((now.tv_sec - tcptv.tv_sec) * 1000000 + (now.tv_usec - tcptv.tv_usec) >= TCP_TMR_INTERVAL * 1000) {
      gettimeofday(&tcptv, &tz); /* Reset TCP timer */
      tcp_tmr();
    }

    /* Check if Bluetooth and NAT timers should be called */ 
    if((now.tv_sec - bttv.tv_sec) * 1000000 + (now.tv_usec - bttv.tv_usec) >= 1000000) {
      gettimeofday(&bttv, &tz); /* Restart Bluetooth timer */
      l2cap_tmr();
      rfcomm_tmr();
      ppp_tmr();
      nat_tmr();
      if(++btiptmr == 240) { /* Akes server special */
	bt_ip_tmr();
	btiptmr = 0;
      }
    }
  }
  
  return 0;
}
示例#24
0
文件: init.c 项目: AKuHAK/ps2sdk
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 */
}
示例#25
0
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 */
}
示例#26
0
/**
 * @brief LWIP handling thread.
 *
 * @param[in] p pointer to a @p lwipthread_opts structure or @p NULL
 * @return The function does not return.
 */
msg_t lwip_thread(void *p) {
  EvTimer evt;
  EventListener el0, el1;
  struct ip_addr ip, gateway, netmask;
  static struct netif thisif;
  static const MACConfig mac_config = {thisif.hwaddr};

  chRegSetThreadName("lwipthread");

  /* Initializes the thing.*/
  sys_init();
  mem_init();
  memp_init();
  pbuf_init();
  netif_init();
  ip_init();
  tcpip_init(NULL, NULL);

  /* TCP/IP parameters, runtime or compile time.*/
  if (p) {
    struct lwipthread_opts *opts = p;
    unsigned i;

    for (i = 0; i < 6; i++)
      thisif.hwaddr[i] = opts->macaddress[i];
    ip.addr = opts->address;
    gateway.addr = opts->gateway;
    netmask.addr = opts->netmask;
  }
  else {
    thisif.hwaddr[0] = LWIP_ETHADDR_0;
    thisif.hwaddr[1] = LWIP_ETHADDR_1;
    thisif.hwaddr[2] = LWIP_ETHADDR_2;
    thisif.hwaddr[3] = LWIP_ETHADDR_3;
    thisif.hwaddr[4] = LWIP_ETHADDR_4;
    thisif.hwaddr[5] = LWIP_ETHADDR_5;
    LWIP_IPADDR(&ip);
    LWIP_GATEWAY(&gateway);
    LWIP_NETMASK(&netmask);
  }
  macStart(&ETHD1, &mac_config);
  netif_add(&thisif, &ip, &netmask, &gateway, NULL, ethernetif_init, tcpip_input);

  netif_set_default(&thisif);
  netif_set_up(&thisif);

  /* Setup event sources.*/
  evtInit(&evt, S2ST(5));
  evtStart(&evt);
  chEvtRegisterMask(&evt.et_es, &el0, PERIODIC_TIMER_ID);
  chEvtRegisterMask(macGetReceiveEventSource(&ETHD1), &el1, FRAME_RECEIVED_ID);
  chEvtAddEvents(PERIODIC_TIMER_ID | FRAME_RECEIVED_ID);

  /* Goes to the final priority after initialization.*/
  chThdSetPriority(LWIP_THREAD_PRIORITY);

  while (TRUE) {
    eventmask_t mask = chEvtWaitAny(ALL_EVENTS);
    if (mask & PERIODIC_TIMER_ID) {
      bool_t current_link_status = macPollLinkStatus(&ETHD1);
      if (current_link_status != netif_is_link_up(&thisif)) {
        if (current_link_status)
          tcpip_callback_with_block((tcpip_callback_fn) netif_set_link_up,
                                     &thisif, 0);
        else
          tcpip_callback_with_block((tcpip_callback_fn) netif_set_link_down,
                                     &thisif, 0);
      }
    }
    if (mask & FRAME_RECEIVED_ID) {
      struct pbuf *p;
      while ((p = low_level_input(&thisif)) != NULL) {
        struct eth_hdr *ethhdr = p->payload;
        switch (htons(ethhdr->type)) {
        /* IP or ARP packet? */
        case ETHTYPE_IP:
        case ETHTYPE_ARP:
#if PPPOE_SUPPORT
        /* PPPoE packet? */
        case ETHTYPE_PPPOEDISC:
        case ETHTYPE_PPPOE:
#endif /* PPPOE_SUPPORT */
          /* full packet send to tcpip_thread to process */
          if (thisif.input(p, &thisif) == ERR_OK)
            break;
          LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
        default:
          pbuf_free(p);
        }
      }
    }
  }
  return 0;
}
示例#27
0
/********
 * MAIN *
 ********/
void main()
{
#ifdef SIMULATOR
	struct ip_addr dump_ipaddr, dump_netmask, dump_gw;
#else
	struct ip_addr eth_ipaddr, eth_netmask, eth_gw;
#endif
	struct ip_addr ipsec_ipaddr, ipsec_netmask, ipsec_gw;
	unsigned int i;


	serinit();							/* init serial port					*/

	printf("lwIP - IPsec Dynamic SAD/SPD configuration demo (compiled %s at %s)\n", __DATE__, __TIME__);
	printf("CVS ID: $Id: main.c,v 1.8 2003/12/12 14:36:33 schec2 Exp $\n\n");


	/* initialize lwIP */
	etharp_init();
	mem_init();
	memp_init();
	pbuf_init(); 
	netif_init();
	ip_init();
	udp_init();
	tcp_init();
	printf("TCP/IP initialized.\n");

#ifdef SIMULATOR
	/* configure dummy device */
	IP4_ADDR(&dump_ipaddr, 192,168,1,3);
	IP4_ADDR(&dump_netmask, 255,255,255,0);
	IP4_ADDR(&dump_gw, 192,168,1,1);

	/* configure IPsec device */
	IP4_ADDR(&ipsec_ipaddr, 192,168,1,3);
	IP4_ADDR(&ipsec_netmask, 255,255,255,0);
	IP4_ADDR(&ipsec_gw, 192,168,1,1);
#endif

#ifdef MCB167NET
	/* configure Ethernet device */
	IP4_ADDR(&eth_ipaddr, 192,168,1,3);
	IP4_ADDR(&eth_netmask, 255,255,255,0);
	IP4_ADDR(&eth_gw, 192,168,1,1);

	/* configure IPsec device */
	IP4_ADDR(&ipsec_ipaddr, 192,168,1,3);
	IP4_ADDR(&ipsec_netmask, 255,255,255,0);
	IP4_ADDR(&ipsec_gw, 192,168,1,1);
#endif

#ifdef PHYCORE167HSE
	/* configure Ethernet device */
	IP4_ADDR(&eth_ipaddr, 192,168,1,4);
	IP4_ADDR(&eth_netmask, 255,255,255,0);
	IP4_ADDR(&eth_gw, 192,168,1,1);

	/* configure IPsec device */
	IP4_ADDR(&ipsec_ipaddr, 192,168,1,4);
	IP4_ADDR(&ipsec_netmask, 255,255,255,0);
	IP4_ADDR(&ipsec_gw, 192,168,1,1);
#endif


	/* Initialize the physical device first (so that ethif->next will point *
	 * to ipsecif). The IPsec device will process the packets and pass them *
	 * upper to the IP layer (using ip_input)                               *
	 * If the simulator is used, dumpdev will replace cs8900.               */
#ifdef SIMULATOR
	printf("Setting up dp0...");
	dumpif = netif_add(&dump_ipaddr, &dump_netmask, &dump_gw, NULL,  dumpdev_init, ipsecdev_input);
	printf("OK\n");

	printf("Setting up is0...");
	ipsecif = netif_add(&ipsec_ipaddr, &ipsec_netmask, &ipsec_gw, NULL,  ipsecdev_init, ip_input);
	printf("OK\n");
#else
	printf("Setting up et0...");
	ethif = netif_add(&eth_ipaddr, &eth_netmask, &eth_gw, NULL,  cs8900if_init, ipsecdev_input);
	printf("OK\n");

	printf("Setting up is0...");
	ipsecif = netif_add(&ipsec_ipaddr, &ipsec_netmask, &ipsec_gw, NULL,  ipsecdev_init, ip_input);
	printf("OK\n");
#endif

	/* configure IPsec tunnel */
#ifdef PHYCORE167HSE
	ipsec_set_tunnel("192.168.1.4", "192.168.1.5");
#else
	ipsec_set_tunnel("192.168.1.3", "192.168.1.5");
#endif

	/* set the IPsec interface "is0" as default interface for lwIP */
	netif_set_default(ipsecif);			/* use ipsec interface by default	*/


	/* start custom applications here */
	dumpwebpage_init();					/* start dumpwebpage 				*/
 	netconfig_init();					/* start dynamic network confiuratio*/

	printf("Applications started.\n");
	DP2  = 0x00FF;						/* configure the status LED on Port2*/
	ODP2 = 0x0000;

	while(1)
	{
		P2 = ~P2;						/* blink LED 						*/

		for (i = 0; i < 50000; i++)  
		{       	
    		_nop_(); _nop_();			/* delay or use this time for the   */
			_nop_(); _nop_();			/* application						*/
			_nop_(); _nop_();
			if((i % 250) == 0) 
			{							/* periodically call to the     	*/
#ifdef SIMULATOR
      			dumpdev_service(dumpif);/* dump device driver (polling mode)*/
#else
      			cs8900if_service(ethif);/* CS8900 driver (polling mode) 	*/
#endif
				tcp_tmr();				/* poll TCP timer					*/
    		}


		}
  	}

}
示例#28
0
/*-----------------------------------------------------------------------------------*/
void 
maintask(void)
{
  struct phybusif_cb *cb;
  CLKBLK ks_clk *tmr;
  u8_t bt_timer = 0;
  u16_t http_timer = 0;
  u16_t dma0bsz = TCR0+1; /* DMA 0 Buf size */
  u8_t bt_ip_timer = 0;

  mem_init();
  memp_init();
  pbuf_init(); 
  netif_init();
  ip_init();
  tcp_init();
  sio_print("TCP/IP initialized.\n");
  
  lwbt_memp_init();
  phybusif_init();
  if(hci_init() != ERR_OK) {
    sio_print("HCI initialization failed!");
  }
  l2cap_init();
  sdp_init();
  rfcomm_init();
  ppp_init();
  
  sio_print("Bluetooth initialized.\n");

  httpd_init();
  sio_print("Applications started.\n");

  cb = mem_malloc(sizeof(struct phybusif_cb));
  cb->dmabuf = get_dm0ichars();
  phybusif_reset(cb);
  
  tmr = KS_alloc_timer();
  if(tmr == 0) {
    sio_print("tmr==0!\n");
  }
  KS_start_timer(tmr, (TICKS)0, (TICKS)100/CLKTICK, TIMERSEM); /* TCP timer ticks every 100ms */

  /* Reset Bluetooth module */
  PD7.0 = 1; /* Enable output */
  sio_print("Reseting BT module\n");
  P7.0 = 1; /* Stop reset */
  
  KS_delay(SELFTASK,(TICKS)4000/CLKTICK); /* Wait for bluetooth module to init */

  /* Control application initialisation */
  bt_ip_start();

  while(1) {
    dma_input(cb, dma0bsz); /* Check for input */

    /* Handle timers */
    if(KS_inqsema(TIMERSEM) == SEMA_DONE) {
      KS_wait(TIMERSEM);
      tcp_tmr();
      ++bt_timer;
      if(bt_timer == 10) {
        l2cap_tmr();
        rfcomm_tmr();
        ppp_tmr();
        bt_timer = 0;
        ++bt_ip_timer;
        if(bt_ip_timer == 240) {
          bt_ip_tmr();
          bt_ip_timer = 0;
        } 
      }
      
    }
  }
}
void zot_network_task(cyg_addrword_t arg)
{
	sys_sem_t sem;

	sys_init();
	mem_init();
	memp_init();
	pbuf_init();
	
	sem = sys_sem_new(0);
	tcpip_init(tcpip_init_done, &sem);

#ifdef PRINT_DIAGNOSTIC
//	if( !diag_flag )
	if( 1 )
#endif
	{
		if(EEPROM_Data.PrintServerMode & PS_DHCP_ON)
		{

#ifdef LINKLOCAL_IP	
            #if defined(N716U2W) || defined(N716U2)
			if(EEPROM_Data.RENVEnable == 1)
            #endif
				Link_local_ip_init();	
#endif
			
			mib_DHCP_p->IPAddr = 0;
			mib_DHCP_p->SubnetMask = 0;
			mib_DHCP_p->GwyAddr = 0;
/*				
			memset( EEPROM_Data.BoxIPAddress, 0, 4);
			memset( EEPROM_Data.SubNetMask, 0, 4);
			memset( EEPROM_Data.GetwayAddress, 0, 4);
*/			
			//Create DHCP Thread
		    cyg_thread_create(DHCP_TASK_PRI,
		                  dhcp_init,
		                  0,
		                  "dhcp_init",
		                  (void *) (DHCP_Stack),
		                  DHCP_TASK_STACK_SIZE,
		                  &DHCP_TaskHdl,
		                  &DHCP_Task);
			
			//Start DHCP Thread
			cyg_thread_resume(DHCP_TaskHdl);

		}
#ifdef RENDEZVOUS
		else
		{
			ppause(3000);
			cyg_semaphore_post( &rendezvous_sem);
		}
#endif		
		
		
	}
	
	sys_sem_wait(sem);
	sys_sem_free(sem);
}
示例#30
0
static int sef_cb_init_fresh(__unused int type, __unused sef_init_info_t *info)
{
	int err;
	unsigned int hz;

	nic_init_all();
	inet_read_conf();

	/* init lwip library */
	stats_init();
	sys_init();
	mem_init();
	memp_init();
	pbuf_init();

	hz = sys_hz();

	arp_ticks = ARP_TMR_INTERVAL / (1000 / hz);
	tcp_fticks = TCP_FAST_INTERVAL / (1000 / hz);
	tcp_sticks = TCP_SLOW_INTERVAL / (1000 / hz);

	etharp_init();
	
	set_timer(&arp_tmr, arp_ticks, arp_watchdog, 0);
	set_timer(&tcp_ftmr, tcp_fticks, tcp_fwatchdog, 0);
	set_timer(&tcp_stmr, tcp_sticks, tcp_swatchdog, 0);
	
	netif_init();
	netif_lo = netif_find(__UNCONST("lo0"));

	/* Read configuration. */
#if 0
	nw_conf();

	/* Get a random number */
	timerand= 1;
	fd = open(RANDOM_DEV_NAME, O_RDONLY | O_NONBLOCK);
	if (fd != -1)
	{
		err= read(fd, randbits, sizeof(randbits));
		if (err == sizeof(randbits))
			timerand= 0;
		else
		{
			printf("inet: unable to read random data from %s: %s\n",
				RANDOM_DEV_NAME, err == -1 ? strerror(errno) :
				err == 0 ? "EOF" : "not enough data");
		}
		close(fd);
	}
	else
	{
		printf("inet: unable to open random device %s: %s\n",
				RANDOM_DEV_NAME, strerror(errno));
	}
	if (timerand)
	{
		printf("inet: using current time for random-number seed\n");
		err= gettimeofday(&tv, NULL);
		if (err == -1)
		{
			printf("sysutime failed: %s\n", strerror(errno));
			exit(1);
		}
		memcpy(randbits, &tv, sizeof(tv));
	}
	init_rand256(randbits);
#endif

	/* Subscribe to driver events for network drivers. */
	if ((err = ds_subscribe("drv\\.net\\..*",
					DSF_INITIAL | DSF_OVERWRITE)) != OK)
		panic(("inet: can't subscribe to driver events"));

	/* Announce we are up. LWIP announces its presence to VFS just like
	 * any other character driver.
	 */
	chardriver_announce();

	return(OK);
}