29#include "ns3/inet6-socket-address.h"
32#include "ns3/packet.h"
33#include "ns3/uinteger.h"
38#include <netinet/in.h>
39#include <sys/socket.h>
56 .SetGroupName(
"Internet")
57 .AddAttribute(
"Protocol",
58 "Protocol number to match.",
61 MakeUintegerChecker<uint16_t>());
178 ipv6->DeleteRawSocket(
this);
230 return SendTo(p, flags, to);
257 p->AddPacketTag(ipTclassTag);
264 p->AddPacketTag(tag);
267 if (ipv6->GetRoutingProtocol())
279 oif = ipv6->GetNetDevice(index);
282 route = ipv6->GetRoutingProtocol()->RouteOutput(p, hdr, oif, err);
293 p->CopyData(&type,
sizeof(type));
297 p->RemoveHeader(hdr);
309 ipv6->Send(p, route->GetSource(), dst,
m_protocol, route);
333 return RecvFrom(maxSize, flags, tmp);
350 if (
data.packet->GetSize() > maxSize)
353 if (!(flags & MSG_PEEK))
355 data.packet->RemoveAtStart(maxSize);
367 std::vector<Ipv6Address> sourceAddresses)
373 "Can join only one IPv6 multicast group.");
380 if (filterMode ==
INCLUDE && sourceAddresses.empty())
386 NS_ASSERT_MSG(index >= 0,
"Interface without a valid index");
387 ipv6l3->RemoveMulticastAddress(address, index);
391 ipv6l3->RemoveMulticastAddress(address);
400 NS_ASSERT_MSG(index >= 0,
"Interface without a valid index");
401 ipv6l3->AddMulticastAddress(address, index);
405 ipv6l3->AddMulticastAddress(address);
424 for (std::list<Data>::const_iterator it =
m_data.begin(); it !=
m_data.end(); ++it)
445 if (boundNetDevice != device)
461 copy->PeekHeader(icmpHeader);
462 uint8_t type = icmpHeader.
GetType();
475 copy->RemovePacketTag(tag);
480 copy->AddPacketTag(tag);
488 copy->AddPacketTag(ipTclassTag);
495 copy->AddPacketTag(ipHopLimitTag);
498 copy->AddHeader(hdr);
513 return allowBroadcast;
a polymophic address class
uint32_t GetSerializedSize() const override
Get the serialized size.
static uint16_t GetStaticProtocolNumber()
Get ICMPv6 protocol number.
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
static bool IsMatchingType(const Address &addr)
If the address match.
Ipv6Address GetIpv6() const
Get the IPv6 address.
Describes an IPv6 address.
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
bool IsAny() const
If the IPv6 address is the "Any" address.
IPv6 layer implementation.
This class implements a tag that carries socket ancillary data to the socket interface.
void SetTrafficClass(uint8_t tclass)
Set the tag's Traffic Class.
void SetRecvIf(uint32_t ifindex)
Set the tag's receiving interface.
void SetHoplimit(uint8_t ttl)
Set the tag's Hop Limit.
void SetAddress(Ipv6Address addr)
Set the tag's address.
bool Icmpv6FilterWillBlock(uint8_t type)
Ask the filter about the status of one ICMPv6 type.
Socket::SocketErrno m_err
Last error number.
void Icmpv6FilterSetBlockAll()
Set the filter to block all the ICMPv6 types.
int Listen() override
Listen for incoming connections.
bool SetAllowBroadcast(bool allowBroadcast) override
Configure whether broadcast datagram transmissions are allowed.
int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress) override
Send data to a specified peer.
void SetNode(Ptr< Node > node)
Set the node associated with this socket.
uint32_t GetRxAvailable() const override
Return number of bytes which can be returned from one or multiple calls to Recv.
void Icmpv6FilterSetBlock(uint8_t type)
Set the filter to block one ICMPv6 type.
Ipv6Address m_src
Source address.
Icmpv6Filter m_icmpFilter
ICMPv6 filter.
int Bind6() override
Allocate a local IPv6 endpoint for this socket.
int Close() override
Close a socket.
int Send(Ptr< Packet > p, uint32_t flags) override
Send data (or dummy data) to the remote host.
int ShutdownSend() override
~Ipv6RawSocketImpl() override
int GetPeerName(Address &address) const override
Get the peer address of a connected socket.
bool GetAllowBroadcast() const override
Query whether broadcast datagram transmissions are allowed.
Ptr< Node > GetNode() const override
Return the node this socket is associated with.
Socket::SocketType GetSocketType() const override
Get socket type (NS3_SOCK_RAW)
static TypeId GetTypeId()
Get the type ID of this class.
bool m_shutdownRecv
Flag to shutdown receive capability.
Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress) override
Read a single packet from the socket and retrieve the sender address.
int Bind() override
Allocate a local IPv4 endpoint for this socket.
int GetSockName(Address &address) const override
Get socket address.
int ShutdownRecv() override
bool m_shutdownSend
Flag to shutdown send capability.
bool ForwardUp(Ptr< const Packet > p, Ipv6Header hdr, Ptr< NetDevice > device)
Forward up to receive method.
int Connect(const Address &address) override
Initiate a connection to a remote host.
bool Icmpv6FilterWillPass(uint8_t type)
Ask the filter about the status of one ICMPv6 type.
uint32_t GetTxAvailable() const override
Returns the number of bytes which can be sent in a single call to Send.
Socket::SocketErrno GetErrno() const override
Get last error number.
Ipv6Address m_dst
Destination address.
uint16_t m_protocol
Protocol.
void DoDispose() override
Dispose object.
std::list< Data > m_data
Packet waiting to be processed.
void Icmpv6FilterSetPass(uint8_t type)
Set the filter to pass one ICMPv6 type.
void Ipv6JoinGroup(Ipv6Address address, Socket::Ipv6MulticastFilterMode filterMode, std::vector< Ipv6Address > sourceAddresses) override
Joins a IPv6 multicast group.
void Icmpv6FilterSetPassAll()
Clean the ICMPv6 filter structure.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Smart pointer class similar to boost::intrusive_ptr.
A low-level Socket API based loosely on the BSD Socket API.
Ptr< NetDevice > GetBoundNetDevice()
Returns socket's bound NetDevice, if any.
Ptr< Packet > Recv()
Read a single packet from the socket.
virtual void Ipv6LeaveGroup()
Leaves IPv6 multicast group this socket is joined to.
void NotifySend(uint32_t spaceAvailable)
Notify through the callback (if set) that some data have been sent.
bool IsRecvPktInfo() const
Get status indicating whether enable/disable packet information to socket.
Ipv6Address m_ipv6MulticastGroupAddress
IPv6 multicast group address.
SocketType
Enumeration of the possible socket types.
void NotifyDataRecv()
Notify through the callback (if set) that some data have been received.
Ipv6MulticastFilterMode
Enumeration of the possible filter of a socket.
Ptr< NetDevice > m_boundnetdevice
the device this socket is bound to (might be null).
bool IsIpv6RecvTclass() const
Ask if the socket is currently passing information about IPv6 Traffic Class up the stack.
bool IsIpv6RecvHopLimit() const
Ask if the socket is currently passing information about IPv6 Hop Limit up the stack.
virtual uint8_t GetIpv6HopLimit() const
Query the value of IP Hop Limit field of this socket.
SocketErrno
Enumeration of the possible errors returned by a socket.
void NotifyDataSent(uint32_t size)
Notify through the callback (if set) that some data have been sent.
void NotifyConnectionSucceeded()
Notify through the callback (if set) that the connection has been established.
void DoDispose() override
Destructor implementation.
uint8_t GetIpv6Tclass() const
Query the value of IPv6 Traffic Class field of this socket.
bool IsManualIpv6HopLimit() const
Checks if the socket has a specific IPv6 Hop Limit set.
bool IsManualIpv6Tclass() const
Checks if the socket has a specific IPv6 Tclass set.
void NotifyConnectionFailed()
Notify through the callback (if set) that the connection has not been established due to an error.
This class implements a tag that carries the socket-specific HOPLIMIT of a packet to the IPv6 layer.
void SetHopLimit(uint8_t hopLimit)
Set the tag's Hop Limit.
indicates whether the socket has IPV6_TCLASS set.
void SetTclass(uint8_t tclass)
Set the tag's Tclass.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t GetSize(Ptr< const Packet > packet, const WifiMacHeader *hdr, bool isAmpdu)
Return the total size of the packet after WifiMacHeader and FCS trailer have been added.
IPv6 raw data and additional information.
Struct to hold the ICMPv6 filter.
uint32_t icmpv6Filt[8]
ICMPv6 filter specification.
uint32_t pktSize
packet size used for the simulation (in bytes)