当前位置: 首页>>代码示例>>C++>>正文


C++ NetworkInterface::name方法代码示例

本文整理汇总了C++中NetworkInterface::name方法的典型用法代码示例。如果您正苦于以下问题:C++ NetworkInterface::name方法的具体用法?C++ NetworkInterface::name怎么用?C++ NetworkInterface::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NetworkInterface的用法示例。


在下文中一共展示了NetworkInterface::name方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: receive_probe_requests

void receive_probe_requests(NetworkInterface iface) {
	SnifferConfiguration config;
	config.set_rfmon(true);
	config.set_filter("type mgt subtype probe-req || type data subtype null");
	Sniffer sniffer(iface.name(), config);
	while(true) process(sniffer.next_packet());
}
开发者ID:timaa2k,项目名称:phonescan,代码行数:7,代码来源:main.cpp

示例2: socket_open_error

void PacketSender::open_l2_socket(const NetworkInterface& iface) {
    #if defined(BSD) || defined(__FreeBSD_kernel__)
        int sock = -1;
        // At some point, there should be an available device
        for (int i = 0; sock == -1;i++) {
            std::ostringstream oss;
            oss << "/dev/bpf" << i;

            sock = open(oss.str().c_str(), O_RDWR);
        }
        if(sock == -1) 
            throw socket_open_error(make_error_string());
        
        struct ifreq ifr;
        strncpy(ifr.ifr_name, iface.name().c_str(), sizeof(ifr.ifr_name) - 1);
        if(ioctl(sock, BIOCSETIF, (caddr_t)&ifr) < 0) {
            ::close(sock);
            throw socket_open_error(make_error_string());
        }
        _ether_socket[iface.id()] = sock;
    #else
    if (_ether_socket == INVALID_RAW_SOCKET) {
        _ether_socket = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
        
        if (_ether_socket == -1)
            throw socket_open_error(make_error_string());
    }
    #endif
}
开发者ID:jalons,项目名称:libtins,代码行数:29,代码来源:packet_sender.cpp

示例3: testForName

void NetworkInterfaceTest::testForName()
{
	NetworkInterface::Map map = NetworkInterface::map();
	for (NetworkInterface::Map::const_iterator it = map.begin(); it != map.end(); ++it)
	{
		NetworkInterface ifc = NetworkInterface::forName(it->second.name());
		assert (ifc.name() == it->second.name());
	}
}
开发者ID:trafficsim-jp,项目名称:poco,代码行数:9,代码来源:NetworkInterfaceTest.cpp

示例4: GetByName

NetworkInterface* NetworkInterface::GetByName(const String& name, bool do_update)
{
	if ((__interfaces != NULL)&&(!do_update))
	{
		for (uint32 i = 0; i < __interfaces->size(); ++i)
		{	
			NetworkInterface* iface = (*__interfaces)[i];
			if (iface->name() == name)
				return iface;
		}
	}
	if (do_update)
	{
		__update();
		// and repeat same code from above (blah copy paste)
		for (uint32 i = 0; i < __interfaces->size(); ++i)
		{	
			NetworkInterface* iface = (*__interfaces)[i];
			if (iface->name() == name)
				return iface;
		}
	}
	return NULL;
}
开发者ID:311labs,项目名称:SRL,代码行数:24,代码来源:NetworkInterface.cpp

示例5:

NetworkState::NetworkState(String interfaceName):
    interfaceName_(interfaceName),
    networkMask_(0)
{
    Ref<RouteInfoList> routingTable = RouteInfo::queryTable();
    for (int i = 0; i < routingTable->count(); ++i) {
        RouteInfo *entry = routingTable->at(i);
        if (entry->source() || entry->destination()) continue;
        if (interfaceName_ != "" && entry->outputInterface() != interfaceName_) continue;
        interfaceName_ = entry->outputInterface();
        gateway_ = entry->gateway();
        break;
    }

    Ref<NetworkInterfaceList> interfaceList = NetworkInterface::queryAll(AF_UNSPEC);
    for (int i = 0; i < interfaceList->count(); ++i) {
        NetworkInterface *candidate = interfaceList->at(i);
        if (candidate->name() == interfaceName_) {
            interface_ = candidate;
            Ref<SocketAddressList> addressList = interface_->addressList();
            if (!gateway_) {
                for (int j = 0; j < addressList->count(); ++j) {
                    SocketAddress *address = addressList->at(j);
                    if (address->family() != AF_INET) continue;
                    address_ = address;
                    break;
                }
            }
            if (!address_) {
                for (int j = 0; j < addressList->count(); ++j) {
                    SocketAddress *address = addressList->at(j);
                    if (gateway_ && address->family() != gateway_->family()) continue;
                    address_ = address;
                    break;
                }
            }
        }
    }

    Ref<SocketAddressEntry> entry = cast<SocketAddressEntry>(address_);
    if (entry)
        networkMask_ = entry->networkMask();
}
开发者ID:frankencode,项目名称:fluxkit,代码行数:43,代码来源:NetworkState.cpp


注:本文中的NetworkInterface::name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。