author | Craig Dowell <craigdo@ee.washington.edu> |
Tue, 09 Dec 2008 20:29:04 -0800 | |
changeset 3997 | a66553c56a8f |
parent 3820 | c04ecfdce1ef |
child 4472 | e20a31541404 |
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,2006,2007 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 |
|
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
21 |
#ifndef UDP_L4_PROTOCOL_H |
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
22 |
#define UDP_L4_PROTOCOL_H |
238
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> |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
#include "ns3/packet.h" |
524
082ffdd8fbd7
move code around
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
515
diff
changeset
|
27 |
#include "ns3/ipv4-address.h" |
557
927a5bb6432a
convert UdpSocket and Udp to Ptr<Node>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
524
diff
changeset
|
28 |
#include "ns3/ptr.h" |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
#include "ipv4-end-point-demux.h" |
295
5fc7ae0d0300
remove UdpIpv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
30 |
#include "ipv4-l4-protocol.h" |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
31 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
32 |
namespace ns3 { |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
|
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
632
diff
changeset
|
34 |
class Node; |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
35 |
class Socket; |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
36 |
/** |
3691 | 37 |
* \ingroup udp |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
38 |
* \brief Implementation of the UDP protocol |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
39 |
*/ |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
40 |
class UdpL4Protocol : public Ipv4L4Protocol { |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
41 |
public: |
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1867
diff
changeset
|
42 |
static TypeId GetTypeId (void); |
295
5fc7ae0d0300
remove UdpIpv4L4Protocol class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
241
diff
changeset
|
43 |
static const uint8_t PROT_NUMBER; |
2595
b504951bcca8
fix doxygen errors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2592
diff
changeset
|
44 |
|
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1867
diff
changeset
|
45 |
UdpL4Protocol (); |
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
46 |
virtual ~UdpL4Protocol (); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
47 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2542
diff
changeset
|
48 |
void SetNode (Ptr<Node> node); |
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2542
diff
changeset
|
49 |
|
2498
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1867
diff
changeset
|
50 |
virtual int GetProtocolNumber (void) const; |
e01570293b98
convert InternetNode to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1867
diff
changeset
|
51 |
|
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
52 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
53 |
* \return A smart Socket pointer to a UdpSocket, allocated by this instance |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
54 |
* of the UDP protocol |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
55 |
*/ |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
557
diff
changeset
|
56 |
Ptr<Socket> CreateSocket (void); |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
345
diff
changeset
|
57 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
453
diff
changeset
|
58 |
Ipv4EndPoint *Allocate (void); |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2595
diff
changeset
|
59 |
Ipv4EndPoint *Allocate (Ipv4Address address); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
453
diff
changeset
|
60 |
Ipv4EndPoint *Allocate (uint16_t port); |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2595
diff
changeset
|
61 |
Ipv4EndPoint *Allocate (Ipv4Address address, uint16_t port); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
453
diff
changeset
|
62 |
Ipv4EndPoint *Allocate (Ipv4Address localAddress, uint16_t localPort, |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2595
diff
changeset
|
63 |
Ipv4Address peerAddress, uint16_t peerPort); |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
64 |
|
515
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
513
diff
changeset
|
65 |
void DeAllocate (Ipv4EndPoint *endPoint); |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
513
diff
changeset
|
66 |
|
240
7da682f99bf9
add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
67 |
// called by UdpSocket. |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
68 |
/** |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
69 |
* \brief Send a packet via UDP |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
70 |
* \param packet The packet to send |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
71 |
* \param saddr The source Ipv4Address |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
72 |
* \param daddr The destination Ipv4Address |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
73 |
* \param sport The source port number |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
74 |
* \param dport The destination port number |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
75 |
*/ |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
76 |
void Send (Ptr<Packet> packet, |
240
7da682f99bf9
add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
77 |
Ipv4Address saddr, Ipv4Address daddr, |
7da682f99bf9
add non-debugged udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
78 |
uint16_t sport, uint16_t dport); |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
79 |
/** |
1795
820cc1254290
get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
80 |
* \brief Receive a packet up the protocol stack |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
81 |
* \param p The Packet to dump the contents into |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
82 |
* \param source The source's Ipv4Address |
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
83 |
* \param destination The destinations Ipv4Address |
1795
820cc1254290
get rid of doxygen warnings
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1524
diff
changeset
|
84 |
* \param interface the interface from which the packet is coming. |
632
1e419ebb4012
Internet-node module dox
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
607
diff
changeset
|
85 |
*/ |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
86 |
// inherited from Ipv4L4Protocol |
3820 | 87 |
virtual enum Ipv4L4Protocol::RxStatus Receive(Ptr<Packet> p, |
88 |
Ipv4Address const &source, |
|
89 |
Ipv4Address const &destination, |
|
3997
a66553c56a8f
make a pass through doxygen fixing errors
Craig Dowell <craigdo@ee.washington.edu>
parents:
3820
diff
changeset
|
90 |
Ptr<Ipv4Interface> interface); |
3820 | 91 |
|
3997
a66553c56a8f
make a pass through doxygen fixing errors
Craig Dowell <craigdo@ee.washington.edu>
parents:
3820
diff
changeset
|
92 |
/** |
a66553c56a8f
make a pass through doxygen fixing errors
Craig Dowell <craigdo@ee.washington.edu>
parents:
3820
diff
changeset
|
93 |
* \brief Receive an ICMP packet |
a66553c56a8f
make a pass through doxygen fixing errors
Craig Dowell <craigdo@ee.washington.edu>
parents:
3820
diff
changeset
|
94 |
* \param icmpSource The IP address of the source of the packet. |
a66553c56a8f
make a pass through doxygen fixing errors
Craig Dowell <craigdo@ee.washington.edu>
parents:
3820
diff
changeset
|
95 |
* \param icmpTtl The time to live from the IP header |
a66553c56a8f
make a pass through doxygen fixing errors
Craig Dowell <craigdo@ee.washington.edu>
parents:
3820
diff
changeset
|
96 |
* \param icmpType The type of the message from the ICMP header |
a66553c56a8f
make a pass through doxygen fixing errors
Craig Dowell <craigdo@ee.washington.edu>
parents:
3820
diff
changeset
|
97 |
* \param icmpCode The message code from the ICMP header |
a66553c56a8f
make a pass through doxygen fixing errors
Craig Dowell <craigdo@ee.washington.edu>
parents:
3820
diff
changeset
|
98 |
* \param icmpInfo 32-bit integer carrying informational value of varying semantics. |
a66553c56a8f
make a pass through doxygen fixing errors
Craig Dowell <craigdo@ee.washington.edu>
parents:
3820
diff
changeset
|
99 |
* \param payloadSource The IP source addresss from the IP header of the packet |
a66553c56a8f
make a pass through doxygen fixing errors
Craig Dowell <craigdo@ee.washington.edu>
parents:
3820
diff
changeset
|
100 |
* \param payloadDestination The IP destination address from the IP header of the packet |
a66553c56a8f
make a pass through doxygen fixing errors
Craig Dowell <craigdo@ee.washington.edu>
parents:
3820
diff
changeset
|
101 |
* \param payload Payload of the ICMP packet |
a66553c56a8f
make a pass through doxygen fixing errors
Craig Dowell <craigdo@ee.washington.edu>
parents:
3820
diff
changeset
|
102 |
*/ |
3820 | 103 |
virtual void ReceiveIcmp (Ipv4Address icmpSource, uint8_t icmpTtl, |
104 |
uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo, |
|
105 |
Ipv4Address payloadSource,Ipv4Address payloadDestination, |
|
106 |
const uint8_t payload[8]); |
|
513
b7c7ea629de9
make L3Demux an NsUnknown object.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
504
diff
changeset
|
107 |
protected: |
b7c7ea629de9
make L3Demux an NsUnknown object.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
504
diff
changeset
|
108 |
virtual void DoDispose (void); |
b7c7ea629de9
make L3Demux an NsUnknown object.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
504
diff
changeset
|
109 |
private: |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
632
diff
changeset
|
110 |
Ptr<Node> m_node; |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
453
diff
changeset
|
111 |
Ipv4EndPointDemux *m_endPoints; |
3363
33d1ca2e4ba4
bug 236: add optional support for tcp and udp checksum.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
3260
diff
changeset
|
112 |
bool m_calcChecksum; |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
113 |
}; |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
114 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
115 |
}; // namespace ns3 |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
116 |
|
742
b73f8e30c75e
Udp -> UdpL4Protocol
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
741
diff
changeset
|
117 |
#endif /* UDP_L4_PROTOCOL_H */ |