Lines Matching refs:rd
70 rd_t *rd; in rd_new() local
71 rd = (rd_t *)coap_malloc(sizeof(rd_t)); in rd_new()
72 if (rd) in rd_new()
73 memset(rd, 0, sizeof(rd_t)); in rd_new()
75 return rd; in rd_new()
79 rd_delete(rd_t *rd) { in rd_delete() argument
80 if (rd) { in rd_delete()
81 coap_free(rd->data.s); in rd_delete()
82 coap_free(rd); in rd_delete()
103 rd_t *rd = NULL; in hnd_get_resource() local
106 HASH_FIND(hh, resources, resource->key, sizeof(coap_key_t), rd); in hnd_get_resource()
116 if (rd && rd->etag_len) in hnd_get_resource()
117 coap_add_option(response, COAP_OPTION_ETAG, rd->etag_len, rd->etag); in hnd_get_resource()
119 if (rd && rd->data.s) in hnd_get_resource()
120 coap_add_data(response, rd->data.length, rd->data.s); in hnd_get_resource()
140 rd_t *rd = NULL; in hnd_put_resource()
145 HASH_FIND(hh, resources, resource->key, sizeof(coap_key_t), rd); in hnd_put_resource()
146 if (rd) { in hnd_put_resource()
149 if (!etag || (COAP_OPT_LENGTH(etag) != rd->etag_len) in hnd_put_resource()
150 || memcmp(COAP_OPT_VALUE(etag), rd->etag, rd->etag_len) != 0) { in hnd_put_resource()
161 coap_free(rd->data.s); in hnd_put_resource()
162 rd->data.s = tmp.s; in hnd_put_resource()
163 rd->data.length = tmp.length; in hnd_put_resource()
164 memcpy(rd->data.s, data, rd->data.length); in hnd_put_resource()
169 rd->etag_len = min(COAP_OPT_LENGTH(etag), sizeof(rd->etag)); in hnd_put_resource()
170 memcpy(rd->etag, COAP_OPT_VALUE(etag), rd->etag_len); in hnd_put_resource()
209 rd_t *rd = NULL; in hnd_delete_resource() local
211 HASH_FIND(hh, resources, resource->key, sizeof(coap_key_t), rd); in hnd_delete_resource()
212 if (rd) { in hnd_delete_resource()
213 HASH_DELETE(hh, resources, rd); in hnd_delete_resource()
214 rd_delete(rd); in hnd_delete_resource()
356 rd_t *rd; in make_rd() local
361 rd = rd_new(); in make_rd()
363 if (!rd) { in make_rd()
368 if (coap_get_data(pdu, &rd->data.length, &data)) { in make_rd()
369 rd->data.s = (unsigned char *)coap_malloc(rd->data.length); in make_rd()
370 if (!rd->data.s) { in make_rd()
372 rd_delete(rd); in make_rd()
375 memcpy(rd->data.s, data, rd->data.length); in make_rd()
380 rd->etag_len = min(COAP_OPT_LENGTH(etag), sizeof(rd->etag)); in make_rd()
381 memcpy(rd->etag, COAP_OPT_VALUE(etag), rd->etag_len); in make_rd()
384 return rd; in make_rd()
505 rd_t *rd; in hnd_post_rd() local
506 rd = make_rd(peer, request); in hnd_post_rd()
507 if (rd) { in hnd_post_rd()
508 coap_hash_path(loc, loc_size, rd->key); in hnd_post_rd()
509 HASH_ADD(hh, resources, key, sizeof(coap_key_t), rd); in hnd_post_rd()