21 #include <netinet/in.h>
22 #include <sys/socket.h>
23 #include <sys/types.h>
24 #include "ns3/inet6-socket-address.h"
26 #include "ns3/packet.h"
27 #include "ns3/uinteger.h"
29 #include "ns3/ipv6-route.h"
30 #include "ns3/ipv6-routing-protocol.h"
31 #include "ns3/ipv6-packet-info-tag.h"
33 #include "ipv6-l3-protocol.h"
34 #include "ipv6-raw-socket-impl.h"
35 #include "icmpv6-header.h"
36 #include "icmpv6-l4-protocol.h"
44 NS_OBJECT_ENSURE_REGISTERED (Ipv6RawSocketImpl);
50 .AddAttribute (
"Protocol",
"Protocol number to match.",
53 MakeUintegerChecker<uint16_t> ())
61 m_err = Socket::ERROR_NOTERROR;
110 m_err = Socket::ERROR_INVAL;
144 ipv6->DeleteRawSocket (
this);
169 m_err = Socket::ERROR_INVAL;
181 m_err = Socket::ERROR_OPNOTSUPP;
189 return SendTo (p, flags, to);
198 m_err = Socket::ERROR_INVAL;
211 if (ipv6->GetRoutingProtocol ())
215 SocketErrno err = ERROR_NOTERROR;
221 int32_t index = ipv6->GetInterfaceForAddress (
m_src);
223 oif = ipv6->GetNetDevice (index);
226 route = ipv6->GetRoutingProtocol ()->RouteOutput (p, hdr, oif, err);
238 if (type == Icmpv6Header::ICMPV6_ECHO_REQUEST)
247 ipv6->Send (p, route->GetSource (), dst,
m_protocol, route);
263 return RecvFrom (maxSize, flags, tmp);
282 if (!(flags & MSG_PEEK))
304 for (std::list<Data>::const_iterator it =
m_data.begin (); it !=
m_data.end (); ++it)
306 rx+= (it->packet)->GetSize ();
324 if (boundNetDevice != device)
341 uint8_t type = icmpHeader.
GetType ();
355 tag.SetRecvIf (device->GetIfIndex ());
402 (
m_icmpFilter.icmpv6Filt[(type) >> 5]) |= (uint32_t(1) << ((type) & 31));
408 (
m_icmpFilter.icmpv6Filt[(type) >> 5]) &= ~(uint32_t(1) << ((type) & 31));
414 return (((
m_icmpFilter.icmpv6Filt[(type) >> 5]) & (uint32_t(1) << ((type) & 31))) != 0);
420 return (((
m_icmpFilter.icmpv6Filt[(type) >> 5]) & (uint32_t(1) << ((type) & 31))) == 0);
void SetNode(Ptr< Node > node)
Set the node.
bool IsAny() const
If the IPv6 address is the "Any" address.
uint32_t RemoveHeader(Header &header)
Ipv6Address GetIpv6(void) const
Get the IPv6 address.
#define NS_LOG_FUNCTION(parameters)
virtual void DoDispose()
Dispose object.
virtual int Connect(const Address &address)
Connect to address.
virtual uint32_t GetSerializedSize() const
Get the serialized size.
Ipv6Address m_src
Source address.
Ptr< Packet > Recv(void)
Read a single packet from the socket.
IPv6 layer implementation.
void AddPacketTag(const Tag &tag) const
bool m_shutdownSend
Flag to shutdown send capability.
#define NS_ASSERT(condition)
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
#define NS_LOG_COMPONENT_DEFINE(name)
uint32_t GetSize(void) const
virtual int ShutdownSend()
Shutdown send capability.
#define NS_LOG_FUNCTION_NOARGS()
static TypeId GetTypeId()
Get the type ID of this class.
bool ForwardUp(Ptr< const Packet > p, Ipv6Header hdr, Ptr< NetDevice > device)
Forward up to receive method.
virtual enum Socket::SocketType GetSocketType() const
Get socket type (NS3_SOCK_RAW)
virtual enum Socket::SocketErrno GetErrno() const
Get last error number.
bool IsRecvPktInfo() const
Get status indicating whether enable/disable packet information to socket.
virtual int Send(Ptr< Packet > p, uint32_t flags)
Send a packet.
a polymophic address class
virtual int Bind()
Bind socket.
bool m_shutdownRecv
Flag to shutdown receive capability.
Ptr< NetDevice > GetBoundNetDevice()
Returns socket's bound netdevice, if any.
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
A low-level Socket API based loosely on the BSD Socket API.A few things to keep in mind about this ty...
void RemoveAtStart(uint32_t size)
std::list< struct Data > m_data
Packet waiting to be processed.
Hold an unsigned integer type.
virtual int GetSockName(Address &address) const
Get socket address.
Ipv6RawSocketImpl()
Constructor.
void Icmpv6FilterSetBlock(uint8_t type)
Set the filter to block one ICMPv6 type.
virtual int Bind6()
Allocate a local IPv6 endpoint for this socket.
#define NS_LOG_LOGIC(msg)
virtual Ptr< Node > GetNode() const
Get node.
IPv6 raw data and additional information.
Struct to hold the ICMPv6 filter.
virtual int Listen()
Listen.
Ptr< Packet > Copy(void) const
uint32_t PeekHeader(Header &header) const
static uint16_t GetStaticProtocolNumber()
Get ICMPv6 protocol number.
bool Icmpv6FilterWillBlock(uint8_t type)
Ask the filter about the status of one ICMPv6 type.
void Icmpv6FilterSetPass(uint8_t type)
Set the filter to pass one ICMPv6 type.
virtual ~Ipv6RawSocketImpl()
Destructor.
icmpv6Filter m_icmpFilter
ICMPv6 filter.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)
Receive packet.
virtual bool SetAllowBroadcast(bool allowBroadcast)
Configure whether broadcast datagram transmissions are allowed.
virtual void DoDispose(void)
virtual uint32_t GetRxAvailable() const
Get RX size available.
Describes an IPv6 address.
virtual uint32_t GetTxAvailable() const
Get TX size available.
enum Socket::SocketErrno m_err
Last error number.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)
Send a packet.
virtual int Close()
Close the socket.
Ipv6Address m_dst
Destination address.
bool RemovePacketTag(Tag &tag)
#define NS_LOG_DEBUG(msg)
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
bool Icmpv6FilterWillPass(uint8_t type)
Ask the filter about the status of one ICMPv6 type.
void Icmpv6FilterSetPassAll()
Clean the ICMPv6 filter structure.
static bool IsMatchingType(const Address &addr)
If the address match.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
This class implements a tag that carries socket ancillary data to the socket interface. This is used like socket option of IP_PKTINFO/IPV6_PKTINFO in RFC 3542 See: http://tools.ietf.org/html/rfc3542.
virtual int ShutdownRecv()
Shutdown receive capability.
Ptr< T > GetObject(void) const
virtual bool GetAllowBroadcast() const
Query whether broadcast datagram transmissions are allowed.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
void AddHeader(const Header &header)
uint16_t m_protocol
Protocol.
void Icmpv6FilterSetBlockAll()
Set the filter to block all the ICMPv6 types.