int main() { struct ip_addr ipaddr, netmask, gw; /* the mac address of the board. this should be unique per board */ unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x01, 0x02 }; echo_netif = &server_netif; #if defined (__arm__) && !defined (ARMR5) #if XPAR_GIGE_PCS_PMA_SGMII_CORE_PRESENT == 1 || XPAR_GIGE_PCS_PMA_1000BASEX_CORE_PRESENT == 1 ProgramSi5324(); ProgramSfpPhy(); #endif #endif init_platform(); #if LWIP_DHCP==1 ipaddr.addr = 0; gw.addr = 0; netmask.addr = 0; #else /* initliaze IP addresses to be used */ IP4_ADDR(&ipaddr, 192, 168, 1, 10); IP4_ADDR(&netmask, 255, 255, 255, 0); IP4_ADDR(&gw, 192, 168, 1, 1); #endif print_app_header(); lwip_init(); /* Add network interface to the netif_list, and set it as default */ if (!xemac_add(echo_netif, &ipaddr, &netmask, &gw, mac_ethernet_address, PLATFORM_EMAC_BASEADDR)) { xil_printf("Error adding N/W interface\n\r"); return -1; } netif_set_default(echo_netif); /* now enable interrupts */ platform_enable_interrupts(); /* specify that the network if is up */ netif_set_up(echo_netif); #if (LWIP_DHCP==1) /* Create a new DHCP client for this interface. * Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at * the predefined regular intervals after starting the client. */ dhcp_start(echo_netif); dhcp_timoutcntr = 24; while(((echo_netif->ip_addr.addr) == 0) && (dhcp_timoutcntr > 0)) xemacif_input(echo_netif); if (dhcp_timoutcntr <= 0) { if ((echo_netif->ip_addr.addr) == 0) { xil_printf("DHCP Timeout\r\n"); xil_printf("Configuring default IP of 192.168.1.10\r\n"); IP4_ADDR(&(echo_netif->ip_addr), 192, 168, 1, 10); IP4_ADDR(&(echo_netif->netmask), 255, 255, 255, 0); IP4_ADDR(&(echo_netif->gw), 192, 168, 1, 1); } } ipaddr.addr = echo_netif->ip_addr.addr; gw.addr = echo_netif->gw.addr; netmask.addr = echo_netif->netmask.addr; #endif print_ip_settings(&ipaddr, &netmask, &gw); /* start the application (web server, rxtest, txtest, etc..) */ start_application(); /* receive and process packets */ while (1) { if (TcpFastTmrFlag) { tcp_fasttmr(); TcpFastTmrFlag = 0; } if (TcpSlowTmrFlag) { tcp_slowtmr(); TcpSlowTmrFlag = 0; } xemacif_input(echo_netif); transfer_data(); } /* never reached */ cleanup_platform(); return 0; }
int main() { // disable caches -- still fast enough for copies, no worries about coherency Xil_DCacheDisable(); struct ip_addr ipaddr, netmask, gw; /* the mac address of the board. this should be unique per board */ unsigned char mac_ethernet_address[] = { 0x00, 0x0a, 0x35, 0x00, 0x05, 0x12 }; echo_netif = &server_netif; #if XPAR_GIGE_PCS_PMA_CORE_PRESENT == 1 ProgramSi5324(); ProgramSfpPhy(); #endif init_platform(); /* initliaze IP addresses to be used */ /* 129.241.110.214 */ ipaddr.addr=0; netmask.addr=0; gw.addr=0; /*IP4_ADDR(&ipaddr, 129, 241, 110, 240); IP4_ADDR(&netmask, 255, 255, 254, 0); IP4_ADDR(&gw, 129, 241, 110, 1);*/ print_app_header(); print_ip_settings(&ipaddr, &netmask, &gw); lwip_init(); /* Add network interface to the netif_list, and set it as default */ if (!xemac_add(echo_netif, &ipaddr, &netmask, &gw, mac_ethernet_address, PLATFORM_EMAC_BASEADDR)) { xil_printf("Error adding N/W interface\n\r"); return -1; } netif_set_default(echo_netif); /* Create a new DHCP client for this interface. * Note: you must call dhcp_fine_tmr() and dhcp_coarse_tmr() at * the predefined regular intervals after starting the client. */ /* dhcp_start(echo_netif); */ dhcp_start(echo_netif); /* now enable interrupts */ platform_enable_interrupts(); /* specify that the network if is up */ netif_set_up(echo_netif); /* start the application (web server, rxtest, txtest, etc..) */ start_application(); /* receive and process packets */ int msg = 0; while (!finished) { xemacif_input(echo_netif); transfer_data(); if(!msg && echo_netif->ip_addr.addr) { msg=1; xil_printf("Acquired DHCP address!\n"); print_ip("",&(echo_netif->ip_addr)); } } xil_printf("Cheetah finished, exiting..\n"); cleanup_platform(); return 0; }