src/internet/model/ipv4-raw-socket-impl.h
author Vedran Miletić <rivanvx@gmail.com>
Tue, 02 Aug 2011 17:42:33 -0400
changeset 7385 10beb0e53130
parent 7176 9f2663992e99
child 7717 cfa1741013dd
permissions -rw-r--r--
standardize emacs c++ mode comments
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7385
10beb0e53130 standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents: 7176
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     2
#ifndef IPV4_RAW_SOCKET_IMPL_H
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     3
#define IPV4_RAW_SOCKET_IMPL_H
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     4
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     5
#include "ns3/socket.h"
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     6
#include "ns3/ipv4-header.h"
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 3820
diff changeset
     7
#include "ns3/ipv4-route.h"
6442
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 6437
diff changeset
     8
#include "ns3/ipv4-interface.h"
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
     9
#include <list>
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    10
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    11
namespace ns3 {
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    12
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    13
class NetDevice;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    14
class Node;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    15
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    16
class Ipv4RawSocketImpl : public Socket
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    17
{
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    18
public:
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    19
  static TypeId GetTypeId (void);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    20
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    21
  Ipv4RawSocketImpl ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    22
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    23
  void SetNode (Ptr<Node> node);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    24
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    25
  virtual enum Socket::SocketErrno GetErrno (void) const;
6689
e2de571e920a Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents: 6448
diff changeset
    26
  virtual enum Socket::SocketType GetSocketType (void) const;
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    27
  virtual Ptr<Node> GetNode (void) const;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    28
  virtual int Bind (const Address &address);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    29
  virtual int Bind ();
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    30
  virtual int GetSockName (Address &address) const; 
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    31
  virtual int Close (void);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    32
  virtual int ShutdownSend (void);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    33
  virtual int ShutdownRecv (void);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    34
  virtual int Connect (const Address &address);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    35
  virtual int Listen (void);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    36
  virtual uint32_t GetTxAvailable (void) const;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    37
  virtual int Send (Ptr<Packet> p, uint32_t flags);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    38
  virtual int SendTo (Ptr<Packet> p, uint32_t flags, 
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    39
                      const Address &toAddress);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    40
  virtual uint32_t GetRxAvailable (void) const;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    41
  virtual Ptr<Packet> Recv (uint32_t maxSize, uint32_t flags);
7176
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    42
  virtual Ptr<Packet> RecvFrom (uint32_t maxSize, uint32_t flags,
9f2663992e99 internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents: 6834
diff changeset
    43
                                Address &fromAddress);
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    44
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    45
  void SetProtocol (uint16_t protocol);
6442
f380cf1aa4d8 Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 6437
diff changeset
    46
  bool ForwardUp (Ptr<const Packet> p, Ipv4Header ipHeader, Ptr<Ipv4Interface> incomingInterface);
6448
184a509cc71d Still Bug 943: fix UdpSocketImpl::GetAllowBroadcast, let Socket::SetAllowBroadcast return a bool indicating success/failure, instead of a fatal error.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6442
diff changeset
    47
  virtual bool SetAllowBroadcast (bool allowBroadcast);
6437
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6334
diff changeset
    48
  virtual bool GetAllowBroadcast () const;
c11291f51d57 Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6334
diff changeset
    49
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    50
private:
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    51
  virtual void DoDispose (void);
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    52
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    53
  struct Data {
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    54
    Ptr<Packet> packet;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    55
    Ipv4Address fromIp;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    56
    uint16_t fromProtocol;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    57
  };
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    58
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    59
  enum Socket::SocketErrno m_err;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    60
  Ptr<Node> m_node;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    61
  Ipv4Address m_src;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    62
  Ipv4Address m_dst;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    63
  uint16_t m_protocol;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    64
  std::list<struct Data> m_recv;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    65
  bool m_shutdownSend;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    66
  bool m_shutdownRecv;
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    67
  uint32_t m_icmpFilter;
6334
c9373f264dfe Bug 932 - Support IP_HDRINCL option for Ipv4RawSocket
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents: 4472
diff changeset
    68
  bool m_iphdrincl;
3820
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    69
};
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    70
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    71
} // namespace ns3
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    72
c04ecfdce1ef apply icmp patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff changeset
    73
#endif /* IPV4_RAW_SOCKET_IMPL_H */