author | John Abraham<john.abraham@gatech.edu> |
Sat, 14 May 2011 04:27:39 -0400 | |
changeset 7222 | bcee1d4b5bc3 |
parent 6834 | 036f9a0b9899 |
child 7256 | b04ba6772f8c |
permissions | -rw-r--r-- |
3578 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* This program is free software; you can redistribute it and/or modify |
|
4 |
* it under the terms of the GNU General Public License version 2 as |
|
5 |
* published by the Free Software Foundation; |
|
6 |
* |
|
7 |
* This program is distributed in the hope that it will be useful, |
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
10 |
* GNU General Public License for more details. |
|
11 |
* |
|
12 |
* You should have received a copy of the GNU General Public License |
|
13 |
* along with this program; if not, write to the Free Software |
|
14 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
15 |
*/ |
|
16 |
||
17 |
#ifndef NSC_TCP_L4_PROTOCOL_H |
|
18 |
#define NSC_TCP_L4_PROTOCOL_H |
|
19 |
||
20 |
#include <stdint.h> |
|
21 |
||
22 |
#include "ns3/packet.h" |
|
23 |
#include "ns3/ipv4-address.h" |
|
24 |
#include "ns3/ptr.h" |
|
25 |
#include "ns3/object-factory.h" |
|
4740
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
26 |
#include "ns3/timer.h" |
3578 | 27 |
#include "ipv4-l4-protocol.h" |
28 |
||
4740
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
29 |
struct INetStack; |
3578 | 30 |
|
31 |
namespace ns3 { |
|
32 |
||
33 |
class Node; |
|
34 |
class Socket; |
|
4740
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
35 |
class Ipv4EndPointDemux; |
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
36 |
class Ipv4Interface; |
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
37 |
class NscTcpSocketImpl; |
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
38 |
class Ipv4EndPoint; |
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
39 |
class NscInterfaceImpl; |
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
40 |
|
3578 | 41 |
/** |
3691 | 42 |
* \ingroup nsctcp |
43 |
* |
|
44 |
* \brief Nsc wrapper glue, to interface with the Ipv4 protocol underneath. |
|
3578 | 45 |
*/ |
4740
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
46 |
class NscTcpL4Protocol : public Ipv4L4Protocol { |
3578 | 47 |
public: |
48 |
static const uint8_t PROT_NUMBER; |
|
49 |
static TypeId GetTypeId (void); |
|
50 |
/** |
|
51 |
* \brief Constructor |
|
52 |
*/ |
|
53 |
NscTcpL4Protocol (); |
|
54 |
virtual ~NscTcpL4Protocol (); |
|
55 |
||
56 |
void SetNode (Ptr<Node> node); |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
57 |
void SetNscLibrary (const std::string &lib); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
58 |
std::string GetNscLibrary (void) const; |
3578 | 59 |
virtual int GetProtocolNumber (void) const; |
60 |
virtual int GetVersion (void) const; |
|
61 |
||
62 |
/** |
|
63 |
* \return A smart Socket pointer to a NscTcpSocketImpl, allocated by this instance |
|
64 |
* of the TCP protocol |
|
65 |
*/ |
|
66 |
Ptr<Socket> CreateSocket (void); |
|
67 |
||
68 |
Ipv4EndPoint *Allocate (void); |
|
69 |
Ipv4EndPoint *Allocate (Ipv4Address address); |
|
70 |
Ipv4EndPoint *Allocate (uint16_t port); |
|
71 |
Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port); |
|
72 |
Ipv4EndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort, |
|
73 |
Ipv4Address peerAddress, uint16_t peerPort); |
|
74 |
||
75 |
void DeAllocate (Ipv4EndPoint *endPoint); |
|
76 |
||
77 |
/** |
|
6273
8d70de29d514
spell check, mostly in comments.
Andrey Mazo <mazo@iitp.ru>
parents:
4741
diff
changeset
|
78 |
* \brief Receive a packet up the protocol stack |
3578 | 79 |
* \param p The Packet to dump the contents into |
6445 | 80 |
* \param header IPv4 Header information |
3578 | 81 |
* \param incomingInterface The Ipv4Interface it was received on |
82 |
*/ |
|
3820 | 83 |
virtual Ipv4L4Protocol::RxStatus Receive (Ptr<Packet> p, |
6442
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6273
diff
changeset
|
84 |
Ipv4Header const &header, |
3820 | 85 |
Ptr<Ipv4Interface> incomingInterface); |
3578 | 86 |
|
6723
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6445
diff
changeset
|
87 |
// From Ipv4L4Protocol |
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6445
diff
changeset
|
88 |
virtual void SetDownTarget (Ipv4L4Protocol::DownTargetCallback cb); |
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6445
diff
changeset
|
89 |
// From Ipv4L4Protocol |
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6445
diff
changeset
|
90 |
virtual Ipv4L4Protocol::DownTargetCallback GetDownTarget (void) const; |
4740
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
91 |
protected: |
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
92 |
virtual void DoDispose (void); |
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
93 |
virtual void NotifyNewAggregate (); |
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
94 |
private: |
4741
ae4aa2deec45
Make some copy-constructors private, remove not implemented method declarations, to make Python bindings work.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4740
diff
changeset
|
95 |
NscTcpL4Protocol (NscTcpL4Protocol const &); |
ae4aa2deec45
Make some copy-constructors private, remove not implemented method declarations, to make Python bindings work.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4740
diff
changeset
|
96 |
NscTcpL4Protocol& operator= (NscTcpL4Protocol const &); |
ae4aa2deec45
Make some copy-constructors private, remove not implemented method declarations, to make Python bindings work.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4740
diff
changeset
|
97 |
|
3578 | 98 |
// NSC callbacks. |
99 |
// NSC invokes these hooks to interact with the simulator. |
|
100 |
// In any case, these methods are only to be called by NSC. |
|
101 |
// |
|
102 |
// send_callback is invoked by NSCs 'ethernet driver' to re-inject |
|
103 |
// a packet (i.e. an octet soup consisting of an IP Header, TCP Header |
|
104 |
// and user payload, if any), into ns-3. |
|
4740
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
105 |
void send_callback(const void *data, int datalen); |
3578 | 106 |
// This is called by the NSC stack whenever something of interest |
107 |
// has happened, e.g. when data arrives on a socket, a listen socket |
|
108 |
// has a new connection pending, etc. |
|
4740
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
109 |
void wakeup(); |
3578 | 110 |
// This is called by the Linux stack RNG initialization. |
111 |
// Its also used by the cradle code to add a timestamp to |
|
112 |
// printk/printf/debug output. |
|
4740
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
113 |
void gettime(unsigned int *sec, unsigned int *usec); |
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
114 |
void AddInterface (void); |
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
115 |
void SoftInterrupt (void); |
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
116 |
friend class NscInterfaceImpl; |
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
117 |
friend class NscTcpSocketImpl; |
3578 | 118 |
Ptr<Node> m_node; |
119 |
Ipv4EndPointDemux *m_endPoints; |
|
120 |
INetStack* m_nscStack; |
|
4740
34acfd7ad508
export headers from internet-stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4472
diff
changeset
|
121 |
NscInterfaceImpl *m_nscInterface; |
3578 | 122 |
void *m_dlopenHandle; |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4283
diff
changeset
|
123 |
std::string m_nscLibrary; |
3578 | 124 |
Timer m_softTimer; |
4283
5854cddf4493
Bugs 458, swap 2 LOC for 526
Craig Dowell <craigdo@ee.washington.edu>
parents:
3820
diff
changeset
|
125 |
std::vector<Ptr<NscTcpSocketImpl> > m_sockets; |
6723
fff5c512f345
bug 967: decouple Ipv4L4Protocols from Ipv4L3Protocol::Send() via a new callback
Tom Henderson <tomh@tomh.org>
parents:
6445
diff
changeset
|
126 |
Ipv4L4Protocol::DownTargetCallback m_downTarget; |
3578 | 127 |
}; |
128 |
||
129 |
}; // namespace ns3 |
|
130 |
||
131 |
#endif /* NSC_TCP_L4_PROTOCOL_H */ |