Пример #1
0
void
athena_ProcessMessage(Athena *athena, CCNxMetaMessage *ccnxMessage, PARCBitVector *ingressVector)
{
    if (ccnxMetaMessage_IsInterest(ccnxMessage)) {
        const char *name = ccnxName_ToString(ccnxInterest_GetName(ccnxMessage));
        parcLog_Debug(athena->log, "Processing Interest Message: %s", name);
        parcMemory_Deallocate(&name);

        CCNxInterest *interest = ccnxMetaMessage_GetInterest(ccnxMessage);
        _processInterest(athena, interest, ingressVector);
        athena->stats.numProcessedInterests++;
    } else if (ccnxMetaMessage_IsContentObject(ccnxMessage)) {
        const char *name = ccnxName_ToString(ccnxContentObject_GetName(ccnxMessage));
        parcLog_Debug(athena->log, "Processing Content Object Message: %s", name);
        parcMemory_Deallocate(&name);

        CCNxContentObject *contentObject = ccnxMetaMessage_GetContentObject(ccnxMessage);
        _processContentObject(athena, contentObject, ingressVector);
        athena->stats.numProcessedContentObjects++;
    } else if (ccnxMetaMessage_IsControl(ccnxMessage)) {
        parcLog_Debug(athena->log, "Processing Control Message");

        CCNxControl *control = ccnxMetaMessage_GetControl(ccnxMessage);
        _processControl(athena, control, ingressVector);
        athena->stats.numProcessedControlMessages++;
    } else if (ccnxMetaMessage_IsInterestReturn(ccnxMessage)) {
        parcLog_Debug(athena->log, "Processing Interest Return Message");

        CCNxInterestReturn *interestReturn = ccnxMetaMessage_GetInterestReturn(ccnxMessage);
        _processInterestReturn(athena, interestReturn, ingressVector);
        athena->stats.numProcessedInterestReturns++;
    } else {
        trapUnexpectedState("Invalid CCNxMetaMessage type");
    }
}
Пример #2
0
static bool
_ccnxPortalRTA_IsConnected(CCNxPortal *portal)
{
    bool result = false;

    CCNxMetaMessage *response;

    if ((response = ccnxPortal_Receive(portal, CCNxStackTimeout_Never)) != NULL) {
        if (ccnxMetaMessage_IsControl(response)) {
            CCNxControl *control = ccnxMetaMessage_GetControl(response);

            if (ccnxControl_IsNotification(control)) {
                NotifyStatus *status = ccnxControl_GetNotifyStatus(control);

                if (notifyStatus_IsConnectionOpen(status) == true) {
                    result = true;
                }
                notifyStatus_Release(&status);
            }
        }
        ccnxMetaMessage_Release(&response);
    }

    return result;
}
Пример #3
0
/**
 * Called by the command parser for each command.
 *
 * The command parser will make a CCNxControl message inside the CCNxMetaMessage and send it here.
 * This function must return a ACK or NACK in a CCNxControl in a CCNxMetaMessage.
 *
 * @param [in] userdata A void * to MetisConfigurationFile
 * @param [in] msg The CCNxControl message to process
 *
 * @retval CCNxMetaMessage A CPI ACK or NACK in a CCNxControl in a CCNxMetaMessage
 *
 * Example:
 * @code
 * <#example#>
 * @endcode
 */
static CCNxMetaMessage *
_writeRead(void *userdata, CCNxMetaMessage *msgin)
{
    MetisConfigurationFile *configFile = (MetisConfigurationFile *) userdata;

    CCNxControl *request = ccnxMetaMessage_GetControl(msgin);
    CCNxControl *response = metisConfiguration_ReceiveControl(metisForwarder_GetConfiguration(configFile->metis), request, 0);

    CCNxMetaMessage *msgout = ccnxMetaMessage_CreateFromControl(response);
    ccnxControl_Release(&response);

    return msgout;
}
static CCNxControl *
customWriteReadResponse(void *userdata, CCNxMetaMessage *messageToWrite)
{
    CPIConnectionList *connlist = cpiConnectionList_Create();
    CPIConnection *conn = cpiConnection_Create(1, cpiAddress_CreateFromInterface(1), cpiAddress_CreateFromInterface(2), cpiConnection_L2);
    cpiConnectionList_Append(connlist, conn);

    PARCJSON *connectionListAsJson = cpiConnectionList_ToJson(connlist);

    CCNxControl *inboundControlMessage = ccnxMetaMessage_GetControl(messageToWrite);

    // Create a response to the inbound Control message.
    CCNxControl *outboundControlMessage = cpi_CreateResponse(inboundControlMessage, connectionListAsJson);
    parcJSON_Release(&connectionListAsJson);

    ccnxControl_Release(&inboundControlMessage);

    cpiConnectionList_Destroy(&connlist);

    return outboundControlMessage;
}
Пример #5
0
customWriteReadResponse(void *userdata, CCNxMetaMessage *messageToWrite)
{
    CPIRouteEntryList *routeEntryList = cpiRouteEntryList_Create();
    CPIAddress *nexthop = cpiAddress_CreateFromInterface(10);
    CPIRouteEntry *route = cpiRouteEntry_Create(ccnxName_CreateFromURI("lci:/foo"),
                                                1,
                                                nexthop,
                                                cpiNameRouteProtocolType_STATIC,
                                                cpiNameRouteType_LONGEST_MATCH,
                                                &((struct timeval) { 100, 0 }), // lifetime
                                                1);   // cost

    cpiRouteEntryList_Append(routeEntryList, route);
    PARCJSON *setJson = cpiRouteEntryList_ToJson(routeEntryList);

    CCNxControl *inboundControlMessage = ccnxMetaMessage_GetControl(messageToWrite);

    // Create a response to the inbound Control message.
    CCNxControl *outboundControlMessage = cpi_CreateResponse(inboundControlMessage, setJson);
    parcJSON_Release(&setJson);

    ccnxControl_Release(&inboundControlMessage);

    cpiAddress_Destroy(&nexthop);
    cpiRouteEntryList_Destroy(&routeEntryList);

    return outboundControlMessage;
}

static MetisCommandReturn
testListRoutes(const LongBowTestCase *testCase, int argc)