author | Raj Bhattacharjea <raj.b@gatech.edu> |
Sat, 13 Dec 2008 23:26:01 -0500 | |
changeset 4022 | 142c13a3975f |
parent 3820 | c04ecfdce1ef |
child 5856 | 7fd20c798a7d |
permissions | -rw-r--r-- |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2005 INRIA |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
*/ |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#ifndef IPV4_END_POINT_H |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
#define IPV4_END_POINT_H |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include <stdint.h> |
524
082ffdd8fbd7
move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
25 |
#include "ns3/ipv4-address.h" |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
26 |
#include "ns3/callback.h" |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
namespace ns3 { |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
class Header; |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
31 |
class Packet; |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
|
3266
1ae7df5cf87b
Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
3260
diff
changeset
|
33 |
/** |
1ae7df5cf87b
Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
3260
diff
changeset
|
34 |
* \brief A representation of an internet endpoint/connection |
1ae7df5cf87b
Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
3260
diff
changeset
|
35 |
* |
1ae7df5cf87b
Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
3260
diff
changeset
|
36 |
* This class provides an internet four-tuple (source and destination ports |
1ae7df5cf87b
Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
3260
diff
changeset
|
37 |
* and addresses). These are used in the ns3::Ipv4EndPointDemux as targets |
1ae7df5cf87b
Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
3260
diff
changeset
|
38 |
* of lookups. The class also has a callback for notification to higher |
1ae7df5cf87b
Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
3260
diff
changeset
|
39 |
* layers that a packet from a lower layer was received. In the ns3 |
1ae7df5cf87b
Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
3260
diff
changeset
|
40 |
* internet-stack, these notifications are automatically registered to be |
1ae7df5cf87b
Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
3260
diff
changeset
|
41 |
* received by the corresponding socket. |
1ae7df5cf87b
Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
3260
diff
changeset
|
42 |
*/ |
1ae7df5cf87b
Update the internet-stack documentation
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
3260
diff
changeset
|
43 |
|
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
44 |
class Ipv4EndPoint { |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
45 |
public: |
2365
89da0ca7c55e
undoes 2326:eec07777d1a2 because localInterface is no longer needed (see bug 136)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
2326
diff
changeset
|
46 |
Ipv4EndPoint (Ipv4Address address, uint16_t port); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
47 |
~Ipv4EndPoint (); |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
48 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
49 |
Ipv4Address GetLocalAddress (void); |
1317
82629189efff
Fold the two patches for bu6 69 together, building on the bug 65 patch
Tom Henderson <tomh@tomh.org>
parents:
1308
diff
changeset
|
50 |
void SetLocalAddress (Ipv4Address address); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
51 |
uint16_t GetLocalPort (void); |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
52 |
Ipv4Address GetPeerAddress (void); |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
53 |
uint16_t GetPeerPort (void); |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
54 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
55 |
void SetPeer (Ipv4Address address, uint16_t port); |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
56 |
|
3820 | 57 |
// Called from socket implementations to get notified about important events. |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1317
diff
changeset
|
58 |
void SetRxCallback (Callback<void,Ptr<Packet>, Ipv4Address, uint16_t> callback); |
3820 | 59 |
void SetIcmpCallback (Callback<void,Ipv4Address,uint8_t,uint8_t,uint8_t,uint32_t> callback); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
60 |
void SetDestroyCallback (Callback<void> callback); |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
61 |
|
3820 | 62 |
// Called from an L4Protocol implementation to notify an endpoint of a |
63 |
// packet reception. |
|
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1317
diff
changeset
|
64 |
void ForwardUp (Ptr<Packet> p, Ipv4Address saddr, uint16_t sport); |
3820 | 65 |
// Called from an L4Protocol implementation to notify an endpoint of |
66 |
// an icmp message reception. |
|
67 |
void ForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, |
|
68 |
uint8_t icmpType, uint8_t icmpCode, |
|
69 |
uint32_t icmpInfo); |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
70 |
|
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
71 |
private: |
4022
142c13a3975f
Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
3820
diff
changeset
|
72 |
void DoForwardUp (Ptr<Packet> p, Ipv4Address saddr, uint16_t sport); |
142c13a3975f
Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
3820
diff
changeset
|
73 |
void DoForwardIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, |
142c13a3975f
Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
3820
diff
changeset
|
74 |
uint8_t icmpType, uint8_t icmpCode, |
142c13a3975f
Mathieu's patch: Avoid stack explosion (bug 417)
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
3820
diff
changeset
|
75 |
uint32_t icmpInfo); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
76 |
Ipv4Address m_localAddr; |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
77 |
uint16_t m_localPort; |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
78 |
Ipv4Address m_peerAddr; |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
79 |
uint16_t m_peerPort; |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1317
diff
changeset
|
80 |
Callback<void,Ptr<Packet>, Ipv4Address, uint16_t> m_rxCallback; |
3820 | 81 |
Callback<void,Ipv4Address,uint8_t,uint8_t,uint8_t,uint32_t> m_icmpCallback; |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
82 |
Callback<void> m_destroyCallback; |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
83 |
}; |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
84 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
85 |
}; // namespace ns3 |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
86 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
87 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
88 |
#endif /* IPV4_END_POINT_H */ |