static const CPIAddress * _metisStreamConnection_GetRemoteAddress(const MetisIoOperations *ops) { assertNotNull(ops, "Parameter must be non-null"); const _MetisStreamState *stream = (const _MetisStreamState *) metisIoOperations_GetClosure(ops); return metisAddressPair_GetRemote(stream->addressPair); }
static CCNxControl * metisConfiguration_ProcessConnectionList(MetisConfiguration *config, CCNxControl *request, unsigned ingressId) { CPIConnectionList *tunnelList = cpiConnectionList_Create(); MetisConnectionTable *table = metisForwarder_GetConnectionTable(config->metis); MetisConnectionList *connList = metisConnectionTable_GetEntries(table); for (size_t i = 0; i < metisConnectionList_Length(connList); i++) { // Don't release original, we're not storing it MetisConnection *original = metisConnectionList_Get(connList, i); const MetisAddressPair *addressPair = metisConnection_GetAddressPair(original); CPIAddress *localAddress = cpiAddress_Copy(metisAddressPair_GetLocal(addressPair)); CPIAddress *remoteAddress = cpiAddress_Copy(metisAddressPair_GetRemote(addressPair)); CPIConnectionType type = metisIoOperations_GetConnectionType(metisConnection_GetIoOperations(original)); CPIConnection *cpiConn = cpiConnection_Create(metisConnection_GetConnectionId(original), localAddress, remoteAddress, type); cpiConnection_SetState(cpiConn, metisConnection_IsUp(original) ? CPI_IFACE_UP : CPI_IFACE_DOWN); cpiConnectionList_Append(tunnelList, cpiConn); } PARCJSON *connectListJson = cpiConnectionList_ToJson(tunnelList); CCNxControl *response = cpi_CreateResponse(request, connectListJson); parcJSON_Release(&connectListJson); cpiConnectionList_Destroy(&tunnelList); metisConnectionList_Destroy(&connList); return response; }
PARCEventQueue * metisDispatcher_StreamBufferConnect(MetisDispatcher *dispatcher, const MetisAddressPair *pair) { const CPIAddress *localAddress = metisAddressPair_GetLocal(pair); const CPIAddress *remoteAddress = metisAddressPair_GetRemote(pair); // they must be of the same address family if (cpiAddress_GetType(localAddress) != cpiAddress_GetType(remoteAddress)) { char message[2048]; char *localAddressString = cpiAddress_ToString(localAddress); char *remoteAddressString = cpiAddress_ToString(remoteAddress); snprintf(message, 2048, "Remote address not same type as local address, expected %d got %d\nlocal %s remote %s", cpiAddress_GetType(localAddress), cpiAddress_GetType(remoteAddress), localAddressString, remoteAddressString); parcMemory_Deallocate((void **) &localAddressString); parcMemory_Deallocate((void **) &remoteAddressString); assertTrue(cpiAddress_GetType(localAddress) == cpiAddress_GetType(remoteAddress), "%s", message); } switch (cpiAddress_GetType(localAddress)) { case cpiAddressType_INET: return metisDispatcher_StreamBufferConnect_INET(dispatcher, localAddress, remoteAddress); break; case cpiAddressType_INET6: return metisDispatcher_StreamBufferConnect_INET6(dispatcher, localAddress, remoteAddress); break; default: trapIllegalValue(pair, "local address unsupported CPI address type: %d", cpiAddress_GetType(localAddress)); } }