|
| L3AddressResolver () |
|
virtual | ~L3AddressResolver () |
|
virtual L3Address | resolve (const char *str, int addrType=DEFAULT_ADDR_TYPE) |
| Accepts dotted decimal notation ("127.0.0.1"), module name of the host or router ("host[2]"), and empty string (""). More...
|
|
virtual std::vector< L3Address > | resolve (std::vector< std::string > strs, int addrType=DEFAULT_ADDR_TYPE) |
| Utility function: Calls resolve() for each item in the string vector, and returns the result in an address vector. More...
|
|
virtual bool | tryResolve (const char *str, L3Address &result, int addrType=DEFAULT_ADDR_TYPE) |
| Similar to resolve(), but returns false (instead of throwing an error) if the address cannot be resolved because the given host (or interface) doesn't have an address assigned yet. More...
|
|
|
virtual L3Address | addressOf (cModule *host, int addrType=DEFAULT_ADDR_TYPE) |
| Returns IPv4 or IPv6 address of the given host or router. More...
|
|
virtual L3Address | addressOf (cModule *host, const char *ifname, int addrType=DEFAULT_ADDR_TYPE) |
| Similar to addressOf(), but only looks at the given interface. More...
|
|
virtual L3Address | addressOf (cModule *host, cModule *destmod, int addrType=DEFAULT_ADDR_TYPE) |
| Returns IPv4 or IPv6 address of the given host or router. More...
|
|
virtual L3Address | routerIdOf (cModule *host) |
| Returns the router Id of the given router. More...
|
|
virtual L3Address | getAddressFrom (IInterfaceTable *ift, int addrType=DEFAULT_ADDR_TYPE) |
| Returns the IPv4 or IPv6 address of the given host or router, given its IInterfaceTable module. More...
|
|
virtual L3Address | getAddressFrom (InterfaceEntry *ie, int addrType=DEFAULT_ADDR_TYPE) |
| Returns the IPv4 or IPv6 address of the given interface (of a host or router). More...
|
|
virtual IInterfaceTable * | interfaceTableOf (cModule *host) |
| The function tries to look up the IInterfaceTable module as submodule "interfaceTable" or "networkLayer.interfaceTable" within the host/router module. More...
|
|
virtual IIPv4RoutingTable * | routingTableOf (cModule *host) |
| The function tries to look up the IIPv4RoutingTable module as submodule "routingTable" or "networkLayer.routingTable" within the host/router module. More...
|
|
virtual IPv6RoutingTable * | routingTable6Of (cModule *host) |
| The function tries to look up the IPv6RoutingTable module as submodule "routingTable6" or "networkLayer.routingTable6" within the host/router module. More...
|
|
virtual IInterfaceTable * | findInterfaceTableOf (cModule *host) |
| Like interfaceTableOf(), but doesn't throw error if not found. More...
|
|
virtual IIPv4RoutingTable * | findIPv4RoutingTableOf (cModule *host) |
| Like routingTableOf(), but doesn't throw error if not found. More...
|
|
virtual IPv6RoutingTable * | findIPv6RoutingTableOf (cModule *host) |
| Like interfaceTableOf(), but doesn't throw error if not found. More...
|
|
virtual GenericRoutingTable * | findGenericRoutingTableOf (cModule *host) |
| Like interfaceTableOf(), but doesn't throw error if not found. More...
|
|
virtual cModule * | findHostWithAddress (const L3Address &addr) |
| Find the Host with the specified address. More...
|
|
|
virtual bool | getIPv4AddressFrom (L3Address &retAddr, IInterfaceTable *ift, bool netmask) |
|
virtual bool | getIPv6AddressFrom (L3Address &retAddr, IInterfaceTable *ift, bool netmask) |
|
virtual bool | getMACAddressFrom (L3Address &retAddr, IInterfaceTable *ift, bool netmask) |
|
virtual bool | getModulePathAddressFrom (L3Address &retAddr, IInterfaceTable *ift, bool netmask) |
|
virtual bool | getModuleIdAddressFrom (L3Address &retAddr, IInterfaceTable *ift, bool netmask) |
|
virtual bool | getInterfaceIPv4Address (L3Address &ret, InterfaceEntry *ie, bool mask) |
|
virtual bool | getInterfaceIPv6Address (L3Address &ret, InterfaceEntry *ie, bool mask) |
|
virtual bool | getInterfaceMACAddress (L3Address &ret, InterfaceEntry *ie, bool mask) |
|
virtual bool | getInterfaceModulePathAddress (L3Address &ret, InterfaceEntry *ie, bool mask) |
|
virtual bool | getInterfaceModuleIdAddress (L3Address &ret, InterfaceEntry *ie, bool mask) |
|
Utility class for finding IPv4 or IPv6 address of a host or router.
Syntax variations understood:
- literal IPv4 address: "186.54.66.2"
- literal IPv6 address: "3011:7cd6:750b:5fd6:aba3:c231:e9f9:6a43"
- module name: "server", "subnet.server[3]"
- interface of a host or router: "server%eth0", "subnet.server[3]%eth0"
- IPv4 or IPv6 address of a host or router: "server(ipv4)", "subnet.server[3](ipv6)"
- IPv4 or IPv6 address of an interface of a host or router: "server%eth0(ipv4)", "subnet.server[3]%eth0(ipv6)"
- routerId: "router1%routerId", "R1%routerId"
- interface of a host or router toward defined another node: "client1>router"
Accepts dotted decimal notation ("127.0.0.1"), module name of the host or router ("host[2]"), and empty string ("").
For the latter, it returns the null address. If module name is specified, the module will be looked up using getModuleByPath()
, and then addressOf() will be called to determine its IP address.
Referenced by inet::UDPBasicApp::chooseDestAddr(), inet::MultiFieldClassifier::configureFilters(), inet::NetPerfMeter::createAndBindSocket(), inet::Define_Module(), inet::NetPerfMeter::establishConnection(), inet::xmlutils::getParameterIPAddressValue(), inet::PingApp::handleMessage(), inet::VoIPStreamSender::initialize(), inet::WiseRoute::initialize(), inet::SCTPNatServer::initialize(), inet::SCTPServer::initialize(), inet::SCTPClient::initialize(), inet::SCTPNatPeer::initialize(), inet::SCTPPeer::initialize(), inet::dymo::DYMO::initialize(), inet::ospf::ipv4AddressFromAddressString(), inet::ospf::ipv4NetmaskFromAddressString(), inet::PingApp::parseDestAddressesPar(), inet::UDPBasicBurst::processStart(), inet::IPv4NetworkConfigurator::readManualMulticastRouteConfiguration(), inet::IPv4NetworkConfigurator::readManualRouteConfiguration(), inet::RSVP::readTrafficRouteFromXML(), inet::UDPVideoStreamCli::requestStream(), resolve(), inet::IPv4NetworkConfigurator::resolveInterfaceAndGateway(), inet::tcp::TCPSpoof::sendSpoofPacket(), inet::SimpleVoIPSender::sendVoIPPacket(), inet::UDPSink::setSocketOptions(), inet::SCTPNatPeer::socketClosed(), inet::SCTPNatPeer::socketPeerClosed(), and inet::DHCPServer::startApp().
50 throw cRuntimeError(
"L3AddressResolver: address `%s' not configured (yet?)",
s);
virtual bool tryResolve(const char *str, L3Address &result, int addrType=DEFAULT_ADDR_TYPE)
Similar to resolve(), but returns false (instead of throwing an error) if the address cannot be resol...
Definition: L3AddressResolver.cc:64
value< double, units::s > s
Definition: Units.h:1049
Similar to resolve(), but returns false (instead of throwing an error) if the address cannot be resolved because the given host (or interface) doesn't have an address assigned yet.
(It still throws an error on any other error condition).
Referenced by inet::TCPAppBase::connect(), inet::SCTPClient::connect(), inet::SCTPPeer::connect(), inet::IPvXTrafGen::handleMessage(), inet::UDPBasicApp::processStart(), and resolve().
72 if (result.tryParse(
s))
79 std::string modname, ifname,
protocol, destnodename;
82 const char *endp = strchr(p,
'\0');
83 const char *nextsep = strpbrk(p,
"%>(/");
86 modname.assign(p, nextsep - p);
93 nextsep = strpbrk(p,
"(/");
97 ifname.assign(p, nextsep - p);
103 nextsep = strpbrk(p,
"(/");
107 destnodename.assign(p, nextsep - p);
114 nextsep = strpbrk(p,
")");
118 protocol.assign(p, nextsep - p);
139 throw cRuntimeError(
"L3AddressResolver: syntax error parsing address spec `%s'",
s);
142 cModule *
mod = getSimulation()->getModuleByPath(modname.c_str());
144 throw cRuntimeError(
"L3AddressResolver: module `%s' not found", modname.c_str());
147 if (!protocol.empty()) {
148 if (protocol ==
"ipv4")
150 else if (protocol ==
"ipv6")
152 else if (protocol ==
"mac")
154 else if (protocol ==
"modulepath")
156 else if (protocol ==
"moduleid")
159 throw cRuntimeError(
"L3AddressResolver: error parsing address spec `%s': address type must be `(ipv4)' or `(ipv6)'",
s);
166 if (!destnodename.empty()) {
167 cModule *destnode = getSimulation()->getModuleByPath(destnodename.c_str());
169 throw cRuntimeError(
"L3AddressResolver: destination module `%s' not found", destnodename.c_str());
170 result =
addressOf(mod, destnode, addrType);
172 else if (ifname.empty())
174 else if (ifname ==
"routerId")
177 result =
addressOf(mod, ifname.c_str(), addrType);
double mod(double dividend, double divisor)
Returns the rest of a whole-numbered division.
Definition: INETMath.h:108
Definition: L3AddressResolver.h:81
virtual L3Address addressOf(cModule *host, int addrType=DEFAULT_ADDR_TYPE)
Returns IPv4 or IPv6 address of the given host or router.
Definition: L3AddressResolver.cc:191
uint8_t protocol
Definition: TCP_NSC.cc:88
virtual L3Address routerIdOf(cModule *host)
Returns the router Id of the given router.
Definition: L3AddressResolver.cc:181
Definition: L3AddressResolver.h:82
const value< double, compose< units::m, pow< units::s,-1 > > > c(299792458)
bool isUnspecified() const
Definition: L3Address.cc:133
Definition: L3AddressResolver.h:85
Definition: L3AddressResolver.h:83
Definition: L3AddressResolver.h:84
Definition: L3AddressResolver.h:80
value< double, units::s > s
Definition: Units.h:1049