Ejemplo n.º 1
0
/* DELETE handler for dynamic resources created by POST /test */
void 
hnd_delete_resource(coap_context_t  *ctx, struct coap_resource_t *resource, 
		coap_address_t *peer, coap_pdu_t *request, str *token,
		coap_pdu_t *response) {
  coap_payload_t *payload;

  payload = coap_find_payload(resource->key);

  if (payload)
    coap_delete_payload(payload);

  coap_delete_resource(ctx, resource->key);

  response->hdr->code = COAP_RESPONSE_CODE(202);
}
Ejemplo n.º 2
0
void 
hnd_delete_resource(coap_context_t  *ctx, struct coap_resource_t *resource, 
		    coap_address_t *peer, coap_pdu_t *request, str *token,
		    coap_pdu_t *response, void *userdata) {
  rd_t *rd = NULL;

  HASH_FIND(hh, resources, resource->key, sizeof(coap_key_t), rd);
  if (rd) {
    HASH_DELETE(hh, resources, rd);
    rd_delete(rd);
  }
  /* FIXME: link attributes for resource have been created dynamically
   * using coap_malloc() and must be released. */
  coap_delete_resource(ctx, resource->key);

  response->hdr->code = COAP_RESPONSE_CODE(202);
}