add linux tap -> netif
This commit is contained in:
@@ -22,6 +22,10 @@
|
|||||||
#include "Signals.hpp"
|
#include "Signals.hpp"
|
||||||
#include "VirtualTap.hpp"
|
#include "VirtualTap.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
#include <lwip/tcpip.h>
|
||||||
|
#include "LwipLinuxTap.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
using namespace ZeroTier;
|
using namespace ZeroTier;
|
||||||
@@ -559,9 +563,20 @@ void* _runNodeService(void* arg)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testtap(){
|
||||||
|
tcpip_init(nullptr, nullptr);
|
||||||
|
ip4_addr_t ipaddr, netmask, gw;
|
||||||
|
IP4_ADDR(&gw, 172, 2, 0, 1);
|
||||||
|
IP4_ADDR(&ipaddr, 172, 2, 0, 100);
|
||||||
|
IP4_ADDR(&netmask, 255, 255, 255, 0);
|
||||||
|
init_default_netif(&ipaddr, &netmask, &gw);
|
||||||
|
netif_set_up(&get_default_netif());
|
||||||
|
}
|
||||||
|
|
||||||
int zts_node_start()
|
int zts_node_start()
|
||||||
{
|
{
|
||||||
ACQUIRE_SERVICE_OFFLINE();
|
ACQUIRE_SERVICE_OFFLINE();
|
||||||
|
testtap();
|
||||||
// Start TCP/IP stack
|
// Start TCP/IP stack
|
||||||
zts_lwip_driver_init();
|
zts_lwip_driver_init();
|
||||||
// Start callback thread
|
// Start callback thread
|
||||||
|
|||||||
20
src/LwipLinuxTap.cpp
Normal file
20
src/LwipLinuxTap.cpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#include "lwip/netif.h"
|
||||||
|
#include "lwip/ip_addr.h"
|
||||||
|
#include "lwip/tcpip.h"
|
||||||
|
extern "C" {
|
||||||
|
#include "netif/tapif.h"
|
||||||
|
}
|
||||||
|
|
||||||
|
static netif default_network_interface;
|
||||||
|
|
||||||
|
void init_default_netif(const ip4_addr_t* ipaddr, const ip4_addr_t* netmask, const ip4_addr_t* gw)
|
||||||
|
{
|
||||||
|
netif_add(&default_network_interface, ipaddr, netmask, gw, nullptr, tapif_init, tcpip_input);
|
||||||
|
|
||||||
|
netif_set_default(&default_network_interface);
|
||||||
|
}
|
||||||
|
|
||||||
|
netif& get_default_netif()
|
||||||
|
{
|
||||||
|
return default_network_interface;
|
||||||
|
}
|
||||||
11
src/LwipLinuxTap.h
Normal file
11
src/LwipLinuxTap.h
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#ifndef LWIP_LINUX_UNIX_TAP_NETWORK_INTERFACE_H
|
||||||
|
#define LWIP_LINUX_UNIX_TAP_NETWORK_INTERFACE_H
|
||||||
|
|
||||||
|
#include "lwip/netif.h"
|
||||||
|
|
||||||
|
void init_default_netif(const ip4_addr_t* ipaddr, const ip4_addr_t* netmask, const ip4_addr_t* gw);
|
||||||
|
|
||||||
|
netif& get_default_netif();
|
||||||
|
|
||||||
|
|
||||||
|
#endif //LWIP_LINUX_UNIX_TAP_NETWORK_INTERFACE_H
|
||||||
Reference in New Issue
Block a user