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


C++ IpAddress::remanent_mask方法代码示例

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


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

示例1: addFieldData

void StatStore::addFieldData(int id, uint8_t* fieldData, int fieldDataLength, VERMONT::IpfixRecord::FieldInfo::Type::EnterpriseNo eid) {
    // we subscribed to: see Stat::init_*()-functions
    // addFieldData will be executed until there are no more fieldData
    // in the current IPFIX record; so we are sure to get everything
    // we subscribed to (so don't get worried because of
    // the "breaks" in the "switch" loop hereafter)

    IpAddress SourceIP = IpAddress(0,0,0,0);
    IpAddress DestIP = IpAddress(0,0,0,0);

    switch (id) {

	case IPFIX_TYPEID_protocolIdentifier:

	    if (fieldDataLength != IPFIX_LENGTH_protocolIdentifier) {
		msgStr << MsgStream::ERROR << "Got IPFIX field (id=" << id << ") with unsupported length " << fieldDataLength << ". Skipping record." << MsgStream::endl;
		return;
	    }

	    e_source.setProtocolID(*fieldData);
	    e_dest.setProtocolID(*fieldData);

	    break;


	case IPFIX_TYPEID_sourceIPv4Address:

	    if (fieldDataLength != IPFIX_LENGTH_sourceIPv4Address) {
		msgStr << MsgStream::ERROR << "Got IPFIX field (id=" << id << ") with unsupported length " << fieldDataLength << ". Skipping record." << MsgStream::endl;
		return;
	    }

	    SourceIP.setAddress(fieldData[0],fieldData[1],fieldData[2],fieldData[3]);
	    SourceIP.remanent_mask(netmask);
	    e_source.setIpAddress(SourceIP);

	    break;


	case IPFIX_TYPEID_destinationIPv4Address:

	    if (fieldDataLength != IPFIX_LENGTH_destinationIPv4Address) {
		msgStr << MsgStream::ERROR << "Got IPFIX field (id=" << id << ") with unsupported length " << fieldDataLength << ". Skipping record." << MsgStream::endl;
		return;
	    }

	    DestIP.setAddress(fieldData[0],fieldData[1],fieldData[2],fieldData[3]);
	    DestIP.remanent_mask(netmask);
	    e_dest.setIpAddress(DestIP);

	    break;

	    // Ports do only matter, if endpoint_key contains "port"
	    // AND (endpoint_key contains "protocol" AND TCP and/or UDP are selected
	    // OR protocols dont matter)
	case IPFIX_TYPEID_sourceTransportPort:

	    if (fieldDataLength != IPFIX_LENGTH_sourceTransportPort
		    && fieldDataLength != IPFIX_LENGTH_sourceTransportPort-1) {
		msgStr << MsgStream::ERROR << "Got IPFIX field (id=" << id << ") with unsupported length " << fieldDataLength << ". Skipping record." << MsgStream::endl;
		return;
	    }

	    e_source.setPortNr((int)fieldToInt(fieldData, fieldDataLength));
	    break;


	case IPFIX_TYPEID_destinationTransportPort:

	    if (fieldDataLength != IPFIX_LENGTH_destinationTransportPort
		    && fieldDataLength != IPFIX_LENGTH_destinationTransportPort-1) {
		std::cerr << "Error! Got invalid IPFIX field data (destination port)! "
		    << "Skipping record.\n";
		return;
	    }

	    e_dest.setPortNr((int)fieldToInt(fieldData, fieldDataLength));
	    break;


	case IPFIX_TYPEID_packetDeltaCount:

	    if (fieldDataLength != IPFIX_LENGTH_packetDeltaCount) {
		std::cerr << "Error! Got invalid IPFIX field data (#packets)! "
		    << "Skipping record.\n";
		return;
	    }
	    packet_nb = ntohll(*(uint64_t*)fieldData);

	    break;


	case IPFIX_TYPEID_octetDeltaCount:

	    if (fieldDataLength != IPFIX_LENGTH_octetDeltaCount) {
		std::cerr << "Error! Got invalid IPFIX field data (#octets)! "
		    << "Skipping record.\n";
		return;
	    }
	    byte_nb = ntohll(*(uint64_t*)fieldData);
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:vermont-svn,代码行数:101,代码来源:stat-store.cpp


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