int init_transport(struct ip_addr server) { struct pbuf *pbuf; udp_cnx = udp_new(); udp_recv(udp_cnx, time_recv, (void*) L4_Myself().raw); udp_bind(udp_cnx, IP_ADDR_ANY, NFS_LOCAL_PORT); udp_connect(udp_cnx, &server, 37 /* Time port */); do { pbuf = pbuf_alloc(PBUF_TRANSPORT, UDP_PAYLOAD, PBUF_RAM); udp_send(udp_cnx, pbuf); sos_usleep(100); pbuf_free(pbuf); } while (time_of_day == 0); udp_remove(udp_cnx); cur_xid = time_of_day * 10000; /* Generate a randomish xid */ udp_cnx = udp_new(); udp_recv(udp_cnx, my_recv, NULL); udp_connect(udp_cnx, &server, 0); udp_bind(udp_cnx, IP_ADDR_ANY, NFS_LOCAL_PORT); return 0; }
static void nfsfs_timeout_thread(void) { while (1) { sos_usleep(NFSFS_TIMEOUT_MS); nfs_timeout(); dprintf(4, "*** nfs_timeout_thread: timout event!\n"); } }
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__); }