本文整理汇总了C++中Address::getAddressPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ Address::getAddressPtr方法的具体用法?C++ Address::getAddressPtr怎么用?C++ Address::getAddressPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Address
的用法示例。
在下文中一共展示了Address::getAddressPtr方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slurp
/*
* Call this after converting to atomic rules by DST to be sure there
* is just one object in DST.
*/
bool RoutingCompiler::sameDestinationDifferentGateways::processNext()
{
slurp();
if (tmp_queue.size()==0) return false;
// map destination to gateway.
std::map<string, string> dst_to_gw;
std::map<string, string> dst_to_rule;
for (deque<Rule*>::iterator k=tmp_queue.begin(); k!=tmp_queue.end(); ++k)
{
RoutingRule *rule = RoutingRule::cast( *k );
RuleElementRDst *dstrel = rule->getRDst();
Address *dst = Address::cast(FWReference::getObject(dstrel->front()));
const InetAddr* dst_addr = dst->getAddressPtr();
const InetAddr* dst_netm = dst->getNetmaskPtr();
string key = dst_addr->toString() + "/" + dst_netm->toString();
// RuleElementRItf *itfrel = rule->getRItf();
// FWObject *itf = FWReference::cast(itfrel->front())->getPointer();
RuleElementRGtw *gtwrel = rule->getRGtw();
Address *gtw = Address::cast(FWReference::getObject(gtwrel->front()));
const InetAddr* gtw_addr = gtw->getAddressPtr();
const InetAddr* gtw_netm = gtw->getNetmaskPtr();
string val = gtw_addr->toString() + "/" + gtw_netm->toString();
if (!dst_to_gw[key].empty() && dst_to_gw[key] != val)
{
compiler->abort(
rule,
"Rules " + dst_to_rule[key] + " and " + rule->getLabel() +
" define routes to the same destination " + key +
" via different gateways. This configuration is not supported"
" for " + compiler->fw->getStr("host_OS"));
} else
{
dst_to_gw[key] = val;
dst_to_rule[key] = rule->getLabel();
}
}
return true;
}
示例2: string
/*
* checks if one of the children of RuleElement is a host, IPv4 or
* network object with address 0.0.0.0 and netmask 0.0.0.0.
*
* Exceptions:
* - object 'any'
* - interface with dynamic address.
*
* In addition check for address A.B.C.D/0 which is most likely a
* mistake if A.B.C.D != 0.0.0.0. See #475
*/
Address* PolicyCompiler::checkForZeroAddr::findZeroAddress(RuleElement *re)
{
Address *a=NULL;
for (FWObject::iterator i=re->begin(); i!=re->end(); i++)
{
FWObject *o = FWReference::getObject(*i);
assert(o!=NULL);
MultiAddress *maddr = MultiAddress::cast(o);
if (maddr && maddr->isRunTime()) continue;
Address *addr = Address::cast(o);
if (addr==NULL && o!=NULL)
compiler->warning(
re->getParent(),
string("findZeroAddress: Unknown object in rule element: ") +
o->getName() +
" type=" + o->getTypeName());
if (addr && addr->hasInetAddress())
{
if (Interface::cast(o)!=NULL &&
(Interface::cast(o)->isDyn() ||
Interface::cast(o)->isUnnumbered() ||
Interface::cast(o)->isBridgePort()))
continue;
if ( ! addr->isAny())
{
const InetAddr *ad = addr->getAddressPtr();
const InetAddr *nm = addr->getNetmaskPtr();
// AddressRange has address but not netmask
// AddressRange with address 0.0.0.0 is acceptable
// (not equivalent to "any")
if (ad->isAny() && nm!=NULL && nm->isAny())
{
a = addr;
break;
}
// Address A.B.C.D/0 is most likely a mistake if
// A.B.C.D != 0.0.0.0
if ((Network::cast(addr) || NetworkIPv6::cast(addr)) &&
!ad->isAny() && nm!=NULL && nm->isAny())
{
a = addr;
break;
}
}
}
}
return a;
}
示例3: QWidget
InterfaceEditorWidget::InterfaceEditorWidget(QWidget *parent, Interface *iface) :
QWidget(parent),
m_ui(new Ui::InterfaceEditorWidget)
{
tabw = dynamic_cast<QTabWidget*>(parent);
this->interfacep = iface;
m_ui->setupUi(this);
setClusterMode(false);
this->m_ui->name->setText(interfacep->getName().c_str());
this->m_ui->label->setText(interfacep->getLabel().c_str());
// if (iface->getPhysicalAddress() != NULL)
// m_ui->mac->setText(iface->getPhysicalAddress()->getPhysAddress().c_str());
this->m_ui->comment->setPlainText(iface->getComment().c_str());
if ( this->interfacep->isDyn() ) this->m_ui->type->setCurrentIndex(1);
if ( this->interfacep->isUnnumbered() ) this->m_ui->type->setCurrentIndex(2);
FWObjectTypedChildIterator adriter = iface->findByType(IPv4::TYPENAME);
for ( ; adriter != adriter.end(); ++adriter )
{
Address *addr = Address::cast(*adriter);
int row = addNewAddress(addr->getAddressPtr()->toString().c_str(),
addr->getNetmaskPtr()->toString().c_str(),
addr->getAddressPtr()->isV4());
fwaddrs[row] = addr;
}
FWObjectTypedChildIterator adriter2 = iface->findByType(IPv6::TYPENAME);
for ( ; adriter2 != adriter2.end(); ++adriter2 )
{
Address *addr = Address::cast(*adriter2);
int row = addNewAddress(addr->getAddressPtr()->toString().c_str(),
addr->getNetmaskPtr()->toString().c_str(),
addr->getAddressPtr()->isV4());
fwaddrs[row] = addr;
}
}
示例4: testDNSNameObject
bool DNSTest::testDNSNameObject(FWObjectDatabase *objdb, FWObject *root,
const string &dnsrec,
char* results[])
{
list<std::string> expected_results;
for (char** cptr=results; *cptr!=NULL; ++cptr)
expected_results.push_back(*cptr);
FWObject *nobj = objdb->create(DNSName::TYPENAME);
if (root != NULL)
{
root->add(nobj);
}
DNSName* dnsnameobj = DNSName::cast(nobj);
dnsnameobj->setName(dnsrec);
dnsnameobj->setStr("dnsrec", dnsrec);
dnsnameobj->setRunTime(false);
for (FWObject::iterator j=dnsnameobj->begin();
j!=dnsnameobj->end(); ++j)
{
Address* addr = Address::cast(FWReference::cast(*j)->getPointer());
const InetAddr* inet_addr = addr->getAddressPtr();
list<std::string>::const_iterator res;
res = std::find(expected_results.begin(),
expected_results.end(),
inet_addr->toString());
if ( res != expected_results.end())
{
return true;
}
else
{
return false;
}
}
return true;
}
示例5: groupMemberToString
QString PIXObjectGroup::groupMemberToString(FWObject *obj,
NamedObjectsManager*)
throw(libfwbuilder::FWException)
{
ostringstream ostr;
if (this->getObjectGroupType() == NETWORK)
{
Address *a = Address::cast(obj);
assert(a!=NULL);
const InetAddr *addr = a->getAddressPtr();
ostr << "network-object ";
if (Network::cast(obj)!=NULL)
{
const InetAddr *mask = a->getNetmaskPtr();
ostr << addr->toString() << " ";
ostr << mask->toString() << " ";
} else {
ostr << "host ";
ostr << addr->toString() << " ";
}
return ostr.str().c_str();
} else
{
if (IPService::isA(obj))
{
ostr << "protocol-object ";
Service *s=Service::cast(obj);
assert(s!=NULL);
ostr << s->getProtocolName();
return ostr.str().c_str();
}
if (ICMPService::isA(obj))
{
ostr << "icmp-object ";
ICMPService *s=ICMPService::cast(obj);
assert(s!=NULL);
if ( s->getInt("type")== -1)
ostr << "any";
else
ostr << s->getInt("type");
return ostr.str().c_str();
}
if (TCPService::isA(obj) || UDPService::isA(obj))
{
ostr << "port-object ";
Service *s=Service::cast(obj);
assert(s!=NULL);
int rs=TCPUDPService::cast(s)->getDstRangeStart();
int re=TCPUDPService::cast(s)->getDstRangeEnd();
if (rs<0) rs=0;
if (re<0) re=0;
if (rs>0 || re>0) {
if (rs==re) ostr << "eq " << rs;
else ostr << "range " << rs << " " << re;
}
else ostr << "range 0 65535";
return ostr.str().c_str();
}
QString err("PIXObjectGroup: Unsupported object '%1' found in "
"object group");
throw FWException(err.arg(obj->getName().c_str()).toStdString());
}
return ostr.str().c_str();
}
示例6: pixNetworkZoneChecks
void CompilerDriver_pix::pixNetworkZoneChecks(Firewall *fw,
list<FWObject*> &all_interfaces)
{
multimap<string, FWObject*> netzone_objects;
Helper helper(NULL);
for (std::list<FWObject*>::iterator i=all_interfaces.begin(); i!=all_interfaces.end(); ++i)
{
Interface *iface = dynamic_cast<Interface*>(*i);
assert(iface);
if (iface->getOptionsObject()->getBool("cluster_interface")) continue;
if (iface->isDedicatedFailover()) continue;
if (iface->isUnprotected()) continue;
/*
* in PIX, we need network zones to be defined for all
* interfaces
*/
string netzone_id = iface->getStr("network_zone");
if (netzone_id=="")
{
QString err("Network zone definition is missing for interface '%1' (%2)");
abort(fw, NULL, NULL,
err.arg(iface->getName().c_str())
.arg(iface->getLabel().c_str()).toStdString());
throw FatalErrorInSingleRuleCompileMode();
}
FWObject *netzone = objdb->findInIndex(
FWObjectDatabase::getIntId(netzone_id));
if (netzone==NULL)
{
QString err("Network zone points at nonexisting object for "
"interface '%1' (%2)");
abort(fw, NULL, NULL,
err.arg(iface->getName().c_str())
.arg(iface->getLabel().c_str()).toStdString());
throw FatalErrorInSingleRuleCompileMode();
}
/*
* netzone may be a group, in which case we need to expand it
* (recursively).
*
* 1. We create new temporary object (type Group).
*
* 2. put it in the database somewhere
*
* 3. add all objects that belong to the network zone to this
* group. We add objects directly, not as a reference.
*
* 4. finally replace reference to the old network zone object in the
* interface with reference to this new group.
*
* 5. we store ID of the original network zone object
* using iface->setStr("orig_netzone_id")
*
* This ensures netzones do not contain other groups and do not
* require any recursive expanding anymore. Since objects were added
* to netzones directly, we do not need to bother with dereferencing,
* too.
*/
list<FWObject*> ol;
helper.expand_group_recursive(netzone, ol);
FWObject *nz = objdb->createObjectGroup();
assert(nz!=NULL);
nz->setName("netzone_" + iface->getLabel());
objdb->add(nz);
for (list<FWObject*>::iterator j=ol.begin(); j!=ol.end(); ++j)
{
Address *addr = Address::cast(*j);
if (addr == NULL || addr->getAddressPtr() == NULL)
{
QString err("Network zone of interface '%1' uses object '%2' "
"that is not an address");
abort(fw, NULL, NULL,
err.arg(iface->getLabel().c_str())
.arg((*j)->getName().c_str()).toStdString());
throw FatalErrorInSingleRuleCompileMode();
}
/*
Commented out for SF bug 3213019
currently we do not support ipv6 with PIX/ASA and FWSM. If user
creates a group to be used as network zone object and places ipv6
address in it, this address should be ignored while compiling the
policy but this should not be an error. Compiler uses network zone
group to do various address matching operations when it tries to
determine an interface for a rule where user did not specify
one. Since we never (should) have ipv6 in policy and nat rules,
compiler is not going to have anything to compare to ipv6 address in
the network zone even if there is one and this ipv6 address is going
to be ignored.
if (addr->getAddressPtr()->isV6())
//.........这里部分代码省略.........