Commit 86a4ce45 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[1238] Changes after review: openSocket*() now returns int

parent 14a64484
......@@ -87,11 +87,7 @@ bool IfaceMgr::Iface::delAddress(const isc::asiolink::IOAddress& addr) {
// of the same address added, we are in deep problems anyway.
size_t size = addrs_.size();
addrs_.erase(remove(addrs_.begin(), addrs_.end(), addr), addrs_.end());
if (addrs_.size() < size) {
return (true);
} else {
return (false);
}
return (addrs_.size() < size);
}
bool IfaceMgr::Iface::delSocket(uint16_t sockfd) {
......@@ -274,9 +270,8 @@ IfaceMgr::getIface(const std::string& ifname) {
return (NULL); // not found
}
uint16_t
IfaceMgr::openSocket(const std::string& ifname,
const IOAddress& addr,
int
IfaceMgr::openSocket(const std::string& ifname, const IOAddress& addr,
int port) {
Iface* iface = getIface(ifname);
if (!iface) {
......@@ -293,7 +288,7 @@ IfaceMgr::openSocket(const std::string& ifname,
}
}
uint16_t
int
IfaceMgr::openSocket4(Iface& iface, const IOAddress& addr, int port) {
cout << "Creating UDP4 socket on " << iface.getFullName()
......@@ -335,7 +330,7 @@ IfaceMgr::openSocket4(Iface& iface, const IOAddress& addr, int port) {
return (sock);
}
uint16_t
int
IfaceMgr::openSocket6(Iface& iface, const IOAddress& addr, int port) {
cout << "Creating UDP6 socket on " << iface.getFullName()
......
......@@ -291,8 +291,8 @@ public:
///
/// @return socket descriptor, if socket creation, binding and multicast
/// group join were all successful.
uint16_t openSocket(const std::string& ifname,
const isc::asiolink::IOAddress& addr, int port);
int openSocket(const std::string& ifname,
const isc::asiolink::IOAddress& addr, int port);
/// Opens IPv6 sockets on detected interfaces.
///
......@@ -328,7 +328,7 @@ protected:
/// @param port a port that created socket should be bound to
///
/// @return socket descriptor
uint16_t openSocket4(Iface& iface, const isc::asiolink::IOAddress& addr, int port);
int openSocket4(Iface& iface, const isc::asiolink::IOAddress& addr, int port);
/// @brief Opens IPv6 socket.
///
......@@ -341,7 +341,7 @@ protected:
/// @param port a port that created socket should be bound to
///
/// @return socket descriptor
uint16_t openSocket6(Iface& iface, const isc::asiolink::IOAddress& addr, int port);
int openSocket6(Iface& iface, const isc::asiolink::IOAddress& addr, int port);
/// @brief Adds an interface to list of known interfaces.
///
......
......@@ -57,15 +57,13 @@ TEST_F(Dhcpv6SrvTest, basic) {
// interfaces.txt instead. It will pretend to have detected
// fe80::1234 link-local address on eth0 interface. Obviously
// an attempt to bind this socket will fail.
Dhcpv6Srv * srv = 0;
Dhcpv6Srv* srv = 0;
ASSERT_NO_THROW( {
// open an unpriviledged port
srv = new Dhcpv6Srv(DHCP6_SERVER_PORT + 10000);
});
if (srv) {
delete srv;
}
delete srv;
}
TEST_F(Dhcpv6SrvTest, Solicit_basic) {
......@@ -75,7 +73,7 @@ TEST_F(Dhcpv6SrvTest, Solicit_basic) {
// a dummy content for client-id
boost::shared_array<uint8_t> clntDuid(new uint8_t[32]);
for (int i = 0; i < 32; i++)
clntDuid[i] = 100+i;
clntDuid[i] = 100 + i;
boost::shared_ptr<Pkt6> sol =
boost::shared_ptr<Pkt6>(new Pkt6(DHCPV6_SOLICIT,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment