struct AddressSyntaxException : public AddressException
{
AddressSyntaxException() : AddressException("invalid address syntax") {}
- AddressSyntaxException(const std::string &addr)
+ AddressSyntaxException(std::string const & addr)
: AddressException("Invalid address syntax (\"" + addr + "\")") {}
};
struct UnknownHostnameException : public AddressException
{
UnknownHostnameException() : AddressException("failed to resolve hostname") {}
- UnknownHostnameException(const std::string &hostname)
+ UnknownHostnameException(std::string const & hostname)
: AddressException("Failed to resolve hostname (\"" + hostname + "\")") {}
};
+ /** \brief Unknown interface */
+ struct UnknownInterfaceException : public AddressException
+ {
+ UnknownInterfaceException() : AddressException("Unknown interface") {}
+ UnknownInterfaceException(std::string const & interface)
+ : AddressException("Unknown interface (\"" + interface + "\")") {}
+ };
+
}
///////////////////////////////hh.e////////////////////////////////////////
char name[IFNAMSIZ];
::bzero(name, IFNAMSIZ);
if (! ::if_indextoname(addr_.sll_ifindex, name))
- throw AddressSyntaxException();
+ throw UnknownInterfaceException();
return std::string(name);
}
else {
addr_.sll_ifindex = if_nametoindex(iface.c_str());
if (addr_.sll_ifindex == 0)
- throw AddressSyntaxException();
+ throw UnknownInterfaceException(iface);
}
}
PacketSocketHandle::bind() with.
\param[in] proto Protocol (Ethertype) to listen for
\param[in] iface Interface name to bind to */
- explicit LLSocketAddress(std::string const &iface);
+ explicit LLSocketAddress(std::string const & iface);
///< Create address for \c bind()
/**< This constructs an LLSocketAddress valid for calling
\c PacketSocketHandle::bind() with.
- \param[in] iface Interface name to bind to */
+ \param[in] iface Interface name to bind to
+ \throws UnknownInterfaceException if \a iface is not
+ a valid interface name. */
// This constructor is for sending packets
explicit LLSocketAddress(MACAddress const & addr, std::string const & iface="");
use with \c PacketSocketHandle::sendto() on a \c
SOCK_DGRAM packet socket.
\param addr Address to send data to
- \param iface Interface to send packet from */
+ \param iface Interface to send packet from
+ \throws UnknownInterfaceException if \a iface is not
+ a valid interface name. */
LLSocketAddress(const LLSocketAddress& other);
LLSocketAddress& operator=(const LLSocketAddress& other);
void address(MACAddress const & addr); ///< Change address
void interface(std::string const & iface); ///< Change interface
+ /**< \throws UnknownInterfaceException if \a iface
+ is not a valid interface name. */
void protocol(unsigned prot); ///< Change protocol
using BSDSocketAddress::sockaddr_p;
to a MAC address. This conversion is only possible, if
the EUI-64 is MAC compatible: the 4th/5th byte (in
transmission order) must be 0xFFFE.
- \throws AddressSyntaxException if \a v is not a MAC
+ \throws AddressSyntaxException if \a eui is not a MAC
compatible EUI-64. */
bool local() const; ///< \c true, if address is locally administered