Beispiel #1
0
void Core_initTunnel(String* desiredDeviceName,
                     struct Sockaddr* addr,
                     uint8_t addressPrefix,
                     struct Ducttape* dt,
                     struct Log* logger,
                     struct IpTunnel* ipTunnel,
                     struct EventBase* eventBase,
                     struct Allocator* alloc,
                     struct Except* eh)
{
    Log_debug(logger, "Initializing TUN device [%s]",
              (desiredDeviceName) ? desiredDeviceName->bytes : "<auto>");

    char assignedTunName[TUNInterface_IFNAMSIZ];
    char* desiredName = (desiredDeviceName) ? desiredDeviceName->bytes : NULL;
    struct Interface* tun =
        TUNInterface_new(desiredName, assignedTunName, eventBase, logger, eh, alloc);

    IpTunnel_setTunName(assignedTunName, ipTunnel);

    Ducttape_setUserInterface(dt, tun);

    NetDev_addAddress(assignedTunName, addr, addressPrefix, logger, eh);
    NetDev_setMTU(assignedTunName, DEFAULT_MTU, logger, eh);
}
Beispiel #2
0
void Core_initTunnel(String* desiredDeviceName,
                     uint8_t ipAddr[16],
                     uint8_t addressPrefix,
                     struct Ducttape* dt,
                     struct Log* logger,
                     struct IpTunnel* ipTunnel,
                     struct EventBase* eventBase,
                     struct Allocator* alloc,
                     struct Except* eh)
{
    Log_debug(logger, "Initializing TUN device [%s]",
              (desiredDeviceName) ? desiredDeviceName->bytes : "<auto>");
    char assignedTunName[TUNConfigurator_IFNAMSIZ];
    void* tunPtr = TUNConfigurator_initTun(((desiredDeviceName) ? desiredDeviceName->bytes : NULL),
                                           assignedTunName,
                                           logger,
                                           eh);

    struct TUNInterface* tun = TUNInterface_new(tunPtr, eventBase, alloc, logger);

    // broken
    //struct ICMP6Generator* icmp = ICMP6Generator_new(alloc);
    //InterfaceConnector_connect(&icmp->external, &tun->iface);
    //Ducttape_setUserInterface(dt, &icmp->internal);
    Ducttape_setUserInterface(dt, &tun->iface);

    TUNConfigurator_addIp6Address(assignedTunName, ipAddr, addressPrefix, logger, eh);
    TUNConfigurator_setMTU(assignedTunName, DEFAULT_MTU, logger, eh);
    IpTunnel_setTunName(assignedTunName, ipTunnel);
}
Beispiel #3
0
void Core_initTunnel(String* desiredDeviceName,
                     uint8_t ipAddr[16],
                     uint8_t addressPrefix,
                     struct Ducttape* dt,
                     struct Log* logger,
                     struct event_base* eventBase,
                     struct Allocator* alloc,
                     struct Except* eh)
{
    Log_debug(logger, "Initializing TUN device [%s]",
              (desiredDeviceName) ? desiredDeviceName->bytes : "<auto>");
    char assignedTunName[TUNConfigurator_IFNAMSIZ];
    void* tunPtr = TUNConfigurator_initTun(((desiredDeviceName) ? desiredDeviceName->bytes : NULL),
                                           assignedTunName,
                                           logger,
                                           eh);

    struct TUNInterface* tun = TUNInterface_new(tunPtr, eventBase, alloc);
    Ducttape_setUserInterface(dt, &tun->iface);

    TUNConfigurator_setIpAddress(assignedTunName, ipAddr, addressPrefix, logger, eh);
    TUNConfigurator_setMTU(assignedTunName, DEFAULT_MTU, logger, eh);
}