Ejemplo n.º 1
0
static CCNxControl *
metisConfiguration_ProcessAddConnectionEthernet(MetisConfiguration *config, CCNxControl *control, unsigned ingressId)
{
    bool success = false;

    CPIConnectionEthernet *etherConn = cpiConnectionEthernet_FromControl(control);
    assertNotNull(etherConn, "Control message did not parse to CPIConnectionEthernet");

    if (cpiConnectionEthernet_GetEthertype(etherConn) == ETHERTYPE) {
        CPIAddress *linkAddress = metisSystem_GetMacAddressByName(config->metis, cpiConnectionEthernet_GetInterfaceName(etherConn));
        if (linkAddress != NULL) {
            MetisListenerSet *listenerSet = metisForwarder_GetListenerSet(config->metis);
            MetisListenerOps *listenerOps = metisListenerSet_Find(listenerSet, METIS_ENCAP_ETHER, linkAddress);

            if (listenerOps) {
                // Now add the connection
                success = _metisConfiguration_AddConnectionEthernet(config, etherConn, linkAddress, listenerOps);
            } else {
                char *str = cpiAddress_ToString(linkAddress);
                metisLogger_Log(config->logger, MetisLoggerFacility_Config, PARCLogLevel_Error, __func__,
                                "Could not find listener for interface '%s' addr %s ethertype 0x%04x",
                                cpiConnectionEthernet_GetInterfaceName(etherConn),
                                str,
                                cpiConnectionEthernet_GetEthertype(etherConn));
                parcMemory_Deallocate((void **) &str);
            }


            cpiAddress_Destroy(&linkAddress);
        } else {
            metisLogger_Log(config->logger, MetisLoggerFacility_Config, PARCLogLevel_Error, __func__,
                            "Could not resolve interface '%s' to a MAC address",
                            cpiConnectionEthernet_GetInterfaceName(etherConn));
        }
    } else {
        metisLogger_Log(config->logger, MetisLoggerFacility_Config, PARCLogLevel_Error, __func__,
                        "Control message asked for ethertype %04x, only %04x supported",
                        cpiConnectionEthernet_GetEthertype(etherConn), ETHERTYPE);
    }

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

    cpiConnectionEthernet_Release(&etherConn);
    return response;
}
Ejemplo n.º 2
0
static void
setupInetListener(MetisForwarder *metis, uint16_t port)
{
    struct sockaddr_in addr;

    memset(&addr, 0, sizeof(addr));
    addr.sin_family = AF_INET;
    addr.sin_port = htons(port);
    inet_pton(AF_INET, "127.0.0.1", &(addr.sin_addr));

    MetisListenerSet *listeners = metisForwarder_GetListenerSet(metis);
    MetisListenerOps *ops = metisUdpListener_CreateInet(metis, addr);
    metisListenerSet_Add(listeners, ops);

    // crank the handle
    metisDispatcher_RunDuration(metisForwarder_GetDispatcher(metis), &((struct timeval) { 0, 10000 }));