/** * Add an IP-based tunnel. * * The call cal fail if the symbolic name is a duplicate. It could also fail if there's an problem creating * the local side of the tunnel (i.e. the local socket address is not usable). * * @return true Tunnel added * @return false Tunnel not added (an error) */ static CCNxControl * metisConfiguration_ProcessCreateTunnel(MetisConfiguration *config, CCNxControl *control, unsigned ingressId) { bool success = false; CPIInterfaceIPTunnel *iptun = cpiLinks_CreateIPTunnelFromControlMessage(control); const char *symbolicName = cpiInterfaceIPTunnel_GetSymbolicName(iptun); if (!metisSymbolicNameTable_Exists(config->symbolicNameTable, symbolicName)) { const CPIAddress *source = cpiInterfaceIPTunnel_GetSourceAddress(iptun); const CPIAddress *destination = cpiInterfaceIPTunnel_GetDestinationAddress(iptun); MetisIoOperations *ops = NULL; switch (cpiInterfaceIPTunnel_GetTunnelType(iptun)) { case IPTUN_TCP: ops = metisTcpTunnel_Create(config->metis, source, destination); break; case IPTUN_UDP: ops = metisUdpTunnel_Create(config->metis, source, destination); break; case IPTUN_GRE: metisLogger_Log(config->logger, MetisLoggerFacility_Config, PARCLogLevel_Error, __func__, "Unsupported tunnel protocol: GRE"); break; default: metisLogger_Log(config->logger, MetisLoggerFacility_Config, PARCLogLevel_Error, __func__, "Unsupported tunnel protocol: %d", cpiInterfaceIPTunnel_GetTunnelType(iptun)); break; } if (ops != NULL) { MetisConnection *conn = metisConnection_Create(ops); metisConnectionTable_Add(metisForwarder_GetConnectionTable(config->metis), conn); metisSymbolicNameTable_Add(config->symbolicNameTable, symbolicName, metisConnection_GetConnectionId(conn)); success = true; _logProcessCreateTunnelMessage(config, iptun, PARCLogLevel_Info, "success"); } else { _logProcessCreateTunnelMessage(config, iptun, PARCLogLevel_Warning, "failed, could not create IoOperations"); } } else { _logProcessCreateTunnelMessage(config, iptun, PARCLogLevel_Warning, "failed, symbolic name exists"); } // send the ACK or NACK CCNxControl *response; if (success) { response = _createAck(config, control, ingressId); } else { response = _createNack(config, control, ingressId); } cpiInterfaceIPTunnel_Release(&iptun); return response; }
struct sockaddr_in metisA_AnyIpAddress; memset(&metisA_AnyIpAddress, 0, sizeof(metisA_AnyIpAddress)); metisA_AnyIpAddress.sin_family = PF_INET; metisA_AnyIpAddress.sin_addr.s_addr = INADDR_ANY; // connect to 127.0.0.1:10002 struct sockaddr_in metisB_LoopbackAddress; memset(&metisB_LoopbackAddress, 0, sizeof(metisB_LoopbackAddress)); metisB_LoopbackAddress.sin_family = PF_INET; metisB_LoopbackAddress.sin_port = htons(metisB_port); inet_pton(AF_INET, "127.0.0.1", &(metisB_LoopbackAddress.sin_addr)); CPIAddress *metisA_localCpiAddress = cpiAddress_CreateFromInet(&metisA_AnyIpAddress); CPIAddress *metisA_remoteCpiAddress = cpiAddress_CreateFromInet(&metisB_LoopbackAddress); MetisIoOperations *ops = metisTcpTunnel_Create(metis_a, metisA_localCpiAddress, metisA_remoteCpiAddress); MetisConnection *conn = metisConnection_Create(ops); 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");