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

📄 pppradiuscomponent.c

📁 Radius PNE 3.3 source code, running at more than vxworks6.x version.
💻 C
📖 第 1 页 / 共 5 页
字号:
    {    return ERROR;    }    }/******************************************************************************** radiusStackDataShow - show connection data***/LOCAL STATUS radiusStackDataShow    (    PFW_PLUGIN_OBJ_STATE * pComponentState    )    {    return OK;    }/******************************************************************************** radiusProcessServerConfig - Parse RADIUS server configuration string** The RADIUS server configuration can be either*      1. Any*      2. All*      3. List of IP address, port number*/LOCAL void radiusProcessServerConfig    (    char               * configString,    RADIUS_SERVER_DATA * serverData,    PFW_OBJ            * pfw    )    {    char * str;    int i;    bzero ((void *) serverData, sizeof (RADIUS_SERVER_DATA));    /* RADIUS server is set to ANY - default */    serverData->serverFlag = RADIUS_SERVER_ANY;    serverData->serverHandle = INVALID_HANDLE;    if ((strcmp(configString, "ANY") == 0) ||        (strcmp(configString, "Any") == 0) ||        (strcmp(configString, "any") == 0))        {        /* RADIUS server is set to ANY */        return;        }    if ((strcmp(configString, "ALL") == 0) ||        (strcmp(configString, "All") == 0) ||        (strcmp(configString, "all") == 0))        {        /* RADIUS server is set to ALL */        serverData->serverFlag = RADIUS_SERVER_ALL;        return;        }    if ((serverData->serverString = (char *)            pfwMalloc (pfw, strlen(configString) + 1)) == NULL)        {        return;        }    bzero((void *) serverData->serverString, strlen(configString) + 1);    strcpy(serverData->serverString, configString);    str = serverData->serverString;    /* Coverity bugs fix, SPR 119177, coverity is failing to check for NULL in while loop */    if (str == NULL)        return;    /*     * The configuration string format should be     *      a.b.c.d, port: w.x.y.z, port ...     */    /*     * Since the IPv6 address formatting contains "colon"     * between every 2 bytes, the configuration string format     * should be as follows,     * In the case of IPv6 address,     *        a:b:c:d:e:f:g:h, port; p:q:r:s:t:u:v:w, port ...     * In the case of IPv4 address,     *        a.b.c.d, port; w.x.y.z, port ...     */    while (str && *str)       {       /* scan for ',' after the IP address */       while (*str && (*str != ',')) str++;       /* server IP address should be followed by ',' */       if (*str == ',')           {           *str = 0;            str ++;            serverData->serverCount ++;           }       else           {           return;           }       /* scan for ';' after the port number */       while (*str && (*str != ';')) str++;       if (*str == ';')           {           *str = 0;            str ++;           }       }    if ((serverData->serverConfig = (RADIUS_SERVER_CONFIG *)               pfwMalloc(pfw, serverData->serverCount *               sizeof (RADIUS_SERVER_CONFIG))) == NULL)       {       return;       }    str = serverData->serverString;    for (i = 0; i < serverData->serverCount; i++)       {       if (strchr(str, ':') != NULL) /* IPv6 address found */         {#ifdef INET6            serverData->serverConfig[i].Ipv6Address = str;            serverData->serverConfig[i].IpAddress = NULL;            str += strlen (str) + 1;#else            logMsg("IPv6 not supported\n",0,0,0,0,0,0);#endif         }       else /* IPv4 address found */        {       serverData->serverConfig[i].IpAddress = str;#ifdef INET6       serverData->serverConfig[i].Ipv6Address = NULL;#endif       str += strlen (str) + 1;       }       serverData->serverConfig[i].portNumber = atoi(str);       str += strlen (str) + 1;       }    serverData->serverFlag = RADIUS_SERVER_OTHER;    }/******************************************************************************** radiusProcessFramedRoute - parse the framed route attribute from server** The format of framed attribute value returned by RADIUS server is a string*  "destination[/mask] gateway metrics ..."**/LOCAL void radiusProcessFramedRoute    (    char * configString,    RADIUS_RECEIVED_ATTRIBUTES * attr,    PFW_OBJ * pfw    )    {    char * pDest = 0;    char * pMask = 0;    char * pGate = 0;    char * str;    ULONG ipAddr;    pDest = str = configString;    /* scan for destination IP address in dot decimal notation */    while (*str && (isdigit((int) *str) || (*str == '.'))) str++;    /* the destination IP address should be followed by space or '/' */    if ((*str != ' ') && (*str != '/'))       {       return;       }    /* see if the destination IP is followed by netmask */    if (*str == '/')       {       *str = 0; str ++;       pMask = str;       while (*str && (isdigit((int) *str))) str++;       if (*str != ' ')          {          return;          }       }    *str = 0; str ++;    pGate = str;    /* scan for gateway IP address in dot decimal notation */    while (*str && (isdigit((int) *str) || (*str == '.'))) str++;    if (*str != ' ')       {       return;       }    *str = 0;    /* free old data, if any */    if (attr->gateway != NULL)        pfwFree(attr->gateway);    if (attr->destination != NULL)        pfwFree(attr->destination);    attr->gateway = pfwMalloc(pfw, strlen(pGate) + 1);    attr->destination = pfwMalloc(pfw, strlen(pDest) + 1);    if (attr->destination != NULL)       strcpy(attr->destination, pDest);    if (attr->gateway != NULL)       strcpy(attr->gateway, pGate);    if (pMask)       {       attr->destMask = 0xffffffff << (32 - atoi(pMask));       }    else       {       /* if netmask is absent,  infer from the destination IP */       ipAddr = inet_addr(pDest);       if (IN_CLASSA(ipAddr))       {           attr->destMask = IN_CLASSA_NET;       }       else if (IN_CLASSB(ipAddr))       {           attr->destMask = IN_CLASSB_NET;           }       else       {           attr->destMask = IN_CLASSC_NET;           }       }    }#ifdef INET6/******************************************************************************** radiusProcessFramedIPv6Route - parse the framed route attribute from server** The format of framed attribute value returned by RADIUS server is a string*  "destination[/mask] gateway metrics ..."**/LOCAL void radiusProcessFramedIPv6Route    (    char * configString,    RADIUS_RECEIVED_ATTRIBUTES * attr,    PFW_OBJ * pfw    )    {    char * pDest = 0;    char * pMask = 0;    char * pGate = 0;    char * str;    pDest = str = configString;    /* scan for destination IPv6 address in colon hexa decimal notation */    while (*str && (isxdigit((int)*str) || (*str) == ':')) str++;    /* the destination IP address should be followed by space or '/' */    if ((*str != ' ') && (*str != '/'))       {       return;       }    /* see if the destination IP is followed by netmask */    if (*str == '/')       {       *str = 0; str++;       pMask = str;       while (*str && (isdigit((int)*str))) str++;       if (*str != ' ')          {          return;          }       }    *str = 0; str++;    pGate = str;    /* scan for gateway IP address in dot decimal notation */    while (*str && (isxdigit((int)*str) || (*str == ':') || (*str == '%') || isalnum((int)*str))) {        str++;    }    if ((*str) != ' ')       {        return;       }    *str = 0;    /* free old data, if any */    if (attr->gatewayIPv6 != NULL)        pfwFree(attr->gatewayIPv6);    if (attr->destinationPrefix != NULL)        pfwFree(attr->destinationPrefix);    attr->gatewayIPv6 = pfwMalloc(pfw, strlen(pGate) + 1);    attr->destinationPrefix = pfwMalloc(pfw, strlen(pDest) + 1);    if (attr->destinationPrefix != NULL)       strcpy(attr->destinationPrefix, pDest);    if (attr->gatewayIPv6 != NULL)       strcpy(attr->gatewayIPv6, pGate);    if (pMask)       {       attr->destPrefixLength = (BYTE)atoi(pMask);       }    else       {       /* if prefix length is absent,  infer from the destination prefix    * or reset to zero. if prefix length is zero, don't use it while    * adding route    */       /* Currently not infering from destination destination prefix and    * setting it to zero.    */       attr->destPrefixLength = 0;       }    }#endif /* INET6 *//******************************************************************************** radius_serviceType**/LOCAL STATUS radius_serviceType    (    PFW_OBJ *pfw,    PFW_PARAMETER_OPERATION_TYPE opertype,    void *pData,    char *value    )    {    char ** pConfigString;    RADIUS_PROFILE_DATA * pProfileData = (RADIUS_PROFILE_DATA *)pData;    pConfigString = &pProfileData->radius_serviceType;    return radius_stringProfileHandler (pfw, opertype,                                        pConfigString, value);    }/******************************************************************************** radius_authenticationServer**/LOCAL STATUS radius_authenticationServer    (    PFW_OBJ *pfw,    PFW_PARAMETER_OPERATION_TYPE opertype,    void *pData,    char *value    )    {    char ** pConfigString;    RADIUS_PROFILE_DATA * pProfileData = (RADIUS_PROFILE_DATA *)pData;    pConfigString = &pProfileData->radius_authenticationServer;    return radius_stringProfileHandler (pfw, opertype,                                        pConfigString, value);    }/******************************************************************************** radius_accountingServer**/LOCAL STATUS radius_accountingServer    (    PFW_OBJ *pfw,    PFW_PARAMETER_OPERATION_TYPE opertype,    void *pData,    char *value    )    {    char ** pConfigString;    RADIUS_PROFILE_DATA * pProfileData = (RADIUS_PROFILE_DATA *)pData;    pConfigString = &pProfileData->radius_accountingServer;    return radius_stringProfileHandler (pfw, opertype,                                        pConfigString, value);    }/******************************************************************************** radius_nasIPaddress**/LOCAL STATUS radius_nasIPaddress    (    PFW_OBJ *pfw,    PFW_PARAMETER_OPERATION_TYPE opertype,    void *pData,    char *value    )    {    char ** pConfigString;

⌨️ 快捷键说明

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