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
f2b1c5c8
Commit
f2b1c5c8
authored
6 years ago
by
Hauke Petersen
Browse files
Options
Downloads
Patches
Plain Diff
net/gcoap: use sock_udp_ep_equal()
parent
8d1d509a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile.dep
+1
-0
1 addition, 0 deletions
Makefile.dep
sys/net/application_layer/gcoap/gcoap.c
+4
-22
4 additions, 22 deletions
sys/net/application_layer/gcoap/gcoap.c
with
5 additions
and
22 deletions
Makefile.dep
+
1
−
0
View file @
f2b1c5c8
...
@@ -733,6 +733,7 @@ endif
...
@@ -733,6 +733,7 @@ endif
ifneq
(,$(filter gcoap,$(USEMODULE)))
ifneq
(,$(filter gcoap,$(USEMODULE)))
USEMODULE
+=
nanocoap
USEMODULE
+=
nanocoap
USEMODULE
+=
gnrc_sock_udp
USEMODULE
+=
gnrc_sock_udp
USEMODULE
+=
sock_util
endif
endif
ifneq
(,$(filter luid,$(USEMODULE)))
ifneq
(,$(filter luid,$(USEMODULE)))
...
...
This diff is collapsed.
Click to expand it.
sys/net/application_layer/gcoap/gcoap.c
+
4
−
22
View file @
f2b1c5c8
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include
"assert.h"
#include
"assert.h"
#include
"net/gcoap.h"
#include
"net/gcoap.h"
#include
"net/sock/util.h"
#include
"mutex.h"
#include
"mutex.h"
#include
"random.h"
#include
"random.h"
#include
"thread.h"
#include
"thread.h"
...
@@ -45,7 +46,6 @@ static size_t _handle_req(coap_pkt_t *pdu, uint8_t *buf, size_t len,
...
@@ -45,7 +46,6 @@ static size_t _handle_req(coap_pkt_t *pdu, uint8_t *buf, size_t len,
sock_udp_ep_t
*
remote
);
sock_udp_ep_t
*
remote
);
static
ssize_t
_finish_pdu
(
coap_pkt_t
*
pdu
,
uint8_t
*
buf
,
size_t
len
);
static
ssize_t
_finish_pdu
(
coap_pkt_t
*
pdu
,
uint8_t
*
buf
,
size_t
len
);
static
void
_expire_request
(
gcoap_request_memo_t
*
memo
);
static
void
_expire_request
(
gcoap_request_memo_t
*
memo
);
static
bool
_endpoints_equal
(
const
sock_udp_ep_t
*
ep1
,
const
sock_udp_ep_t
*
ep2
);
static
void
_find_req_memo
(
gcoap_request_memo_t
**
memo_ptr
,
coap_pkt_t
*
pdu
,
static
void
_find_req_memo
(
gcoap_request_memo_t
**
memo_ptr
,
coap_pkt_t
*
pdu
,
const
sock_udp_ep_t
*
remote
);
const
sock_udp_ep_t
*
remote
);
static
int
_find_resource
(
coap_pkt_t
*
pdu
,
const
coap_resource_t
**
resource_ptr
,
static
int
_find_resource
(
coap_pkt_t
*
pdu
,
const
coap_resource_t
**
resource_ptr
,
...
@@ -298,7 +298,7 @@ static size_t _handle_req(coap_pkt_t *pdu, uint8_t *buf, size_t len,
...
@@ -298,7 +298,7 @@ static size_t _handle_req(coap_pkt_t *pdu, uint8_t *buf, size_t len,
}
}
/* otherwise OK to re-register resource with the same token */
/* otherwise OK to re-register resource with the same token */
}
}
else
if
(
_endpoints
_equal
(
remote
,
resource_memo
->
observer
))
{
else
if
(
sock_udp_ep
_equal
(
remote
,
resource_memo
->
observer
))
{
/* accept new token for resource */
/* accept new token for resource */
memo
=
resource_memo
;
memo
=
resource_memo
;
}
}
...
@@ -477,7 +477,7 @@ static void _find_req_memo(gcoap_request_memo_t **memo_ptr, coap_pkt_t *src_pdu,
...
@@ -477,7 +477,7 @@ static void _find_req_memo(gcoap_request_memo_t **memo_ptr, coap_pkt_t *src_pdu,
if
(
coap_get_token_len
(
memo_pdu
)
==
cmplen
)
{
if
(
coap_get_token_len
(
memo_pdu
)
==
cmplen
)
{
memo_pdu
->
token
=
&
memo_pdu
->
hdr
->
data
[
0
];
memo_pdu
->
token
=
&
memo_pdu
->
hdr
->
data
[
0
];
if
((
memcmp
(
src_pdu
->
token
,
memo_pdu
->
token
,
cmplen
)
==
0
)
if
((
memcmp
(
src_pdu
->
token
,
memo_pdu
->
token
,
cmplen
)
==
0
)
&&
_endpoints
_equal
(
&
memo
->
remote_ep
,
remote
))
{
&&
sock_udp_ep
_equal
(
&
memo
->
remote_ep
,
remote
))
{
*
memo_ptr
=
memo
;
*
memo_ptr
=
memo
;
break
;
break
;
}
}
...
@@ -591,24 +591,6 @@ static ssize_t _write_options(coap_pkt_t *pdu, uint8_t *buf, size_t len)
...
@@ -591,24 +591,6 @@ static ssize_t _write_options(coap_pkt_t *pdu, uint8_t *buf, size_t len)
return
bufpos
-
buf
;
return
bufpos
-
buf
;
}
}
static
bool
_endpoints_equal
(
const
sock_udp_ep_t
*
ep1
,
const
sock_udp_ep_t
*
ep2
)
{
if
(
ep1
->
family
!=
ep2
->
family
)
{
return
false
;
}
if
(
ep1
->
port
!=
ep2
->
port
)
{
return
false
;
}
switch
(
ep1
->
family
)
{
case
AF_INET6
:
return
memcmp
(
&
ep1
->
addr
.
ipv6
[
0
],
&
ep2
->
addr
.
ipv6
[
0
],
16
)
==
0
;
case
AF_INET
:
return
ep1
->
addr
.
ipv4_u32
==
ep2
->
addr
.
ipv4_u32
;
}
return
false
;
}
/*
/*
* Find registered observer for a remote address and port.
* Find registered observer for a remote address and port.
*
*
...
@@ -627,7 +609,7 @@ static int _find_observer(sock_udp_ep_t **observer, sock_udp_ep_t *remote)
...
@@ -627,7 +609,7 @@ static int _find_observer(sock_udp_ep_t **observer, sock_udp_ep_t *remote)
if
(
_coap_state
.
observers
[
i
].
family
==
AF_UNSPEC
)
{
if
(
_coap_state
.
observers
[
i
].
family
==
AF_UNSPEC
)
{
empty_slot
=
i
;
empty_slot
=
i
;
}
}
else
if
(
_endpoints
_equal
(
&
_coap_state
.
observers
[
i
],
remote
))
{
else
if
(
sock_udp_ep
_equal
(
&
_coap_state
.
observers
[
i
],
remote
))
{
*
observer
=
&
_coap_state
.
observers
[
i
];
*
observer
=
&
_coap_state
.
observers
[
i
];
break
;
break
;
}
}
...
...
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