author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Fri, 10 Aug 2007 15:47:13 +0200 | |
changeset 1333 | c0d66de933e9 |
parent 524 | 082ffdd8fbd7 |
child 1303 | 9856d1175cbb |
child 1434 | 2b63aafb050b |
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 |
* All rights reserved. |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* 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
|
7 |
* 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
|
8 |
* published by the Free Software Foundation; |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* 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
|
11 |
* 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
|
12 |
* 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
|
13 |
* GNU General Public License for more details. |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* 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
|
16 |
* 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
|
17 |
* 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
|
18 |
* |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
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 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
#include "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 |
namespace ns3 { |
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 |
Ipv4EndPoint::Ipv4EndPoint (Ipv4Address address, uint16_t port) |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
: m_localAddr (address), |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
m_localPort (port), |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
m_peerAddr (Ipv4Address::GetAny ()), |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
30 |
m_peerPort (0) |
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 |
Ipv4EndPoint::~Ipv4EndPoint () |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
33 |
{ |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
34 |
if (!m_destroyCallback.IsNull ()) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
35 |
{ |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
36 |
m_destroyCallback (); |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
37 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
38 |
} |
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
39 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
40 |
Ipv4Address |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
41 |
Ipv4EndPoint::GetLocalAddress (void) |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
42 |
{ |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
43 |
return m_localAddr; |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
44 |
} |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
45 |
uint16_t |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
46 |
Ipv4EndPoint::GetLocalPort (void) |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
47 |
{ |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
48 |
return m_localPort; |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
49 |
} |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
50 |
Ipv4Address |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
51 |
Ipv4EndPoint::GetPeerAddress (void) |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
52 |
{ |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
53 |
return m_peerAddr; |
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 |
uint16_t |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
56 |
Ipv4EndPoint::GetPeerPort (void) |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
57 |
{ |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
58 |
return m_peerPort; |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
59 |
} |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
60 |
void |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
61 |
Ipv4EndPoint::SetPeer (Ipv4Address address, uint16_t port) |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
62 |
{ |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
63 |
m_peerAddr = address; |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
64 |
m_peerPort = port; |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
65 |
} |
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
66 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
67 |
void |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
68 |
Ipv4EndPoint::SetRxCallback (Callback<void,const Packet &, Ipv4Address, uint16_t> callback) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
69 |
{ |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
70 |
m_rxCallback = callback; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
71 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
72 |
|
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
73 |
void |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
74 |
Ipv4EndPoint::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
|
75 |
{ |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
76 |
m_destroyCallback = callback; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
77 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
78 |
|
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
79 |
void |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
80 |
Ipv4EndPoint::ForwardUp (const Packet &p, Ipv4Address saddr, uint16_t sport) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
81 |
{ |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
82 |
if (!m_rxCallback.IsNull ()) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
83 |
{ |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
84 |
m_rxCallback (p, saddr, sport); |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
85 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
86 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
87 |
|
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
238
diff
changeset
|
88 |
|
238
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
89 |
|
2f09fd9cf32e
add start of udp stack
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
90 |
}; // namespace ns3 |