void Main_task( uint_32 temp) { IPCFG_IP_ADDRESS_DATA ip_data; uint_32 error; _enet_address enet_address; _RTCSPCB_init = 3; _RTCS_msgpool_init = 3; _RTCS_socket_part_init = 3; error = RTCS_create(); if (error== RTCS_OK) { ip_data.ip = ENET_IPADDR; ip_data.mask = ENET_IPMASK; ip_data.gateway = ENET_IPGATEWAY; ENET_get_mac_address (BSP_DEFAULT_ENET_DEVICE, ENET_IPADDR, enet_address); error = ipcfg_init_device (BSP_DEFAULT_ENET_DEVICE, enet_address); error = ipcfg_bind_staticip (BSP_DEFAULT_ENET_DEVICE, &ip_data); } if (error== 0) { // Direct call to lw Telnet Server so that we become the Telnet Server while (1) lw_telnet_server(user_fn); } }
void SEC_InitializeNetworking(uint_32 pcbs, uint_32 msgs, uint_32 sockets, boolean dhcp) { int_32 error; IPCFG_IP_ADDRESS_DATA ip_data; _enet_address enet_address; /* runtime RTCS configuration */ _RTCSPCB_init = pcbs; _RTCS_msgpool_init = msgs; _RTCS_socket_part_init = sockets; error = RTCS_create(); if (error == RTCS_OK) { ip_data.ip = ENET_IPADDR; ip_data.mask = ENET_IPMASK; ip_data.gateway = ENET_IPGATEWAY; ENET_get_mac_address(BSP_DEFAULT_ENET_DEVICE, ENET_IPADDR, enet_address); ipcfg_init_device(BSP_DEFAULT_ENET_DEVICE, enet_address); ipcfg_add_dns_ip(BSP_DEFAULT_ENET_DEVICE,LWDNS_server_ipaddr); // check link status printf("\nWaiting for ethernet cable plug in ... "); while(!ipcfg_get_link_active(BSP_DEFAULT_ENET_DEVICE)) {}; printf("Cable connected\n"); /* If DHCP Enabled, get IP address from DHCP server */ if (dhcp) { printf("\nDHCP bind ... "); error = ipcfg_bind_dhcp_wait(BSP_DEFAULT_ENET_DEVICE, 1, &ip_data); if (error != IPCFG_ERROR_OK) { printf("Error %08x!\n", error); } else { printf("Successful!\n"); } } else { /* Else bind with static IP */ printf ("\nStatic IP bind ... "); error = ipcfg_bind_staticip(BSP_DEFAULT_ENET_DEVICE, &ip_data); if (error != IPCFG_ERROR_OK) { printf("Error %08x!\n",error); } else { printf("Successful!\n"); } } if (error == IPCFG_ERROR_OK) { ipcfg_get_ip(BSP_DEFAULT_ENET_DEVICE, &ip_data); printf("\nIP Address : %d.%d.%d.%d\n",IPBYTES(ip_data.ip)); printf("\nSubnet Address : %d.%d.%d.%d\n",IPBYTES(ip_data.mask)); printf("\nGateway Address : %d.%d.%d.%d\n",IPBYTES(ip_data.gateway)); printf("\nDNS Address : %d.%d.%d.%d\n",IPBYTES(ipcfg_get_dns_ip(BSP_DEFAULT_ENET_DEVICE,0))); } } else { printf("\nRTCS_Create failed !\n"); _task_block(); } }
boolean init_network() { IPCFG_IP_ADDRESS_DATA ip_data; _enet_address enet_address; uint_32 error; _RTCS_socket_part_init = RTCS_NUMBER_OF_SOCKETS; _RTCS_socket_part_grow = 2; _RTCS_socket_part_max = 20; error = RTCS_create(); if (error != RTCS_OK) { printf("init_network: RTCS failed to initialize, error = %X", error); _task_block(); } _IP_forward = TRUE; ip_data.ip = ENET_IPADDR; ip_data.mask = ENET_IPMASK; // we dont need the gateway adress for the netgear-switch //ip_data.gateway = ENET_GATEWAY; // calculate the mac-adress ENET_get_mac_address (ENET_DEVICE, ENET_IPADDR, enet_address); // initialize the device error = ipcfg_init_device (ENET_DEVICE, enet_address); if (error != RTCS_OK) { printf("\nFailed to initialize ethernet device, error = %X", error); _task_block(); } #if RTCSCFG_ENABLE_LWDNS LWDNS_server_ipaddr = ENET_GATEWAY; ipcfg_add_dns_ip(ENET_DEVICE,LWDNS_server_ipaddr); #endif /* RTCSCFG_ENABLE_LWDNS */ printf("Setting static IP address ... "); error = ipcfg_bind_staticip (ENET_DEVICE, &ip_data); if (error != IPCFG_ERROR_OK) { printf("\nRTCS failed to bind interface with IPv4, error = %X", error); _task_block(); } else printf("OK\n"); ipcfg_get_ip(ENET_DEVICE, &ip_data); printf("IP Address : %d.%d.%d.%d\n",IPBYTES(ip_data.ip)); printf("Subnet Address : %d.%d.%d.%d\n",IPBYTES(ip_data.mask)); printf("Gateway Address : %d.%d.%d.%d\n",IPBYTES(ip_data.gateway)); printf("DNS Address : %d.%d.%d.%d\n",IPBYTES(ipcfg_get_dns_ip(ENET_DEVICE,0))); printf("MAC Address : %02x:%02x:%02x:%02x:%02x:%02x\n", enet_address[0], enet_address[1], enet_address[2], enet_address[3], enet_address[4], enet_address[5]); return TRUE; }
static int32_t Shell_ipconfig_staticip (uint32_t enet_device, uint32_t index, int32_t argc, char *argv[]) { uint32_t error; #if RTCSCFG_ENABLE_IP4 IPCFG_IP_ADDRESS_DATA ip_data; #endif #if RTCSCFG_ENABLE_IP6 /*IPv6 adds*/ struct addrinfo hints; // used for getaddrinfo() struct addrinfo * addrinfo_res; // used for getaddrinfo() IPCFG6_BIND_ADDR_DATA ip6_bind_data; // structure for bind interface in6_addr ip6; #endif /* Here we need validate IP address and detect it family */ /* Dont forget destroy addrinfo_res by freeaddrinfo(addrinfo_res) */ #if RTCSCFG_ENABLE_IP6 memset(&hints,0,sizeof(hints)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_DGRAM; hints.ai_flags = AI_NUMERICHOST; if (getaddrinfo ( argv[index+1], NULL, &hints, &addrinfo_res) != 0) { printf("GETADDRINFO error\n"); return(SHELL_EXIT_ERROR); // we can return right here and do not need free freeaddrinfo(addrinfo_res) } if(addrinfo_res->ai_family == AF_INET6) { IN6_ADDR_COPY(&((struct sockaddr_in6 *)((*addrinfo_res).ai_addr))->sin6_addr,&ip6_bind_data.ip_addr); ip6_bind_data.ip_addr_type = IP6_ADDR_TYPE_MANUAL; freeaddrinfo(addrinfo_res); error = ipcfg6_bind_addr (enet_device, &ip6_bind_data); if (error != RTCS_OK) { printf("\nIPCFG Bind IP6(1) is failed, error = %X\n", error); return SHELL_EXIT_ERROR; } printf ("IP6 bind successful.\n"); return SHELL_EXIT_SUCCESS; } #if RTCSCFG_ENABLE_IP4 else if(addrinfo_res->ai_family == AF_INET) { freeaddrinfo(addrinfo_res); #endif #endif //RTCSCFG_ENABLE_IP6 #if RTCSCFG_ENABLE_IP4 if (argc > ++index) { if (! Shell_parse_ip_address (argv[index], &ip_data.ip)) { printf ("Error in static ip command, invalid ip address!\n"); return SHELL_EXIT_ERROR; } } else { printf ("Error in static ip command, missing ip address parameter!\n"); return SHELL_EXIT_ERROR; } if (argc > ++index) { if (! Shell_parse_ip_address (argv[index], &ip_data.mask)) { printf ("Error in static ip command, invalid mask!\n"); return SHELL_EXIT_ERROR; } } else { printf ("Error in static ip command, missing mask parameter!\n"); return SHELL_EXIT_ERROR; } #if RTCSCFG_ENABLE_GATEWAYS if (argc > ++index) { if (! Shell_parse_ip_address (argv[index], &ip_data.gateway)) { printf ("Error in static ip command, invalid gateway!\n"); return SHELL_EXIT_ERROR; } } #endif error = ipcfg_bind_staticip (enet_device, &ip_data); if (error != 0) { printf ("Error during static ip bind %08x!\n", error); return SHELL_EXIT_ERROR; } printf ("Static IP4 bind successful.\n"); return SHELL_EXIT_SUCCESS; #endif #if RTCSCFG_ENABLE_IP6 #if RTCSCFG_ENABLE_IP4 }//end if family #endif printf ("Static bind unsuccessful. Unknown family detected.\n"); return SHELL_EXIT_ERROR; #endif }
void HVAC_initialize_networking(void) { int_32 error; IPCFG_IP_ADDRESS_DATA ip_data; _enet_address enet_address; #if DEMOCFG_USE_POOLS && defined(DEMOCFG_RTCS_POOL_ADDR) && defined(DEMOCFG_RTCS_POOL_SIZE) /* use external RAM for RTCS buffers */ _RTCS_mem_pool = _mem_create_pool((pointer)DEMOCFG_RTCS_POOL_ADDR, DEMOCFG_RTCS_POOL_SIZE); #endif #if RTCS_MINIMUM_FOOTPRINT /* runtime RTCS configuration for devices with small RAM, for others the default BSP setting is used */ _RTCSPCB_init = 4; _RTCSPCB_grow = 2; _RTCSPCB_max = 20; _RTCS_msgpool_init = 4; _RTCS_msgpool_grow = 2; _RTCS_msgpool_max = 20; _RTCS_socket_part_init = 4; _RTCS_socket_part_grow = 2; _RTCS_socket_part_max = 20; #endif error = RTCS_create(); LWDNS_server_ipaddr = ENET_IPGATEWAY; ip_data.ip = ENET_IPADDR; ip_data.mask = ENET_IPMASK; ip_data.gateway = ENET_IPGATEWAY; ENET_get_mac_address (DEMOCFG_DEFAULT_DEVICE, ENET_IPADDR, enet_address); error = ipcfg_init_device (DEMOCFG_DEFAULT_DEVICE, enet_address); #if DEMOCFG_USE_WIFI iwcfg_set_essid (DEMOCFG_DEFAULT_DEVICE,DEMOCFG_SSID); if ((strcmp(DEMOCFG_SECURITY,"wpa") == 0)||strcmp(DEMOCFG_SECURITY,"wpa2") == 0) { iwcfg_set_passphrase (DEMOCFG_DEFAULT_DEVICE,DEMOCFG_PASSPHRASE); } if (strcmp(DEMOCFG_SECURITY,"wep") == 0) { iwcfg_set_wep_key (DEMOCFG_DEFAULT_DEVICE,DEMOCFG_WEP_KEY,strlen(DEMOCFG_WEP_KEY),DEMOCFG_WEP_KEY_INDEX); } iwcfg_set_sec_type (DEMOCFG_DEFAULT_DEVICE,DEMOCFG_SECURITY); iwcfg_set_mode (DEMOCFG_DEFAULT_DEVICE,DEMOCFG_NW_MODE); #endif error = ipcfg_bind_staticip (DEMOCFG_DEFAULT_DEVICE, &ip_data); #if DEMOCFG_ENABLE_FTP_SERVER FTPd_init("FTP_server", 7, 3000 ); #endif #if DEMOCFG_ENABLE_TELNET_SERVER TELNETSRV_init("Telnet_server", 7, 2000, (RTCS_TASK_PTR) &Telnetd_shell_template ); #endif #if DEMOCFG_ENABLE_KLOG && MQX_KERNEL_LOGGING RTCSLOG_enable(RTCSLOG_TYPE_FNENTRY); RTCSLOG_enable(RTCSLOG_TYPE_PCB); #endif }
void SEC_InitializeNetworking(uint_32 pcbs, uint_32 msgs, uint_32 sockets, boolean dhcp) { int_32 error; IPCFG_IP_ADDRESS_DATA ip_data; _enet_address enet_address; #if PSP_MQX_CPU_IS_MCF51CN _enet_handle ehandle; _rtcs_if_handle ihandle; #endif /* runtime RTCS configuration */ _RTCSPCB_init = pcbs; _RTCS_msgpool_init = msgs; _RTCS_socket_part_init = sockets; error = RTCS_create(); if (error == RTCS_OK) { ip_data.ip = ENET_IPADDR; ip_data.mask = ENET_IPMASK; ip_data.gateway = ENET_IPGATEWAY; #if RTCSCFG_ENABLE_LWDNS LWDNS_server_ipaddr = ENET_IPDNS; #endif ENET_get_mac_address(BSP_DEFAULT_ENET_DEVICE, ENET_IPADDR, enet_address); #if PSP_MQX_CPU_IS_MCF51CN ENET_initialize_ex(&ENET_param, BSP_DEFAULT_ENET_DEVICE, &ehandle); if (RTCS_if_add(ehandle, RTCS_IF_ENET, &ihandle) == 0) { if (ipcfg_init_interface(-1, ihandle) != 0) { RTCS_if_remove(ihandle); ENET_shutdown(ehandle); _task_block(); } } else { ENET_shutdown(ehandle); } #else ipcfg_init_device(BSP_DEFAULT_ENET_DEVICE, enet_address); #endif ipcfg_add_dns_ip(BSP_DEFAULT_ENET_DEVICE,LWDNS_server_ipaddr); // check link status printf("\nWaiting for ethernet cable plug in ... "); while(!ipcfg_get_link_active(BSP_DEFAULT_ENET_DEVICE)) {}; printf("Cable connected\n"); /* If DHCP Enabled, get IP address from DHCP server */ if (dhcp) { printf("\nDHCP bind ... "); error = ipcfg_bind_dhcp_wait(BSP_DEFAULT_ENET_DEVICE, 1, &ip_data); if (error != IPCFG_ERROR_OK) { printf("Error %08x!\n", error); } else { printf("Successful!\n"); } } else { /* Else bind with static IP */ printf ("\nStatic IP bind ... "); error = ipcfg_bind_staticip(BSP_DEFAULT_ENET_DEVICE, &ip_data); if (error != IPCFG_ERROR_OK) { printf("Error %08x!\n",error); } else { printf("Successful!\n"); } } if (error == IPCFG_ERROR_OK) { ipcfg_get_ip(BSP_DEFAULT_ENET_DEVICE, &ip_data); printf("\nIP Address : %d.%d.%d.%d\n",IPBYTES(ip_data.ip)); printf("\nSubnet Address : %d.%d.%d.%d\n",IPBYTES(ip_data.mask)); printf("\nGateway Address : %d.%d.%d.%d\n",IPBYTES(ip_data.gateway)); printf("\nDNS Address : %d.%d.%d.%d\n",IPBYTES(ipcfg_get_dns_ip(BSP_DEFAULT_ENET_DEVICE,0))); } } else { printf("\nRTCS_Create failed !\n"); _task_block(); } SEC_GetTime(); }
void Main_task(uint32_t temp) { #include <ipcfg.h> IPCFG_IP_ADDRESS_DATA ip_data; _rtcs_if_handle ihandle; uint32_t error; _ip_address new_target; _enet_address enet_address; /* runtime RTCS configuration */ _RTCSPCB_init = 4; _RTCSPCB_grow = 2; _RTCSPCB_max = 6; _RTCS_socket_part_init = 4; _RTCS_socket_part_grow = 2; _RTCS_socket_part_max = 6; error = RTCS_create(); if (error) { printf("\nFailed to initialize RTCS, error = %X", error); _task_block(); } /* Endif */ ip_data.ip = ENET_IPADDR; ip_data.mask = ENET_IPMASK; ip_data.gateway = ENET_IPGATEWAY; ENET_get_mac_address (BSP_DEFAULT_ENET_DEVICE, ENET_IPADDR, enet_address); error = ipcfg_init_device (BSP_DEFAULT_ENET_DEVICE, enet_address); error = ipcfg_bind_staticip (BSP_DEFAULT_ENET_DEVICE, &ip_data); ihandle = ipcfg_get_ihandle( BSP_DEFAULT_ENET_DEVICE ); /* ** Install some MIBs for the SNMP agent ** MIB1213_init must be called before SNMP_init functions ** It should not be removed. ** If application wishes to use MQX RTOS, MIBMQX_init must be called ** before SNMP_init functions. */ MIB1213_init(); /* init MQX MIB */ #if 0 /* It conflicts with the sample MIB and should only be reinstated when * "your_company" is changed to a more appropriate identifier. * You can find it in the snmp_demo.def file. */ MIBMQX_init(); #endif /* demo MIB table init */ MIBdemo_init(); /* ** Initialize the agent. ** There are two functions for initializing SNMP agent. ** If application wants to send ColdStart/WarmStart traps at ** the initialization time, it must call: ** SNMP_init_with_traps(agent task name, agent task priority, ** agent task stack size, list of trap receivers); ** ** Calling this function will initialize SNMP agent and send ** ColdStart/WarmStart (depending on system up time) traps to the ** station(s). ** ** If application does not want to send ColdStart/WarmStart traps at ** the initialization time, it must call: ** SNMP_init(agent task name, agent task priority, ** agent task stack size); ** ** Note1: If application wishes to use SNMP_init() to initialize the ** SNMP agent, there is no IP address for trap to be sent. ** Application must add trap receivers to the list by calling ** RTCS_trap_target_add(_ip_address). To remove receiver from ** trap receivers list call RTCS_trap_target_remove(_ip_address). ** ** This function initializes SNMP agent without sending any traps. ** ** This example will use SNMP_init_with_traps. */ //error = SNMP_init("SNMP", 7, 3000); error = SNMP_init_with_traps("SNMP", 7, 2500, my_trap_list); if (error) { printf("\nFailed to initialize SNMP agent, error = %X", error); _task_block(); } /* Endif */ printf("Demo started, wait... \n\r"); /* ** RTCS/SNMP agent now supports private and public communities. ** User can add community to the community list, that is defined ** in snmpcfg.h by adding community string to the SNMPCFG_COMMUNITY_LIST ** and changing the SNMPCFG_NUM_COMMUNITY respectively. ** ** Note1: Communities cannot be added dynamically. ** Note2: RTCS/SNMP agent will respond to get, set and getnext messages ** to communities defined in SNMPCFG_COMMUNITY_LIST. ** ** Application can select communities for send and receive traps by calling ** SNMP_trap_select_community(community name); Where community name should ** match one of the strings in the SNMPCFG_COMMUNITY_LIST. By default ** current community is set to first string in SNMPCFG_COMMUNITY_LIST[]. ** This function returns TRUE if the community was changed successfully, ** FALSE on failure. ** ** Note3: SNMP_trap_select_community(char *community_name); should be ** called after SNMP_init (or with trap) has been called. ** ** Note4: mylinkdown trap is enterprise specific, therefore application ** need to implement this trap. SNMP_trap_myLinkDown is just an example ** for use as reference. */ /* Send some traps to private and public communities */ /* trap will be sent to four IPs in my_trap_list */ if(SNMP_trap_select_community("private")) { SNMP_trap_linkDown(ihandle); SNMP_trap_linkUp(ihandle); SNMP_trap_myLinkDown(ihandle); SNMP_trap_coldStart(); SNMP_trap_warmStart(); } new_target = ENET_TRAP_ADDR5; /* Add a new IP address to the trap list */ error = RTCS_trap_target_add(new_target); if (error) { printf("\nFailed to add target trap, error = %X", error); } /* Endif */ /* trap will be sent to five IPs */ if(SNMP_trap_select_community("public")) { SNMP_trap_linkDown(ihandle); SNMP_trap_linkUp(ihandle); SNMP_trap_myLinkDown(ihandle); SNMP_trap_coldStart(); SNMP_trap_warmStart(); } /* Remove the new IP address from trap list */ error = RTCS_trap_target_remove(new_target); if (error) { printf("\nFailed to remove target trap, error = %X", error); } /* Endif */ #ifdef SNMPCFG_SEND_V2_TRAPS if (SNMP_trap_select_community("public")) { SNMPv2_trap_linkDown(ihandle); SNMPv2_trap_linkUp(ihandle); SNMPv2_trap_coldStart(); SNMPv2_trap_warmStart(); } #endif /* Call the counter demo function */ Snmp_task(0); _task_block(); }
void HVAC_initialize_networking(void) { int32_t error; IPCFG_IP_ADDRESS_DATA ip_data; _enet_address enet_address; #if DEMOCFG_USE_POOLS && defined(DEMOCFG_RTCS_POOL_ADDR) && defined(DEMOCFG_RTCS_POOL_SIZE) /* use external RAM for RTCS buffers */ _RTCS_mem_pool = _mem_create_pool((void *)DEMOCFG_RTCS_POOL_ADDR, DEMOCFG_RTCS_POOL_SIZE); #endif /* runtime RTCS configuration for devices with small RAM, for others the default BSP setting is used */ _RTCSPCB_init = 4; _RTCSPCB_grow = 2; _RTCSPCB_max = 20; _RTCS_msgpool_init = 4; _RTCS_msgpool_grow = 2; _RTCS_msgpool_max = 20; _RTCS_socket_part_init = 4; _RTCS_socket_part_grow = 2; _RTCS_socket_part_max = 20; error = RTCS_create(); LWDNS_server_ipaddr = ENET_IPGATEWAY; ip_data.ip = ENET_IPADDR; ip_data.mask = ENET_IPMASK; ip_data.gateway = ENET_IPGATEWAY; ENET_get_mac_address (DEMOCFG_DEFAULT_DEVICE, ENET_IPADDR, enet_address); error = ipcfg_init_device (DEMOCFG_DEFAULT_DEVICE, enet_address); #if DEMOCFG_USE_WIFI iwcfg_set_essid (DEMOCFG_DEFAULT_DEVICE,DEMOCFG_SSID); if ((strcmp(DEMOCFG_SECURITY,"wpa") == 0)||strcmp(DEMOCFG_SECURITY,"wpa2") == 0) { iwcfg_set_passphrase (DEMOCFG_DEFAULT_DEVICE,DEMOCFG_PASSPHRASE); } if (strcmp(DEMOCFG_SECURITY,"wep") == 0) { iwcfg_set_wep_key (DEMOCFG_DEFAULT_DEVICE,DEMOCFG_WEP_KEY,strlen(DEMOCFG_WEP_KEY),DEMOCFG_WEP_KEY_INDEX); } iwcfg_set_sec_type (DEMOCFG_DEFAULT_DEVICE,DEMOCFG_SECURITY); iwcfg_set_mode (DEMOCFG_DEFAULT_DEVICE,DEMOCFG_NW_MODE); #endif error = ipcfg_bind_staticip (DEMOCFG_DEFAULT_DEVICE, &ip_data); #if DEMOCFG_ENABLE_FTP_SERVER { /* FTP server parameters are global variables. */ ftpsrv_params.root_dir = FTPSRV_ROOTDIR; #if RTCSCFG_ENABLE_IP4 ftpsrv_params.af |= AF_INET; #endif #if RTCSCFG_ENABLE_IP6 ftpsrv_params.af |= AF_INET6; #endif ftpsrv_params.auth_table = (FTPSRV_AUTH_STRUCT*) ftpsrv_users; if (FTPSRV_init(&ftpsrv_params) != 0) { printf("FTP Server Started. Root directory is set to \"%s\", login: \"%s\", password: \"%s\".\n", ftpsrv_params.root_dir, ftpsrv_users[0].uid, ftpsrv_users[0].pass); } } #endif #if DEMOCFG_ENABLE_TELNET_SERVER TELNETSRV_init("Telnet_server", 7, 2000, (RTCS_TASK_PTR) &Telnetd_shell_template ); #endif #if DEMOCFG_ENABLE_KLOG && MQX_KERNEL_LOGGING RTCSLOG_enable(RTCSLOG_TYPE_FNENTRY); RTCSLOG_enable(RTCSLOG_TYPE_PCB); #endif }
void rtcs_init() { IPCFG_IP_ADDRESS_DATA ip_data; _enet_address enet_address; uint_32 error = RTCS_create(); if (error != RTCS_OK) { printf("\nRTCS failed to initialize, error = %X", error); _task_block(); } _IP_forward = TRUE; #ifdef BSP_ENET_DEVICE_COUNT #if (BSP_ENET_DEVICE_COUNT > 0) /*Following section is relevant only in case there as some enet driver available in BSP (FEC, MACNET, WIFI or other enet driver)*/ ip_data.ip = ENET_IPADDR; ip_data.mask = ENET_IPMASK; ip_data.gateway = ENET_GATEWAY; /* calcualte unique mac address from IP ADDRES */ ENET_get_mac_address (ENET_DEVICE, ENET_IPADDR, enet_address); error = ipcfg_init_device (ENET_DEVICE, enet_address); if (error != RTCS_OK) { printf("\nFailed to initialize ethernet device, error = %X", error); _task_block(); } #if RTCSCFG_ENABLE_LWDNS LWDNS_server_ipaddr = ENET_GATEWAY; ipcfg_add_dns_ip(ENET_DEVICE,LWDNS_server_ipaddr); #endif /* RTCSCFG_ENABLE_LWDNS */ printf("\nWaiting for ethernet cable plug in ... "); while(!ipcfg_get_link_active(ENET_DEVICE)) {}; printf("Cable connected\n"); #if RTCS_DHCP printf("Contacting DHCP server ... "); error = ipcfg_bind_dhcp_wait(ENET_DEVICE, FALSE, &ip_data); #else printf("Setting static IP address ... "); error = ipcfg_bind_staticip (ENET_DEVICE, &ip_data); #endif /* RTCS_DHCP */ if (error != IPCFG_ERROR_OK) { printf("\nRTCS failed to bind interface with IPv4, error = %X", error); _task_block(); } else { printf("OK\n"); } ipcfg_get_ip(ENET_DEVICE, &ip_data); printf("\nIP Address : %d.%d.%d.%d\n",IPBYTES(ip_data.ip)); printf("\nSubnet Address : %d.%d.%d.%d\n",IPBYTES(ip_data.mask)); printf("\nGateway Address : %d.%d.%d.%d\n",IPBYTES(ip_data.gateway)); printf("\nDNS Address : %d.%d.%d.%d\n",IPBYTES(ipcfg_get_dns_ip(ENET_DEVICE,0))); #endif /* BSP_ENET_DEVICE_COUNT > 0 */ #endif /* BSP_ENET_DEVICE_COUNT */ #if RTCS_PPP PPP_start(); #endif /* RTCS_PPP */ /* TODO: start server(s) in separate tasks */ }