Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
cm-projects
RIOT
Commits
9d1dd39f
Commit
9d1dd39f
authored
9 years ago
by
Oleg Hahm
Browse files
Options
Downloads
Patches
Plain Diff
conn: fix UDP port byteorder in recvfrom
Additionally cleans up some superfluous functions.
parent
3fc71ef6
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sys/net/gnrc/conn/gnrc_conn.c
+3
-31
3 additions, 31 deletions
sys/net/gnrc/conn/gnrc_conn.c
with
3 additions
and
31 deletions
sys/net/gnrc/conn/gnrc_conn.c
+
3
−
31
View file @
9d1dd39f
...
...
@@ -20,35 +20,6 @@
#include
"net/gnrc/ipv6/netif.h"
#include
"net/udp.h"
static
inline
size_t
_srcaddr
(
void
*
addr
,
gnrc_pktsnip_t
*
hdr
)
{
switch
(
hdr
->
type
)
{
#ifdef MODULE_GNRC_IPV6
case
GNRC_NETTYPE_IPV6
:
memcpy
(
addr
,
&
((
ipv6_hdr_t
*
)
hdr
->
data
)
->
src
,
sizeof
(
ipv6_addr_t
));
return
sizeof
(
ipv6_addr_t
);
#endif
default:
(
void
)
addr
;
return
0
;
}
}
static
inline
void
_srcport
(
uint16_t
*
port
,
gnrc_pktsnip_t
*
hdr
)
{
switch
(
hdr
->
type
)
{
#ifdef MODULE_GNRC_UDP
case
GNRC_NETTYPE_UDP
:
memcpy
(
port
,
&
((
udp_hdr_t
*
)
hdr
->
data
)
->
src_port
,
sizeof
(
uint16_t
));
break
;
#endif
default:
(
void
)
port
;
(
void
)
hdr
;
break
;
}
}
int
gnrc_conn_recvfrom
(
conn_t
*
conn
,
void
*
data
,
size_t
max_len
,
void
*
addr
,
size_t
*
addr_len
,
uint16_t
*
port
)
{
...
...
@@ -77,11 +48,12 @@ int gnrc_conn_recvfrom(conn_t *conn, void *data, size_t max_len, void *addr, siz
msg_send_to_self
(
&
msg
);
/* requeue invalid messages */
continue
;
}
_srcport
(
port
,
l4hdr
);
*
port
=
byteorder_ntohs
(((
udp_hdr_t
*
)
l4hdr
->
data
)
->
src_port
);
}
#endif
/* defined(MODULE_CONN_UDP) */
if
(
addr
!=
NULL
)
{
*
addr_len
=
_srcaddr
(
addr
,
l3hdr
);
memcpy
(
addr
,
&
((
ipv6_hdr_t
*
)
l3hdr
->
data
)
->
src
,
sizeof
(
ipv6_addr_t
));
*
addr_len
=
sizeof
(
ipv6_addr_t
);
}
memcpy
(
data
,
pkt
->
data
,
pkt
->
size
);
size
=
pkt
->
size
;
...
...
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