⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intprismtertap.c

📁 vworks 下wlan的实现代码
💻 C
📖 第 1 页 / 共 4 页
字号:
*/STATUS intPrismTertApFtpDownload    (    char * host,            /* IP addr of host FTP server */    char * user,            /* Username for access to FTP server */    char * pass,            /* Password for access to FTP server */    char * fileName,        /* Name of Tertiary file to transfer */    char * apName,          /* Name to be given to the AP, the SSID */    int apChannel,          /* Channel for the AP to use */    char * wiredDevName,    /* Wired END device name */    int wiredDevNum,        /* Wired END device number */    char * wirelessDevName, /* WLAN END device name */    int wirelessDevNum      /* WLAN END device number */    )    {    char *    pBuffer;    char *    pTmpBuffer;    UINT32    bufferSize = 0;    int       ctrlSock;    int       dataSock;    int       nBytes;    END_OBJ * pWlan;    AP_PARAMS params;    int mode = 0;    UINT16 wepEnable = 0;    UINT16 wepType = 0;    UINT8 wepKey [WLAN_WEP_MAX_KEYSIZE];    UINT16 wepKeyNumber = 0;    BOOL wepAvail = FALSE;    int i = 0;            /* uncomment if adding a STA to the access control list further down...*/    /*  UINT16 station[4]; */    /* create an empty buffer */    pBuffer = (char *) calloc(1, MAX_BUFF_SIZE);    pTmpBuffer = pBuffer;            if (pBuffer == NULL)         {        printf("intPrismTertApFtpDownload: Error - could not allocate"               " buffer of size %i bytes\n", MAX_BUFF_SIZE);        return ERROR;        }        /* open the FTP connection */        /* NOTE: directory is assumed to be current ("") for FTP server */    if (ftpXfer (host, user, pass, "",                 "RETR %s", "", fileName,                 &ctrlSock, &dataSock) == ERROR)        {        printf("intPrismTertApFtpDownload: Error - could not perform ftp "               " transfer\n");                free(pTmpBuffer);                return (ERROR);        }            /* read the file into a buffer */    while ((nBytes = read(dataSock, pBuffer, 512)) > 0)         {        bufferSize += nBytes;        pBuffer = pBuffer + nBytes;        }        if (bufferSize > MAX_BUFF_SIZE)         {        printf("intPrismTertApFtpDownload: Error - buffer for tertiary F/W"               " is too small at %i bytes\n", MAX_BUFF_SIZE);                free(pTmpBuffer);        return ERROR;        }        /* close the FTP connection */    close(dataSock);        if (ftpReplyGet (ctrlSock, TRUE) != FTP_COMPLETE)         {        printf("intPrismTertApFtpDownload: Error - closing FTP connection\n");        free(pTmpBuffer);        return ERROR;        }        if (ftpCommand (ctrlSock, "QUIT", 0, 0, 0, 0, 0, 0) != FTP_COMPLETE)        {        printf("intPrismTertApFtpDownload: Error -closing FTP connection\n");        free(pTmpBuffer);        return ERROR;        }        close(ctrlSock);        pWlan = endFindByName(wirelessDevName, wirelessDevNum);        /* make sure it's an Intersil card */    if ( (pWlan != NULL) &&          ( (((WLAN_DEV *) pWlan)->cardType == WLAN_CARDTYPE_INTERSIL_2) ||           (((WLAN_DEV *) pWlan)->cardType == WLAN_CARDTYPE_INTERSIL_2_5) ||           (((WLAN_DEV *) pWlan)->cardType == WLAN_CARDTYPE_INTERSIL_3)))           {        /* Get the current mode of the card */        intPrismIoctl(pWlan, EIOCGMODE, (caddr_t) &mode);                if (mode == WLAN_CARDMODE_STA)             {            params.cardType = ((WLAN_DEV *) pWlan)->cardType;            params.apName = apName;            params.apChannel = apChannel;            params.apInterfaceNum = wirelessDevNum;              params.wiredDevName = wiredDevName;            params.wiredDevNum = wiredDevNum;            params.pTertiaryBuffer = pTmpBuffer;            params.numBytes = bufferSize;            #if 0            /* this is how one would add a STA to the access control list */            station[0] = 0x0004; /* MAC addr field 1 */            station[1] = 0x5a0c; /* MAC addr field 2 */            station[2] = 0x210f; /* MAC addr field 3 */            station[3] = 0;            if (intPrismIoctl(pWlan, EIOCASTA, (caddr_t) &station) == ERROR)                 {                printf("intPrismTertiApFtpDownload: could not add station to "                       "auth list\n");                }#endif                               /* set mode to AP */            if (intPrismIoctl(pWlan, EIOCSAPMODE, (caddr_t) &params) != ERROR)                 {                printf("intPrismTertApFtpDownload: in AP mode\n");                                /* enable WEP security if so indicated by configWlan.h */                (void) sysWlanCfgParamGet (WLAN_WEP_ENABLE, (INT32) &wepEnable);                  if (wepEnable == TRUE)                     {                    /* Get the wep type (40/64 or 104/128 bit) encryption */                    (void) sysWlanCfgParamGet(WLAN_WEP_TYPE, (INT32) &wepType);                                         if (wepType == WLAN_WEP_TYPE_64)                        {                        for (i = 0; i < WLAN_WEP_NUM_KEYS; i++)                            {                            sysWlanCfgParamGet(WLAN_WEP_KEY0_64 + i,                                                (INT32) wepKey);                            intPrismIoctl((END_OBJ *) pWlan, EIOCSWEPKEY0 + i,                                           (caddr_t) wepKey);                            }                        }                    else if (wepType == WLAN_WEP_TYPE_128)                        {                        sysWlanCfgParamGet(WLAN_WEP_KEY0_128, (INT32)wepKey);                        intPrismIoctl((END_OBJ *)pWlan, EIOCSWEPKEY0,                                       (caddr_t) wepKey);                        }                    /* Get the default wep key number */                    (void) sysWlanCfgParamGet (WLAN_WEP_KEY_NUMBER,                                               (INT32) &wepKeyNumber);                    intPrismIoctl((END_OBJ *) pWlan,                                  EIOCSWEPDEFAULTKEY,                                   (caddr_t)(INT32)wepKeyNumber);                                        /* finally, turn on WEP */                    intPrismIoctl((END_OBJ *) pWlan, EIOCSWEP,                                   (caddr_t)1);                                        /* Check to make sure that WEP was actually enabled */                    intPrismIoctl(pWlan, EIOCGWEPSTATUS, (caddr_t) &wepAvail);                                        if (wepAvail == FALSE)                        {                        printf("intPrismTertApFtpDownload: Error - "                               "WEP was not enabled\n");                        }                    else                        {                        printf("intPrismTertApFtpDownload: WEP Enabled\n");                        }                    }                                } /* end of: if (intPrismIoctl(pWlan, EIOCSAPMODE... != ERROR) */            } /* end of: if (mode == WLAN_CARDMODE_STA) */        else             {            printf("intPrismTertApFtpDownload: currently in AP mode\n");            }        } /* end of: if ( (pWlan != NULL) && ... */      else         {        printf("intPrismTertApFtpDownload: Error - %s%i is not an "               "Intersil/Prism based wlan interface\n",                wirelessDevName, wirelessDevNum);        return ERROR;        }        /* don't forget to free the memory associated with the tert buffer */    if (pTmpBuffer != NULL)         {        free(pTmpBuffer);        }       return OK;    }/* Deprecated routines: kept for backwards compatibility *//****************************************************************************** NOMANUAL - this routine is kept for API compatibility with prior versions, it* is simply a wrapper to the new routine*/   STATUS intPrismApFtpDownload    (    char * host,                char * user,                char * pass,                char * fileName,            char * apName,              int apChannel,              char * wiredDevName,        int wiredDevNum,            char * wirelessDevName,     int wirelessDevNum          )    {    return intPrismTertApFtpDownload(host, user, pass, fileName,                                     apName, apChannel, wiredDevName,                                     wiredDevNum, wirelessDevName,                                      wirelessDevNum);    }/****************************************************************************** NOMANUAL - this routine is kept for API compatibility with prior versions, it* is simply a wrapper to the new routine*/   STATUS intPrismApFileDownload    (    char * tertiaryFilename,    char * apName,              int apChannel,              char * wiredDevName,        int wiredDevNum,            char * wirelessDevName,     int wirelessDevNum          )    {    return intPrismTertApFileDownload(tertiaryFilename, apName, apChannel,                                      wiredDevName, wiredDevNum,                                      wirelessDevName, wirelessDevNum);    }/****************************************************************************** NOMANUAL - this routine is kept for API compatibility with prior versions, it* is simply a wrapper to the new routine*/   void intPrismApChannelInfoOutput    (    LTV_RECORD * pltv    )     {    intPrismTertApChannelInfoOutput(pltv);    }/****************************************************************************** NOMANUAL - this routine is kept for API compatibility with prior versions, it* is simply a wrapper to the new routine*/   void intPrismApChannelInfoShow    (    UINT16 scanTime    )    {    intPrismTertApChannelInfoShow(scanTime);    }/****************************************************************************** NOMANUAL - this routine is kept for API compatibility with prior versions, it* is simply a wrapper to the new routine*/   BOOL intPrismApStationAuthenticate    (    UINT16 mac1,      UINT16 mac2,      UINT16 mac3,      UINT8 authType    )     {    return intPrismTertApStaAuthenticate(mac1, mac2, mac3, authType);    }/****************************************************************************** NOMANUAL - this routine is kept for API compatibility with prior versions, it* is simply a wrapper to the new routine*/   void intPrismApStationListShow(void)     {    intPrismTertApStaListShow();    }/****************************************************************************** NOMANUAL - this routine is kept for API compatibility with prior versions, it* is simply a wrapper to the new routine*/   STATUS intPrismApStationRemove    (    UINT16 mac1,      UINT16 mac2,      UINT16 mac3,      UINT8 authType    )    {    return intPrismTertApStaRemove(mac1, mac2, mac3, authType);    }/****************************************************************************** NOMANUAL - this routine is kept for API compatibility with prior versions, it* is simply a wrapper to the new routine*/   STATUS intPrismApStationAdd    (    UINT16 mac1,      UINT16 mac2,      UINT16 mac3,      UINT8 authType    )    {    return intPrismTertApStaAdd(mac1, mac2, mac3, authType);    }/****************************************************************************** NOMANUAL - this routine is kept for API compatibility with prior versions, it* is simply a wrapper to the new routine*/   STATUS intPrismApStart    (    char * pTertiaryBuffer,    UINT32 numBytes            )     {    return intPrismTertApStart(pTertiaryBuffer, numBytes);    }/****************************************************************************** NOMANUAL - this routine is kept for API compatibility with prior versions, it* is simply a wrapper to the new routine*/   STATUS intPrismApInit    (    UINT16 paramCardType,       char * paramApName,         UINT16 paramApChannel,          UINT16 paramApInterfaceNum,     char * paramWiredDevName,       UINT16 paramWiredDevNum         )    {    return (intPrismTertApInit(paramCardType, paramApName, paramApChannel,                                paramApInterfaceNum, paramWiredDevName,                                paramWiredDevNum));    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -