author | Tommaso Pecorella <tommaso.pecorella@unifi.it> |
Sun, 16 Jun 2013 08:58:39 +0200 | |
changeset 9835 | 3efac978b3c9 |
parent 9236 | 3c5ea0bd869f |
child 10410 | 4d4eb8097fa3 |
permissions | -rw-r--r-- |
7385
10beb0e53130
standardize emacs c++ mode comments
Vedran Miletić <rivanvx@gmail.com>
parents:
7252
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
2 |
/* |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
3 |
* Copyright (c) 2007-2009 Strasbourg University |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
4 |
* |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
8 |
* |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
13 |
* |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
17 |
* |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
18 |
* Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr> |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
19 |
*/ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
20 |
|
6333
c461f7a25895
Bug 858 - support MSG_PEEK in IPv4/IPv6 raw socket
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
5891
diff
changeset
|
21 |
#include <netinet/in.h> |
7485
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7385
diff
changeset
|
22 |
#include <sys/socket.h> |
9bec9af5e3c8
make ns-3 compile on FreeBSD-8.2
Colin Perkins <csp@csperkins.org>
parents:
7385
diff
changeset
|
23 |
#include <sys/types.h> |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
24 |
#include "ns3/inet6-socket-address.h" |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
25 |
#include "ns3/node.h" |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
26 |
#include "ns3/packet.h" |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
27 |
#include "ns3/uinteger.h" |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
28 |
#include "ns3/log.h" |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
29 |
#include "ns3/ipv6-route.h" |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
30 |
#include "ns3/ipv6-routing-protocol.h" |
6442
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6437
diff
changeset
|
31 |
#include "ns3/ipv6-packet-info-tag.h" |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
32 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
33 |
#include "ipv6-l3-protocol.h" |
5217
8a9dbc333e76
Export more IPv6 includes.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
4731
diff
changeset
|
34 |
#include "ipv6-raw-socket-impl.h" |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
35 |
#include "icmpv6-header.h" |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
36 |
#include "icmpv6-l4-protocol.h" |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
37 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
38 |
namespace ns3 |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
39 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
40 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
41 |
NS_LOG_COMPONENT_DEFINE ("Ipv6RawSocketImpl"); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
42 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
43 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
44 |
NS_OBJECT_ENSURE_REGISTERED (Ipv6RawSocketImpl); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
45 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
46 |
TypeId Ipv6RawSocketImpl::GetTypeId () |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
47 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
48 |
static TypeId tid = TypeId ("ns3::Ipv6RawSocketImpl") |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
49 |
.SetParent<Socket> () |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
50 |
.AddAttribute ("Protocol", "Protocol number to match.", |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
51 |
UintegerValue (0), |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
52 |
MakeUintegerAccessor (&Ipv6RawSocketImpl::m_protocol), |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
53 |
MakeUintegerChecker<uint16_t> ()) |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
6834
diff
changeset
|
54 |
; |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
55 |
return tid; |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
56 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
57 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
58 |
Ipv6RawSocketImpl::Ipv6RawSocketImpl () |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
59 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
60 |
NS_LOG_FUNCTION_NOARGS (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
61 |
m_err = Socket::ERROR_NOTERROR; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
62 |
m_node = 0; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
63 |
m_src = Ipv6Address::GetAny (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
64 |
m_dst = Ipv6Address::GetAny (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
65 |
m_protocol = 0; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
66 |
m_shutdownSend = false; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
67 |
m_shutdownRecv = false; |
7696
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
68 |
Icmpv6FilterSetPassAll(); |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
69 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
70 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
71 |
Ipv6RawSocketImpl::~Ipv6RawSocketImpl () |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
72 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
73 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
74 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
75 |
void Ipv6RawSocketImpl::DoDispose () |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
76 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
77 |
NS_LOG_FUNCTION_NOARGS (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
78 |
m_node = 0; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
79 |
Socket::DoDispose (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
80 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
81 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
82 |
void Ipv6RawSocketImpl::SetNode (Ptr<Node> node) |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
83 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
84 |
NS_LOG_FUNCTION (this << node); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
85 |
m_node = node; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
86 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
87 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
88 |
Ptr<Node> Ipv6RawSocketImpl::GetNode () const |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
89 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
90 |
return m_node; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
91 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
92 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
93 |
enum Socket::SocketErrno Ipv6RawSocketImpl::GetErrno () const |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
94 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
95 |
NS_LOG_FUNCTION_NOARGS (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
96 |
return m_err; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
97 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
98 |
|
6689
e2de571e920a
Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents:
6549
diff
changeset
|
99 |
enum Socket::SocketType Ipv6RawSocketImpl::GetSocketType () const |
e2de571e920a
Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents:
6549
diff
changeset
|
100 |
{ |
6692
591fb1aa0ca4
Avoid enum name collision in socket
Josh Pelkey <jpelkey@gatech.edu>
parents:
6689
diff
changeset
|
101 |
return NS3_SOCK_RAW; |
6689
e2de571e920a
Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents:
6549
diff
changeset
|
102 |
} |
e2de571e920a
Implement Socket::GetSocketType
Josh Pelkey <jpelkey@gatech.edu>
parents:
6549
diff
changeset
|
103 |
|
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
104 |
int Ipv6RawSocketImpl::Bind (const Address& address) |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
105 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
106 |
NS_LOG_FUNCTION (this << address); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
107 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
108 |
if (!Inet6SocketAddress::IsMatchingType (address)) |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
109 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
110 |
m_err = Socket::ERROR_INVAL; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
111 |
return -1; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
112 |
} |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
113 |
Inet6SocketAddress ad = Inet6SocketAddress::ConvertFrom (address); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
114 |
m_src = ad.GetIpv6 (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
115 |
return 0; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
116 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
117 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
118 |
int Ipv6RawSocketImpl::Bind () |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
119 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
120 |
NS_LOG_FUNCTION_NOARGS (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
121 |
m_src = Ipv6Address::GetAny (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
122 |
return 0; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
123 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
124 |
|
7717
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7696
diff
changeset
|
125 |
int Ipv6RawSocketImpl::Bind6 () |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7696
diff
changeset
|
126 |
{ |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7696
diff
changeset
|
127 |
return(Bind()); |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7696
diff
changeset
|
128 |
} |
cfa1741013dd
Add support for IPv6 transport protocols
Ken Renard <kdrenard2@gmail.com>
parents:
7696
diff
changeset
|
129 |
|
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
130 |
int Ipv6RawSocketImpl::GetSockName (Address& address) const |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
131 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
132 |
NS_LOG_FUNCTION_NOARGS (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
133 |
address = Inet6SocketAddress (m_src, 0); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
134 |
return 0; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
135 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
136 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
137 |
int Ipv6RawSocketImpl::Close () |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
138 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
139 |
NS_LOG_FUNCTION_NOARGS (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
140 |
Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> (); |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
141 |
|
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
142 |
if (ipv6) |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
143 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
144 |
ipv6->DeleteRawSocket (this); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
145 |
} |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
146 |
return 0; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
147 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
148 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
149 |
int Ipv6RawSocketImpl::ShutdownSend () |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
150 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
151 |
NS_LOG_FUNCTION_NOARGS (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
152 |
m_shutdownSend = true; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
153 |
return 0; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
154 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
155 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
156 |
int Ipv6RawSocketImpl::ShutdownRecv () |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
157 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
158 |
NS_LOG_FUNCTION_NOARGS (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
159 |
m_shutdownRecv = true; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
160 |
return 0; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
161 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
162 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
163 |
int Ipv6RawSocketImpl::Connect (const Address& address) |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
164 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
165 |
NS_LOG_FUNCTION (this << address); |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
166 |
|
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
167 |
if (!Inet6SocketAddress::IsMatchingType (address)) |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
168 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
169 |
m_err = Socket::ERROR_INVAL; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
170 |
return -1; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
171 |
} |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
172 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
173 |
Inet6SocketAddress ad = Inet6SocketAddress::ConvertFrom (address); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
174 |
m_dst = ad.GetIpv6 (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
175 |
return 0; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
176 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
177 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
178 |
int Ipv6RawSocketImpl::Listen () |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
179 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
180 |
NS_LOG_FUNCTION_NOARGS (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
181 |
m_err = Socket::ERROR_OPNOTSUPP; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
182 |
return -1; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
183 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
184 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
185 |
int Ipv6RawSocketImpl::Send (Ptr<Packet> p, uint32_t flags) |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
186 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
187 |
NS_LOG_FUNCTION (this << p << flags); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
188 |
Inet6SocketAddress to = Inet6SocketAddress (m_dst, m_protocol); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
189 |
return SendTo (p, flags, to); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
190 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
191 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
192 |
int Ipv6RawSocketImpl::SendTo (Ptr<Packet> p, uint32_t flags, const Address& toAddress) |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
193 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
194 |
NS_LOG_FUNCTION (this << p << flags << toAddress); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
195 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
196 |
if (!Inet6SocketAddress::IsMatchingType (toAddress)) |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
197 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
198 |
m_err = Socket::ERROR_INVAL; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
199 |
return -1; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
200 |
} |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
201 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
202 |
if (m_shutdownSend) |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
203 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
204 |
return 0; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
205 |
} |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
206 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
207 |
Inet6SocketAddress ad = Inet6SocketAddress::ConvertFrom (toAddress); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
208 |
Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
209 |
Ipv6Address dst = ad.GetIpv6 (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
210 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
211 |
if (ipv6->GetRoutingProtocol ()) |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
212 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
213 |
Ipv6Header hdr; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
214 |
hdr.SetDestinationAddress (dst); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
215 |
SocketErrno err = ERROR_NOTERROR; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
216 |
Ptr<Ipv6Route> route = 0; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
217 |
Ptr<NetDevice> oif (0); /*specify non-zero if bound to a source address */ |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
218 |
|
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
219 |
if (!m_src.IsAny ()) |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
220 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
221 |
int32_t index = ipv6->GetInterfaceForAddress (m_src); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
222 |
NS_ASSERT (index >= 0); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
223 |
oif = ipv6->GetNetDevice (index); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
224 |
} |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
225 |
|
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
226 |
route = ipv6->GetRoutingProtocol ()->RouteOutput (p, hdr, oif, err); |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
227 |
|
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
228 |
if (route) |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
229 |
{ |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
230 |
NS_LOG_LOGIC ("Route exists"); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
231 |
if (m_protocol == Icmpv6L4Protocol::GetStaticProtocolNumber ()) |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
232 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
233 |
/* calculate checksum here for ICMPv6 echo request (sent by ping6) |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
234 |
* as we cannot determine source IPv6 address at application level |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
235 |
*/ |
6549
487146fc889e
get rid of about a zillion PeekData
Craig Dowell <craigdo@ee.washington.edu>
parents:
6448
diff
changeset
|
236 |
uint8_t type; |
487146fc889e
get rid of about a zillion PeekData
Craig Dowell <craigdo@ee.washington.edu>
parents:
6448
diff
changeset
|
237 |
p->CopyData (&type, sizeof(type)); |
487146fc889e
get rid of about a zillion PeekData
Craig Dowell <craigdo@ee.washington.edu>
parents:
6448
diff
changeset
|
238 |
if (type == Icmpv6Header::ICMPV6_ECHO_REQUEST) |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
239 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
240 |
Icmpv6Echo hdr (1); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
241 |
p->RemoveHeader (hdr); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
242 |
hdr.CalculatePseudoHeaderChecksum (route->GetSource (), dst, p->GetSize () + hdr.GetSerializedSize (), Icmpv6L4Protocol::GetStaticProtocolNumber ()); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
243 |
p->AddHeader (hdr); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
244 |
} |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
245 |
} |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
246 |
|
9835
3efac978b3c9
Bug 1700 - Ipv6RawSocket does not honor the bound address when sending packets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9236
diff
changeset
|
247 |
if (m_src.IsAny ()) |
3efac978b3c9
Bug 1700 - Ipv6RawSocket does not honor the bound address when sending packets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9236
diff
changeset
|
248 |
{ |
3efac978b3c9
Bug 1700 - Ipv6RawSocket does not honor the bound address when sending packets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9236
diff
changeset
|
249 |
ipv6->Send (p, route->GetSource (), dst, m_protocol, route); |
3efac978b3c9
Bug 1700 - Ipv6RawSocket does not honor the bound address when sending packets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9236
diff
changeset
|
250 |
} |
3efac978b3c9
Bug 1700 - Ipv6RawSocket does not honor the bound address when sending packets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9236
diff
changeset
|
251 |
else |
3efac978b3c9
Bug 1700 - Ipv6RawSocket does not honor the bound address when sending packets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9236
diff
changeset
|
252 |
{ |
3efac978b3c9
Bug 1700 - Ipv6RawSocket does not honor the bound address when sending packets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9236
diff
changeset
|
253 |
ipv6->Send (p, m_src, dst, m_protocol, route); |
3efac978b3c9
Bug 1700 - Ipv6RawSocket does not honor the bound address when sending packets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
9236
diff
changeset
|
254 |
} |
9236
3c5ea0bd869f
Bug 1582 - IPv6 raw socket return value is not like Linux socket
Hajime Tazaki <tazaki@nict.go.jp>
parents:
9148
diff
changeset
|
255 |
// Return only payload size (as Linux does). |
3c5ea0bd869f
Bug 1582 - IPv6 raw socket return value is not like Linux socket
Hajime Tazaki <tazaki@nict.go.jp>
parents:
9148
diff
changeset
|
256 |
return p->GetSize () - hdr.GetSerializedSize (); |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
257 |
} |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
258 |
else |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
259 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
260 |
NS_LOG_DEBUG ("No route, dropped!"); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
261 |
} |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
262 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
263 |
return 0; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
264 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
265 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
266 |
Ptr<Packet> Ipv6RawSocketImpl::Recv (uint32_t maxSize, uint32_t flags) |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
267 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
268 |
NS_LOG_FUNCTION (this << maxSize << flags); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
269 |
Address tmp; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
270 |
return RecvFrom (maxSize, flags, tmp); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
271 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
272 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
273 |
Ptr<Packet> Ipv6RawSocketImpl::RecvFrom (uint32_t maxSize, uint32_t flags, Address& fromAddress) |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
274 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
275 |
NS_LOG_FUNCTION (this << maxSize << flags << fromAddress); |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
276 |
|
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
277 |
if (m_data.empty ()) |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
278 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
279 |
return 0; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
280 |
} |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
281 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
282 |
/* get packet */ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
283 |
struct Data data = m_data.front (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
284 |
m_data.pop_front (); |
9236
3c5ea0bd869f
Bug 1582 - IPv6 raw socket return value is not like Linux socket
Hajime Tazaki <tazaki@nict.go.jp>
parents:
9148
diff
changeset
|
285 |
fromAddress = Inet6SocketAddress (data.fromIp, data.fromProtocol); |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
286 |
if (data.packet->GetSize () > maxSize) |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
287 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
288 |
Ptr<Packet> first = data.packet->CreateFragment (0, maxSize); |
6333
c461f7a25895
Bug 858 - support MSG_PEEK in IPv4/IPv6 raw socket
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
5891
diff
changeset
|
289 |
if (!(flags & MSG_PEEK)) |
c461f7a25895
Bug 858 - support MSG_PEEK in IPv4/IPv6 raw socket
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
5891
diff
changeset
|
290 |
{ |
c461f7a25895
Bug 858 - support MSG_PEEK in IPv4/IPv6 raw socket
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
5891
diff
changeset
|
291 |
data.packet->RemoveAtStart (maxSize); |
c461f7a25895
Bug 858 - support MSG_PEEK in IPv4/IPv6 raw socket
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
5891
diff
changeset
|
292 |
} |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
293 |
m_data.push_front (data); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
294 |
return first; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
295 |
} |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
296 |
|
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
297 |
return data.packet; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
298 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
299 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
300 |
uint32_t Ipv6RawSocketImpl::GetTxAvailable () const |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
301 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
302 |
NS_LOG_FUNCTION_NOARGS (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
303 |
return 0xffffffff; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
304 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
305 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
306 |
uint32_t Ipv6RawSocketImpl::GetRxAvailable () const |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
307 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
308 |
NS_LOG_FUNCTION_NOARGS (); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
309 |
uint32_t rx = 0; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
310 |
|
7252
c8200621e252
rerun check-style.py with uncrustify-0.58
Tom Henderson <tomh@tomh.org>
parents:
7176
diff
changeset
|
311 |
for (std::list<Data>::const_iterator it = m_data.begin (); it != m_data.end (); ++it) |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
312 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
313 |
rx+= (it->packet)->GetSize (); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
314 |
} |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
315 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
316 |
return rx; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
317 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
318 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
319 |
bool Ipv6RawSocketImpl::ForwardUp (Ptr<const Packet> p, Ipv6Header hdr, Ptr<NetDevice> device) |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
320 |
{ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
321 |
NS_LOG_FUNCTION (this << *p << hdr << device); |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
322 |
|
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
323 |
if (m_shutdownRecv) |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
324 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
325 |
return false; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
326 |
} |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
327 |
|
9148
9c37ec6053bd
Bug 1528 - BindToNetDevice not working for IPv6 sockets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7758
diff
changeset
|
328 |
Ptr<NetDevice> boundNetDevice = Socket::GetBoundNetDevice(); |
9c37ec6053bd
Bug 1528 - BindToNetDevice not working for IPv6 sockets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7758
diff
changeset
|
329 |
if (boundNetDevice) |
9c37ec6053bd
Bug 1528 - BindToNetDevice not working for IPv6 sockets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7758
diff
changeset
|
330 |
{ |
9c37ec6053bd
Bug 1528 - BindToNetDevice not working for IPv6 sockets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7758
diff
changeset
|
331 |
if (boundNetDevice != device) |
9c37ec6053bd
Bug 1528 - BindToNetDevice not working for IPv6 sockets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7758
diff
changeset
|
332 |
{ |
9c37ec6053bd
Bug 1528 - BindToNetDevice not working for IPv6 sockets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7758
diff
changeset
|
333 |
return false; |
9c37ec6053bd
Bug 1528 - BindToNetDevice not working for IPv6 sockets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7758
diff
changeset
|
334 |
} |
9c37ec6053bd
Bug 1528 - BindToNetDevice not working for IPv6 sockets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7758
diff
changeset
|
335 |
} |
9c37ec6053bd
Bug 1528 - BindToNetDevice not working for IPv6 sockets
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7758
diff
changeset
|
336 |
|
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
337 |
if ((m_src == Ipv6Address::GetAny () || hdr.GetDestinationAddress () == m_src) && |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
338 |
(m_dst == Ipv6Address::GetAny () || hdr.GetSourceAddress () == m_dst) && |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
339 |
hdr.GetNextHeader () == m_protocol) |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
340 |
{ |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
341 |
Ptr<Packet> copy = p->Copy (); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
342 |
|
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
343 |
if (m_protocol == Icmpv6L4Protocol::GetStaticProtocolNumber ()) |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
344 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
345 |
/* filter */ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
346 |
Icmpv6Header icmpHeader; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
347 |
copy->PeekHeader (icmpHeader); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
348 |
uint8_t type = icmpHeader.GetType (); |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
349 |
|
7696
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
350 |
if (Icmpv6FilterWillBlock(type)) |
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
351 |
{ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
352 |
/* packet filtered */ |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
353 |
return false; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
354 |
} |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
355 |
} |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
356 |
|
6442
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6437
diff
changeset
|
357 |
// Should check via getsockopt ().. |
7758
c678188af993
Replace references to m_recvpktinfo with method call IsRecvPktInfo()
frederic.urbani@inria.fr
parents:
7717
diff
changeset
|
358 |
if (IsRecvPktInfo ()) |
6442
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6437
diff
changeset
|
359 |
{ |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6437
diff
changeset
|
360 |
Ipv6PacketInfoTag tag; |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6437
diff
changeset
|
361 |
copy->RemovePacketTag (tag); |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6437
diff
changeset
|
362 |
tag.SetRecvIf (device->GetIfIndex ()); |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6437
diff
changeset
|
363 |
copy->AddPacketTag (tag); |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6437
diff
changeset
|
364 |
} |
f380cf1aa4d8
Bug 671 add packet-info-tag.cc for IP_PKTINFO/IPV6_PKTINFO
Hajime Tazaki <tazaki@sfc.wide.ad.jp>
parents:
6437
diff
changeset
|
365 |
|
5891
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
366 |
copy->AddHeader (hdr); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
367 |
struct Data data; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
368 |
data.packet = copy; |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
369 |
data.fromIp = hdr.GetSourceAddress (); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
370 |
data.fromProtocol = hdr.GetNextHeader (); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
371 |
m_data.push_back (data); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
372 |
NotifyDataRecv (); |
09a575cdf8db
Indent correctly IPv6 code.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
5856
diff
changeset
|
373 |
return true; |
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
374 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
375 |
return false; |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
376 |
} |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
377 |
|
6448
184a509cc71d
Still Bug 943: fix UdpSocketImpl::GetAllowBroadcast, let Socket::SetAllowBroadcast return a bool indicating success/failure, instead of a fatal error.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6442
diff
changeset
|
378 |
bool |
6437
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6333
diff
changeset
|
379 |
Ipv6RawSocketImpl::SetAllowBroadcast (bool allowBroadcast) |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6333
diff
changeset
|
380 |
{ |
6448
184a509cc71d
Still Bug 943: fix UdpSocketImpl::GetAllowBroadcast, let Socket::SetAllowBroadcast return a bool indicating success/failure, instead of a fatal error.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6442
diff
changeset
|
381 |
if (!allowBroadcast) |
6437
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6333
diff
changeset
|
382 |
{ |
6448
184a509cc71d
Still Bug 943: fix UdpSocketImpl::GetAllowBroadcast, let Socket::SetAllowBroadcast return a bool indicating success/failure, instead of a fatal error.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6442
diff
changeset
|
383 |
return false; |
6437
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6333
diff
changeset
|
384 |
} |
6448
184a509cc71d
Still Bug 943: fix UdpSocketImpl::GetAllowBroadcast, let Socket::SetAllowBroadcast return a bool indicating success/failure, instead of a fatal error.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6442
diff
changeset
|
385 |
return true; |
6437
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6333
diff
changeset
|
386 |
} |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6333
diff
changeset
|
387 |
|
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6333
diff
changeset
|
388 |
bool |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6333
diff
changeset
|
389 |
Ipv6RawSocketImpl::GetAllowBroadcast () const |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6333
diff
changeset
|
390 |
{ |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6333
diff
changeset
|
391 |
return true; |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6333
diff
changeset
|
392 |
} |
c11291f51d57
Bug 943 - Add a SO_BROADCAST socket option
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
6333
diff
changeset
|
393 |
|
7696
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
394 |
void |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
395 |
Ipv6RawSocketImpl::Icmpv6FilterSetPassAll() |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
396 |
{ |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
397 |
memset(&m_icmpFilter, 0xff, sizeof(icmpv6Filter)); |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
398 |
} |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
399 |
|
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
400 |
void |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
401 |
Ipv6RawSocketImpl::Icmpv6FilterSetBlockAll() |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
402 |
{ |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
403 |
memset(&m_icmpFilter, 0x00, sizeof(icmpv6Filter)); |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
404 |
} |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
405 |
|
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
406 |
void |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
407 |
Ipv6RawSocketImpl::Icmpv6FilterSetPass(uint8_t type) |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
408 |
{ |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
409 |
(m_icmpFilter.icmpv6Filt[(type) >> 5]) |= (uint32_t(1) << ((type) & 31)); |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
410 |
} |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
411 |
|
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
412 |
void |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
413 |
Ipv6RawSocketImpl::Icmpv6FilterSetBlock(uint8_t type) |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
414 |
{ |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
415 |
(m_icmpFilter.icmpv6Filt[(type) >> 5]) &= ~(uint32_t(1) << ((type) & 31)); |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
416 |
} |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
417 |
|
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
418 |
bool |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
419 |
Ipv6RawSocketImpl::Icmpv6FilterWillPass(uint8_t type) |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
420 |
{ |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
421 |
return (((m_icmpFilter.icmpv6Filt[(type) >> 5]) & (uint32_t(1) << ((type) & 31))) != 0); |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
422 |
} |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
423 |
|
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
424 |
bool |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
425 |
Ipv6RawSocketImpl::Icmpv6FilterWillBlock(uint8_t type) |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
426 |
{ |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
427 |
return (((m_icmpFilter.icmpv6Filt[(type) >> 5]) & (uint32_t(1) << ((type) & 31))) == 0); |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
428 |
} |
142e062124f4
Bug 1319 - Fix Ipv6RawSocketImpl Icmpv6 filter
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
7485
diff
changeset
|
429 |
|
4731
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
430 |
} /* namespace ns3 */ |
510db8599bfb
second phase of IPv6 checkins from Univ. of Strasbourg team
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents:
diff
changeset
|
431 |