A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ipv6-raw-socket-impl.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007-2009 Strasbourg University
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
19  */
20 
21 #ifndef IPV6_RAW_SOCKET_IMPL_H
22 #define IPV6_RAW_SOCKET_IMPL_H
23 
24 #include <list>
25 
26 #include "ns3/socket.h"
27 #include "ns3/ipv6-address.h"
28 #include "ns3/ipv6-header.h"
29 
30 namespace ns3
31 {
32 
33 class NetDevice;
34 class Node;
35 
65 class Ipv6RawSocketImpl : public Socket
66 {
67 public:
72  static TypeId GetTypeId ();
73 
75  virtual ~Ipv6RawSocketImpl ();
76 
81  void SetNode (Ptr<Node> node);
82 
83  virtual enum Socket::SocketErrno GetErrno () const;
84 
89  virtual enum Socket::SocketType GetSocketType () const;
90 
91  virtual Ptr<Node> GetNode () const;
92 
93  virtual int Bind (const Address& address);
94  virtual int Bind ();
95  virtual int Bind6 ();
96 
97  virtual int GetSockName (Address& address) const;
98 
99  virtual int Close ();
100  virtual int ShutdownSend ();
101  virtual int ShutdownRecv ();
102  virtual int Connect (const Address& address);
103  virtual int Listen ();
104  virtual uint32_t GetTxAvailable () const;
105  virtual uint32_t GetRxAvailable () const;
106  virtual int Send (Ptr<Packet> p, uint32_t flags);
107  virtual int SendTo (Ptr<Packet> p, uint32_t flags, const Address& toAddress);
108  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
109  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags, Address& fromAddress);
110 
115  void SetProtocol (uint16_t protocol);
116 
125 
126  virtual bool SetAllowBroadcast (bool allowBroadcast);
127  virtual bool GetAllowBroadcast () const;
128 
132  void Icmpv6FilterSetPassAll();
133 
138 
143  void Icmpv6FilterSetPass(uint8_t type);
144 
149  void Icmpv6FilterSetBlock(uint8_t type);
150 
156  bool Icmpv6FilterWillPass(uint8_t type);
157 
163  bool Icmpv6FilterWillBlock(uint8_t type);
164 
165 
166 private:
171  struct Data
172  {
175  uint16_t fromProtocol;
176  };
177 
181  virtual void DoDispose ();
182 
187 
192 
197 
202 
206  uint16_t m_protocol;
207 
211  std::list<struct Data> m_data;
212 
217 
222 
226  typedef struct
227  {
228  uint32_t icmpv6Filt[8];
229  } icmpv6Filter;
230 
235 };
236 
237 } /* namespace ns3 */
238 
239 #endif /* IPV6_RAW_SOCKET_IMPL_H */
240 
void SetNode(Ptr< Node > node)
Set the node associated with this socket.
Doxygen introspection did not find any typical Config paths.
Definition: ipv6-header.h:33
virtual void DoDispose()
Dispose object.
virtual int Connect(const Address &address)
Initiate a connection to a remote host.
Ipv6Address fromIp
Source address.
Ipv6Address m_src
Source address.
Ptr< Packet > Recv(void)
Read a single packet from the socket.
Definition: socket.cc:175
bool m_shutdownSend
Flag to shutdown send capability.
uint16_t fromProtocol
Protocol used.
Ptr< Packet > packet
Packet data.
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)
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition: socket.h:82
virtual enum Socket::SocketErrno GetErrno() const
Get last error number.
virtual int Send(Ptr< Packet > p, uint32_t flags)
Send data (or dummy data) to the remote host.
a polymophic address class
Definition: address.h:86
virtual int Bind()
Allocate a local IPv4 endpoint for this socket.
bool m_shutdownRecv
Flag to shutdown receive capability.
A low-level Socket API based loosely on the BSD Socket API.
Definition: socket.h:66
std::list< struct Data > m_data
Packet waiting to be processed.
virtual int GetSockName(Address &address) const
Get socket address.
void Icmpv6FilterSetBlock(uint8_t type)
Set the filter to block one ICMPv6 type.
virtual int Bind6()
Allocate a local IPv6 endpoint for this socket.
virtual Ptr< Node > GetNode() const
Return the node this socket is associated with.
IPv6 raw data and additional information.
Struct to hold the ICMPv6 filter.
virtual int Listen()
Listen for incoming connections.
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.
icmpv6Filter m_icmpFilter
ICMPv6 filter.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)
Read a single packet from the socket and retrieve the sender address.
virtual bool SetAllowBroadcast(bool allowBroadcast)
Configure whether broadcast datagram transmissions are allowed.
virtual uint32_t GetRxAvailable() const
Return number of bytes which can be returned from one or multiple calls to Recv.
void SetProtocol(uint16_t protocol)
Set protocol field.
Describes an IPv6 address.
Definition: ipv6-address.h:46
virtual uint32_t GetTxAvailable() const
Returns the number of bytes which can be sent in a single call to Send.
enum Socket::SocketErrno m_err
Last error number.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)
Send data to a specified peer.
virtual int Close()
Close a socket.
Ipv6Address m_dst
Destination address.
bool Icmpv6FilterWillPass(uint8_t type)
Ask the filter about the status of one ICMPv6 type.
void Icmpv6FilterSetPassAll()
Clean the ICMPv6 filter structure.
tuple address
Definition: first.py:37
virtual bool GetAllowBroadcast() const
Query whether broadcast datagram transmissions are allowed.
SocketType
Enumeration of the possible socket types.
Definition: socket.h:104
a unique identifier for an interface.
Definition: type-id.h:49
Doxygen introspection did not find any typical Config paths.
uint16_t m_protocol
Protocol.
void Icmpv6FilterSetBlockAll()
Set the filter to block all the ICMPv6 types.