static CCNxControl * metisConfiguration_ProcessRegistrationList(MetisConfiguration *config, CCNxControl *request, unsigned ingressId) { MetisFibEntryList *fibList = metisForwarder_GetFibEntries(config->metis); CPIRouteEntryList *routeEntryList = cpiRouteEntryList_Create(); for (size_t i = 0; i < metisFibEntryList_Length(fibList); i++) { const MetisFibEntry *fibEntry = metisFibEntryList_Get(fibList, i); MetisTlvName *prefix = metisFibEntry_GetPrefix(fibEntry); const MetisNumberSet *nexthops = metisFibEntry_GetNexthops(fibEntry); for (int j = 0; j < metisNumberSet_Length(nexthops); j++) { CPIRouteEntry *route = cpiRouteEntry_Create(metisTlvName_ToCCNxName(prefix), metisNumberSet_GetItem(nexthops, j), NULL, cpiNameRouteProtocolType_STATIC, cpiNameRouteType_LONGEST_MATCH, NULL, // lifetime 1); // cost cpiRouteEntryList_Append(routeEntryList, route); } metisTlvName_Release(&prefix); } PARCJSON *entryListJson = cpiRouteEntryList_ToJson(routeEntryList); CCNxControl *response = cpi_CreateResponse(request, entryListJson); parcJSON_Release(&entryListJson); cpiRouteEntryList_Destroy(&routeEntryList); metisFibEntryList_Destroy(&fibList); return response; }
static CCNxControl * 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; }