SLAP_UCHAR_ARRAY*
SlapVcoUint32ArrayToMacAddr
    (
        ANSC_HANDLE                 hThisObject,
        SLAP_UINT32_ARRAY*          uint32_array
    )
{
    ANSC_STATUS                     returnStatus   = ANSC_STATUS_SUCCESS;
    PSLAP_VAR_CONVERTER_OBJECT      pMyObject      = (PSLAP_VAR_CONVERTER_OBJECT)hThisObject;
    SLAP_UCHAR_ARRAY*               var_ucharArray = (SLAP_UCHAR_ARRAY*         )NULL;
    ULONG                           i              = 0;

    var_ucharArray = (SLAP_UCHAR_ARRAY*)AnscAllocateMemory(sizeof(SLAP_UCHAR_ARRAY) + 6);

    if ( !var_ucharArray )
    {
        return  NULL;
    }
    else
    {
        var_ucharArray->Size     = sizeof(SLAP_UCHAR_ARRAY) + 6;
        var_ucharArray->VarCount = 6;
        var_ucharArray->Syntax   = SLAP_VAR_SYNTAX_ucharArray;
    }

    for ( i = 0; i < (ULONG)AnscGetMin2(uint32_array->VarCount, 6); i++ )
    {
        var_ucharArray->Array.arrayUchar[i] = (UCHAR)uint32_array->Array.arrayUint32[i];
    }

    return  var_ucharArray;
}
Пример #2
0
void
SlapVhoShiftLeftParamList
    (
        ANSC_HANDLE                 hThisObject,
        ANSC_HANDLE                 param_list,
        ULONG                       tbs_num
    )
{
    PSLAP_PARAMETER_LIST            tbs_list  = (PSLAP_PARAMETER_LIST)param_list;
    ULONG                           shift_num = AnscGetMin2(tbs_list->ParamCount, tbs_num);
    ULONG                           ii        = 0;

    for ( ii = 0; ii < shift_num; ii++ )
    {
        SlapCleanVariable((&tbs_list->ParamArray[ii]));
        SlapInitVariable ((&tbs_list->ParamArray[ii]));
    }

    for ( ii = 0; ii < (tbs_list->ParamCount - shift_num); ii++ )
    {
        tbs_list->ParamArray[ii] = tbs_list->ParamArray[ii + shift_num];

        SlapInitVariable((&tbs_list->ParamArray[ii + shift_num]));
    }

    tbs_list->ParamCount -= shift_num;

    return;
}
Пример #3
0
BOOL
AnscAsn1ConcOids
    (
        ANSC_HANDLE                 hAsn1Oid1,
        ANSC_HANDLE                 hAsn1Oid2
    )
{
    PANSC_ASN1_OID                  pAsn1Oid1      = (PANSC_ASN1_OID)hAsn1Oid1;
    PANSC_ASN1_OID                  pAsn1Oid2      = (PANSC_ASN1_OID)hAsn1Oid2;
    ULONG                           ulMinSeqLength = AnscGetMin2(pAsn1Oid1->Length, pAsn1Oid2->Length);
    ULONG                           i              = 0;

    if ( pAsn1Oid1->Length < pAsn1Oid2->Length )
    {
        return  FALSE;
    }

    for ( i = 0; i < ulMinSeqLength; i++ )
    {
        if ( pAsn1Oid1->Identifiers[i] != pAsn1Oid2->Identifiers[i] )
        {
            break;
        }
    }

    if ( i >= ulMinSeqLength )
    {
        return  TRUE;
    }

    return  FALSE;
}
Пример #4
0
int
AnscAsn1CompOids
    (
        ANSC_HANDLE                 hAsn1Oid1,
        ANSC_HANDLE                 hAsn1Oid2
    )
{
    PANSC_ASN1_OID                  pAsn1Oid1      = (PANSC_ASN1_OID)hAsn1Oid1;
    PANSC_ASN1_OID                  pAsn1Oid2      = (PANSC_ASN1_OID)hAsn1Oid2;
    ULONG                           ulMinSeqLength = AnscGetMin2(pAsn1Oid1->Length, pAsn1Oid2->Length);
    ULONG                           i              = 0;

    for ( i = 0; i < ulMinSeqLength; i++ )
    {
        if ( pAsn1Oid1->Identifiers[i] == pAsn1Oid2->Identifiers[i] )
        {
            continue;
        }
        else if ( pAsn1Oid1->Identifiers[i] > pAsn1Oid2->Identifiers[i] )
        {
            return  1;
        }
        else
        {
            return  -1;
        }
    }

    if ( pAsn1Oid1->Length == pAsn1Oid2->Length )
    {
        return  0;
    }
    else if ( pAsn1Oid1->Length > pAsn1Oid2->Length )
    {
        return  1;
    }
    else
    {
        return  -1;
    }

    return  0;
}
Пример #5
0
int
AnscAsn1CompOctetStrings
    (
        ANSC_HANDLE                 hAsn1OctetString1,
        ANSC_HANDLE                 hAsn1OctetString2
    )
{
    PANSC_ASN1_OCTET_STRING         pAsn1OctetString1 = (PANSC_ASN1_OCTET_STRING)hAsn1OctetString1;
    PANSC_ASN1_OCTET_STRING         pAsn1OctetString2 = (PANSC_ASN1_OCTET_STRING)hAsn1OctetString2;
    ULONG                           ulMinStrLength    = AnscGetMin2(pAsn1OctetString1->Length, pAsn1OctetString2->Length);
    ULONG                           i                 = 0;

    for ( i = 0; i < ulMinStrLength; i++ )
    {
        if ( pAsn1OctetString1->Octets[i] == pAsn1OctetString2->Octets[i] )
        {
            continue;
        }
        else if ( pAsn1OctetString1->Octets[i] > pAsn1OctetString2->Octets[i] )
        {
            return  1;
        }
        else
        {
            return  -1;
        }
    }

    if ( pAsn1OctetString1->Length == pAsn1OctetString2->Length )
    {
        return  0;
    }
    else if ( pAsn1OctetString1->Length > pAsn1OctetString2->Length )
    {
        return  1;
    }
    else
    {
        return  -1;
    }

    return  0;
}
Пример #6
0
ANSC_STATUS
TlsCcoCbcSetCompressionArray
    (
        ANSC_HANDLE                 hThisObject,
        void*                       item_array,
        ULONG                       item_count
    )
{
    PTLS_CONN_CONTROLLER_OBJECT     pMyObject        = (PTLS_CONN_CONTROLLER_OBJECT  )hThisObject;
    PTLS_CONNECTION_PARAMS          pConnParams      = (PTLS_CONNECTION_PARAMS       )&pMyObject->ConnectionParams;
    UCHAR*                          pCompressionList = (UCHAR*                       )item_array;
    ULONG                           ulListSize       = AnscGetMin2(item_count, TLS_MAX_CIPHER_SUITE_LIST_LENGTH);
    ULONG                           i                = 0;

    pConnParams->CompressionCount = ulListSize;

    for ( i = 0; i < ulListSize; i++ )
    {
        pConnParams->CompressionArray[i] = pCompressionList[i];
    }

    return  ANSC_STATUS_SUCCESS;
}
ANSC_STATUS
StunScoRetryTimerInvoke
    (
        ANSC_HANDLE                 hThisObject
    )
{
    ANSC_STATUS                     returnStatus      = ANSC_STATUS_SUCCESS;
    PSTUN_SIMPLE_CLIENT_OBJECT      pMyObject         = (PSTUN_SIMPLE_CLIENT_OBJECT    )hThisObject;
    PSTUN_SIMPLE_CLIENT_PROPERTY    pProperty         = (PSTUN_SIMPLE_CLIENT_PROPERTY  )&pMyObject->Property;
    PANSC_TIMER_DESCRIPTOR_OBJECT   pRetryTimerObj    = (PANSC_TIMER_DESCRIPTOR_OBJECT )pMyObject->hRetryTimerObj;
    PANSC_SIMPLE_CLIENT_UDP_OBJECT  pSimpleClientUdp1 = (PANSC_SIMPLE_CLIENT_UDP_OBJECT)pMyObject->hSimpleClientUdp1;
    PSTUN_BSM_INTERFACE             pStunBsmIf        = (PSTUN_BSM_INTERFACE           )pMyObject->hStunBsmIf;

    /*
     * Reliability is accomplished through client retransmissions. Clients SHOULD retransmit the
     * request starting with an interval of 100ms, doubling every retransmit until the interval
     * reaches 1.6s. Retransmissions continue with intervals of 1.6s until a response is received,
     * or a total of 9 requests have been sent. If no response is received by 1.6 seconds after the
     * last request has been sent, the client SHOULD consider the transaction to have failed. In
     * other words, requests would be sent at times 0ms, 100ms, 300ms, 700ms, 1500ms, 3100ms,
     * 4700ms, 6300ms, and 7900ms. At 9500ms, the client considers the transaction to have failed
     * if no response has been received.
     */
    if ( pMyObject->SocketState1 == STUN_SCO_SOCKET_STATE_Requesting )
    {
        if ( pMyObject->RetransTime1 >= STUN_MIN_RETRANSMISSION_TIMES )
        {
            pMyObject->ClientState      = STUN_SCO_CLIENT_STATE_Idle;
            pMyObject->SocketState1     = STUN_SCO_SOCKET_STATE_Idle;
            pMyObject->RetransInterval1 = STUN_MIN_RETRANSMISSION_INTERVAL;
            pMyObject->RetransTime1     = 0;
            pMyObject->bMsgIntegrity1   = FALSE;

            if ( pMyObject->LastSendMsg1 )
            {
                AnscFreeMemory(pMyObject->LastSendMsg1);

                pMyObject->LastSendMsg1 = NULL;
                pMyObject->LastMsgSize1 = 0;
            }

            if ( pStunBsmIf )
            {
                returnStatus =
                    pStunBsmIf->Notify
                        (
                            pStunBsmIf->hOwnerContext,
                            STUN_BSM_EVENT_serverUnreachable,
                            (ANSC_HANDLE)NULL
                        );
            }

            return  ANSC_STATUS_SUCCESS;
        }

        if ( pMyObject->LastSendMsg1 )
        {
            pMyObject->RetransInterval1 = AnscGetMin2(pMyObject->RetransInterval1 * 2, STUN_MAX_RETRANSMISSION_INTERVAL);
            pMyObject->RetransTime1    += 1;
            returnStatus                =
                pSimpleClientUdp1->Send2
                    (
                        (ANSC_HANDLE)pSimpleClientUdp1,
                        pProperty->ServerAddr.Value,
                        pProperty->ServerPort,
                        pMyObject->LastSendMsg1,
                        pMyObject->LastMsgSize1,
                        (ANSC_HANDLE)NULL
                    );

            pRetryTimerObj->SetInterval((ANSC_HANDLE)pRetryTimerObj, pMyObject->RetransInterval1);
            pRetryTimerObj->Start      ((ANSC_HANDLE)pRetryTimerObj);
        }
    }

    return  returnStatus;
}
Пример #8
0
int
AnscAsn1CompInts
    (
        ANSC_HANDLE                 hAsn1Int1,
        ANSC_HANDLE                 hAsn1Int2
    )
{
    PANSC_ASN1_INT                  pAsn1Int1      = (PANSC_ASN1_INT)hAsn1Int1;
    PANSC_ASN1_INT                  pAsn1Int2      = (PANSC_ASN1_INT)hAsn1Int2;
    ULONG                           ulMinStrLength = AnscGetMin2(pAsn1Int1->Length, pAsn1Int2->Length);
    ULONG                           i              = 0;

    if ( pAsn1Int1->bNegative != pAsn1Int2->bNegative )
    {
        if ( pAsn1Int1->bNegative )
        {
            return  -1;
        }
        else
        {
            return  1;
        }
    }

    for ( i = 0; i < ulMinStrLength; i++ )
    {
        if ( pAsn1Int1->Octets[i] == pAsn1Int2->Octets[i] )
        {
            continue;
        }
        else if ( pAsn1Int1->Octets[i] > pAsn1Int2->Octets[i] )
        {
            if ( pAsn1Int1->bNegative )
            {
                return  -1;
            }
            else
            {
                return  1;
            }
        }
        else
        {
            if ( pAsn1Int1->bNegative )
            {
                return  1;
            }
            else
            {
                return  -1;
            }
        }
    }

    if ( pAsn1Int1->Length == pAsn1Int2->Length )
    {
        return  0;
    }
    else if ( pAsn1Int1->Length > pAsn1Int2->Length )
    {
        if ( pAsn1Int1->bNegative )
        {
            return  -1;
        }
        else
        {
            return  1;
        }
    }
    else
    {
        if ( pAsn1Int1->bNegative )
        {
            return  1;
        }
        else
        {
            return  -1;
        }
    }

    return  0;
}