Example #1
0
int main (int argc, char ** argv) {
    w=windowcf_create(SPECTRUM_FFT_LENGTH);
    wchA = windowcf_create(TRACK_LENGTH);
    wchB = windowcf_create(TRACK_LENGTH);
    wchC = windowcf_create(TRACK_LENGTH);

    wchA_filtered = windowcf_create(TRACK_LENGTH);
    wchB_filtered = windowcf_create(TRACK_LENGTH);
    wchC_filtered = windowcf_create(TRACK_LENGTH);

    wmag_buffer = windowf_create(TRACK_LENGTH);

    nco = nco_crcf_create(LIQUID_NCO);
    std::cout << "hydromath daemon is beginning..." << std::endl;
    std::cout << "NOTE: if this is symhydromath you must pass in a matfile" << std::endl;

    std::cout << argv[1] << std::endl;
    shm_init();
    shm_getg(hydrophones_results_track, shm_results_track);
    shm_getg(hydrophones_results_spectrum, shm_results_spectrum);

    //shm_results_track.tracked_ping_count=0;
    shm_results_track.tracked_ping_time=0; 


    if (argc > 1) {
        udp_init(argv[1]);
    }
    else {
        udp_init("");
    }
    //std::thread track_thread(direction_loop);
    //
    //std::thread spectrum_thread(spectrum_loop);
    track_sample_idx = 0;  

    while (loop(&spt) == 0) {
        shm_getg(hydrophones_settings, shm_settings);
        for (int i = 0; i < 3*CHANNEL_DEPTH; i+=3) {
            windowcf_push(w,    std::complex<float>(spt.data[i+1],0)); //This uses channel B

            windowcf_push(wchA, std::complex<float>(spt.data[i],0));
            windowcf_push(wchB, std::complex<float>(spt.data[i+1],0));
            windowcf_push(wchC, std::complex<float>(spt.data[i+2],0));
        }
        current_sample_count+=CHANNEL_DEPTH;        
        do_spectrum();
        do_track();
    }

    printf("loop done %li =ci\n",current_sample_count/CHANNEL_DEPTH);
    return 0;
}
Example #2
0
int serverBogusPortCheck(void)
{
    int passed = 1;
    char tempPortName[] = "-53";
    char oldPortName[1024] = "";

    reset_test_state();

    clientDataSent = 0;
    clientDataRcvd = 0;
    serverDataSent = 0;
    serverDataRcvd = 0;

    printf("Checking closing socket in server mode.\n");
    if (passed)
    {
        udp_cleanup(&serverUdpCommStruct);
        passed &= !udp_isOpen(&serverUdpCommStruct);
    }

    if (passed)
    {
        //Backup old host name
        strcpy(oldPortName, serverUdpCommStruct.port);

        //Swapping char * to place bogus name
        strcpy(serverUdpCommStruct.port, tempPortName);

        printf("Confirming bogus port does not work.\n");
        if (passed)
        {
            udp_init(&serverUdpCommStruct);
            passed &= !udp_isOpen(&serverUdpCommStruct);
        }

        if (passed)
            passed &= !biDirectionalCommCheck();

        //Restore old host name
        strcpy(serverUdpCommStruct.port, oldPortName);

        //Reconnect with old host name
        if (passed)
        {
            udp_init(&serverUdpCommStruct);
            passed &= udp_isOpen(&serverUdpCommStruct);
        }
    }

    return passed;
}
Example #3
0
int clientBogusNameCheck(void)
{
    int passed = 1;
    char tempHostName[] = "badName";
    char oldHostName[1024] = "";

    reset_test_state();

    clientDataSent = 0;
    clientDataRcvd = 0;
    serverDataSent = 0;
    serverDataRcvd = 0;

    printf("Checking closing socket in client mode.\n");
    if (passed)
    {
        udp_cleanup(&clientUdpCommStruct);
        passed &= !udp_isOpen(&clientUdpCommStruct);
    }

    if (passed)
    {
        //Backup old host name
        strcpy(oldHostName, clientUdpCommStruct.hostname);

        //Swapping char * to place bogus name
        strcpy(clientUdpCommStruct.hostname, tempHostName);

        printf("Confirming bogus name does not work.\n");
        if (passed)
        {
            udp_init(&clientUdpCommStruct);
            passed &= !udp_isOpen(&clientUdpCommStruct);
        }

        if (passed)
            passed &= !biDirectionalCommCheck();

        //Restore old host name
        strcpy(clientUdpCommStruct.hostname, oldHostName);

        //Reconnect with old host name
        if (passed)
        {
            udp_init(&clientUdpCommStruct);
            passed &= udp_isOpen(&clientUdpCommStruct);
        }
    }

    return passed;
}
void *broadcast_location(void *parameters)
{
    int i;
    char buffer[128] = "\0";
    
    struct client * clientInfo = (struct client*)parameters;
    
    udp_init(clientInfo->client_ip_addr, "6000", &udpCliInfo[clientInfo->mySlot]);
    
    while (1)
    {
        //Formats the information for sending.
        sprintf(buffer, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", clientInfo->team,clientInfo->xLocation,clientInfo->yLocation, clientInfo->mySlot, clientInfo->mouseX, clientInfo->mouseY,clientInfo->fire, clientInfo->bulletX, clientInfo->bulletY, clientInfo->tankAngle, clientInfo->cannonAngle, clientInfo->dead, clientInfo->healthPoints, redpoints, bluepoints);
        //sprintf(buffer, "200,300,0");
        
        //printf("Sending: %s\n", buffer);
        
        //Sends to all Players
        for (i = 0; i < MAX_PLAYERS; i++)
        {
            //Skips slot if no connection
            if( udpCliInfo[i].udpsocksd > 0 )
            {
                if(sendto(udpCliInfo[i].udpsocksd, buffer, strlen(buffer)+1, 0, udpCliInfo[i].p->ai_addr, udpCliInfo[i].p->ai_addrlen) == -1)
                {
                    perror("Send: \n");
                    exit(1);
                }
            }
        }
        
        //waits to not overload client and the network
        usleep(40000);
    }    
}
Example #5
0
int DTrack::init(dtrack_init_type* ini)
{

	// init udp socket:

	_udpsock = udp_init(ini->udpport);
	if(_udpsock < 0){
		return DTRACK_ERR_UDP;
	}

	_udptimeout_us = ini->udptimeout_us;

	// init udp buffer:

	_udpbufsize = ini->udpbufsize;
	
	_udpbuf = (char *)malloc(_udpbufsize);
	if(!_udpbuf){
		udp_exit(_udpsock);
		return DTRACK_ERR_MEM;
	}

	// DTrack remote control parameters:

	_remote_ip = udp_inet_atoh(ini->remote_ip);
	_remote_port = ini->remote_port;

	return DTRACK_ERR_NONE;
}
Example #6
0
/*
 * IP initialization: fill in IP protocol switch table.
 * All protocols not implemented in kernel go to raw IP protocol handler.
 */
void
ip_init(Slirp *slirp)
{
    slirp->ipq.ip_link.next = slirp->ipq.ip_link.prev = &slirp->ipq.ip_link;
    udp_init(slirp);
    tcp_init(slirp);
}
Example #7
0
void tcpipinit()
{
	prog_name= "kernel TCP/IP";

	mu_init(&mu_generic);
	mu_lock(&mu_generic);

	tcpip_dirinit();

	sr_init_cap_names();
	sr_set_cap_name(ETH_DEV0, "eth");
	sr_set_cap_name(IP_DEV0, "ip");
	sr_set_cap_name(TCP_DEV0, "tcp");
	sr_set_cap_name(UDP_DEV0, "udp");
#if 0
	sr_enable_linger_right();
#endif

	bf_init();
	clck_init();
	sr_init();
	eth_init();
	arp_init();
	ip_init();
	tcp_init();
	udp_init();
	add_default_gws();

	mu_unlock(&mu_generic);
	tcpip_chmod();
}
Example #8
0
void tcpip_init(void)
{
	net_mutex = thinkos_mutex_alloc();

	assert(net_mutex > 0);

	tcpip_net_lock();

	DCC_LOG1(LOG_TRACE, "net_mutex=%d", net_mutex);

	mbuf_init();

	pktbuf_pool_init();

#if (ENABLE_NET_RAW)
	raw_init();
#endif

#if (ENABLE_NET_UDP)
	udp_init();
#endif

#if (ENABLE_NET_TCP)
	tcp_init();
#endif

	ifnet_init();

	tcpip_net_unlock();
}
Example #9
0
int
microps_init (const struct microps_param *param) {
    if (ethernet_init() == -1) {
        goto ERROR;
	}
    if (ethernet_device_open(param->ethernet_device, param->ethernet_addr) == -1) {
        goto ERROR;
    }
	if (arp_init() == -1) {
        goto ERROR;
    }
    if (ip_init(param->ip_addr, param->ip_netmask, param->ip_gateway) == -1) {
        goto ERROR;
    }
    if (icmp_init() == -1) {
        goto ERROR;
    }
	if (udp_init() == -1) {
        goto ERROR;
    }
	if (tcp_init() == -1) {
        goto ERROR;
    }
    if (ethernet_device_run() == -1) {
        goto ERROR;        
    }
	return  0;
ERROR:
    //microps_cleanup();
	return -1;
}
int main(int argc, char *argv[])
{

  CHECK_INIT_RETURN(itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX,
                              tasks_info, messages_info, messages_definition_xml,
                              mme_config.itti_config.log_file));
  /* Parse the command line for options and set the mme_config accordingly. */
  CHECK_INIT_RETURN(config_parse_opt_line(argc, argv, &mme_config) < 0);
  MSC_INIT(MSC_MME_GW, THREAD_MAX+TASK_MAX);

  /* Calling each layer init function */
  CHECK_INIT_RETURN(log_init(&mme_config, oai_epc_log_specific));
  CHECK_INIT_RETURN(nas_init(&mme_config));
  CHECK_INIT_RETURN(sctp_init(&mme_config));
  CHECK_INIT_RETURN(udp_init(&mme_config));
  CHECK_INIT_RETURN(gtpv1u_init(&mme_config));
  CHECK_INIT_RETURN(s1ap_mme_init(&mme_config));
  CHECK_INIT_RETURN(mme_app_init(&mme_config));
  CHECK_INIT_RETURN(s6a_init(&mme_config));
  CHECK_INIT_RETURN(sgw_lite_init(mme_config.config_file));
  /* Handle signals here */
  itti_wait_tasks_end();

  return 0;
}
Example #11
0
void
init(void)
{
	app_init();
	doi_init();
	exchange_init();
	group_init();
	ipsec_init();
	isakmp_doi_init();
	libcrypto_init();

	timer_init();

	/* The following group are depending on timer_init having run.  */
	conf_init();
	connection_init();

	/* This depends on conf_init, thus check as soon as possible. */
	log_reinit();

	/* policy_init depends on conf_init having run.  */
	policy_init();

	/* Depends on conf_init and policy_init having run */
	cert_init();
	crl_init();

	sa_init();
	transport_init();
	virtual_init();
	udp_init();
	nat_t_init();
	udp_encap_init();
	vendor_init();
}
Example #12
0
int
microps_init (void) {
    if (ethernet_init() == -1) {
        goto ERROR;
    }
    if (slip_init() == -1) {
        goto ERROR;
    }
    if (arp_init() == -1) {
        goto ERROR;
    }
    if (ip_init() == -1) {
        goto ERROR;
    }
    if (icmp_init() == -1) {
        goto ERROR;
    }
    if (udp_init() == -1) {
        goto ERROR;
    }
    if (tcp_init() == -1) {
        goto ERROR;
    }
    return  0;

ERROR:
    microps_cleanup();
    return -1;
}
Example #13
0
STATIC_INLINE void main_init( void ) {

  mcu_init();

  electrical_init();

  stateInit();

  actuators_init();
#if USE_MOTOR_MIXING
  motor_mixing_init();
#endif

  radio_control_init();

  air_data_init();
#if USE_BARO_BOARD
  baro_init();
#endif
  imu_init();
#if USE_IMU_FLOAT
  imu_float_init();
#endif
  ahrs_aligner_init();
  ahrs_init();

  ins_init();

#if USE_GPS
  gps_init();
#endif

  autopilot_init();

  modules_init();

  settings_init();

  mcu_int_enable();

#if DATALINK == XBEE
  xbee_init();
#endif

#if DATALINK == UDP
  udp_init();
#endif

  // register the timers for the periodic functions
  main_periodic_tid = sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
  modules_tid = sys_time_register_timer(1./MODULES_FREQUENCY, NULL);
  radio_control_tid = sys_time_register_timer((1./60.), NULL);
  failsafe_tid = sys_time_register_timer(0.05, NULL);
  electrical_tid = sys_time_register_timer(0.1, NULL);
  telemetry_tid = sys_time_register_timer((1./TELEMETRY_FREQUENCY), NULL);
#if USE_BARO_BOARD
  baro_tid = sys_time_register_timer(1./BARO_PERIODIC_FREQUENCY, NULL);
#endif
}
Example #14
0
/*
 * IP initialization: fill in IP protocol switch table.
 * All protocols not implemented in kernel go to raw IP protocol handler.
 */
void
ip_init()
{
	ipq.ip_link.next = ipq.ip_link.prev = &ipq.ip_link;
	ip_id = tt.tv_sec & 0xffff;
	udp_init();
	tcp_init();
}
Example #15
0
/*
 * IP initialization: fill in IP protocol switch table.
 * All protocols not implemented in kernel go to raw IP protocol handler.
 */
void ip_init(void)
{
	ipq.next = ipq.prev = (ipqp_32)&ipq;
	ip_id = tt.tv_sec & 0xffff;
	udp_init();
	tcp_init();
	ip_defttl = IPDEFTTL;
}
Example #16
0
uint32_t ipv6_init(const ipv6_init_t * p_init)
{
    uint32_t           index;
    uint32_t           err_code;
    ble_6lowpan_init_t init_params;

    NULL_PARAM_CHECK(p_init);
    NULL_PARAM_CHECK(p_init->p_eui64);
    NULL_PARAM_CHECK(p_init->event_handler);

    SDK_MUTEX_INIT(m_ipv6_mutex);
    IPV6_MUTEX_LOCK();

    IPV6_ENTRY();

    // Initialize related modules.
    UNUSED_VARIABLE(nrf_mem_init());
    UNUSED_VARIABLE(iot_pbuffer_init());

    // Initialize submodules of IPv6 stack.
    UNUSED_VARIABLE(udp_init());
    UNUSED_VARIABLE(icmp6_init());

    // Initialize context manager.
    UNUSED_VARIABLE(iot_context_manager_init());

    IPV6_ADDRESS_INITIALIZE(IPV6_ADDR_ANY);

    // Set application event handler.
    m_event_handler = p_init->event_handler;

    // Clear number of interfaces.
    m_interfaces_count = 0;

    // Clear network interfaces.
    for (index = 0; index < IPV6_MAX_INTERFACE; index++)
    {
        interface_reset(&m_interfaces[index]);
    }

    // Clear all addresses.
    for (index = 0; index < IPV6_MAX_ADDRESS_COUNT; index++)
    {
        addr_free(index, false);
    }

    // 6LoWPAN module initialization.
    init_params.p_eui64       = p_init->p_eui64;
    init_params.event_handler = ble_6lowpan_evt_handler;

    err_code = ble_6lowpan_init(&init_params);

    IPV6_EXIT();

    IPV6_MUTEX_UNLOCK();

    return err_code;
}
Example #17
0
/**
 * 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
}
Example #18
0
/*
 * IP initialization: fill in IP protocol switch table.
 * All protocols not implemented in kernel go to raw IP protocol handler.
 */
void
ip_init()
{
	ipq.ip_link.next = ipq.ip_link.prev = &ipq.ip_link;
	ip_id = tt.tv_sec & 0xffff;
	udp_init();
	tcp_init();
	ip_defttl = IPDEFTTL;
}
Example #19
0
/**
 * 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 */
}
Example #20
0
STATIC_INLINE void main_init( void ) {

  mcu_init();

  electrical_init();

  stateInit();

  actuators_init();
#if USE_MOTOR_MIXING
 // motor_mixing_init();
 // servo_mixing_init();
  set_servo_init();
#endif

  radio_control_init();

  baro_init();
  imu_init();
  autopilot_init();
  nav_init();
  guidance_h_init();
  guidance_v_init();
  stabilization_init();

  ahrs_aligner_init();
  ahrs_init();

  ins_init();

#if USE_GPS
  gps_init();
#endif

  modules_init();

  settings_init();

  mcu_int_enable();

#if DATALINK == XBEE
  xbee_init();
#endif

#if DATALINK == UDP
  udp_init();
#endif

  // register the timers for the periodic functions
  main_periodic_tid = sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
  modules_tid = sys_time_register_timer(1./MODULES_FREQUENCY, NULL);
  radio_control_tid = sys_time_register_timer((1./60.), NULL);
  failsafe_tid = sys_time_register_timer(0.05, NULL);
  electrical_tid = sys_time_register_timer(0.1, NULL);
  baro_tid = sys_time_register_timer(1./BARO_PERIODIC_FREQUENCY, NULL);
  telemetry_tid = sys_time_register_timer((1./TELEMETRY_FREQUENCY), NULL);
}
Example #21
0
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 {
Example #22
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 */
}
Example #23
0
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
}
Example #24
0
void	net_init (void)
{
	int32	nbufs;			/* Total no of buffers		*/

	/* Initialize the network data structure */

	memset((char *)&NetData, NULLCH, sizeof(struct network));

	/* Obtain the Ethernet MAC address */

	control(ETHER0, ETH_CTRL_GET_MAC, (int32)NetData.ethucast, 0);

	memset((char *)NetData.ethbcast, 0xFF, ETH_ADDR_LEN);

	/* Initialize the random port seed */

	netportseed = getticks();

	/* Create the network buffer pool */

	nbufs = UDP_SLOTS * UDP_QSIZ + ICMP_SLOTS * ICMP_QSIZ + 1;

	netbufpool = mkbufpool(PACKLEN, nbufs);

	/* Initialize the ARP cache */

	arp_init();

	/* Initialize UDP */

	udp_init();

	/* Initialize ICMP */

	icmp_init();

	/* Initialize the IP output queue */

	ipoqueue.iqhead = 0;
	ipoqueue.iqtail = 0;
	ipoqueue.iqsem = semcreate(0);
	if((int32)ipoqueue.iqsem == SYSERR) {
		panic("Cannot create ip output queue semaphore");
		return;
	}

	/* Create the IP output process */

	resume(create(ipout, NETSTK, NETPRIO, "ipout", 0, NULL));

	/* Create a network input process */

	resume(create(netin, NETSTK, NETPRIO, "netin", 0, NULL));
}
Example #25
0
File: network.c Project: 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__);
}
Example #26
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 */
}
Example #27
0
void
lwip_raw_init()
{
	ip_init();	/* Doesn't do much, it should be called to handle future changes. */
#if LWIP_UDP
	udp_init();	/* Clears the UDP PCB list. */
#endif
#if LWIP_TCP
	tcp_init();	/* Clears the TCP PCB list and clears some internal TCP timers. */
			/* Note: you must call tcp_fasttmr() and tcp_slowtmr() at the */
			/* predefined regular intervals after this initialization. */
#endif
}
Example #28
0
/*
 * IP initialization: fill in IP protocol switch table.
 * All protocols not implemented in kernel go to raw IP protocol handler.
 */
void
ip_init(PNATState pData)
{
    int i = 0;
    for (i = 0; i < IPREASS_NHASH; ++i)
        TAILQ_INIT(&ipq[i]);
    maxnipq = 100; /* ??? */
    maxfragsperpacket = 16;
    nipq = 0;
    ip_currid = tt.tv_sec & 0xffff;
    udp_init(pData);
    tcp_init(pData);
}
Example #29
0
usb_t usb_init (const usb_descriptors_t *descriptors,
                udp_request_handler_t request_handler)
{
    static usb_dev_t usb_dev;
    usb_t usb = &usb_dev;

    usb->udp = udp_init ((void *)usb_request_handler, usb);

    usb->descriptors = descriptors;
    usb->request_handler = request_handler;
    usb->dev_descriptor = &devDescriptor;

    return usb;
}
Example #30
0
PRIVATE void nw_init()
{
	mq_init();
	qp_init();
	bf_init();
	clck_init();
	sr_init();
	eth_init();
	arp_init();
	psip_init();
	ip_init();
	tcp_init();
	udp_init();
}