Example #1
0
static CCNxControl *
metisConfiguration_ProcessRegisterPrefix(MetisConfiguration *config, CCNxControl *control, unsigned ingressId)
{
    CPIRouteEntry *route = cpiForwarding_RouteFromControlMessage(control);

    bool success = false;

    // if it has a symbolic name set the interface index
    if (cpiRouteEntry_GetSymbolicName(route) != NULL) {
        success = _symbolicRegisterPrefix(config, route);
    } else {
        if (cpiRouteEntry_GetInterfaceIndex(route) == CPI_CURRENT_INTERFACE) {
            // We want to use the ingress interface
            cpiRouteEntry_SetInterfaceIndex(route, ingressId);
        }
        success = metisForwarder_AddOrUpdateRoute(config->metis, route);
    }

    CCNxControl *response;
    if (success) {
        response = _createAck(config, control, ingressId);
    } else {
        response = _createNack(config, control, ingressId);
    }

    cpiRouteEntry_Destroy(&route);
    return response;
}
Example #2
0
static bool
_symbolicRegisterPrefix(MetisConfiguration *config, CPIRouteEntry *route)
{
    bool success = false;

    const char *symbolic = cpiRouteEntry_GetSymbolicName(route);
    unsigned ifidx = metisSymbolicNameTable_Get(config->symbolicNameTable, symbolic);
    if (ifidx != UINT32_MAX) {
        cpiRouteEntry_SetInterfaceIndex(route, ifidx);
        if (metisLogger_IsLoggable(config->logger, MetisLoggerFacility_Config, PARCLogLevel_Debug)) {
            metisLogger_Log(config->logger, MetisLoggerFacility_Config, PARCLogLevel_Debug, __func__,
                            "Add route resolve name '%s' to connid %u",
                            symbolic, ifidx);
        }

        success = metisForwarder_AddOrUpdateRoute(config->metis, route);
    } else {
        if (metisLogger_IsLoggable(config->logger, MetisLoggerFacility_Config, PARCLogLevel_Warning)) {
            metisLogger_Log(config->logger, MetisLoggerFacility_Config, PARCLogLevel_Warning, __func__,
                            "Add route symbolic name '%s' could not be resolved", symbolic);
        }
        // this is a failure
    }
    return success;
}
Example #3
0
    metisConnectionTable_Add(metisForwarder_GetConnectionTable(metis_a), conn);

    cpiAddress_Destroy(&metisA_localCpiAddress);
    cpiAddress_Destroy(&metisA_remoteCpiAddress);

    // ---- run
    metisDispatcher_RunDuration(dispatcher_a, &((struct timeval) { 0, 1000 }));
    metisDispatcher_RunDuration(dispatcher_b, &((struct timeval) { 0, 1000 }));
    // ----

    // ===============================================
    /* 4) setup route to /foo from a to b */

    CCNxName *ccnxName = ccnxName_CreateFromURI("lci:/2=hello");
    CPIRouteEntry *route = cpiRouteEntry_Create(ccnxName, ops->getConnectionId(ops), NULL, cpiNameRouteProtocolType_STATIC, cpiNameRouteType_LONGEST_MATCH, NULL, 1);
    bool success = metisForwarder_AddOrUpdateRoute(metis_a, route);
    cpiRouteEntry_Destroy(&route);
    assertTrue(success, "error adding route from A to B");

    // ---- run
    metisDispatcher_RunDuration(dispatcher_a, &((struct timeval) { 0, 1000 }));
    metisDispatcher_RunDuration(dispatcher_b, &((struct timeval) { 0, 1000 }));
    // ----

    // ===============================================
    /* 5) Connect client 1 to A */

    struct sockaddr_in metisA_LoopbackAddress;
    memset(&metisA_LoopbackAddress, 0, sizeof(metisA_LoopbackAddress));
    metisA_LoopbackAddress.sin_family = PF_INET;
    metisA_LoopbackAddress.sin_port = htons(metisA_port);