diff -r fe4800b06445 src/internet-stack/ipv4-raw-socket-impl.cc --- a/src/internet-stack/ipv4-raw-socket-impl.cc Thu Jun 10 11:45:16 2010 +0530 +++ b/src/internet-stack/ipv4-raw-socket-impl.cc Tue Jun 15 11:33:21 2010 +0100 @@ -1,3 +1,4 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ #include #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 diff -r fe4800b06445 src/internet-stack/ipv4-raw-socket-impl.h --- a/src/internet-stack/ipv4-raw-socket-impl.h Thu Jun 10 11:45:16 2010 +0530 +++ b/src/internet-stack/ipv4-raw-socket-impl.h Tue Jun 15 11:33:21 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 p, Ipv4Header ipHeader, Ptr device); + virtual void SetAllowBroadcast (bool allowBroadcast); + virtual bool GetAllowBroadcast () const; + private: virtual void DoDispose (void); diff -r fe4800b06445 src/internet-stack/ipv6-raw-socket-impl.cc --- a/src/internet-stack/ipv6-raw-socket-impl.cc Thu Jun 10 11:45:16 2010 +0530 +++ b/src/internet-stack/ipv6-raw-socket-impl.cc Tue Jun 15 11:33:21 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 */ diff -r fe4800b06445 src/internet-stack/ipv6-raw-socket-impl.h --- a/src/internet-stack/ipv6-raw-socket-impl.h Thu Jun 10 11:45:16 2010 +0530 +++ b/src/internet-stack/ipv6-raw-socket-impl.h Tue Jun 15 11:33:21 2010 +0100 @@ -186,6 +186,9 @@ */ bool ForwardUp (Ptr p, Ipv6Header hdr, Ptr device); + virtual void SetAllowBroadcast (bool allowBroadcast); + virtual bool GetAllowBroadcast () const; + private: /** * \struct Data diff -r fe4800b06445 src/internet-stack/nsc-tcp-socket-impl.cc --- a/src/internet-stack/nsc-tcp-socket-impl.cc Thu Jun 10 11:45:16 2010 +0530 +++ b/src/internet-stack/nsc-tcp-socket-impl.cc Tue Jun 15 11:33:21 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 diff -r fe4800b06445 src/internet-stack/nsc-tcp-socket-impl.h --- a/src/internet-stack/nsc-tcp-socket-impl.h Thu Jun 10 11:45:16 2010 +0530 +++ b/src/internet-stack/nsc-tcp-socket-impl.h Tue Jun 15 11:33:21 2010 +0100 @@ -82,6 +82,8 @@ virtual Ptr 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); diff -r fe4800b06445 src/internet-stack/tcp-socket-impl.cc --- a/src/internet-stack/tcp-socket-impl.cc Thu Jun 10 11:45:16 2010 +0530 +++ b/src/internet-stack/tcp-socket-impl.cc Tue Jun 15 11:33:21 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 diff -r fe4800b06445 src/internet-stack/tcp-socket-impl.h --- a/src/internet-stack/tcp-socket-impl.h Thu Jun 10 11:45:16 2010 +0530 +++ b/src/internet-stack/tcp-socket-impl.h Tue Jun 15 11:33:21 2010 +0100 @@ -96,6 +96,8 @@ Address &fromAddress); virtual int GetSockName (Address &address) const; virtual void BindToNetDevice (Ptr netdevice); + virtual void SetAllowBroadcast (bool allowBroadcast); + virtual bool GetAllowBroadcast () const; private: friend class Tcp; diff -r fe4800b06445 src/internet-stack/udp-socket-impl.cc --- a/src/internet-stack/udp-socket-impl.cc Thu Jun 10 11:45:16 2010 +0530 +++ b/src/internet-stack/udp-socket-impl.cc Tue Jun 15 11:33:21 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 diff -r fe4800b06445 src/internet-stack/udp-socket-impl.h --- a/src/internet-stack/udp-socket-impl.h Thu Jun 10 11:45:16 2010 +0530 +++ b/src/internet-stack/udp-socket-impl.h Tue Jun 15 11:33:21 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); + virtual void SetAllowBroadcast (bool allowBroadcast); + virtual bool GetAllowBroadcast () const; private: // Attributes set through UdpSocket base class diff -r fe4800b06445 src/node/socket.h --- a/src/node/socket.h Thu Jun 10 11:45:16 2010 +0530 +++ b/src/node/socket.h Tue Jun 15 11:33:21 2010 +0100 @@ -546,6 +546,30 @@ * \returns Pointer to interface. */ Ptr 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);