owamp/protocol.c
/*
 * Function:        _OWPReadTestRequestSlots
 *
 * Description:        
 *         This function reads nslot slot descriptions off of the socket.
 *         If slots is non-null, each slot description is decoded and
 *         placed in the "slots" array. It is assumed to be of at least
 *         length "nslots". If "slots" is NULL, then nslots are read
 *         off the socket and discarded.
 *
 *         The _OWPDecodeSlot function is called to decode each individual
 *         slot. Then the last block of integrity zero padding is checked
 *         to complete the reading of the TestRequest.
 *
 *         The formats are as follows:
 *
 *         size: Each Slot is 16 octets. All slots are followed by 16 octets
 *         of Integrity Zero Padding.
 *
 *            0                   1                   2                   3
 *            0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 *          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *        00|    Slot Type  |                                               |
 *          +-+-+-+-+-+-+-+-+              MBZ                              +
 *        04|                                                               |
 *          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *        08|                 Slot Parameter (Timestamp)                    |
 *        12|                                                               |
 *          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *          ...
 *          ...
 *          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *        00|                                                               |
 *      04|                Integrity Zero Padding (16 octets)             |
 *      08|                                                               |
 *      12|                                                               |
 *          +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 *
 * In Args:        
 *
 * Out Args:        
 *
 * Scope:        
 * Returns:        
 * Side Effect:        
 */
_OWPReadTestRequestSlots
Description:
This function reads nslot slot descriptions off of the socket.
If slots is non-null, each slot description is decoded and
placed in the "slots" array. It is assumed to be of at least
length "nslots". If "slots" is NULL, then nslots are read
off the socket and discarded.

The _OWPDecodeSlot function is called to decode each individual
slot. Then the last block of integrity zero padding is checked
to complete the reading of the TestRequest.

The formats are as follows.

Each Slot is 16 octets. All slots are followed by 16 octets
of Integrity Zero Padding.



In Args.

Out Args.

Side Effect.
_OWPReadTestRequestSlots Description : This function reads nslot slot descriptions off of the socket . If slots is non - null each slot description is decoded and placed in the " slots " array . It is assumed to be of at least length " nslots " . If " slots " is NULL then nslots are read off the socket and discarded . The _OWPDecodeSlot function is called to decode each individual slot . Then the last block of integrity zero padding is checked to complete the reading of the TestRequest . The formats are as follows . Each Slot is 16 octets . All slots are followed by 16 octets of Integrity Zero Padding . In Args . Out Args . Side Effect .
static OWPErrSeverity
_OWPReadTestRequestSlots(
        OWPControl  cntrl,
        int         *intr,
        uint32_t   nslots,
        OWPSlot     *slots
        )
{
    char        *buf = (char *)cntrl->msg;
    uint32_t    i;
    int         len;
    if(!_OWPStateIs(_OWPStateTestRequestSlots,cntrl)){
        OWPError(cntrl->ctx,OWPErrFATAL,OWPErrINVALID,
                "_OWPReadTestRequestSlots called in wrong state.");
        return OWPErrFATAL;
    }
    for(i=0;i<nslots;i++){
        if((len =_OWPReceiveBlocksIntr(cntrl,(uint8_t *)&buf[0],1,intr)) != 1){
            cntrl->state = _OWPStateInvalid;
            if((len < 0) && *intr && (errno==EINTR)){
                return OWPErrFATAL;
            }
            OWPError(cntrl->ctx,OWPErrFATAL,OWPErrUNKNOWN,
                    "_OWPReadTestRequestSlots: Read Error: %M");
            return OWPErrFATAL;
        }
        _OWPRecvHMACAdd(cntrl,buf,1);
        if(!slots){
            continue;
        }
        if(_OWPDecodeSlot(&slots[i],cntrl->msg) != OWPErrOK){
            OWPError(cntrl->ctx,OWPErrFATAL,OWPErrINVALID,
                    "_OWPReadTestRequestSlots: Invalid Slot");
            cntrl->state = _OWPStateInvalid;
            return OWPErrFATAL;
        }
    }
    if((len=_OWPReceiveBlocksIntr(cntrl,(uint8_t *)&buf[0],1,intr)) != 1){
        cntrl->state = _OWPStateInvalid;
        if((len<0) && *intr && (errno == EINTR)){
            return OWPErrFATAL;
        }
        OWPError(cntrl->ctx,OWPErrFATAL,OWPErrUNKNOWN,
                "_OWPReadTestRequestSlots: Read Error: %M");
        return OWPErrFATAL;
    }
    if(!_OWPRecvHMACCheckClear(cntrl,buf)){
        OWPError(cntrl->ctx,OWPErrFATAL,OWPErrINVALID,
                "_OWPReadTestRequestSlots: Invalid HMAC");
        cntrl->state = _OWPStateInvalid;
        return OWPErrFATAL;
    }
    cntrl->state &= ~_OWPStateTestRequestSlots;
    return OWPErrOK;
}
static OWPErrSeverity _OWPReadTestRequestSlots ( OWPControl cntrl , int * intr , uint32_t nslots , OWPSlot * slots ) { char * buf = ( char * ) cntrl -> msg ; uint32_t i ; int len ; if ( ! _OWPStateIs ( _OWPStateTestRequestSlots , cntrl ) ) { OWPError ( cntrl -> ctx , OWPErrFATAL , OWPErrINVALID , " " ) ; return OWPErrFATAL ; } for ( i = 0 ; i < nslots ; i ++ ) { if ( ( len = _OWPReceiveBlocksIntr ( cntrl , ( uint8_t * ) & buf [ 0 ] , 1 , intr ) ) != 1 ) { cntrl -> state = _OWPStateInvalid ; if ( ( len < 0 ) && * intr && ( errno == EINTR ) ) { return OWPErrFATAL ; } OWPError ( cntrl -> ctx , OWPErrFATAL , OWPErrUNKNOWN , " " ) ; return OWPErrFATAL ; } _OWPRecvHMACAdd ( cntrl , buf , 1 ) ; if ( ! slots ) { continue ; } if ( _OWPDecodeSlot ( & slots [ i ] , cntrl -> msg ) != OWPErrOK ) { OWPError ( cntrl -> ctx , OWPErrFATAL , OWPErrINVALID , " " ) ; cntrl -> state = _OWPStateInvalid ; return OWPErrFATAL ; } } if ( ( len = _OWPReceiveBlocksIntr ( cntrl , ( uint8_t * ) & buf [ 0 ] , 1 , intr ) ) != 1 ) { cntrl -> state = _OWPStateInvalid ; if ( ( len < 0 ) && * intr && ( errno == EINTR ) ) { return OWPErrFATAL ; } OWPError ( cntrl -> ctx , OWPErrFATAL , OWPErrUNKNOWN , " " ) ; return OWPErrFATAL ; } if ( ! _OWPRecvHMACCheckClear ( cntrl , buf ) ) { OWPError ( cntrl -> ctx , OWPErrFATAL , OWPErrINVALID , " " ) ; cntrl -> state = _OWPStateInvalid ; return OWPErrFATAL ; } cntrl -> state &= ~ _OWPStateTestRequestSlots ; return OWPErrOK ; }
Function:        _OWPReadTestRequestSlots
 Description:
         This function reads nslot slot descriptions off of the socket.
Function : _OWPReadTestRequestSlots Description : This function reads nslot slot descriptions off of the socket .
/*
         * Read slot into buffer.
         */ /*
         * slots will be null if we are just reading the slots
         * to get the control connection in the correct state
         * to respond with a denied Accept message.
         */ /*
         * Decode slot from buffer into slot record.
         */ /*
     * Now read slot HMAC digest
     */ /*
     * Now check the integrity.
     */ /*
     * TestRequestSlots are read, now ready to send AcceptSession message.
     */