Example #1
0
/*---------------------------------------------------------------------------
 *            OBEXH_ParseAuthChallenge
 *---------------------------------------------------------------------------
 *
 * Synopsis: Applications use this function to collect Authentication
 *           Challenge information as it is indicated in OBxx_HEADER_RX events.
 *           This function converts the raw header data into the provided
 *           structure. It must be called during every OBxx_HEADER_RX event
 *           when the header type is OBEX_AUTH_CHAL.
 *
 * Return:   TRUE when the entire header has been processed.
 */
BOOL OBEXH_ParseAuthChallenge(ObexAppHandle *AppHndl, ObexAuthChallengeInfo *Info)
{
#if OBEX_MAX_REALM_LEN > 0
    U16     toCopy;
#endif
    ObexTlv tlv;

#if XA_ERROR_CHECK == XA_ENABLED
    if (!AppHndl || !Info) {
        return FALSE;
    }
#endif /* XA_ERROR_CHECK == XA_ENABLED */
    ASSERT(AppHndl && Info && IsObexLocked());

    if ((AppHndl->parser).dataLen == 0) {
#if OBEX_MAX_REALM_LEN > 0
        /* Initialize the realm length */
        Info->realmLen = 0;
#endif
    }

    /* Parse Authentication Challenge tags */
    while (OBEXH_ParseTlv(AppHndl, &tlv))
    {
        switch(tlv.tag) {

        case 0: /* Nonce (fixed length, 16 bytes) */
            
            /* If the length is incorrect, clear the NONCE */
            if (tlv.length == AUTH_NONCE_LEN) {
                ASSERT(tlv.valueLen == tlv.length);
                OS_MemCopy(Info->nonce, tlv.value, tlv.valueLen);
            }
            break;

        case 1: /* Options (fixed length, 1 byte) */
            if (tlv.length == 1) {
                Info->options = *tlv.value;
            }
            break;

#if OBEX_MAX_REALM_LEN > 0
        case 2: /* Realm (variable length) */
            toCopy = min(tlv.valueLen, (OBEX_MAX_REALM_LEN - Info->realmLen));

            OS_MemCopy(Info->realm + Info->realmLen, tlv.value, toCopy);
            Info->realmLen += toCopy;
            break;
#endif
        default:
            continue;
        }
    }

    /* Indicate whether the entire header has been parsed. */
    return ((AppHndl->parser).headerLen == 0);
}
Example #2
0
/*---------------------------------------------------------------------------
 *            OBEXH_GetHeader1Byte()
 *---------------------------------------------------------------------------
 *
 * Synopsis:  Returns the value of a 1 byte style header.
 *
 * Return:    Value of header 
 */
U8 OBEXH_GetHeader1Byte(ObexAppHandle *AppHndl)
{
    ObexParser   *oparser;

    ASSERT(AppHndl && IsObexLocked());

    oparser = &AppHndl->parser;
    ASSERT(oparser->rxState == OBSC_RX_PUT_HEAD2);

    return oparser->stageBuff[0];
}
Example #3
0
/*---------------------------------------------------------------------------
 *            OBEXH_GetHeaderBuff()
 *---------------------------------------------------------------------------
 *
 * Synopsis:  Returns a pointer to the current headers buffer. For use
 *            only with Byte Sequence and Unicode headers.
 *
 * Return:    Buffer pointer
 */
U8 *OBEXH_GetHeaderBuff(ObexAppHandle *AppHndl)
{
    ObexParser  *oparser;

    ASSERT(AppHndl && IsObexLocked());

    oparser = &AppHndl->parser;
    ASSERT( oparser->rxState == OBSC_RX_PUT_HEAD3 ||
            oparser->rxState == OBSC_RX_PUT_HEAD2 );

    return oparser->rxBuff;
}
Example #4
0
/*---------------------------------------------------------------------------
 *            OBEXH_GetHeaderAvailLen()
 *---------------------------------------------------------------------------
 *
 * Synopsis:  Returns the currently available (to copy) header length.
 *            For use only with Byte Sequence and Unicode headers.
 *            
 * Return:    Available header length in bytes
 */
U16 OBEXH_GetHeaderAvailLen(ObexAppHandle *AppHndl)
{
    ObexParser  *oparser;

    ASSERT(AppHndl && IsObexLocked());

    oparser = &AppHndl->parser;
    ASSERT(oparser->rxState == OBSC_RX_PUT_HEAD3 ||
           oparser->rxState == OBSC_RX_PUT_HEAD2);

    return oparser->dataLen;
}
Example #5
0
/*---------------------------------------------------------------------------
 *            OBEXH_ParseAuthResponse
 *---------------------------------------------------------------------------
 *
 * Synopsis: Applications use this function to collect Authentication
 *           Response information as it is indicated in OBxx_HEADER_RX events.
 *           This function converts the raw header data into the provided
 *           structure. It must be called during every OBxx_HEADER_RX event
 *           when the header type is OBEX_AUTH_RESP.
 *
 * Return:   TRUE when the entire header has been processed.
 */
BOOL OBEXH_ParseAuthResponse(ObexAppHandle *AppHndl, ObexAuthResponseInfo *Info)
{
#if OBEX_MAX_USERID_LEN > 0
    U16     toCopy;
#endif
    ObexTlv tlv;

#if XA_ERROR_CHECK == XA_ENABLED
    if (!AppHndl || !Info) {
        return FALSE;
    }
#endif /* XA_ERROR_CHECK == XA_ENABLED */
    ASSERT(AppHndl && Info && IsObexLocked());

    if ((AppHndl->parser).dataLen == 0) {
        /* Initialize the User ID length */
#if OBEX_MAX_USERID_LEN > 0
        Info->userIdLen = 0;
#endif
    }

    /* Parse Authentication Response tags */
    while (OBEXH_ParseTlv(AppHndl, &tlv))
    {
        switch(tlv.tag)
        {
        case 0: /* Request-Digest (fixed length, 16 bytes) */
            if (tlv.length == AUTH_NONCE_LEN) {
                OS_MemCopy(Info->digest, tlv.value, tlv.valueLen); 
            }
            break;

#if OBEX_MAX_USERID_LEN > 0
        case 1: /* User Id (variable length) */
            toCopy = min(tlv.valueLen, (OBEX_MAX_USERID_LEN - Info->userIdLen));

            OS_MemCopy(Info->userId + Info->userIdLen, tlv.value, toCopy);
            Info->userIdLen += toCopy;
            break;
#endif /* OBEX_MAX_USERID_LEN > 0 */

        case 2: /* Nonce (fixed length, 16 bytes) */
            if (tlv.length == AUTH_NONCE_LEN) {
                OS_MemCopy(Info->nonce,  tlv.value, tlv.valueLen);
            }
            break;
        }
    }

    /* Indicate whether the entire header has been parsed. */
    return ((AppHndl->parser).headerLen == 0);
}