lc.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2018 HAW Hamburg
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
48 #include "net/sock/udp.h"
49 #include "net/nanocoap.h"
50 #include "clif.h"
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
59 enum {
60  CORD_LC_OK = 0,
62  CORD_LC_ERR = -2,
65 };
66 
70 enum {
73 };
74 
78 typedef struct {
80  char *res_lookif;
81  char *ep_lookif;
82  unsigned res_last_page;
83  unsigned ep_last_page;
84 } cord_lc_rd_t;
85 
92  size_t max_attrs;
93 };
94 
95 typedef struct cord_lc_result cord_lc_res_t;
96 typedef struct cord_lc_result cord_lc_ep_t;
101 typedef struct cord_lc_filter {
103  size_t len;
106 
122 int cord_lc_rd_init(cord_lc_rd_t *rd, void *buf, size_t maxlen,
123  const sock_udp_ep_t *remote);
124 
150 ssize_t cord_lc_raw(const cord_lc_rd_t *rd, unsigned content_format,
151  unsigned lookup_type, cord_lc_filter_t *filters,
152  void *result, size_t maxlen);
153 
178  cord_lc_filter_t *filters, void *buf, size_t maxlen,
179  unsigned type);
180 
202 static inline ssize_t cord_lc_res(cord_lc_rd_t *rd, cord_lc_res_t *resource,
203  cord_lc_filter_t *filters, void *buf,
204  size_t maxlen)
205 {
206  return _lookup_result(rd, resource, filters, buf, maxlen, CORD_LC_RES);
207 }
208 
230 static inline ssize_t cord_lc_ep(cord_lc_rd_t *rd, cord_lc_ep_t *endpoint,
231  cord_lc_filter_t *filters, void *buf,
232  size_t maxlen)
233 {
234  return _lookup_result(rd, endpoint, filters, buf, maxlen, CORD_LC_EP);
235 }
236 
237 #ifdef __cplusplus
238 }
239 #endif
240 
CoRE Link Format encoding and decoding library public definitions.
ssize_t _lookup_result(cord_lc_rd_t *rd, cord_lc_res_t *result, cord_lc_filter_t *filters, void *buf, size_t maxlen, unsigned type)
Get one resource from RD server.
static ssize_t cord_lc_res(cord_lc_rd_t *rd, cord_lc_res_t *resource, cord_lc_filter_t *filters, void *buf, size_t maxlen)
Get one resource from RD server.
Definition: lc.h:202
int cord_lc_rd_init(cord_lc_rd_t *rd, void *buf, size_t maxlen, const sock_udp_ep_t *remote)
Discover the lookup interfaces of a RD server.
ssize_t cord_lc_raw(const cord_lc_rd_t *rd, unsigned content_format, unsigned lookup_type, cord_lc_filter_t *filters, void *result, size_t maxlen)
Raw lookup for registered resources/endpoints at a RD server.
static ssize_t cord_lc_ep(cord_lc_rd_t *rd, cord_lc_ep_t *endpoint, cord_lc_filter_t *filters, void *buf, size_t maxlen)
Get one endpoint from RD server.
Definition: lc.h:230
struct cord_lc_filter cord_lc_filter_t
Filters to use for a lookup.
@ CORD_LC_TIMEOUT
no response from the network
Definition: lc.h:61
@ CORD_LC_NORSC
lookup interface not found
Definition: lc.h:64
@ CORD_LC_OVERFLOW
internal buffers can not handle input
Definition: lc.h:63
@ CORD_LC_OK
everything went as expected
Definition: lc.h:60
@ CORD_LC_ERR
internal error or invalid reply
Definition: lc.h:62
@ CORD_LC_RES
Resource lookup type.
Definition: lc.h:71
@ CORD_LC_EP
Endpoint lookup type.
Definition: lc.h:72
nanocoap API
UDP sock definitions.
Common IP-based transport layer end point.
Definition: sock.h:211
Link format attribute descriptor.
Definition: clif.h:133
Link format descriptor.
Definition: clif.h:143
Filters to use for a lookup.
Definition: lc.h:101
struct cord_lc_filter * next
Next set of filters.
Definition: lc.h:104
size_t len
No.
Definition: lc.h:103
clif_attr_t * array
Array of filter(s)
Definition: lc.h:102
Information about RD server and its lookup interface resources.
Definition: lc.h:78
unsigned res_last_page
Page of last resource lookup.
Definition: lc.h:82
const sock_udp_ep_t * remote
Remote endpoint of RD server.
Definition: lc.h:79
char * res_lookif
Resource lookup interface.
Definition: lc.h:80
unsigned ep_last_page
Page of last endpoint lookup.
Definition: lc.h:83
char * ep_lookif
Endpoint lookup interface.
Definition: lc.h:81
Result of lookup.
Definition: lc.h:89
size_t max_attrs
Max parameters at params.
Definition: lc.h:92
clif_attr_t * attrs
Array of Link Format parameters.
Definition: lc.h:91
clif_t link
Resource link.
Definition: lc.h:90