--- a/src/internet-node/udp-socket.cc Mon Jul 30 13:29:36 2007 +0200
+++ b/src/internet-node/udp-socket.cc Mon Jul 30 13:55:28 2007 +0200
@@ -91,6 +91,10 @@
int
UdpSocket::Bind (const Address &address)
{
+ if (!InetSocketAddress::IsMatchingType (address))
+ {
+ return ERROR_INVAL;
+ }
InetSocketAddress transport = InetSocketAddress::ConvertFrom (address);
Ipv4Address ipv4 = transport.GetIpv4 ();
uint16_t port = transport.GetPort ();
--- a/src/node/inet-socket-address.cc Mon Jul 30 13:29:36 2007 +0200
+++ b/src/node/inet-socket-address.cc Mon Jul 30 13:55:28 2007 +0200
@@ -45,6 +45,12 @@
m_ipv4 = address;
}
+bool
+InetSocketAddress::IsMatchingType (const Address &address)
+{
+ return address.CheckCompatible (GetType (), 6);
+}
+
Address
InetSocketAddress::ConvertTo (void) const
{
--- a/src/node/inet-socket-address.h Mon Jul 30 13:29:36 2007 +0200
+++ b/src/node/inet-socket-address.h Mon Jul 30 13:55:28 2007 +0200
@@ -64,6 +64,8 @@
*/
void SetIpv4 (Ipv4Address address);
+ static bool IsMatchingType (const Address &address);
+
/**
* \returns an Address instance which represents this
* InetSocketAddress instance.
--- a/src/node/socket.h Mon Jul 30 13:29:36 2007 +0200
+++ b/src/node/socket.h Mon Jul 30 13:55:28 2007 +0200
@@ -52,6 +52,7 @@
ERROR_AGAIN,
ERROR_SHUTDOWN,
ERROR_OPNOTSUPP,
+ ERROR_INVAL,
SOCKET_ERRNO_LAST
};