author | Adrian S Tam <adrian.sw.tam@gmail.com> |
Wed, 07 Dec 2011 11:22:10 -0500 | |
changeset 7619 | b4dee6307aa7 |
parent 7442 | 7fbcc8eb8679 |
child 9710 | df21b904fce3 |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7256
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
2 |
/* |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2005 INRIA |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
4 |
* |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
8 |
* |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
13 |
* |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
17 |
* |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
19 |
*/ |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
|
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#include "ipv4-end-point-demux.h" |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
#include "ipv4-end-point.h" |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
984
diff
changeset
|
23 |
#include "ns3/log.h" |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
|
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
25 |
namespace ns3 { |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
984
diff
changeset
|
27 |
NS_LOG_COMPONENT_DEFINE ("Ipv4EndPointDemux"); |
984
3202c053eacc
Allow UDP sockets to receive broadcast (bug #51)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
524
diff
changeset
|
28 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
29 |
Ipv4EndPointDemux::Ipv4EndPointDemux () |
7441
bf446d9feecc
Bug 1163 - Ipv4EndPointDemux::AllocateEphemeralPort forget to increment the port
John Abraham <john.abraham@gatech.edu>
parents:
7386
diff
changeset
|
30 |
: m_ephemeral (49152), m_portLast (65535), m_portFirst (49152) |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
984
diff
changeset
|
31 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
32 |
NS_LOG_FUNCTION_NOARGS (); |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
984
diff
changeset
|
33 |
} |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
34 |
|
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
35 |
Ipv4EndPointDemux::~Ipv4EndPointDemux () |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
36 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
37 |
NS_LOG_FUNCTION_NOARGS (); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
38 |
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
39 |
{ |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
40 |
Ipv4EndPoint *endPoint = *i; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
41 |
delete endPoint; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
42 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
43 |
m_endPoints.clear (); |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
44 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
45 |
|
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
46 |
bool |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
47 |
Ipv4EndPointDemux::LookupPortLocal (uint16_t port) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
48 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
49 |
NS_LOG_FUNCTION_NOARGS (); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
50 |
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
51 |
{ |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
52 |
if ((*i)->GetLocalPort () == port) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
53 |
{ |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
54 |
return true; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
55 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
56 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
57 |
return false; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
58 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
59 |
|
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
60 |
bool |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
61 |
Ipv4EndPointDemux::LookupLocal (Ipv4Address addr, uint16_t port) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
62 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
63 |
NS_LOG_FUNCTION_NOARGS (); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
64 |
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
65 |
{ |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
66 |
if ((*i)->GetLocalPort () == port && |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
67 |
(*i)->GetLocalAddress () == addr) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
68 |
{ |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
69 |
return true; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
70 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
71 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
72 |
return false; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
73 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
74 |
|
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
75 |
Ipv4EndPoint * |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
76 |
Ipv4EndPointDemux::Allocate (void) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
77 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
78 |
NS_LOG_FUNCTION_NOARGS (); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
79 |
uint16_t port = AllocateEphemeralPort (); |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
80 |
if (port == 0) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
81 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
984
diff
changeset
|
82 |
NS_LOG_WARN ("Ephemeral port allocation failed."); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
83 |
return 0; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
84 |
} |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
85 |
Ipv4EndPoint *endPoint = new Ipv4EndPoint (Ipv4Address::GetAny (), port); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
86 |
m_endPoints.push_back (endPoint); |
1524
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1523
diff
changeset
|
87 |
NS_LOG_DEBUG ("Now have >>" << m_endPoints.size () << "<< endpoints."); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
88 |
return endPoint; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
89 |
} |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
984
diff
changeset
|
90 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
91 |
Ipv4EndPoint * |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
92 |
Ipv4EndPointDemux::Allocate (Ipv4Address address) |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
93 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
94 |
NS_LOG_FUNCTION (this << address); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
95 |
uint16_t port = AllocateEphemeralPort (); |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
96 |
if (port == 0) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
97 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
984
diff
changeset
|
98 |
NS_LOG_WARN ("Ephemeral port allocation failed."); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
99 |
return 0; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
100 |
} |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
101 |
Ipv4EndPoint *endPoint = new Ipv4EndPoint (address, port); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
102 |
m_endPoints.push_back (endPoint); |
1524
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1523
diff
changeset
|
103 |
NS_LOG_DEBUG ("Now have >>" << m_endPoints.size () << "<< endpoints."); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
104 |
return endPoint; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
105 |
} |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
984
diff
changeset
|
106 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
107 |
Ipv4EndPoint * |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
108 |
Ipv4EndPointDemux::Allocate (uint16_t port) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
109 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
110 |
NS_LOG_FUNCTION (this << port); |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1828
diff
changeset
|
111 |
|
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
112 |
return Allocate (Ipv4Address::GetAny (), port); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
113 |
} |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
984
diff
changeset
|
114 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
115 |
Ipv4EndPoint * |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
116 |
Ipv4EndPointDemux::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:
diff
changeset
|
117 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
118 |
NS_LOG_FUNCTION (this << address << port); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
119 |
if (LookupLocal (address, port)) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
120 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
984
diff
changeset
|
121 |
NS_LOG_WARN ("Duplicate address/port; failing."); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
122 |
return 0; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
123 |
} |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
124 |
Ipv4EndPoint *endPoint = new Ipv4EndPoint (address, port); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
125 |
m_endPoints.push_back (endPoint); |
1524
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1523
diff
changeset
|
126 |
NS_LOG_DEBUG ("Now have >>" << m_endPoints.size () << "<< endpoints."); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
127 |
return endPoint; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
128 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
129 |
|
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
130 |
Ipv4EndPoint * |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
131 |
Ipv4EndPointDemux::Allocate (Ipv4Address localAddress, uint16_t localPort, |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
132 |
Ipv4Address peerAddress, uint16_t peerPort) |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
133 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
134 |
NS_LOG_FUNCTION (this << localAddress << localPort << peerAddress << peerPort); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
135 |
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
136 |
{ |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
137 |
if ((*i)->GetLocalPort () == localPort && |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
138 |
(*i)->GetLocalAddress () == localAddress && |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
139 |
(*i)->GetPeerPort () == peerPort && |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
140 |
(*i)->GetPeerAddress () == peerAddress) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
141 |
{ |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
984
diff
changeset
|
142 |
NS_LOG_WARN ("No way we can allocate this end-point."); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
143 |
/* no way we can allocate this end-point. */ |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
144 |
return 0; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
145 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
146 |
} |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
147 |
Ipv4EndPoint *endPoint = new Ipv4EndPoint (localAddress, localPort); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
148 |
endPoint->SetPeer (peerAddress, peerPort); |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
149 |
m_endPoints.push_back (endPoint); |
1524
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1523
diff
changeset
|
150 |
|
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1523
diff
changeset
|
151 |
NS_LOG_DEBUG ("Now have >>" << m_endPoints.size () << "<< endpoints."); |
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1523
diff
changeset
|
152 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
153 |
return endPoint; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
154 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
155 |
|
515
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
156 |
void |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
157 |
Ipv4EndPointDemux::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:
495
diff
changeset
|
158 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
159 |
NS_LOG_FUNCTION_NOARGS (); |
515
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
160 |
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
161 |
{ |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
162 |
if (*i == endPoint) |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
163 |
{ |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
164 |
delete endPoint; |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
165 |
m_endPoints.erase (i); |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
166 |
break; |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
167 |
} |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
168 |
} |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
169 |
} |
e907146a191e
fix valgrind warning: UdpSocket must manage carefully its Ipv4EndPoint to avoid double deleting it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
495
diff
changeset
|
170 |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
171 |
/* |
3577
4631eaaf84c4
ipv4-end-point-demux: add method to fetch list of all endpoints
Florian Westphal <fw@strlen.de>
parents:
3260
diff
changeset
|
172 |
* return list of all available Endpoints |
4631eaaf84c4
ipv4-end-point-demux: add method to fetch list of all endpoints
Florian Westphal <fw@strlen.de>
parents:
3260
diff
changeset
|
173 |
*/ |
4631eaaf84c4
ipv4-end-point-demux: add method to fetch list of all endpoints
Florian Westphal <fw@strlen.de>
parents:
3260
diff
changeset
|
174 |
Ipv4EndPointDemux::EndPoints |
4631eaaf84c4
ipv4-end-point-demux: add method to fetch list of all endpoints
Florian Westphal <fw@strlen.de>
parents:
3260
diff
changeset
|
175 |
Ipv4EndPointDemux::GetAllEndPoints (void) |
4631eaaf84c4
ipv4-end-point-demux: add method to fetch list of all endpoints
Florian Westphal <fw@strlen.de>
parents:
3260
diff
changeset
|
176 |
{ |
4631eaaf84c4
ipv4-end-point-demux: add method to fetch list of all endpoints
Florian Westphal <fw@strlen.de>
parents:
3260
diff
changeset
|
177 |
NS_LOG_FUNCTION_NOARGS (); |
4631eaaf84c4
ipv4-end-point-demux: add method to fetch list of all endpoints
Florian Westphal <fw@strlen.de>
parents:
3260
diff
changeset
|
178 |
EndPoints ret; |
4631eaaf84c4
ipv4-end-point-demux: add method to fetch list of all endpoints
Florian Westphal <fw@strlen.de>
parents:
3260
diff
changeset
|
179 |
|
4631eaaf84c4
ipv4-end-point-demux: add method to fetch list of all endpoints
Florian Westphal <fw@strlen.de>
parents:
3260
diff
changeset
|
180 |
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
181 |
{ |
3577
4631eaaf84c4
ipv4-end-point-demux: add method to fetch list of all endpoints
Florian Westphal <fw@strlen.de>
parents:
3260
diff
changeset
|
182 |
Ipv4EndPoint* endP = *i; |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
183 |
ret.push_back (endP); |
3577
4631eaaf84c4
ipv4-end-point-demux: add method to fetch list of all endpoints
Florian Westphal <fw@strlen.de>
parents:
3260
diff
changeset
|
184 |
} |
4631eaaf84c4
ipv4-end-point-demux: add method to fetch list of all endpoints
Florian Westphal <fw@strlen.de>
parents:
3260
diff
changeset
|
185 |
return ret; |
4631eaaf84c4
ipv4-end-point-demux: add method to fetch list of all endpoints
Florian Westphal <fw@strlen.de>
parents:
3260
diff
changeset
|
186 |
} |
4631eaaf84c4
ipv4-end-point-demux: add method to fetch list of all endpoints
Florian Westphal <fw@strlen.de>
parents:
3260
diff
changeset
|
187 |
|
4631eaaf84c4
ipv4-end-point-demux: add method to fetch list of all endpoints
Florian Westphal <fw@strlen.de>
parents:
3260
diff
changeset
|
188 |
|
4631eaaf84c4
ipv4-end-point-demux: add method to fetch list of all endpoints
Florian Westphal <fw@strlen.de>
parents:
3260
diff
changeset
|
189 |
/* |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
190 |
* If we have an exact match, we return it. |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
191 |
* Otherwise, if we find a generic match, we return it. |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
192 |
* Otherwise, we return 0. |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
193 |
*/ |
984
3202c053eacc
Allow UDP sockets to receive broadcast (bug #51)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
524
diff
changeset
|
194 |
Ipv4EndPointDemux::EndPoints |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
195 |
Ipv4EndPointDemux::Lookup (Ipv4Address daddr, uint16_t dport, |
1524
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1523
diff
changeset
|
196 |
Ipv4Address saddr, uint16_t sport, |
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1523
diff
changeset
|
197 |
Ptr<Ipv4Interface> incomingInterface) |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
198 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
199 |
NS_LOG_FUNCTION_NOARGS (); |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
200 |
EndPoints retval1; // Matches exact on local port, wildcards on others |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
201 |
EndPoints retval2; // Matches exact on local port/adder, wildcards on others |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
202 |
EndPoints retval3; // Matches all but local address |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
203 |
EndPoints retval4; // Exact match on all 4 |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
204 |
|
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
205 |
NS_LOG_FUNCTION (this << daddr << dport << saddr << sport << incomingInterface); |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
206 |
NS_LOG_DEBUG ("Looking up endpoint for destination address " << daddr); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
207 |
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
208 |
{ |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
209 |
Ipv4EndPoint* endP = *i; |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
210 |
NS_LOG_DEBUG ("Looking at endpoint dport=" << endP->GetLocalPort () |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
211 |
<< " daddr=" << endP->GetLocalAddress () |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
212 |
<< " sport=" << endP->GetPeerPort () |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
213 |
<< " saddr=" << endP->GetPeerAddress ()); |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
214 |
if (endP->GetLocalPort () != dport) |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
215 |
{ |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
216 |
NS_LOG_LOGIC ("Skipping endpoint " << &endP |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
217 |
<< " because endpoint dport " |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
218 |
<< endP->GetLocalPort () |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
219 |
<< " does not match packet dport " << dport); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
220 |
continue; |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
221 |
} |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
4571
diff
changeset
|
222 |
if (endP->GetBoundNetDevice ()) |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
4571
diff
changeset
|
223 |
{ |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
4571
diff
changeset
|
224 |
if (endP->GetBoundNetDevice () != incomingInterface->GetDevice ()) |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
4571
diff
changeset
|
225 |
{ |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
4571
diff
changeset
|
226 |
NS_LOG_LOGIC ("Skipping endpoint " << &endP |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
227 |
<< " because endpoint is bound to specific device and" |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
228 |
<< endP->GetBoundNetDevice () |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
229 |
<< " does not match packet device " << incomingInterface->GetDevice ()); |
5856
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
4571
diff
changeset
|
230 |
continue; |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
4571
diff
changeset
|
231 |
} |
7fd20c798a7d
bug 742: Implementation of SO_BINDTODEVICE
Antti Mäkelä <zarhan@cc.hut.fi>
parents:
4571
diff
changeset
|
232 |
} |
4571
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
233 |
bool subnetDirected = false; |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
234 |
Ipv4Address incomingInterfaceAddr = daddr; // may be a broadcast |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
235 |
for (uint32_t i = 0; i < incomingInterface->GetNAddresses (); i++) |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
236 |
{ |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
237 |
Ipv4InterfaceAddress addr = incomingInterface->GetAddress (i); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
238 |
if (addr.GetLocal ().CombineMask (addr.GetMask ()) == daddr.CombineMask (addr.GetMask ()) && |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
239 |
daddr.IsSubnetDirectedBroadcast (addr.GetMask ())) |
4571
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
240 |
{ |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
241 |
subnetDirected = true; |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
242 |
incomingInterfaceAddr = addr.GetLocal (); |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
243 |
} |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
244 |
} |
2c9c600270e0
cleanup ip alias unfinished cases (bug 591)
Tom Henderson <tomh@tomh.org>
parents:
4375
diff
changeset
|
245 |
bool isBroadcast = (daddr.IsBroadcast () || subnetDirected == true); |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
246 |
NS_LOG_DEBUG ("dest addr " << daddr << " broadcast? " << isBroadcast); |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
247 |
bool localAddressMatchesWildCard = |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
248 |
endP->GetLocalAddress () == Ipv4Address::GetAny (); |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
249 |
bool localAddressMatchesExact = endP->GetLocalAddress () == daddr; |
1524
3ead2b66f2e4
Fix a regression in handling of broadcast packets and UDP sockets (closes bug #51).
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1523
diff
changeset
|
250 |
|
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1828
diff
changeset
|
251 |
if (isBroadcast) |
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1828
diff
changeset
|
252 |
{ |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
253 |
NS_LOG_DEBUG ("Found bcast, localaddr " << endP->GetLocalAddress ()); |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
254 |
} |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
255 |
|
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
256 |
if (isBroadcast && (endP->GetLocalAddress () != Ipv4Address::GetAny ())) |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
257 |
{ |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
258 |
localAddressMatchesExact = (endP->GetLocalAddress () == |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
259 |
incomingInterfaceAddr); |
2326
eec07777d1a2
Fix broadcast packet reception for locally bound sockets (bug #136)
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1828
diff
changeset
|
260 |
} |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
261 |
// if no match here, keep looking |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
262 |
if (!(localAddressMatchesExact || localAddressMatchesWildCard)) |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
263 |
continue; |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
264 |
bool remotePeerMatchesExact = endP->GetPeerPort () == sport; |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
265 |
bool remotePeerMatchesWildCard = endP->GetPeerPort () == 0; |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
266 |
bool remoteAddressMatchesExact = endP->GetPeerAddress () == saddr; |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
267 |
bool remoteAddressMatchesWildCard = endP->GetPeerAddress () == |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
268 |
Ipv4Address::GetAny (); |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
269 |
// If remote does not match either with exact or wildcard, |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
270 |
// skip this one |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
271 |
if (!(remotePeerMatchesExact || remotePeerMatchesWildCard)) |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
272 |
continue; |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
273 |
if (!(remoteAddressMatchesExact || remoteAddressMatchesWildCard)) |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
274 |
continue; |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
275 |
|
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
276 |
// Now figure out which return list to add this one to |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
277 |
if (localAddressMatchesWildCard && |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
278 |
remotePeerMatchesWildCard && |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
279 |
remoteAddressMatchesWildCard) |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
280 |
{ // Only local port matches exactly |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
281 |
retval1.push_back (endP); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
282 |
} |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
283 |
if ((localAddressMatchesExact || (isBroadcast && localAddressMatchesWildCard))&& |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
284 |
remotePeerMatchesWildCard && |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
285 |
remoteAddressMatchesWildCard) |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
286 |
{ // Only local port and local address matches exactly |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
287 |
retval2.push_back (endP); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
288 |
} |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
289 |
if (localAddressMatchesWildCard && |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
290 |
remotePeerMatchesExact && |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
291 |
remoteAddressMatchesExact) |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
292 |
{ // All but local address |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
293 |
retval3.push_back (endP); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
294 |
} |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
295 |
if (localAddressMatchesExact && |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
296 |
remotePeerMatchesExact && |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
297 |
remoteAddressMatchesExact) |
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
298 |
{ // All 4 match |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
299 |
retval4.push_back (endP); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
300 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
301 |
} |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
302 |
|
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
303 |
// Here we find the most exact match |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
304 |
if (!retval4.empty ()) return retval4; |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
305 |
if (!retval3.empty ()) return retval3; |
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
306 |
if (!retval2.empty ()) return retval2; |
2608
408589d1dfff
merge with HEAD
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2326
diff
changeset
|
307 |
return retval1; // might be empty if no matches |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
308 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
309 |
|
3820 | 310 |
Ipv4EndPoint * |
311 |
Ipv4EndPointDemux::SimpleLookup (Ipv4Address daddr, |
|
312 |
uint16_t dport, |
|
313 |
Ipv4Address saddr, |
|
314 |
uint16_t sport) |
|
315 |
{ |
|
316 |
// this code is a copy/paste version of an old BSD ip stack lookup |
|
317 |
// function. |
|
318 |
uint32_t genericity = 3; |
|
319 |
Ipv4EndPoint *generic = 0; |
|
320 |
for (EndPointsI i = m_endPoints.begin (); i != m_endPoints.end (); i++) |
|
321 |
{ |
|
322 |
if ((*i)->GetLocalPort () != dport) |
|
323 |
{ |
|
324 |
continue; |
|
325 |
} |
|
326 |
if ((*i)->GetLocalAddress () == daddr && |
|
327 |
(*i)->GetPeerPort () == sport && |
|
328 |
(*i)->GetPeerAddress () == saddr) |
|
329 |
{ |
|
330 |
/* this is an exact match. */ |
|
331 |
return *i; |
|
332 |
} |
|
333 |
uint32_t tmp = 0; |
|
334 |
if ((*i)->GetLocalAddress () == Ipv4Address::GetAny ()) |
|
335 |
{ |
|
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
336 |
tmp++; |
3820 | 337 |
} |
338 |
if ((*i)->GetPeerAddress () == Ipv4Address::GetAny ()) |
|
339 |
{ |
|
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
340 |
tmp++; |
3820 | 341 |
} |
342 |
if (tmp < genericity) |
|
343 |
{ |
|
344 |
generic = (*i); |
|
345 |
genericity = tmp; |
|
346 |
} |
|
347 |
} |
|
348 |
return generic; |
|
349 |
} |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
350 |
uint16_t |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
351 |
Ipv4EndPointDemux::AllocateEphemeralPort (void) |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
352 |
{ |
7442 | 353 |
// Similar to counting up logic in netinet/in_pcb.c |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2975
diff
changeset
|
354 |
NS_LOG_FUNCTION_NOARGS (); |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
355 |
uint16_t port = m_ephemeral; |
7442 | 356 |
int count = m_portLast - m_portFirst; |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
357 |
do |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
358 |
{ |
7442 | 359 |
if (count-- < 0) |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
360 |
{ |
7442 | 361 |
return 0; |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
362 |
} |
7442 | 363 |
++port; |
364 |
if (port < m_portFirst || port > m_portLast) |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
365 |
{ |
7442 | 366 |
port = m_portFirst; |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
367 |
} |
7442 | 368 |
} while (LookupPortLocal (port)); |
369 |
m_ephemeral = port; |
|
370 |
return port; |
|
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
371 |
} |
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
372 |
|
7386
2310ed220a61
standardize ns-3 namespace declaration format
Vedran Miletić <rivanvx@gmail.com>
parents:
7385
diff
changeset
|
373 |
} // namespace ns3 |
495
a839408950b9
rework the socket/udp layer to remove the Ipv4EndPointDemux template
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
374 |