static int32_t Shell_ipconfig_init (uint32_t enet_device, uint32_t index, int32_t argc, char *argv[]) { uint32_t error; _enet_address mac; ipcfg_get_mac(enet_device, mac); mac[5] += enet_device; if (argc > ++index) { if (! Shell_parse_enet_address(argv[index], mac)) { printf ("Error init ethernet device %d, invalid MAC address!\n", enet_device); return SHELL_EXIT_ERROR; } } error = ipcfg_init_device (enet_device, mac); if (error != 0) { printf ("Error init ethernet device %d, interface error %08x!\n", enet_device, error); return SHELL_EXIT_ERROR; } printf ("Ethernet device %d initialization successful.\n", enet_device); return SHELL_EXIT_SUCCESS; }
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; }
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 }
/*TASK*----------------------------------------------------------------- * * Function Name : main_task * Returned Value : void * Comments : * *END------------------------------------------------------------------*/ void main_task(uint_32 temp) { int_32 error; HTTPD_STRUCT *server[BSP_ENET_DEVICE_COUNT]; extern const HTTPD_CGI_LINK_STRUCT cgi_lnk_tbl[]; extern const TFS_DIR_ENTRY tfs_data[]; HTTPD_PARAMS_STRUCT *params[BSP_ENET_DEVICE_COUNT]; _enet_address address[BSP_ENET_DEVICE_COUNT]; uint_32 phy_addr[BSP_ENET_DEVICE_COUNT]; uint_32 ip_addr[BSP_ENET_DEVICE_COUNT]; uint_32 i = 0; char* indexes[BSP_ENET_DEVICE_COUNT]; uint_8 n_devices = BSP_ENET_DEVICE_COUNT; #if DEMOCFG_USE_WIFI ENET_ESSID ssid; uint_32 mode;// = DEMOCFG_NW_MODE; uint_32 sectype;// = DEMOCFG_SECURITY; ENET_MEDIACTL_PARAM param; #endif #if RTCSCFG_ENABLE_IP6 IPCFG6_GET_ADDR_DATA data[RTCSCFG_IP6_IF_ADDRESSES_MAX]; char prn_addr6[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"]; uint_32 n = 0; uint_32 j = 0; #endif _int_install_unexpected_isr(); /*---------------- Initialize devices and variables ----------------------*/ _RTCSPCB_init = 4; _RTCSPCB_grow = 2; _RTCSPCB_max = 8; _RTCSTASK_stacksize = 4500; /*--------------------------- Init end -----------------------------------*/ PORT_PCR_REG(PORTC_BASE_PTR, 3) = PORT_PCR_MUX(5); // SIM_SOPT2 |= 3<<5; // 1k LPO error = RTCS_create(); if (error != RTCS_OK) { printf("RTCS failed to initialize, error = 0x%X\n", error); _task_block(); } _IP_forward = TRUE; for (i = 0; (i < n_devices) && (n_devices != 0); i++) { IPCFG_IP_ADDRESS_DATA ip_data; phy_addr[i] = i; ip_addr[i] = IPADDR(A,B,C+i,D); ENET_get_mac_address (phy_addr[i], ip_addr[i], address[i]); /* Init ENET device */ error = ipcfg_init_device (phy_addr[i], address[i]); if (error != RTCS_OK) { printf("IPCFG: Device n.%d init failed. Error = 0x%X\n", i, error); _task_set_error(MQX_OK); n_devices--; i--; continue; } #if RTCSCFG_ENABLE_IP4 ip_data.ip = ip_addr[i]; ip_data.mask = ENET_IPMASK; ip_data.gateway = 0; /* Bind IPv4 address */ //error = ipcfg_bind_staticip (phy_addr[i], &ip_data); error = ipcfg_bind_autoip (phy_addr[i], &ip_data); if (error != RTCS_OK) { printf("\nIPCFG: Failed to bind IP address. Error = 0x%X", error); _task_block(); } #endif /* RTCSCFG_ENABLE_IP4 */ indexes[i] = (char*) _mem_alloc(sizeof("\\index_x.html")); } error = _io_tfs_install("tfs:", tfs_data); #if DEBUG__MESSAGES printf("Preparing http servers...\n"); #endif for (i = 0; i < n_devices; i++) { params[i] = httpd_default_params(NULL); params[i]->af = HTTP_INET_AF; //IPv4+IPv6, set connection family from config.h #if RTCSCFG_ENABLE_IP6 params[i]->if_scope_id = HTTP_SCOPE_ID; // set interface number here. 0 is any . #endif if (params[i]) { sprintf(indexes[i], "\\index.html", i); params[i]->root_dir = (HTTPD_ROOT_DIR_STRUCT*)root_dir; params[i]->index_page = indexes[i]; printf("Starting http server No.%d on IP", i); /* ** If there is only one interface listen on any IP address ** so address can change in runtime (DHCP etc.) */ #if RTCSCFG_ENABLE_IP4 if ((i == 0) && (n_devices == 1)) { params[i]->address = INADDR_ANY; } else { params[i]->address = ip_addr[i]; } /* Print active ip addresses */ printf(" %d.%d.%d.%d", IPBYTES(ip_addr[i])); #endif #if RTCSCFG_ENABLE_IP6 while(!ipcfg6_get_addr_info_n(i, n, &data[n])) { n++; } while(j < n) { if(inet_ntop(AF_INET6, &data[j++].ip_addr, prn_addr6, sizeof(prn_addr6))) { /* Print active ip addresses */ #if RTCSCFG_ENABLE_IP4 printf("%s %s", (HTTP_INET_AF & AF_INET) ? " and" : "", prn_addr6); #else printf(" %s", prn_addr6); #endif } } #endif #if PSP_MQX_CPU_IS_MCF5223X params[i]->max_ses = 1; #else params[i]->max_ses = _RTCS_socket_part_max - 1; #endif server[i] = httpd_init(params[i]); } HTTPD_SET_PARAM_CGI_TBL(server[i], (HTTPD_CGI_LINK_STRUCT*)cgi_lnk_tbl); #if HTTPD_SEPARATE_TASK || !HTTPDCFG_POLL_MODE printf("..."); error = httpd_server_run(server[i]); if (error) { printf("[FAIL]\n"); } else { printf("[OK]\n"); } #endif } /* user stuff come here */ #if HTTPD_SEPARATE_TASK || !HTTPDCFG_POLL_MODE _task_create(0, SHELL_TASK, 0); _task_block(); #else printf("Servers polling started.\n") while (1) { for (i = 0; i < n_devices; i++) { httpd_server_poll(server[i], 1); } /* user stuff come here - only non blocking calls */ } #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 */ }