A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
udp-l4-protocol.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2005,2006,2007 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
21
#ifndef UDP_L4_PROTOCOL_H
22
#define UDP_L4_PROTOCOL_H
23
24
#include <stdint.h>
25
26
#include "ns3/packet.h"
27
#include "ns3/ipv4-address.h"
28
#include "ns3/ipv6-address.h"
29
#include "ns3/ptr.h"
30
#include "ns3/ip-l4-protocol.h"
31
#include "
ipv6-interface.h
"
32
#include "
ipv6-header.h
"
33
34
namespace
ns3 {
35
36
class
Node;
37
class
Socket;
38
class
Ipv4EndPointDemux;
39
class
Ipv4EndPoint;
40
class
Ipv6EndPointDemux;
41
class
Ipv6EndPoint;
42
class
UdpSocketImpl;
43
48
class
UdpL4Protocol
:
public
IpL4Protocol
{
49
public
:
50
static
TypeId
GetTypeId
(
void
);
51
static
const
uint8_t
PROT_NUMBER
;
52
53
UdpL4Protocol
();
54
virtual
~UdpL4Protocol
();
55
56
void
SetNode
(
Ptr<Node>
node);
57
58
virtual
int
GetProtocolNumber
(
void
)
const
;
59
64
Ptr<Socket>
CreateSocket
(
void
);
65
66
Ipv4EndPoint
*
Allocate
(
void
);
67
Ipv4EndPoint
*
Allocate
(
Ipv4Address
address);
68
Ipv4EndPoint
*
Allocate
(uint16_t
port
);
69
Ipv4EndPoint
*
Allocate
(
Ipv4Address
address, uint16_t
port
);
70
Ipv4EndPoint
*
Allocate
(
Ipv4Address
localAddress, uint16_t localPort,
71
Ipv4Address
peerAddress, uint16_t peerPort);
72
Ipv6EndPoint
*
Allocate6
(
void
);
73
Ipv6EndPoint
*
Allocate6
(
Ipv6Address
address);
74
Ipv6EndPoint
*
Allocate6
(uint16_t
port
);
75
Ipv6EndPoint
*
Allocate6
(
Ipv6Address
address, uint16_t
port
);
76
Ipv6EndPoint
*
Allocate6
(
Ipv6Address
localAddress, uint16_t localPort,
77
Ipv6Address
peerAddress, uint16_t peerPort);
78
79
void
DeAllocate
(
Ipv4EndPoint
*endPoint);
80
void
DeAllocate
(
Ipv6EndPoint
*endPoint);
81
82
// called by UdpSocket.
91
void
Send
(
Ptr<Packet>
packet,
92
Ipv4Address
saddr,
Ipv4Address
daddr,
93
uint16_t sport, uint16_t dport);
94
void
Send
(
Ptr<Packet>
packet,
95
Ipv4Address
saddr,
Ipv4Address
daddr,
96
uint16_t sport, uint16_t dport,
Ptr<Ipv4Route>
route);
97
void
Send
(
Ptr<Packet>
packet,
98
Ipv6Address
saddr,
Ipv6Address
daddr,
99
uint16_t sport, uint16_t dport);
100
void
Send
(
Ptr<Packet>
packet,
101
Ipv6Address
saddr,
Ipv6Address
daddr,
102
uint16_t sport, uint16_t dport,
Ptr<Ipv6Route>
route);
109
// inherited from Ipv4L4Protocol
110
virtual
enum
IpL4Protocol::RxStatus
Receive
(
Ptr<Packet>
p,
111
Ipv4Header
const
&header,
112
Ptr<Ipv4Interface>
interface);
113
virtual
enum
IpL4Protocol::RxStatus
Receive
(
Ptr<Packet>
p,
114
Ipv6Address
&src,
115
Ipv6Address
&dst,
116
Ptr<Ipv6Interface>
interface);
117
129
virtual
void
ReceiveIcmp
(
Ipv4Address
icmpSource, uint8_t icmpTtl,
130
uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
131
Ipv4Address
payloadSource,
Ipv4Address
payloadDestination,
132
const
uint8_t payload[8]);
133
virtual
void
ReceiveIcmp
(
Ipv6Address
icmpSource, uint8_t icmpTtl,
134
uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo,
135
Ipv6Address
payloadSource,
Ipv6Address
payloadDestination,
136
const
uint8_t payload[8]);
137
138
// From IpL4Protocol
139
virtual
void
SetDownTarget
(
IpL4Protocol::DownTargetCallback
cb);
140
virtual
void
SetDownTarget6
(
IpL4Protocol::DownTargetCallback6
cb);
141
// From IpL4Protocol
142
virtual
IpL4Protocol::DownTargetCallback
GetDownTarget
(
void
)
const
;
143
virtual
IpL4Protocol::DownTargetCallback6
GetDownTarget6
(
void
)
const
;
144
145
protected
:
146
virtual
void
DoDispose
(
void
);
147
/*
148
* This function will notify other components connected to the node that a new stack member is now connected
149
* This will be used to notify Layer 3 protocol of layer 4 protocol stack to connect them together.
150
*/
151
virtual
void
NotifyNewAggregate
();
152
private
:
153
Ptr<Node>
m_node
;
154
Ipv4EndPointDemux
*
m_endPoints
;
155
Ipv6EndPointDemux
*
m_endPoints6
;
156
UdpL4Protocol
(
const
UdpL4Protocol
&o);
157
UdpL4Protocol
&
operator =
(
const
UdpL4Protocol
&o);
158
std::vector<Ptr<UdpSocketImpl> >
m_sockets
;
159
IpL4Protocol::DownTargetCallback
m_downTarget
;
160
IpL4Protocol::DownTargetCallback6
m_downTarget6
;
161
};
162
163
}
// namespace ns3
164
165
#endif
/* UDP_L4_PROTOCOL_H */
src
internet
model
udp-l4-protocol.h
Generated on Tue Nov 13 2012 10:32:16 for ns-3 by
1.8.1.2