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
15c07e0d
Commit
15c07e0d
authored
10 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
Network: Misc changes to UDP bind logic for the case of multiple networks
parent
4dd021f3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
configs/sama5d3-xplained/bridge/defconfig
+2
-2
2 additions, 2 deletions
configs/sama5d3-xplained/bridge/defconfig
net/udp/udp_conn.c
+23
-26
23 additions, 26 deletions
net/udp/udp_conn.c
with
25 additions
and
28 deletions
configs/sama5d3-xplained/bridge/defconfig
+
2
−
2
View file @
15c07e0d
...
...
@@ -823,7 +823,7 @@ CONFIG_EXAMPLES_BRIDGE_NET1_PRIORITY=100
# Network 2 configuration
#
CONFIG_EXAMPLES_BRIDGE_NET2_IFNAME="eth1"
CONFIG_EXAMPLES_BRIDGE_NET2_RECVPORT=547
3
CONFIG_EXAMPLES_BRIDGE_NET2_RECVPORT=547
1
CONFIG_EXAMPLES_BRIDGE_NET2_IOBUFIZE=1024
# CONFIG_EXAMPLES_BRIDGE_NET2_DHCPC is not set
CONFIG_EXAMPLES_BRIDGE_NET2_NOMAC=y
...
...
@@ -832,7 +832,7 @@ CONFIG_EXAMPLES_BRIDGE_NET2_IPADDR=0x0a000003
CONFIG_EXAMPLES_BRIDGE_NET2_DRIPADDR=0x0a000001
CONFIG_EXAMPLES_BRIDGE_NET2_NETMASK=0xffffff00
CONFIG_EXAMPLES_BRIDGE_NET2_IPHOST=0x0a000001
CONFIG_EXAMPLES_BRIDGE_NET2_HOSTPORT=547
4
CONFIG_EXAMPLES_BRIDGE_NET2_HOSTPORT=547
2
CONFIG_EXAMPLES_BRIDGE_NET2_STACKSIZE=2048
CONFIG_EXAMPLES_BRIDGE_NET2_PRIORITY=100
# CONFIG_EXAMPLES_BUTTONS is not set
...
...
This diff is collapsed.
Click to expand it.
net/udp/udp_conn.c
+
23
−
26
View file @
15c07e0d
...
...
@@ -344,19 +344,25 @@ FAR struct udp_conn_s *udp_active(FAR struct udp_iphdr_s *buf)
while
(
conn
)
{
/* If the local UDP port is non-zero, the connection is considered
* to be used. If so, the local port number is checked against the
* destination port number in the received packet. If the two port
* numbers match, the remote port number is checked if the
* connection is bound to a remote port. Finally, if the
* connection is bound to a remote IP address, the source IP
* address of the packet is checked.
* to be used. If so, then the following checks are performed:
*
* - The local port number is checked against the destination port
* number in the received packet.
* - The remote port number is checked if the connection is bound
* to a remote 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.
*
* If all of the above are true then the newly received UDP packet
* is destined for this UDP connection.
*/
if
(
conn
->
lport
!=
0
&&
buf
->
destport
==
conn
->
lport
&&
(
conn
->
rport
==
0
||
buf
->
srcport
==
conn
->
rport
)
&&
(
net_ipaddr_cmp
(
conn
->
ripaddr
,
g_allzeroaddr
)
||
net_ipaddr_cmp
(
conn
->
ripaddr
,
g_alloneaddr
)
||
net_ipaddr_hdrcmp
(
buf
->
srcipaddr
,
&
conn
->
ripaddr
)))
(
net_ipaddr_cmp
(
conn
->
ripaddr
,
g_allzeroaddr
)
||
net_ipaddr_cmp
(
conn
->
ripaddr
,
g_alloneaddr
)
||
net_ipaddr_hdrcmp
(
buf
->
srcipaddr
,
&
conn
->
ripaddr
)))
{
/* Matching connection found.. return a reference to it */
...
...
@@ -413,11 +419,13 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in6 *addr)
int
udp_bind
(
FAR
struct
udp_conn_s
*
conn
,
FAR
const
struct
sockaddr_in
*
addr
)
#endif
{
FAR
struct
net_driver_s
*
dev
;
net_ipaddr_t
ipaddr
;
net_lock_t
flags
;
int
ret
;
#ifdef CONFIG_NETDEV_MULTINIC
FAR
struct
net_driver_s
*
dev
;
net_ipaddr_t
ipaddr
;
#ifdef CONFIG_NET_IPv6
/* Get the IPv6 address that we are binding to */
...
...
@@ -448,18 +456,11 @@ int udp_bind(FAR struct udp_conn_s *conn, FAR const struct sockaddr_in *addr)
ipaddr
=
dev
->
d_ipaddr
;
}
else
{
/* We cannot bind the socket to an IP address if it cannot be routed
* by a registered network device.
*/
dev
=
netdev_findbyaddr
(
ipaddr
);
if
(
!
dev
)
{
return
-
EADDRNOTAVAIL
;
}
}
/* Bind the local IP address to the connection */
net_ipaddr_copy
(
conn
->
lipaddr
,
ipaddr
);
#endif
/* Is the user requesting to bind to any port? */
...
...
@@ -561,10 +562,6 @@ int udp_connect(FAR struct udp_conn_s *conn,
/* Use the IP address assigned to the default device */
net_ipaddr_copy
(
conn
->
lipaddr
,
dev
->
d_ipaddr
);
/* Make sure that we re-assign a valid port on this IP address */
conn
->
lport
=
0
;
}
#endif
/* CONFIG_NETDEV_MULTINIC */
...
...
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