tZGBool ExtractandValidateRfChannelList(tZGS8  *p_string, tZGU8 *p_rfchan)
{
    tZGS8 *p1, *p2;
    tZGU8  index =0;
    tZGU16  temp;

    if ( strlen( (char*) p_string) == 0u ) return kZGBoolFalse;

    p1 = p2 = p_string;

    do
    {

       if ( (p2 = (tZGS8 *) strchr( (const char *) p1, (int) ',')) != NULL )
       {
          *p2='\0';
          p2++;
       }

       if( !ConvertASCIIUnsignedDecimalToBinary(p1, &temp) )
          return  kZGBoolFalse;

       p1 = p2;
       p_string[index] = (tZGU8) temp;
       index++;

    } while (  p2 != NULL );



    *p_rfchan = index;
    return kZGBoolTrue;
}
Exemple #2
0
static BOOL iwconfigSetChannel(void)
{
    UINT8 *p1, *p2;
    UINT8 *p_channelList;
    UINT8 index = 0;
    UINT16 temp;

    if (ARGC < 3u)
    {
        WFConsolePrintRomStr("Missing value for last parameter", TRUE);
        return FALSE;
    }

    if ( !iwconfigCb.isIdle )
    {
        WFConsolePrintRomStr("Channel can only be set in idle mode", TRUE);
        return FALSE;
    }

    p_channelList = (UINT8*) ARGV[2];
    p1 = p2 = p_channelList;

    if ( strlen( (char*) p_channelList) == 0u )
        return FALSE;

    if ( (3u <= ARGC) && (strcmppgm2ram((char*)ARGV[2], "all") == 0) )
    {
        WF_CASetChannelList(p_channelList, 0); // reset to domain default channel list
        return TRUE;
    }

    do
    {
        if ( (p2 = (UINT8*) strchr( (const char *) p1, (int) ',')) != NULL )
        {
            *p2='\0';
            p2++;
        }

        if( !ConvertASCIIUnsignedDecimalToBinary((INT8 *)p1, &temp) )
            return  FALSE;

        p1 = p2;
        p_channelList[index] = (UINT8) temp;
        index++;

    } while (  p2 != NULL );

    WF_CASetChannelList(p_channelList, index);

    return TRUE;
}
tZGBool ExtractandValidateU16Range(tZGS8 *p_string, tZGU16 *pValue, tZGU16 minValue, tZGU16 maxValue)
{
    /* extract next parameter as an unsigned short integer */
    if (!ConvertASCIIUnsignedDecimalToBinary(p_string, pValue))
    {
        /* ZGConsolePrintf("   Unable to parse paramter value"); */
        return kZGBoolFalse;
    }

    if ((*pValue < minValue) || (*pValue > maxValue))
    {
        /* ZGConsolePrintf("   parameter value out of range"); */
        return kZGBoolFalse;
    }

    return kZGBoolTrue;
}
Exemple #4
0
static BOOL iwconfigSetRTS(void)
{
    UINT16 rtsThreshold;

    if (ARGC < 3u)
    {
        WFConsolePrintRomStr("Missing value for last parameter", TRUE);
        return FALSE;
    }

    if( !ConvertASCIIUnsignedDecimalToBinary(ARGV[2], &rtsThreshold) )
        return  FALSE;

    WF_SetRtsThreshold(rtsThreshold);

    return TRUE;
}
BOOL ExtractandValidateU16Range(INT8 *p_string, UINT16 *pValue, UINT16 minValue, UINT16 maxValue)
{
    /* extract next parameter as an unsigned short integer */
    if (!ConvertASCIIUnsignedDecimalToBinary(p_string, pValue))
    {
        /* WFConsolePrintf("   Unable to parse paramter value"); */
        return FALSE;
    }

    if ((*pValue < minValue) || (*pValue > maxValue))
    {
        /* WFConsolePrintf("   parameter value out of range"); */
        return FALSE;
    }

    return TRUE;
}
Exemple #6
0
bool ExtractandValidateU16Range(int8_t *p_string, uint16_t *pValue, uint16_t minValue, uint16_t maxValue)
{
    /* extract next parameter as an unsigned short integer */
    if (!ConvertASCIIUnsignedDecimalToBinary(p_string, pValue))
    {
        /* IperfConsolePrintf("   Unable to parse paramter value"); */
        return false;
    }

    if ((*pValue < minValue) || (*pValue > maxValue))
    {
        /* IperfConsolePrintf("   parameter value out of range"); */
        return false;
    }

    return true;
}
tZGBool ExtractandValidateRts(tZGS8 *p_string, tZGU16 *p_rts)
{
    // extract RTS
    if (!ConvertASCIIUnsignedDecimalToBinary(p_string, p_rts))
    {
        sprintf( (char *) g_ConsoleContext.txBuf,
                  "   Unable to parse RTS");
        ZG_PUTSUART( (char *) g_ConsoleContext.txBuf );
        return kZGBoolFalse;
    }

    if ((*p_rts < 256u) || (*p_rts > 2347u))
    {
        sprintf( (char *) g_ConsoleContext.txBuf,
                 "   RTS out of range");

        ZG_PUTSUART( (char *) g_ConsoleContext.txBuf );

        return kZGBoolFalse;
    }

    return kZGBoolTrue;
}
Exemple #8
0
static tZGBool isIPAddress(tZGS8 *p_string, tZGU8 *p_Address)
{
    tZGU8 digIndex = 0;
    tZGU8 bufIndex = 0;
    tZGU8 dotCount = 0;
    tZGS8 buf[4];
    tZGU8 i;
    tZGU16 tmp;

    memset(buf, 0x00, sizeof(buf));
    for (i = 0; i < strlen((char *)p_string); ++i)
    {
        // if gathering digits
        if (isdigit(p_string[i]))
        {
            // store digit in buf, fail if user has more than 3 digits
            buf[bufIndex++] = p_string[i];
            if (bufIndex > 3u)
            {
                return kZGBoolFalse;
            }
        }
        // else encountered a dot
        else if (p_string[i] == (tZGS8)'.')
        {
            // keep track of dots and fail if we encounter too many of them
            ++dotCount;
            if (dotCount > 3u)
            {
                return kZGBoolFalse;
            }

            // convert the number we just pulled from the input string, fail if not a number
            if (!ConvertASCIIUnsignedDecimalToBinary(buf, &tmp))
            {
                return kZGBoolFalse;
            }
            // else a valid number
            else
            {
                // fail if greater than 255
                if ( tmp > 255u)
                {
                    return kZGBoolFalse;
                }

                 p_Address[digIndex] = (tZGU8) (tmp & 0xFF);

                // get ready for next number
                memset(buf, 0x00, sizeof(buf));
                bufIndex = 0;
                ++digIndex;
            }
        }
        // else got a character that is neither number nor dot
        else
        {
            return kZGBoolFalse;
        }

    }

    // fail if more than 3 dots
    if (dotCount != 3u)
    {
        return kZGBoolFalse;
    }

    // if made it here then make sure we have the last number
    if (buf[0] == 0)
    {
        return kZGBoolFalse;
    }

    // convert last number to binary, fail if we can't
    if (!ConvertASCIIUnsignedDecimalToBinary(buf, &tmp))
    {
        return kZGBoolFalse;
    }

    p_Address[digIndex] = (tZGU8) (tmp & 0xFF);

    // IP digits will be in p_Address[]
    return kZGBoolTrue;
}