src/adapters/net.cpp
/**
   * Query driver info to check if the
   * interface is a TUN/TAP device or BRIDGE
   */
Query driver info to check if the
interface is a TUN/TAP device or BRIDGE
Query driver info to check if the interface is a TUN / TAP device or BRIDGE
void network::check_tuntap_or_bridge() {
    struct ethtool_drvinfo driver {};
    struct ifreq request {};
    driver.cmd = ETHTOOL_GDRVINFO;
    memset(&request, 0, sizeof(request));
    strncpy(request.ifr_name, m_interface.c_str(), IFNAMSIZ - 1);
    request.ifr_data = reinterpret_cast<char*>(&driver);
    if (ioctl(*m_socketfd, SIOCETHTOOL, &request) == -1) {
      return;
    }
    if (strncmp(driver.bus_info, "tun", 3) == 0) {
      m_tuntap = true;
    } else if (strncmp(driver.bus_info, "tap", 3) == 0) {
      m_tuntap = true;
    } else {
      m_tuntap = false;
    }
    if (strncmp(driver.driver, "bridge", 6) == 0) {
      m_bridge = true;
    }
  }
void network :: check_tuntap_or_bridge ( ) { struct ethtool_drvinfo driver { } ; struct ifreq request { } ; driver . cmd = ETHTOOL_GDRVINFO ; memset ( & request , 0 , sizeof ( request ) ) ; strncpy ( request . ifr_name , m_interface . c_str ( ) , IFNAMSIZ - 1 ) ; request . ifr_data = reinterpret_cast < char * > ( & driver ) ; if ( ioctl ( * m_socketfd , SIOCETHTOOL , & request ) == -1 ) { return ; } if ( strncmp ( driver . bus_info , " " , 3 ) == 0 ) { m_tuntap = true ; } else if ( strncmp ( driver . bus_info , " " , 3 ) == 0 ) { m_tuntap = true ; } else { m_tuntap = false ; } if ( strncmp ( driver . driver , " " , 6 ) == 0 ) { m_bridge = true ; } }
Query driver info to check if the
 interface is a TUN/TAP device or BRIDGE
Query driver info to check if the interface is a TUN / TAP device or BRIDGE
/*
     * Only copy array size minus one bytes over to ensure there is a
     * terminating NUL byte (which is guaranteed by memset)
     */ // Check if it's a TUN/TAP device