Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sys/include/net/nanocoap.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@
#include <arpa/inet.h>
#endif

#ifdef MODULE_GCOAP
#include "net/sock/udp.h"
Copy link
Contributor

@kaspar030 kaspar030 Mar 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "net/sock/udp.h"
typedef struct sock_udp_ep_t;

#endif

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -189,6 +193,11 @@ typedef struct {
coap_optpos_t options[NANOCOAP_NOPTS_MAX]; /**< option offset array */
#ifdef MODULE_GCOAP
uint32_t observe_value; /**< observe value */
/**
* remote UDP endpoint. As of now, gcoap supports only UDP as transport, so
* we use sock_udp_ep_t here directly. If gcoap is extended to provide other
* transports, this probably needs to be changed to some union type here */
sock_udp_ep_t *udp_remote;
#endif
} coap_pkt_t;

Expand Down
3 changes: 3 additions & 0 deletions sys/net/application_layer/gcoap/gcoap.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ static void _on_sock_evt(sock_udp_t *sock, sock_async_flags_t type, void *arg)
return;
}

/* remember set senders port and address for later use */
pdu.udp_remote = &remote;

/* validate class and type for incoming */
switch (coap_get_code_class(&pdu)) {
/* incoming request */
Expand Down