static Fs* ipgetfs(int dev) { extern void (*ipprotoinit[])(Fs*); Fs *f; int i; if(dev >= Nfs) return nil; qlock(&fslock); if(ipfs[dev] == nil){ f = smalloc(sizeof(Fs)); ip_init(f); arpinit(f); netloginit(f); for(i = 0; ipprotoinit[i]; i++) ipprotoinit[i](f); f->dev = dev; ipfs[dev] = f; } qunlock(&fslock); return ipfs[dev]; }
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; }
int main(void) { // SystemINIT SystemInit(); // Init Debug Serial serial_init(); // Init COOS CoInitOS (); // Setup tasks cli_init(); // Init Serial Client ip_init(); // Init IP Stack http_init(); // Init HTTP Server // Start Tasks! CoStartOS (); // Never to get here!!! while(1) { } }
/* Like tox_bootstrap_from_address but for TCP relays only. * * return 0 on failure. * return 1 on success. */ int tox_add_tcp_relay(Tox *tox, const char *address, uint16_t port, const uint8_t *public_key) { Messenger *m = tox; IP_Port ip_port, ip_port_v4; if (!addr_parse_ip(address, &ip_port.ip)) { if (m->options.udp_disabled) /* Disable DNS when udp is disabled. */ return 0; IP *ip_extra = NULL; ip_init(&ip_port.ip, m->options.ipv6enabled); if (m->options.ipv6enabled) { /* setup for getting BOTH: an IPv6 AND an IPv4 address */ ip_port.ip.family = AF_UNSPEC; ip_reset(&ip_port_v4.ip); ip_extra = &ip_port_v4.ip; } if (!addr_resolve(address, &ip_port.ip, ip_extra)) return 0; } ip_port.port = htons(port); add_tcp_relay(m->net_crypto, ip_port, public_key); onion_add_path_node(m->onion_c, ip_port, public_key); //TODO: move this return 1; }
void net_init(const uint8_t *mac_address, struct ip_info *p_ip_info, const uint8_t *hostname, bool use_dhcp) { uint16_t i; net_timers_init(); if (use_dhcp) { p_ip_info->ip.addr = 0; p_ip_info->gw.addr = 0; p_ip_info->netmask.addr = 0; } else { arp_init(mac_address, p_ip_info); } ip_init(mac_address, p_ip_info); if (use_dhcp) { if (dhcp_client(mac_address, p_ip_info, hostname) < 0) { DEBUG_PUTS("DHCP Client failed"); } else { arp_init(mac_address, p_ip_info); ip_set_ip(p_ip_info); } } for (i = 0; i < ETH_ADDR_LEN; i++) { s_mac_address[i] = mac_address[i]; } uint8_t *src = (uint8_t *) p_ip_info; uint8_t *dst = (uint8_t *) &s_ip_info; for (i = 0; i < sizeof(struct ip_info); i++) { *dst++ = *src++; } }
/* ALLOCATE/CREATE IP ADDRESS */ IPADDRESS * ip_new ( int family ) /* Dynamic allocation */ { IPADDRESS * p = NULL; if( family == IPV4_FAMILY ) { p = ( IPADDRESS * )SnortAlloc( sizeof(IPADDRESS) + IPV4_LEN - 1 ); ip_init( p, family ); } else if( family == IPV6_FAMILY ) { p = ( IPADDRESS * )SnortAlloc( sizeof(IPADDRESS) + IPV6_LEN - 1 ); ip_init( p, family ); } return p; }
/* Run this at startup. * * return allocated instance of tox on success. * return 0 if there are problems. */ Tox *tox_new(Tox_Options *options) { LOGGER_INIT(LOGGER_OUTPUT_FILE, LOGGER_LEVEL); Messenger_Options m_options = {0}; if (options == NULL) { m_options.ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; } else { m_options.ipv6enabled = options->ipv6enabled; m_options.udp_disabled = options->udp_disabled; m_options.proxy_enabled = options->proxy_enabled; if (m_options.proxy_enabled) { ip_init(&m_options.proxy_info.ip_port.ip, m_options.ipv6enabled); if (m_options.ipv6enabled) m_options.proxy_info.ip_port.ip.family = AF_UNSPEC; if (!addr_resolve_or_parse_ip(options->proxy_address, &m_options.proxy_info.ip_port.ip, NULL)) return NULL; m_options.proxy_info.ip_port.port = htons(options->proxy_port); } } return new_messenger(&m_options); }
void dhcp_callback(enum dhcp_event event) { switch(event) { case dhcp_event_timeout: DBG_INFO("[dhcp]: timeout\n"); const ip_address ip = NET_IP_ADDRESS; const ip_address gw = NET_IP_GATEWAY; const ip_address nm = NET_IP_NETMASK; ip_init(&ip, &nm, &gw); netstat(stdout, NETSTAT_OPT_ALL); break; case dhcp_event_lease_acquired: DBG_INFO("[dhcp]: lease acquired\n"); netstat(stdout, NETSTAT_OPT_ALL); break; case dhcp_event_lease_expiring: DBG_INFO("[dhcp]: lease expiring\n"); break; case dhcp_event_lease_expired: DBG_INFO("[dhcp]: lease expired\n"); break; case dhcp_event_lease_denied: DBG_INFO("[dhcp]: lease denied\n"); break; case dhcp_event_error: DBG_ERROR("[dhcp]: error\n"); break; default: DBG_ERROR("[dhcp]: unknown event (0x%x)\n", event); break; } }
void spmd() { const size_t M = 4; double matrix[] = {0.2,0.2,0.5,0.0,0.2,0.2,0.0,0.0,0.2,0.2,0.0,0.0,0.2,0.2,0.0,1}; //test matrix //double matrix[M*M]; //fill_matrix(M, matrix); bsp_begin( bsp_nprocs() ); double *ip_buffer, *x, *y; size_t np; ip_init( &ip_buffer ); np = M/bsp_nprocs(); //double x_array[] = {0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,0.10,0.11,0.12}; x = vector+(bsp_pid()*np); y = matrix; y = y + count*M + (bsp_pid()*np); bsp_sync(); //printf("1e element(k=%d) in thread %d van y= %f\n",k,bsp_pid(),*y); double alpha = ip( x, y, ip_buffer, np ); alpha+= 0.1*((double) 1/M); // this is now the vector-matrix product of pi(stationary vector and P (stochastic matrix) + E //printf("alpha thread %d = %f met k=%d\n",bsp_pid(),alpha,count); //printf("alpha van thread %d = %f.(k= %d)\n",bsp_pid(),alpha,k); bsp_end(); vector_tmp[count] = alpha; }
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(); }
int slirp_init(void) { // debug_init("/tmp/slirp.log", DEBUG_DEFAULT); #ifdef _WIN32 { WSADATA Data; WSAStartup(MAKEWORD(2,0), &Data); atexit(slirp_cleanup); } #endif link_up = 1; if_init(); ip_init(); /* Initialise mbufs *after* setting the MTU */ m_init(); /* set default addresses */ inet_aton("127.0.0.1", &loopback_addr); if (get_dns_addr(&dns_addr) < 0) return -1; inet_aton(CTL_SPECIAL, &special_addr); alias_addr.s_addr = special_addr.s_addr | htonl(CTL_ALIAS); getouraddr(); return 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; }
/** * 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 }
void slirp_init(int restricted, const char *special_ip) { #if DEBUG int slirp_logmask = 0; char slirp_logfile[512]; { const char* env = getenv( "ANDROID_SLIRP_LOGMASK" ); if (env != NULL) slirp_logmask = atoi(env); else if (VERBOSE_CHECK(slirp)) slirp_logmask = DEBUG_DEFAULT; } { char* p = slirp_logfile; char* end = p + sizeof(slirp_logfile); p = bufprint_temp_file( p, end, "slirp.log" ); if (p >= end) { dprint( "cannot create slirp log file in temporary directory" ); slirp_logmask = 0; } } if (slirp_logmask) { dprint( "sending slirp logs with mask %x to %s", slirp_logmask, slirp_logfile ); debug_init( slirp_logfile, slirp_logmask ); } #endif link_up = 1; slirp_restrict = restricted; if_init(); ip_init(); m_init(); inet_strtoip("127.0.0.1", &loopback_addr_ip); if (dns_addr_count == 0) { if (slirp_get_system_dns_servers() < 0) { dns_addr[0] = loopback_addr_ip; dns_addr_count = 1; fprintf (stderr, "Warning: No DNS servers found\n"); } } inet_strtoip(CTL_SPECIAL, &special_addr_ip); alias_addr_ip = special_addr_ip | CTL_ALIAS; getouraddr(); register_savevm("slirp", 0, 1, slirp_state_save, slirp_state_load, NULL); slirp_net_forward_init(); }
/** * 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 */ }
END_TEST START_TEST(test_addto_lists_ipv6) { IP ip; ip_init(&ip, 1); test_addto_lists(ip); }
END_TEST #if TOX_ENABLE_IPV6_DEFAULT == 1 START_TEST(test_addto_lists_ipv6) { IP ip; ip_init(&ip, 1); test_addto_lists(ip); }
void main(void) { SPI_MasterInit(); ip_init(); while (1){ ip_task(); } }
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 {
/** * 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 */ }
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 }
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 ); }
/** * 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 */ }
int main(void) { char packet[1500]; struct cfg_s cfg; /*wait 500 for ethernet*/ _delay_ms(500); enc_init(); twi_init(); spi_init(); ip_init(); pwm_init(); sei(); /* * EEPROM: * Mac Address:6 * IP:4 * Subnet Mask:4 * Port:2 * ID:4 */ eeprom_read_block(&eecfg, &cfg, sizeof(struct cfg_s)); ip_setipmac((char*)cfg.ip, (char*)cfg.subnet, (char*)cfg.mac); while(1) { /* * Provide encoder deltas * Provide Integrated/Corrected Gyro * Accelerometer? * Pipe PWMS * Pipe Spike * IP? - TCP/UDP * * Do reliability on cpu side. * Send immediate acks only. * * Timeout of 250 ms? */ /* TODO: * ANALOG: * GYRO * TEMP * ACCELEROMETER * CONTROL STATION * PID? */ /*LOOP*/ } }
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 }
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(); }
void intHARDWARE(){ lcd_init(none); initUI(); ip_init(inputPanelCallBack); initSmsClient(); ip_enable(); //fill message buffer //allow user to move and delete message // make sure it does not behave like school solution and crash }
/* 1. 向全局协议簇数组中,注册协议簇 proto_ops结构 * 2. 向全局传输层协议链表中,注册传输层协议 proto结构 * 3. 初始化arp模块 向全局变量ptype_base中注册处理函数,供链路层向上传递数据 注册定时时间,清理arp项过期 * 4. 初始化ip模块 向全局变量ptype_base中注册处理函数,供链路层向上传递数据 */ void inet_proto_init(struct net_proto *pro) { struct inet_protocol *p; int i; printk("Swansea University Computer Society TCP/IP for NET3.019\n"); /* * Tell SOCKET that we are alive... * 向SOCKET模块注册协议簇 */ (void) sock_register(inet_proto_ops.family, &inet_proto_ops); seq_offset = CURRENT_TIME*250; /* * Add all the protocols. */ for(i = 0; i < SOCK_ARRAY_SIZE; i++) { tcp_prot.sock_array[i] = NULL; udp_prot.sock_array[i] = NULL; raw_prot.sock_array[i] = NULL; } tcp_prot.inuse = 0; tcp_prot.highestinuse = 0; udp_prot.inuse = 0; udp_prot.highestinuse = 0; raw_prot.inuse = 0; raw_prot.highestinuse = 0; printk("IP Protocols: "); for(p = inet_protocol_base; p != NULL;) { struct inet_protocol *tmp = (struct inet_protocol *) p->next; inet_add_protocol(p); printk("%s%s",p->name,tmp?", ":"\n"); p = tmp; } /* * Set the ARP module up */ arp_init(); /* * Set the IP module up */ ip_init(); }
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(); }
Onions *new_onions(uint16_t port) { IP ip; ip_init(&ip, 1); ip.ip6.uint8[15] = 1; Onions *on = malloc(sizeof(Onions)); DHT *dht = new_DHT(new_net_crypto(new_networking(ip, port))); on->onion = new_onion(dht); on->onion_a = new_onion_announce(dht); if (on->onion && on->onion_a) return on; return NULL; }