/* * Extract MAC address from vxboot string */ LOCAL STATUS sysNetBootLineMacAddrGet ( int ifUnit, UINT8 * macAddr, int ifMacAddrLen ) { char* bootLine; BOOT_PARAMS params; if ((ifUnit > 1) ||(macAddr == NULL) || (ifMacAddrLen < 6)) { return(ERROR); } bootLine = BOOT_LINE_ADRS; if (usrBootLineCrack(bootLine, ¶ms) != OK) { return (ERROR); } if (params.other [0] != EOS) { int intArr[6]; char *pStr; int ix, jx; /* extract enet MAC address from 'other' parameter */ pStr = params.other; for(jx = 0; jx <=1; jx++) { if ((pStr = strstr(pStr, ";mac=")) != NULL) { if (sscanf(&pStr[5], "%02x:%02x:%02x:%02x:%02x:%02x", &intArr[0], &intArr[1], &intArr[2], &intArr[3], &intArr[4], &intArr[5]) == 6) { if (ifUnit == jx) { for (ix = 0; ix < 6; ix++) { macAddr[5 - ix] = intArr[ix]; } return (OK); } else { pStr += 5; } } } } } return(ERROR); }
/****************************************************************************** * 函数名称: ftpDownload * 函数功能: 通过FTP从PC机下载文件到指定的地址 * 创建日期: 2003-04-25 * 作 者: 邱文 * 输入参数: CHAR *fileName: 要下载的文件名 CHAR *TEMPBUFFER: 存放在系统内存的起始地址 * 输出参数: 无 * 返 回: fileLength(文件长度),失败返回0 * 被调函数:ftpXfer() and ftpCommand() * 调用函数:bsp_menu_ftpDownload() *******************************************************************************/ LOCAL DWORD ftpDownload_ALTERA ( BYTE *fileName, BYTE *TEMPBUFFER ) { BOOT_PARAMS params; int dataSock; int ctrlSock; CHAR buf[1024]; SDWORD nBytes; DWORD fileLength = 0; SDWORD status; BYTE *tempBuffer = TEMPBUFFER; if ( ( NULL == fileName ) || ( NULL == tempBuffer ) ) { return 0; } if (usrBootLineCrack (BOOT_LINE_ADRS, ¶ms) != OK) { printf("根启动参数无效 \n"); return (0); } if (ftpXfer (params.had, params.usr, params.passwd, "", "RETR %s", "", fileName,&ctrlSock, &dataSock) == ERROR) { printf("下载文件 \"%s\" 出错 \n", fileName); return (0); } while ((nBytes = read (dataSock, buf, sizeof (buf))) > 0) { memcpy (tempBuffer, buf, nBytes); fileLength += nBytes; tempBuffer += nBytes; } /* BSP_MENU_PRINT(" 拷贝到缓冲区成功\n");*/ close (dataSock); /* BSP_MENU_PRINT(" 关闭文件成功\n");*/ if (fileLength > 0) { status = OK; if (ftpCommand (ctrlSock, "QUIT", 0, 0, 0, 0, 0, 0) != FTP_COMPLETE) status = ERROR; close (ctrlSock); /*printf("\r\nFTP下载成功, 文件长度为 %d",fileLength);*/ return fileLength; } else { #if 0 if (nBytes < 0) /* read error? */ status = 0; if (ftpReplyGet (ctrlSock, TRUE) != FTP_COMPLETE) status = 0; #endif if (ftpCommand (ctrlSock, "QUIT", 0, 0, 0, 0, 0, 0) != FTP_COMPLETE) { status = 0; } close (ctrlSock); printf("FTP下载失败\n"); return 0; } }
STATUS usrVxFusionInit ( char * bootString /* boot parameter string */ ) { STATUS rval; /* the return val from distInit() */ BOOT_PARAMS params; /* boot paramters */ char ipStrAddr [INET_ADDR_LEN]; /* ip address portion of string */ u_long ipAddress; /* ipAddress in integer form */ char *pLoc; /* ptr to delimiting character */ char bootDevStr [BOOT_DEV_LEN]; /* boot device */ char interface [BOOT_DEV_LEN]; /* interface */ if (bootString == NULL) bootString = BOOT_LINE_ADRS; /* interpret boot command */ if (usrBootLineCrack (bootString, ¶ms) != OK) return (ERROR); /* * Determine the booting network interface. If the booting interface is * a non-shared memory interface, assume it is an ethernet interface * and use the ethernet internet address as the node id. If the booting * interface is a shared memory interface, use the backplane internet * address as the node id. * * Once these values are determined, call distInit() filling in the rest * of the parameters using the default values. */ strcpy (bootDevStr, params.bootDev); if ( strncmp (bootDevStr, "sm=",3) == 0) { /* Shared memory */ pLoc = strchr (bootDevStr,'='); if (pLoc) *pLoc = '\0'; sprintf (interface,"%s%d",bootDevStr, params.unitNum); strncpy (ipStrAddr, params.bad, INET_ADDR_LEN); ipStrAddr[INET_ADDR_LEN-1] = '\0'; pLoc = strchr (ipStrAddr,':'); /* Strip subnet mask */ if (pLoc) *pLoc = '\0'; ipAddress = inet_network (ipStrAddr); } else { /* Not shared memory - assume an ethernet interface */ pLoc = strchr (bootDevStr,'('); if (pLoc) *pLoc = '\0'; sprintf (interface,"%s%d",bootDevStr, params.unitNum); strncpy (ipStrAddr, params.ead, INET_ADDR_LEN); ipStrAddr[INET_ADDR_LEN-1] = '\0'; pLoc = strchr (ipStrAddr,':'); /* Strip subnet mask */ if (pLoc) *pLoc = '\0'; ipAddress = inet_network (ipStrAddr); } printf ("Initializing VxFusion with parameters: \n"); printf (" node id: 0x%lx\n", ipAddress); printf (" interface: %s\n", interface); printf (" max number of TBufs: %u\n", 1 << DIST_MAX_TBUFS_LOG2_DFLT); printf (" max number of nodes in node DB: %u\n", 1 << DIST_MAX_NODES_LOG2_DFLT); printf (" max number of queues on this node: %u\n", 1 << DIST_MAX_QUEUES_LOG2_DFLT); printf (" max number of groups in group DB: %u\n", 1 << DIST_MAX_GROUPS_LOG2_DFLT); printf (" max number of entries in name DB: %u\n", 1 << DIST_MAX_NAME_DB_ENTRIES_LOG2_DFLT); printf (" number of clock ticks to wait: "); if (DIST_MAX_TICKS_TO_WAIT_DFLT < 0) { printf ("FOREVER\n"); } else { printf ("%d\n", DIST_MAX_TICKS_TO_WAIT_DFLT); } rval = distInit (ipAddress, distIfUdpInit, interface, DIST_MAX_TBUFS_LOG2_DFLT, DIST_MAX_NODES_LOG2_DFLT, DIST_MAX_QUEUES_LOG2_DFLT, DIST_MAX_GROUPS_LOG2_DFLT, DIST_MAX_NAME_DB_ENTRIES_LOG2_DFLT, DIST_MAX_TICKS_TO_WAIT_DFLT ); if (rval != OK) { printf ("Unable to initialize VxFusion.\n"); return (ERROR); } printf ("VxFusion initialization successful.\n"); return (OK); }