Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
NuttX RTOS
Commits
251249a9
Commit
251249a9
authored
10 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
Back out a misconception about INADDR_ANY introduce with some previous commits
parent
b3461045
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
net/ipv6/Make.defs
+1
-1
1 addition, 1 deletion
net/ipv6/Make.defs
net/ipv6/ipv6.h
+0
-2
0 additions, 2 deletions
net/ipv6/ipv6.h
net/ipv6/ipv6_global.c
+0
-61
0 additions, 61 deletions
net/ipv6/ipv6_global.c
net/udp/udp_conn.c
+18
-54
18 additions, 54 deletions
net/udp/udp_conn.c
with
19 additions
and
118 deletions
net/ipv6/Make.defs
+
1
−
1
View file @
251249a9
...
...
@@ -37,7 +37,7 @@
ifeq ($(CONFIG_NET_IPv6),y)
NET_CSRCS +=
ipv6_global.c
ipv6_neighbor.c
NET_CSRCS += ipv6_neighbor.c
# Include utility build support
...
...
This diff is collapsed.
Click to expand it.
net/ipv6/ipv6.h
+
0
−
2
View file @
251249a9
...
...
@@ -70,8 +70,6 @@ struct net_neighbor_addr_s
* Public Data
****************************************************************************/
extern
const
in6_addr_t
g_in6addr_any
;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
...
...
This diff is collapsed.
Click to expand it.
net/ipv6/ipv6_global.c
deleted
100644 → 0
+
0
−
61
View file @
b3461045
/****************************************************************************
* net/ipv6/ipv6_global.c
*
* Copyright (C) 2012, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include
<nuttx/config.h>
#include
<netinit/in.h>
#include
"ipv6/ipv6.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
const
in6_addr_t
g_in6addr_any
=
IN6ADDR_ANY_INIT
;
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
This diff is collapsed.
Click to expand it.
net/udp/udp_conn.c
+
18
−
54
View file @
251249a9
...
...
@@ -140,10 +140,17 @@ static FAR struct udp_conn_s *udp_find_conn(uint16_t portno)
#ifdef CONFIG_NETDEV_MULTINIC
/* If the port local port number assigned to the connections matches
* AND the IP address of the connection matches, then return a
* reference to the connection structure.
* reference to the connection structure. INADDR_ANY is a special
* case: There can only be instance of a port number with INADDR_ANY.
*/
if
(
conn
->
lport
==
portno
&&
net_ipaddr_cmp
(
conn
->
lipaddr
,
ipaddr
))
if
(
conn
->
lport
==
portno
&&
(
net_ipaddr_cmp
(
conn
->
lipaddr
,
ipaddr
)
||
#ifdef CONFIG_NET_IPv6
net_ipaddr_cmp
(
conn
->
lipaddr
,
g_allzeroaddr
)))
#else
net_ipaddr_cmp
(
conn
->
lipaddr
,
INADDR_ANY
)))
#endif
{
return
conn
;
}
...
...
@@ -353,7 +360,9 @@ FAR struct udp_conn_s *udp_active(FAR struct udp_iphdr_s *buf)
* - If multiple network interfaces are supported, then the local
* IP address is available and we will insist that the
* destination IP matches the bound address (or the destination
* IP address is a broadcase address).
* IP address is a broadcast address). If a socket is bound to
* INADDRY_ANY (lipaddr), then it should receive all packets
* directed to the port.
* - Finally, if the connection is bound to a remote IP address,
* the source IP address of the packet is checked. Broadcast
* addresses are also accepted.
...
...
@@ -365,7 +374,8 @@ FAR struct udp_conn_s *udp_active(FAR struct udp_iphdr_s *buf)
if
(
conn
->
lport
!=
0
&&
buf
->
destport
==
conn
->
lport
&&
(
conn
->
rport
==
0
||
buf
->
srcport
==
conn
->
rport
)
&&
#ifdef CONFIG_NETDEV_MULTINIC
(
net_ipaddr_hdrcmp
(
buf
->
destipaddr
,
&
g_alloneaddr
)
||
(
net_ipaddr_hdrcmp
(
buf
->
destipaddr
,
&
g_allzeroaddr
)
||
net_ipaddr_hdrcmp
(
buf
->
destipaddr
,
&
g_alloneaddr
)
||
net_ipaddr_hdrcmp
(
buf
->
destipaddr
,
&
conn
->
lipaddr
))
&&
#endif
(
net_ipaddr_cmp
(
conn
->
ripaddr
,
g_allzeroaddr
)
||
...
...
@@ -431,7 +441,6 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in *addr)
int
ret
;
#ifdef CONFIG_NETDEV_MULTINIC
FAR
struct
net_driver_s
*
dev
;
net_ipaddr_t
ipaddr
;
#ifdef CONFIG_NET_IPv6
...
...
@@ -439,33 +448,17 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in *addr)
ipaddr
=
addr
->
sin6_addr
.
in6_u
.
u6_addr16
;
/* Is the address IN6ADDR_ANY? */
if
(
net_ipaddr_cmp
(
ipaddr
,
g_in6addr_any
))
#else
/* Get the IPv4 address that we are binding to */
ipaddr
=
addr
->
sin_addr
.
s_addr
;
/* Is the address INADDR_ANY? */
if
(
net_ipaddr_cmp
(
ipaddr
,
INADDR_ANY
))
#endif
{
/* Get the default device */
dev
=
netdev_default
();
if
(
dev
==
NULL
)
{
return
-
EADDRNOTAVAIL
;
}
/* Use the IP address assigned to the default device */
ipaddr
=
dev
->
d_ipaddr
;
}
/* Bind the local IP address to the connection */
/* Bind the local IP address to the connection. NOTE this address may be
* INADDR_ANY meaning, essentially, that we are binding to all interfaces
* for receiving (Sending will use the default port).
*/
net_ipaddr_copy
(
conn
->
lipaddr
,
ipaddr
);
#endif
...
...
@@ -544,35 +537,6 @@ int udp_connect(FAR struct udp_conn_s *conn,
FAR
const
struct
sockaddr_in
*
addr
)
#endif
{
#ifdef CONFIG_NETDEV_MULTINIC
FAR
struct
net_driver_s
*
dev
;
/* Has this connection already been bound to a local IP address (lipaddr)? */
#ifdef CONFIG_NET_IPv6
/* Is the address IN6ADDR_ANY? */
if
(
net_ipaddr_cmp
(
conn
->
lipaddr
,
g_in6addr_any
))
#else
/* Is the address INADDR_ANY? */
if
(
net_ipaddr_cmp
(
conn
->
lipaddr
,
INADDR_ANY
))
#endif
{
/* Get the default device */
dev
=
netdev_default
();
if
(
dev
==
NULL
)
{
return
-
EADDRNOTAVAIL
;
}
/* Use the IP address assigned to the default device */
net_ipaddr_copy
(
conn
->
lipaddr
,
dev
->
d_ipaddr
);
}
#endif
/* CONFIG_NETDEV_MULTINIC */
/* Has this address already been bound to a local port (lport)? */
if
(
!
conn
->
lport
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment