• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ parcBuffer_Release函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中parcBuffer_Release函数的典型用法代码示例。如果您正苦于以下问题:C++ parcBuffer_Release函数的具体用法?C++ parcBuffer_Release怎么用?C++ parcBuffer_Release使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parcBuffer_Release函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: LONGBOW_TEST_CASE

LONGBOW_TEST_CASE(Specialization, parcBufferPool_Drain)
{
    size_t oldLimit = 3;
    size_t newLimit = 2;
   
    PARCBufferPool *pool = parcBufferPool_Create(oldLimit, 10);
   
    PARCBuffer *buffer1 = parcBufferPool_GetInstance(pool);
    PARCBuffer *buffer2 = parcBufferPool_GetInstance(pool);
    PARCBuffer *buffer3 = parcBufferPool_GetInstance(pool);
    parcBuffer_AssertValid(buffer1);
    parcBuffer_AssertValid(buffer2);
    parcBuffer_AssertValid(buffer3);
    parcBuffer_Release(&buffer1);
    parcBuffer_Release(&buffer2);
    parcBuffer_Release(&buffer3);
   
    size_t limit = parcBufferPool_SetLimit(pool, newLimit);
    assertTrue(limit == oldLimit, "Expected the limit to be %zu, actual %zu", oldLimit, limit);
   
    size_t drained = parcBufferPool_Drain(pool);
    assertTrue(drained == 1, "Expected the drained to be 1, actual %zu", drained);
   
    parcBufferPool_Release(&pool);
}
开发者ID:PARC,项目名称:Libparc,代码行数:25,代码来源:test_parc_BufferPool.c


示例2: _createInterest

/**
 * Create and return a CCNxInterest whose Name contains our commend (e.g. "fetch" or "list"),
 * and, optionally, the name of a target object (e.g. "file.txt"). The newly created CCNxInterest
 * must eventually be released by calling ccnxInterest_Release().
 *
 * @param command The command to embed in the created CCNxInterest.
 * @param targetName The name of the content, if any, that the command applies to.
 *
 * @return A newly created CCNxInterest for the specified command and targetName.
 */
static CCNxInterest *
_createInterest(const char *command, const char *targetName)
{
    CCNxName *interestName = ccnxName_CreateFromURI(tutorialCommon_DomainPrefix); // Start with the prefix. We append to this.

    // Create a NameSegment for our command, which we will append after the prefix we just created.
    PARCBuffer *commandBuffer = parcBuffer_WrapCString((char *) command);
    CCNxNameSegment *commandSegment = ccnxNameSegment_CreateTypeValue(CCNxNameLabelType_NAME, commandBuffer);
    parcBuffer_Release(&commandBuffer);

    // Append the new command segment to the prefix
    ccnxName_Append(interestName, commandSegment);
    ccnxNameSegment_Release(&commandSegment);

    // If we have a target, then create another NameSegment for it and append that.
    if (targetName != NULL) {
        // Create a NameSegment for our target object
        PARCBuffer *targetBuf = parcBuffer_WrapCString((char *) targetName);
        CCNxNameSegment *targetSegment = ccnxNameSegment_CreateTypeValue(CCNxNameLabelType_NAME, targetBuf);
        parcBuffer_Release(&targetBuf);


        // Append it to the ccnxName.
        ccnxName_Append(interestName, targetSegment);
        ccnxNameSegment_Release(&targetSegment);
    }

    CCNxInterest *result = ccnxInterest_CreateSimple(interestName);
    ccnxName_Release(&interestName);

    return result;
}
开发者ID:isolis,项目名称:ccnx-tutorial,代码行数:42,代码来源:tutorial_Client.c


示例3: LONGBOW_TEST_CASE

LONGBOW_TEST_CASE(Global, ccnxInterest_Equals)
{
    CCNxName *nameA = ccnxName_CreateFromURI("lci:/name");
    PARCBuffer *keyA = parcBuffer_Allocate(8);
    parcBuffer_PutUint64(keyA, 1234L);

    CCNxInterest *interestA = ccnxInterest_Create(nameA,
                                                  1000, /* lifetime */
                                                  keyA, /* KeyId */
                                                  NULL  /* ContentObjectHash */
                                                  );

    CCNxName *nameB = ccnxName_CreateFromURI("lci:/name");
    PARCBuffer *keyB = parcBuffer_Allocate(8);
    parcBuffer_PutUint64(keyB, 1234L);
    CCNxInterest *interestB = ccnxInterest_Create(nameB,
                                                  1000, /* lifetime */
                                                  keyB, /* KeyId */
                                                  NULL  /* ContentObjectHash */
                                                  );

    assertTrue(ccnxInterest_Equals(interestA, interestB), "Expected equivalent interests to be equal.");

    ccnxName_Release(&nameA);
    ccnxName_Release(&nameB);
    parcBuffer_Release(&keyA);
    parcBuffer_Release(&keyB);
    ccnxInterest_Release(&interestA);
    ccnxInterest_Release(&interestB);
}
开发者ID:mword,项目名称:Libccnx-common,代码行数:30,代码来源:test_ccnx_Interest.c


示例4: LONGBOW_TEST_CASE

LONGBOW_TEST_CASE(parc_JSONArray, parcJSONArray_BuildString)
{
    PARCJSONArray *array = parcJSONArray_Create();
    PARCJSONValue *expected = parcJSONValue_CreateFromInteger(10);
    parcJSONArray_AddValue(array, expected);

    PARCBufferComposer *composer = parcBufferComposer_Create();
    parcJSONArray_BuildString(array, composer, false);

    PARCBuffer *tempBuffer = parcBufferComposer_ProduceBuffer(composer);
    parcBufferComposer_Release(&composer);
    char *result = parcBuffer_ToString(tempBuffer);
    parcBuffer_Release(&tempBuffer);

    assertTrue(strlen(result) > 0, "Expected non-empty string result");

    parcMemory_Deallocate((void **) &result);

    composer = parcBufferComposer_Create();
    parcJSONArray_BuildString(array, composer, true);
    tempBuffer = parcBufferComposer_ProduceBuffer(composer);
    parcBufferComposer_Release(&composer);
    result = parcBuffer_ToString(tempBuffer);
    parcBuffer_Release(&tempBuffer);

    assertTrue(strlen(result) > 0, "Expected non-empty string result");

    parcMemory_Deallocate((void **) &result);

    parcJSONValue_Release(&expected);
    parcJSONArray_Release(&array);
}
开发者ID:isolis,项目名称:Libparc,代码行数:32,代码来源:test_parc_JSONArray.c


示例5: LONGBOW_TEST_CASE

LONGBOW_TEST_CASE(Global, ccnxContentObject_GetKeyId)
{
    CCNxName *name = ccnxName_CreateFromCString("lci:/hello/dolly");
    PARCBuffer *payload = parcBuffer_WrapCString("hello");

    CCNxContentObject *contentObject = ccnxContentObject_CreateWithDataPayload(name, payload);

    assertNull(ccnxContentObject_GetKeyId(contentObject), "Expect NULL for KeyId here");

    PARCBuffer *testKeyId = parcBuffer_WrapCString("keyhash");
    PARCBuffer *sigbits = parcBuffer_WrapCString("siggybits");
    PARCSignature *signature = parcSignature_Create(PARCSigningAlgorithm_RSA, PARC_HASH_SHA256, parcBuffer_Flip(sigbits));

    ccnxContentObject_SetSignature(contentObject, testKeyId, signature, NULL);

    PARCBuffer *keyId = ccnxContentObject_GetKeyId(contentObject);

    assertTrue(parcBuffer_Equals(keyId, testKeyId), "Expect key ids to match");

    parcBuffer_Release(&payload);
    parcBuffer_Release(&sigbits);
    parcBuffer_Release(&keyId);
    parcSignature_Release(&signature);
    ccnxName_Release(&name);
    ccnxContentObject_Release(&contentObject);
}
开发者ID:GlennCScott,项目名称:Libccnx-common,代码行数:26,代码来源:test_ccnx_ContentObject.c


示例6: _parcPkcs12KeyStore_Finalize

static bool
_parcPkcs12KeyStore_Finalize(PARCPkcs12KeyStore **instancePtr)
{
    assertNotNull(instancePtr, "Parameter must be a non-null pointer to a PARCPublicKeySigner pointer.");
    PARCPkcs12KeyStore *keystore = *instancePtr;

    EVP_PKEY_free(keystore->private_key);
    EVP_PKEY_free(keystore->public_key);
    X509_free(keystore->x509_cert);

    if (keystore->public_key_digest != NULL) {
        parcBuffer_Release(&keystore->public_key_digest);
    }
    if (keystore->certificate_digest != NULL) {
        parcBuffer_Release(&keystore->certificate_digest);
    }
    if (keystore->public_key_der != NULL) {
        parcBuffer_Release(&keystore->public_key_der);
    }
    if (keystore->certificate_der != NULL) {
        parcBuffer_Release(&keystore->certificate_der);
    }
    if (keystore->private_key_der != NULL) {
        parcBuffer_Release(&keystore->private_key_der);
    }

    parcCryptoHasher_Release(&(keystore->hasher));

    return true;
}
开发者ID:rayyagar,项目名称:Libparc,代码行数:30,代码来源:parc_Pkcs12KeyStore.c


示例7: LONGBOW_TEST_CASE

LONGBOW_TEST_CASE(Global, parc_Chunker_ReverseIterator_Buffer)
{
    PARCBuffer *buffer = parcBuffer_Allocate(1024);

    for (size_t i = 0; i < 32; i++) {
        for (size_t j = 0; j < 32; j++) {
            parcBuffer_PutUint8(buffer, i);
        }
    }
    parcBuffer_Flip(buffer);

    PARCBufferChunker *chunker = parcBufferChunker_Create(buffer, 32); // each chunk is 32 bytes
    assertNotNull(chunker, "Expected non-NULL Chunker");

    PARCIterator *itr = parcBufferChunker_ReverseIterator(chunker);
    size_t count = 0;
    while (parcIterator_HasNext(itr)) {
        PARCBuffer *payload = (PARCBuffer *) parcIterator_Next(itr);

        uint8_t *contents = parcBuffer_Overlay(payload, 0);
        for (size_t i = 0; i < 32; i++) {
            assertTrue(contents[i] == (31 - count), "Expected %zu at index %zu, got %d", (31 - count), i, contents[i]);
        }
        count++;

        parcBuffer_Release(&payload);
    }
    assertTrue(count == 32, "Expected to iterate over 32 content objects from the chunker, but for %zu", count);
    parcIterator_Release(&itr);

    parcBufferChunker_Release(&chunker);
    parcBuffer_Release(&buffer);
}
开发者ID:rayyagar,项目名称:Libparc,代码行数:33,代码来源:test_parc_BufferChunker.c


示例8: LONGBOW_TEST_CASE

LONGBOW_TEST_CASE(Global, ccnxTlvCodecName_Encode)
{
    uint8_t truthBytes[] = { 0x10, 0x20, 0x00, 0x0E, 0x00, CCNxNameLabelType_NAME, 0x00, 0x0A, 'b', 'r', 'a', 'n', 'd', 'y', 'w', 'i', 'n', 'e' };
    PARCBuffer *truth = parcBuffer_Wrap(truthBytes, sizeof(truthBytes), 0, sizeof(truthBytes));

    CCNxCodecTlvEncoder *encoder = ccnxCodecTlvEncoder_Create();
    ccnxCodecTlvEncoder_Initialize(encoder);

    PARCBuffer *buffer = parcBuffer_WrapCString("brandywine");
    CCNxNameSegment *segment = ccnxNameSegment_CreateTypeValue(CCNxNameLabelType_NAME, buffer);

    CCNxName *name = ccnxName_Append(ccnxName_Create(), segment);
    ccnxNameSegment_Release(&segment);
    parcBuffer_Release(&buffer);

    ccnxCodecSchemaV1NameCodec_Encode(encoder, 0x1020, name);

    ccnxCodecTlvEncoder_Finalize(encoder);
    PARCBuffer *test = ccnxCodecTlvEncoder_CreateBuffer(encoder);

    if (!parcBuffer_Equals(truth, test)) {
        printf("Buffers do not match\n");
        printf("Excpected:\n");
        parcBuffer_Display(truth, 3);
        printf("Got:\n");
        parcBuffer_Display(test, 3);
        assertTrue(parcBuffer_Equals(truth, test), "Buffers do not match");
    }

    ccnxName_Release(&name);
    parcBuffer_Release(&test);
    ccnxCodecTlvEncoder_Destroy(&encoder);
    parcBuffer_Release(&truth);
}
开发者ID:PARC,项目名称:Libccnx-common,代码行数:34,代码来源:test_ccnxCodecSchemaV1_NameCodec.c


示例9: LONGBOW_TEST_CASE

LONGBOW_TEST_CASE(JSON, parcJSON_BuildString)
{
    TestData *data = longBowTestCase_GetClipBoardData(testCase);
    PARCBufferComposer *composer = parcBufferComposer_Create();
    parcJSON_BuildString(data->json, composer, false);

    PARCBuffer *tempBuffer = parcBufferComposer_ProduceBuffer(composer);
    char *actual = parcBuffer_ToString(tempBuffer);
    parcBuffer_Release(&tempBuffer);
    parcBufferComposer_Release(&composer);

    assertTrue(strcmp(data->expected, actual) == 0, "Expected %s, actual %s", data->expected, actual);
    parcMemory_Deallocate((void **) &actual);

    composer = parcBufferComposer_Create();
    parcJSON_BuildString(data->json, composer, true);

    tempBuffer = parcBufferComposer_ProduceBuffer(composer);
    actual = parcBuffer_ToString(tempBuffer);
    parcBuffer_Release(&tempBuffer);
    parcBufferComposer_Release(&composer);

    assertTrue(strcmp(data->compactExpected, actual) == 0, "Expected %s, actual %s", data->compactExpected, actual);
    parcMemory_Deallocate((void **) &actual);
}
开发者ID:PARC,项目名称:Libparc,代码行数:25,代码来源:test_parc_JSON.c


示例10: LONGBOW_TEST_CASE

LONGBOW_TEST_CASE(Global, parcSignature_Equals)
{
    PARCBuffer *bits = parcBuffer_Allocate(10); // arbitrary bufer size -- not important
    PARCBuffer *otherBits = parcBuffer_Allocate(strlen("hello"));
    parcBuffer_PutArray(otherBits, strlen("hello"), (uint8_t *) "hello");

    PARCSignature *x = parcSignature_Create(PARCSigningAlgorithm_DSA, PARC_HASH_SHA256, bits);
    PARCSignature *y = parcSignature_Create(PARCSigningAlgorithm_DSA, PARC_HASH_SHA256, bits);
    PARCSignature *z = parcSignature_Create(PARCSigningAlgorithm_DSA, PARC_HASH_SHA256, bits);
    PARCSignature *unequal1 = parcSignature_Create(PARCSigningAlgorithm_HMAC, PARC_HASH_SHA256, bits);
    PARCSignature *unequal2 = parcSignature_Create(PARCSigningAlgorithm_DSA, PARC_HASH_CRC32C, bits);
    PARCSignature *unequal3 = parcSignature_Create(PARCSigningAlgorithm_DSA, PARC_HASH_SHA256, otherBits);

    parcObjectTesting_AssertEqualsFunction(parcSignature_Equals, x, y, z, unequal1, unequal2, unequal3, NULL);

    parcSignature_Release(&x);
    parcSignature_Release(&y);
    parcSignature_Release(&z);
    parcSignature_Release(&unequal1);
    parcSignature_Release(&unequal2);
    parcSignature_Release(&unequal3);

    parcBuffer_Release(&bits);
    parcBuffer_Release(&otherBits);
}
开发者ID:isolis,项目名称:Libparc,代码行数:25,代码来源:test_parc_Signature.c


示例11: LONGBOW_TEST_CASE

LONGBOW_TEST_CASE(CreateAcquireRelease, CreateCompare)
{
    PARCSortedList *instance = parcSortedList_CreateCompare(_compareTwoBuffersByLength);

    PARCBuffer *buf1 = parcBuffer_WrapCString("medium long");
    PARCBuffer *buf2 = parcBuffer_WrapCString("somewhat longer");
    PARCBuffer *buf3 = parcBuffer_WrapCString("short");

    parcSortedList_Add(instance, buf1);
    parcSortedList_Add(instance, buf2);
    parcSortedList_Add(instance, buf3);

    PARCBuffer *test = parcSortedList_GetAtIndex(instance, 0);
    assertTrue(test == buf3, "Expected the shortes buffer first");

    test = parcSortedList_GetAtIndex(instance, 1);
    assertTrue(test == buf1, "Expected the medium length buffer second");

    test = parcSortedList_GetAtIndex(instance, 2);
    assertTrue(test == buf2, "Expected the longest buffer last");

    parcBuffer_Release(&buf1);
    parcBuffer_Release(&buf2);
    parcBuffer_Release(&buf3);

    parcSortedList_Release(&instance);
}
开发者ID:PARC,项目名称:Libparc,代码行数:27,代码来源:test_parc_SortedList.c


示例12: _SignDigest

static PARCSignature *
_SignDigest(PARCPublicKeySigner *signer, const PARCCryptoHash *digestToSign)
{
    parcSecurity_AssertIsInitialized();

    assertNotNull(signer, "Parameter must be non-null CCNxFileKeystore");
    assertNotNull(digestToSign, "Buffer to sign must not be null");

    // TODO: what is the best way to expose this?
    PARCKeyStore *keyStore = signer->keyStore;
    PARCBuffer *privateKeyBuffer = parcKeyStore_GetDEREncodedPrivateKey(keyStore);
    EVP_PKEY *privateKey = NULL;
    size_t keySize = parcBuffer_Remaining(privateKeyBuffer);
    uint8_t *bytes = parcBuffer_Overlay(privateKeyBuffer, keySize);
    privateKey = d2i_PrivateKey(EVP_PKEY_RSA, &privateKey, (const unsigned char **) &bytes, keySize);
    parcBuffer_Release(&privateKeyBuffer);

    RSA *rsa = EVP_PKEY_get1_RSA(privateKey);

    int opensslDigestType;

    switch (parcCryptoHash_GetDigestType(digestToSign)) {
        case PARCCryptoHashType_SHA256:
            opensslDigestType = NID_sha256;
            break;
        case PARCCryptoHashType_SHA512:
            opensslDigestType = NID_sha512;
            break;
        default:
            trapUnexpectedState("Unknown digest type: %s",
                                parcCryptoHashType_ToString(parcCryptoHash_GetDigestType(digestToSign)));
    }

    uint8_t *sig = parcMemory_Allocate(RSA_size(rsa));
    assertNotNull(sig, "parcMemory_Allocate(%u) returned NULL", RSA_size(rsa));

    unsigned sigLength = 0;
    PARCBuffer *bb_digest = parcCryptoHash_GetDigest(digestToSign);
    int result = RSA_sign(opensslDigestType,
                          (unsigned char *) parcByteArray_Array(parcBuffer_Array(bb_digest)),
                          (int) parcBuffer_Remaining(bb_digest),
                          sig,
                          &sigLength,
                          rsa);
    assertTrue(result == 1, "Got error from RSA_sign: %d", result);
    RSA_free(rsa);

    PARCBuffer *bbSign = parcBuffer_Allocate(sigLength);
    parcBuffer_Flip(parcBuffer_PutArray(bbSign, sigLength, sig));
    parcMemory_Deallocate((void **) &sig);

    PARCSignature *signature =
    parcSignature_Create(_GetSigningAlgorithm(signer),
                         parcCryptoHash_GetDigestType(digestToSign),
                         bbSign
                         );
    parcBuffer_Release(&bbSign);
    return signature;
}
开发者ID:PARC,项目名称:Libparc,代码行数:59,代码来源:parc_PublicKeySigner.c


示例13: LONGBOW_TEST_CASE

LONGBOW_TEST_CASE(Global, ccnxLink_Equals)
{
    CCNxName *name = ccnxName_CreateFromCString("lci:/foo/bar/name");
    PARCBuffer *keyId = parcBuffer_Allocate(10);
    PARCBuffer *contentObjectHash = parcBuffer_Allocate(20);
    CCNxLink *x = ccnxLink_Create(name, keyId, contentObjectHash);
    ccnxName_Release(&name);
    parcBuffer_Release(&keyId);
    parcBuffer_Release(&contentObjectHash);

    name = ccnxName_CreateFromCString("lci:/foo/bar/name");
    keyId = parcBuffer_Allocate(10);
    contentObjectHash = parcBuffer_Allocate(20);
    CCNxLink *y = ccnxLink_Create(name, keyId, contentObjectHash);
    ccnxName_Release(&name);
    parcBuffer_Release(&keyId);
    parcBuffer_Release(&contentObjectHash);

    name = ccnxName_CreateFromCString("lci:/foo/bar/name");
    keyId = parcBuffer_Allocate(10);
    contentObjectHash = parcBuffer_Allocate(20);
    CCNxLink *z = ccnxLink_Create(name, keyId, contentObjectHash);
    ccnxName_Release(&name);
    parcBuffer_Release(&keyId);
    parcBuffer_Release(&contentObjectHash);

    name = ccnxName_CreateFromCString("lci:/foo/bar/othername");
    keyId = parcBuffer_Allocate(10);
    contentObjectHash = parcBuffer_Allocate(20);
    CCNxLink *unequal1 = ccnxLink_Create(name, keyId, contentObjectHash);
    ccnxName_Release(&name);
    parcBuffer_Release(&keyId);
    parcBuffer_Release(&contentObjectHash);

    name = ccnxName_CreateFromCString("lci:/foo/bar/name");
    keyId = NULL;
    contentObjectHash = parcBuffer_Allocate(20);
    CCNxLink *unequal2 = ccnxLink_Create(name, keyId, contentObjectHash);
    ccnxName_Release(&name);
    parcBuffer_Release(&contentObjectHash);

    name = ccnxName_CreateFromCString("lci:/foo/bar/name");
    keyId = parcBuffer_Allocate(10);
    contentObjectHash = NULL;
    CCNxLink *unequal3 = ccnxLink_Create(name, keyId, contentObjectHash);
    ccnxName_Release(&name);
    parcBuffer_Release(&keyId);

    assertEqualsContract(ccnxLink_Equals, x, y, z, unequal1, unequal2, unequal3);

    ccnxLink_Release(&x);
    ccnxLink_Release(&y);
    ccnxLink_Release(&z);
    ccnxLink_Release(&unequal1);
    ccnxLink_Release(&unequal2);
    ccnxLink_Release(&unequal3);
}
开发者ID:rayyagar,项目名称:Libccnx-common,代码行数:57,代码来源:test_ccnx_Link.c


示例14: _messageLengthFromHeader

//
// Peek at the header and derive our total message length
//
static size_t
_messageLengthFromHeader(AthenaTransportLink *athenaTransportLink, _UDPLinkData *linkData)
{
    // Peek at our message header to determine the total length of buffer we need to allocate.
    size_t fixedHeaderLength = ccnxCodecTlvPacket_MinimalHeaderLength();
    PARCBuffer *wireFormatBuffer = parcBuffer_Allocate(fixedHeaderLength);
    const uint8_t *peekBuffer = parcBuffer_Overlay(wireFormatBuffer, 0);

    ssize_t readCount = recv(linkData->fd, (void *) peekBuffer, fixedHeaderLength, MSG_PEEK);

    if (readCount == -1) {
        parcBuffer_Release(&wireFormatBuffer);
        if ((errno == EAGAIN) || (errno == EINTR)) {
            parcLog_Debug(athenaTransportLink_GetLogger(athenaTransportLink), "recv retry (%s)", strerror(errno));
            linkData->_stats.receive_ReadRetry++;
        } else {
            linkData->_stats.receive_ReadError++;
            parcLog_Debug(athenaTransportLink_GetLogger(athenaTransportLink), "recv error (%s)", strerror(errno));
            athenaTransportLink_SetEvent(athenaTransportLink, AthenaTransportLinkEvent_Error);
        }
        return -1;
    }

    // A zero read means no data
    if (readCount == 0) {
        parcBuffer_Release(&wireFormatBuffer);
        return -1;
    }

    // Check for a short header read, since we're only peeking here we just return and retry later
    if (readCount != fixedHeaderLength) {
        linkData->_stats.receive_ReadHeaderFailure++;
        parcBuffer_Release(&wireFormatBuffer);
        return -1;
    }

    // Obtain the total size of the message from the header
    size_t messageLength = ccnxCodecTlvPacket_GetPacketLength(wireFormatBuffer);
    parcBuffer_Release(&wireFormatBuffer);

    // Could do more to check the integrity of the message and framing.
    // If length is greater than our MTU we will find out in the read.
    if (messageLength < fixedHeaderLength) {
        linkData->_stats.receive_BadMessageLength++;
        parcLog_Error(athenaTransportLink_GetLogger(athenaTransportLink), "Framing error, flushing link.");
        char trash[MAXPATHLEN];
        // Flush link to attempt to resync our framing
        while (read(linkData->fd, trash, sizeof(trash)) == sizeof(trash)) {
            parcLog_Error(athenaTransportLink_GetLogger(athenaTransportLink), "... flushing link.");
        }
        return -1;
    }

    return messageLength;
}
开发者ID:mahyuddin,项目名称:Athena,代码行数:58,代码来源:athena_TransportLinkModuleUDP.c


示例15: LONGBOW_TEST_CASE

LONGBOW_TEST_CASE(Global, athena_ProcessContentObject)
{
    PARCURI *connectionURI;
    Athena *athena = athena_Create(100);

    CCNxName *name = ccnxName_CreateFromCString("lci:/cakes/and/pies");
    uint64_t chunkNum = 0;
    CCNxNameSegment *chunkSegment = ccnxNameSegmentNumber_Create(CCNxNameLabelType_CHUNK, chunkNum);
    ccnxName_Append(name, chunkSegment);
    ccnxNameSegment_Release(&chunkSegment);

    PARCBuffer *payload = parcBuffer_WrapCString("this is a payload");
    CCNxContentObject *contentObject = ccnxContentObject_CreateWithNameAndPayload(name, payload);

    ccnxName_Release(&name);
    parcBuffer_Release(&payload);

    connectionURI = parcURI_Parse("tcp://localhost:50100/listener/name=TCPListener");
    const char *result = athenaTransportLinkAdapter_Open(athena->athenaTransportLinkAdapter, connectionURI);
    assertTrue(result != NULL, "athenaTransportLinkAdapter_Open failed (%s)", strerror(errno));
    parcURI_Release(&connectionURI);

    connectionURI = parcURI_Parse("tcp://localhost:50100/name=TCP_0");
    result = athenaTransportLinkAdapter_Open(athena->athenaTransportLinkAdapter, connectionURI);
    assertTrue(result != NULL, "athenaTransportLinkAdapter_Open failed (%s)", strerror(errno));
    parcURI_Release(&connectionURI);

    int linkId = athenaTransportLinkAdapter_LinkNameToId(athena->athenaTransportLinkAdapter, "TCP_0");
    PARCBitVector *ingressVector = parcBitVector_Create();
    parcBitVector_Set(ingressVector, linkId);

    athena_EncodeMessage(contentObject);

    athena_ProcessMessage(athena, contentObject, ingressVector);

    parcBitVector_Release(&ingressVector);

    // Make sure we recover processing a "nameless" content object
    payload = parcBuffer_WrapCString("Hello World");
    CCNxContentObject *reply = ccnxContentObject_CreateWithPayload(payload);
    parcBuffer_Release(&payload);

    CCNxMetaMessage *response = ccnxMetaMessage_CreateFromContentObject(reply);
    ccnxContentObject_Release(&reply);
    athena_EncodeMessage(response);

    athena_ProcessMessage(athena, response, ingressVector);

    assertNull(ingressVector, "Processing nameless content object didn't fail.");

    ccnxInterest_Release(&contentObject);
    ccnxInterest_Release(&response);
    athena_Release(&athena);
}
开发者ID:PARC,项目名称:Athena,代码行数:54,代码来源:test_athena.c


示例16: _destroy

static void
_destroy(PARCBufferChunker **chunkerP)
{
    if ((*chunkerP)->data != NULL) {
        parcBuffer_Release(&(*chunkerP)->data);
    }

    if ((*chunkerP)->currentElement != NULL) {
        parcBuffer_Release(&(*chunkerP)->currentElement);
    }
}
开发者ID:isolis,项目名称:Libparc,代码行数:11,代码来源:parc_BufferChunker.c


示例17: LONGBOW_TEST_CASE

LONGBOW_TEST_CASE(Local, _athenaLRUContentStore_GetMatchByName)
{
    AthenaLRUContentStore *impl = _createLRUContentStore();

    PARCBuffer *payload = parcBuffer_Allocate(500);

    CCNxName *name = ccnxName_CreateFromURI("lci:/boose/roo/pie");
    CCNxContentObject *contentObject = ccnxContentObject_CreateWithDataPayload(name, payload);
    parcBuffer_Release(&payload);

    bool status = _athenaLRUContentStore_PutContentObject(impl, contentObject);
    assertTrue(status, "Expected to put content into the store");

    PARCBuffer *payload2 = parcBuffer_Allocate(500);
    CCNxName *name2 = ccnxName_CreateFromURI("lci:/roo/pie/boose");
    CCNxContentObject *contentObject2 = ccnxContentObject_CreateWithDataPayload(name2, payload2);
    parcBuffer_Release(&payload2);

    bool status2 = _athenaLRUContentStore_PutContentObject(impl, contentObject2);
    assertTrue(status2, "Expected to put content into the store");

    // At this point, both objects should be in the store.
    athenaLRUContentStore_Display(impl, 2);

    assertTrue(impl->stats.numAdds == 2, "Expected 2 store adds");

    // Now try to fetch each of them.

    CCNxInterest *interest1 = ccnxInterest_CreateSimple(name);
    CCNxContentObject *match = _athenaLRUContentStore_GetMatch(impl, interest1);
    assertTrue(match == contentObject, "Expected to match the first content object");

    CCNxInterest *interest2 = ccnxInterest_CreateSimple(name2);
    CCNxContentObject *match2 = _athenaLRUContentStore_GetMatch(impl, interest2);
    assertTrue(match2 == contentObject2, "Expected to match the second content object");

    // Now try to match a non-existent name.
    CCNxName *nameNoMatch = ccnxName_CreateFromURI("lci:/pie/roo/boose/this/should/not/match");
    CCNxInterest *interest3 = ccnxInterest_CreateSimple(nameNoMatch);
    CCNxContentObject *noMatch = _athenaLRUContentStore_GetMatch(impl, interest3);
    assertNull(noMatch, "Expected a NULL response from an unmatchable name");

    ccnxInterest_Release(&interest1);
    ccnxInterest_Release(&interest2);
    ccnxInterest_Release(&interest3);
    ccnxName_Release(&nameNoMatch);
    ccnxName_Release(&name);
    ccnxName_Release(&name2);
    ccnxContentObject_Release(&contentObject);
    ccnxContentObject_Release(&contentObject2);

    _athenaLRUContentStore_Release((AthenaContentStoreImplementation *) &impl);
}
开发者ID:chris-wood,项目名称:ghost,代码行数:53,代码来源:test_athena_LRUContentStore.c


示例18: _ETHReceiveMessage

//
// Receive a message from the specified link.
//
static CCNxMetaMessage *
_ETHReceiveMessage(AthenaTransportLink *athenaTransportLink, struct ether_addr *peerAddress, socklen_t *peerAddressLength)
{
    struct _ETHLinkData *linkData = athenaTransportLink_GetPrivateData(athenaTransportLink);
    CCNxMetaMessage *ccnxMetaMessage = NULL;
    AthenaTransportLinkEvent events = 0;

    PARCBuffer *message = athenaEthernet_Receive(linkData->athenaEthernet, -1, &events);
    if (message == NULL) {
        return NULL;
    }
    // Mark any pending events
    if (events) {
        athenaTransportLink_SetEvent(athenaTransportLink, events);
    }

    // Map the header
    struct ether_header *header = parcBuffer_Overlay(message, sizeof(struct ether_header));

    // If the destination does not match my address, drop the message
    if (memcmp(&linkData->link.myAddress, header->ether_dhost, ETHER_ADDR_LEN * sizeof(uint8_t)) != 0) {
        linkData->_stats.receive_NoLinkDestination++;
        parcBuffer_Release(&message);
        return NULL;
    }
    assertTrue(header->ether_type == htons(CCNX_ETHERTYPE), "Unexpected ether type %x", header->ether_type);

    // Set peerAddress from header source address
    *peerAddressLength = ETHER_ADDR_LEN * sizeof(uint8_t);
    memcpy(peerAddress, header->ether_shost, *peerAddressLength);

    parcBuffer_SetPosition(message, sizeof(struct ether_header));
    PARCBuffer *wireFormatBuffer = parcBuffer_Slice(message);
    parcBuffer_Release(&message);
    parcBuffer_SetPosition(wireFormatBuffer, 0);

    // Construct, and return a ccnxMetaMessage from the wire format buffer.
    ccnxMetaMessage = ccnxMetaMessage_CreateFromWireFormatBuffer(wireFormatBuffer);
    if (ccnxMetaMessage == NULL) {
        linkData->_stats.receive_DecodeFailed++;
        parcLog_Error(athenaTransportLink_GetLogger(athenaTransportLink), "Failed to decode message from received packet.");
    } else if (ccnxTlvDictionary_GetSchemaVersion(ccnxMetaMessage) == CCNxTlvDictionary_SchemaVersion_V0) {
        parcLog_Debug(athenaTransportLink_GetLogger(athenaTransportLink),
                      "received deprecated version %d message\n", ccnxTlvDictionary_GetSchemaVersion(ccnxMetaMessage));
    }
    parcBuffer_Release(&wireFormatBuffer);

    return ccnxMetaMessage;
}
开发者ID:mahyuddin,项目名称:Athena,代码行数:52,代码来源:athena_TransportLinkModuleETH.c


示例19: testData_Release

void
testData_Release(TestData **dataPtr)
{
    TestData *data = *dataPtr;

    ccnxKeyLocator_Release(&data->locatorByKey);
    ccnxKeyLocator_Release(&data->locatorByName);
    ccnxName_Release(&data->keyname);
    parcBuffer_Release(&data->cert);
    parcBuffer_Release(&data->key);
    parcBuffer_Release(&data->keyid);

    parcMemory_Deallocate((void **) &data);
    *dataPtr = NULL;
}
开发者ID:mword,项目名称:Libccnx-common,代码行数:15,代码来源:testrig_validation.c


示例20: _athenaLRUContentStoreEntry_Finalize

static void
_athenaLRUContentStoreEntry_Finalize(_AthenaLRUContentStoreEntry **entryPtr)
{
    _AthenaLRUContentStoreEntry *entry = (_AthenaLRUContentStoreEntry *) *entryPtr;
    //printf("LRUContentStoreEntry being finalized.  %p\n", entry);
    ccnxContentObject_Release(&entry->contentObject);

    if (entry->keyId) {
        parcBuffer_Release(&entry->keyId);
    }

    if (entry->contentObjectHash) {
        parcBuffer_Release(&entry->contentObjectHash);
    }
}
开发者ID:PARC,项目名称:Athena,代码行数:15,代码来源:athena_LRUContentStore.c



注:本文中的parcBuffer_Release函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ parcMemory_Deallocate函数代码示例发布时间:2022-05-30
下一篇:
C++ parcBuffer_Allocate函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap