--- a/src/internet-stack/ipv4-raw-socket-impl.cc Mon Jun 14 17:35:42 2010 +0100
+++ b/src/internet-stack/ipv4-raw-socket-impl.cc Tue Jun 15 18:29:45 2010 +0100
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
#include <netinet/in.h>
#include "ipv4-raw-socket-impl.h"
#include "ipv4-l3-protocol.h"
@@ -323,4 +324,19 @@
return false;
}
+void
+Ipv4RawSocketImpl::SetAllowBroadcast (bool allowBroadcast)
+{
+ if (!allowBroadcast)
+ {
+ NS_FATAL_ERROR ("not implemented");
+ }
+}
+
+bool
+Ipv4RawSocketImpl::GetAllowBroadcast () const
+{
+ return true;
+}
+
} // namespace ns3
--- a/src/internet-stack/ipv4-raw-socket-impl.h Mon Jun 14 17:35:42 2010 +0100
+++ b/src/internet-stack/ipv4-raw-socket-impl.h Tue Jun 15 18:29:45 2010 +0100
@@ -1,3 +1,4 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
#ifndef IPV4_RAW_SOCKET_IMPL_H
#define IPV4_RAW_SOCKET_IMPL_H
@@ -41,6 +42,9 @@
void SetProtocol (uint16_t protocol);
bool ForwardUp (Ptr<const Packet> p, Ipv4Header ipHeader, Ptr<NetDevice> device);
+ virtual void SetAllowBroadcast (bool allowBroadcast);
+ virtual bool GetAllowBroadcast () const;
+
private:
virtual void DoDispose (void);
--- a/src/internet-stack/ipv6-raw-socket-impl.cc Mon Jun 14 17:35:42 2010 +0100
+++ b/src/internet-stack/ipv6-raw-socket-impl.cc Tue Jun 15 18:29:45 2010 +0100
@@ -337,5 +337,20 @@
return false;
}
+void
+Ipv6RawSocketImpl::SetAllowBroadcast (bool allowBroadcast)
+{
+ if (!allowBroadcast)
+ {
+ NS_FATAL_ERROR ("not implemented");
+ }
+}
+
+bool
+Ipv6RawSocketImpl::GetAllowBroadcast () const
+{
+ return true;
+}
+
} /* namespace ns3 */
--- a/src/internet-stack/ipv6-raw-socket-impl.h Mon Jun 14 17:35:42 2010 +0100
+++ b/src/internet-stack/ipv6-raw-socket-impl.h Tue Jun 15 18:29:45 2010 +0100
@@ -186,6 +186,9 @@
*/
bool ForwardUp (Ptr<const Packet> p, Ipv6Header hdr, Ptr<NetDevice> device);
+ virtual void SetAllowBroadcast (bool allowBroadcast);
+ virtual bool GetAllowBroadcast () const;
+
private:
/**
* \struct Data
--- a/src/internet-stack/nsc-tcp-socket-impl.cc Mon Jun 14 17:35:42 2010 +0100
+++ b/src/internet-stack/nsc-tcp-socket-impl.cc Tue Jun 15 18:29:45 2010 +0100
@@ -818,4 +818,19 @@
return ERROR_INVAL;
}
+void
+NscTcpSocketImpl::SetAllowBroadcast (bool allowBroadcast)
+{
+ if (allowBroadcast)
+ {
+ NS_FATAL_ERROR ("not implemented");
+ }
+}
+
+bool
+NscTcpSocketImpl::GetAllowBroadcast () const
+{
+ return false;
+}
+
}//namespace ns3
--- a/src/internet-stack/nsc-tcp-socket-impl.h Mon Jun 14 17:35:42 2010 +0100
+++ b/src/internet-stack/nsc-tcp-socket-impl.h Tue Jun 15 18:29:45 2010 +0100
@@ -82,6 +82,8 @@
virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
Address &fromAddress);
virtual int GetSockName (Address &address) const;
+ virtual void SetAllowBroadcast (bool allowBroadcast);
+ virtual bool GetAllowBroadcast () const;
private:
void NSCWakeup(void);
--- a/src/internet-stack/tcp-socket-impl.cc Mon Jun 14 17:35:42 2010 +0100
+++ b/src/internet-stack/tcp-socket-impl.cc Tue Jun 15 18:29:45 2010 +0100
@@ -1855,6 +1855,18 @@
return m_delAckMaxCount;
}
+void
+TcpSocketImpl::SetAllowBroadcast (bool allowBroadcast)
+{
+ NS_FATAL_ERROR ("not implemented");
+}
+
+bool
+TcpSocketImpl::GetAllowBroadcast () const
+{
+ return false;
+}
+
}//namespace ns3
--- a/src/internet-stack/tcp-socket-impl.h Mon Jun 14 17:35:42 2010 +0100
+++ b/src/internet-stack/tcp-socket-impl.h Tue Jun 15 18:29:45 2010 +0100
@@ -96,6 +96,8 @@
Address &fromAddress);
virtual int GetSockName (Address &address) const;
virtual void BindToNetDevice (Ptr<NetDevice> netdevice);
+ virtual void SetAllowBroadcast (bool allowBroadcast);
+ virtual bool GetAllowBroadcast () const;
private:
friend class Tcp;
--- a/src/internet-stack/udp-socket-impl.cc Mon Jun 14 17:35:42 2010 +0100
+++ b/src/internet-stack/udp-socket-impl.cc Tue Jun 15 18:29:45 2010 +0100
@@ -703,5 +703,20 @@
return m_mtuDiscover;
}
+void
+UdpSocketImpl::SetAllowBroadcast (bool allowBroadcast)
+{
+ if (!allowBroadcast)
+ {
+ NS_FATAL_ERROR ("not implemented");
+ }
+}
+
+bool
+UdpSocketImpl::GetAllowBroadcast () const
+{
+ return true;
+}
+
} //namespace ns3
--- a/src/internet-stack/udp-socket-impl.h Mon Jun 14 17:35:42 2010 +0100
+++ b/src/internet-stack/udp-socket-impl.h Tue Jun 15 18:29:45 2010 +0100
@@ -78,6 +78,8 @@
virtual int MulticastJoinGroup (uint32_t interfaceIndex, const Address &groupAddress);
virtual int MulticastLeaveGroup (uint32_t interfaceIndex, const Address &groupAddress);
virtual void BindToNetDevice (Ptr<NetDevice> netdevice);
+ virtual void SetAllowBroadcast (bool allowBroadcast);
+ virtual bool GetAllowBroadcast () const;
private:
// Attributes set through UdpSocket base class
--- a/src/node/packet-socket.cc Mon Jun 14 17:35:42 2010 +0100
+++ b/src/node/packet-socket.cc Tue Jun 15 18:29:45 2010 +0100
@@ -461,4 +461,16 @@
return 0;
}
+void
+PacketSocket::SetAllowBroadcast (bool allowBroadcast)
+{
+ NS_FATAL_ERROR ("not implemented");
+}
+
+bool
+PacketSocket::GetAllowBroadcast () const
+{
+ return true;
+}
+
}//namespace ns3
--- a/src/node/packet-socket.h Mon Jun 14 17:35:42 2010 +0100
+++ b/src/node/packet-socket.h Tue Jun 15 18:29:45 2010 +0100
@@ -102,6 +102,8 @@
virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
Address &fromAddress);
virtual int GetSockName (Address &address) const;
+ virtual void SetAllowBroadcast (bool allowBroadcast);
+ virtual bool GetAllowBroadcast () const;
private:
void ForwardUp (Ptr<NetDevice> device, Ptr<const Packet> packet,
--- a/src/node/socket.h Mon Jun 14 17:35:42 2010 +0100
+++ b/src/node/socket.h Tue Jun 15 18:29:45 2010 +0100
@@ -546,6 +546,30 @@
* \returns Pointer to interface.
*/
Ptr<NetDevice> GetBoundNetDevice ();
+
+
+ /**
+ * \brief Configure whether broadcast datagram transmissions are allowed
+ *
+ * This method corresponds to using setsockopt() SO_BROADCAST of
+ * real network or BSD sockets. If set on a socket, this option
+ * will enable or disable packets to be transmitted to broadcast
+ * destination addresses.
+ *
+ * \param allowBroadcast Whether broadcast is allowed
+ */
+ virtual void SetAllowBroadcast (bool allowBroadcast) = 0;
+
+ /**
+ * \brief Query whether broadcast datagram transmissions are allowed
+ *
+ * This method corresponds to using getsockopt() SO_BROADCAST of
+ * real network or BSD sockets.
+ *
+ * \returns true if broadcast is allowed, false otherwise
+ */
+ virtual bool GetAllowBroadcast () const = 0;
+
protected:
void NotifyConnectionSucceeded (void);