Skip to content

Commit

Permalink
WIP - Remove unused context pointer in endpoint and use NTOHS macro e…
Browse files Browse the repository at this point in the history
…verywhere
  • Loading branch information
franc0is committed Sep 7, 2015
1 parent f8d2b79 commit f66b8d5
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 10 deletions.
2 changes: 0 additions & 2 deletions include/coap/coap_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ typedef struct coap_endpoint_t {

#ifdef WITH_LWIP
struct udp_pcb *pcb;
/**< @FIXME this was added in a hurry, not sure it confirms to the overall model --chrysn */
struct coap_context_t *context;
#endif /* WITH_LWIP */

coap_address_t addr; /**< local interface address */
Expand Down
1 change: 1 addition & 0 deletions platform/contiki/platform_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
#define _PLATFORM_UTILS_H_

#define HTONS(BYTES) uip_htons(BYTES);
#define NTOHS(BYTES) uip_ntohs(BYTES);

#endif /* _PLATFORM_UTILS_H_ */
1 change: 1 addition & 0 deletions platform/lwip/platform_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
#define _PLATFORM_UTILS_H_

#define HTONS(BYTES) htons(BYTES);
#define NTOHS(BYTES) ntohs(BYTES);

#endif /* _PLATFORM_UTILS_H_ */
7 changes: 7 additions & 0 deletions platform/posix/platform_utils.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#ifndef _PLATFORM_UTILS_H_
#define _PLATFORM_UTILS_H_

#undef NTOHS
#define NTOHS(BYTES) ntohs(BYTES)

#undef HTONS
#define HTONS(BYTES) htons(BYTES)


#endif /* _PLATFORM_UTILS_H_ */
3 changes: 0 additions & 3 deletions src/coap_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ coap_new_context(
coap_register_option(c, COAP_OPTION_BLOCK1);

c->endpoint = coap_new_endpoint(listen_addr, COAP_ENDPOINT_NOSEC);
#ifdef WITH_LWIP
c->endpoint->context = c;
#endif
if (c->endpoint == NULL) {
goto onerror;
}
Expand Down
8 changes: 3 additions & 5 deletions src/pdu.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "encode.h"
#include "mem.h"

#include "platform_utils.h"

void
coap_pdu_clear(coap_pdu_t *pdu, size_t size) {
assert(pdu);
Expand Down Expand Up @@ -70,11 +72,7 @@ coap_pdu_t *
coap_new_pdu(void) {
coap_pdu_t *pdu;

#ifndef WITH_CONTIKI
pdu = coap_pdu_init(0, 0, ntohs(COAP_INVALID_TID), COAP_MAX_PDU_SIZE);
#else /* WITH_CONTIKI */
pdu = coap_pdu_init(0, 0, uip_ntohs(COAP_INVALID_TID), COAP_MAX_PDU_SIZE);
#endif /* WITH_CONTIKI */
pdu = coap_pdu_init(0, 0, NTOHS(COAP_INVALID_TID), COAP_MAX_PDU_SIZE);

#ifndef NDEBUG
if (!pdu)
Expand Down

0 comments on commit f66b8d5

Please sign in to comment.