net/sock/util: Move configuration macros to 'CONFIG_' namespace
Macros that changed: SOCK_SCHEME_MAXLEN -> CONFIG_SOCK_SCHEME_MAXLEN SOCK_HOSTPORT_MAXLEN -> CONFIG_SOCK_HOSTPORT_MAXLEN SOCK_URLPATH_MAXLEN -> CONFIG_SOCK_URLPATH_MAXLEN
This commit is contained in:
parent
26a1348a9a
commit
c74fa5367c
@ -14,7 +14,7 @@ SUIT_NOTIFY_VERSION ?= latest
|
||||
SUIT_NOTIFY_MANIFEST ?= $(APPLICATION)-riot.suitv4_signed.$(SUIT_NOTIFY_VERSION).bin
|
||||
|
||||
# Long manifest names require more buffer space when parsing
|
||||
export CFLAGS += -DSOCK_URLPATH_MAXLEN=128
|
||||
export CFLAGS += -DCONFIG_SOCK_URLPATH_MAXLEN=128
|
||||
|
||||
SUIT_VENDOR ?= "riot-os.org"
|
||||
SUIT_SEQNR ?= $(APP_VER)
|
||||
|
||||
@ -53,9 +53,9 @@ int sock_udp_ep_fmt(const sock_udp_ep_t *endpoint, char *addr_str, uint16_t *por
|
||||
* "host.name:1234" and "/url/path".
|
||||
*
|
||||
* @note Caller has to make sure hostport and urlpath can hold the results!
|
||||
* Make sure to provide space for @ref SOCK_HOSTPORT_MAXLEN respectively
|
||||
* @ref SOCK_URLPATH_MAXLEN bytes, if pointers are not NULL.
|
||||
* Scheme part of the URL is limited to @ref SOCK_SCHEME_MAXLEN length.
|
||||
* Make sure to provide space for @ref CONFIG_SOCK_HOSTPORT_MAXLEN respectively
|
||||
* @ref CONFIG_SOCK_URLPATH_MAXLEN bytes, if pointers are not NULL.
|
||||
* Scheme part of the URL is limited to @ref CONFIG_SOCK_SCHEME_MAXLEN length.
|
||||
*
|
||||
* @pre `url != NULL`
|
||||
*
|
||||
@ -109,22 +109,22 @@ bool sock_udp_ep_equal(const sock_udp_ep_t *a, const sock_udp_ep_t *b);
|
||||
*
|
||||
* Ensures a hard limit on the string iterator
|
||||
* */
|
||||
#ifndef SOCK_SCHEME_MAXLEN
|
||||
#define SOCK_SCHEME_MAXLEN (16U)
|
||||
#ifndef CONFIG_SOCK_SCHEME_MAXLEN
|
||||
#define CONFIG_SOCK_SCHEME_MAXLEN (16U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief maximum length of host:port part for sock_urlsplit()
|
||||
*/
|
||||
#ifndef SOCK_HOSTPORT_MAXLEN
|
||||
#define SOCK_HOSTPORT_MAXLEN (64U)
|
||||
#ifndef CONFIG_SOCK_HOSTPORT_MAXLEN
|
||||
#define CONFIG_SOCK_HOSTPORT_MAXLEN (64U)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief maximum length path for sock_urlsplit()
|
||||
*/
|
||||
#ifndef SOCK_URLPATH_MAXLEN
|
||||
#define SOCK_URLPATH_MAXLEN (64U)
|
||||
#ifndef CONFIG_SOCK_URLPATH_MAXLEN
|
||||
#define CONFIG_SOCK_URLPATH_MAXLEN (64U)
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
|
||||
@ -83,10 +83,10 @@ int sock_udp_ep_fmt(const sock_udp_ep_t *endpoint, char *addr_str, uint16_t *por
|
||||
|
||||
static char* _find_hoststart(const char *url)
|
||||
{
|
||||
/* Increment SOCK_SCHEME_MAXLEN due to comparison with the colon after the
|
||||
/* Increment CONFIG_SOCK_SCHEME_MAXLEN due to comparison with the colon after the
|
||||
* scheme part
|
||||
*/
|
||||
size_t remaining = SOCK_SCHEME_MAXLEN + 1;
|
||||
size_t remaining = CONFIG_SOCK_SCHEME_MAXLEN + 1;
|
||||
char *urlpos = (char*)url;
|
||||
while(*urlpos && remaining) {
|
||||
remaining--;
|
||||
@ -103,7 +103,7 @@ static char* _find_hoststart(const char *url)
|
||||
|
||||
static char* _find_pathstart(const char *url)
|
||||
{
|
||||
size_t remaining = SOCK_HOSTPORT_MAXLEN;
|
||||
size_t remaining = CONFIG_SOCK_HOSTPORT_MAXLEN;
|
||||
char *urlpos = (char*)url;
|
||||
while(*urlpos && remaining) {
|
||||
remaining--;
|
||||
@ -127,9 +127,9 @@ int sock_urlsplit(const char *url, char *hostport, char *urlpath)
|
||||
|
||||
if (hostport) {
|
||||
size_t hostlen = pathstart - hoststart;
|
||||
/* hostlen must be smaller SOCK_HOSTPORT_MAXLEN to have space for the null
|
||||
/* hostlen must be smaller CONFIG_SOCK_HOSTPORT_MAXLEN to have space for the null
|
||||
* terminator */
|
||||
if (hostlen > SOCK_HOSTPORT_MAXLEN - 1) {
|
||||
if (hostlen > CONFIG_SOCK_HOSTPORT_MAXLEN - 1) {
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
memcpy(hostport, hoststart, hostlen);
|
||||
@ -138,7 +138,7 @@ int sock_urlsplit(const char *url, char *hostport, char *urlpath)
|
||||
|
||||
if (urlpath) {
|
||||
size_t pathlen = strlen(pathstart);
|
||||
if (pathlen > SOCK_URLPATH_MAXLEN - 1) {
|
||||
if (pathlen > CONFIG_SOCK_URLPATH_MAXLEN - 1) {
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
memcpy(urlpath, pathstart, pathlen);
|
||||
@ -153,7 +153,7 @@ int sock_udp_str2ep(sock_udp_ep_t *ep_out, const char *str)
|
||||
char *hoststart = (char*)str;
|
||||
char *hostend;
|
||||
|
||||
char hostbuf[SOCK_HOSTPORT_MAXLEN];
|
||||
char hostbuf[CONFIG_SOCK_HOSTPORT_MAXLEN];
|
||||
|
||||
memset(ep_out, 0, sizeof(sock_udp_ep_t));
|
||||
|
||||
|
||||
@ -268,8 +268,8 @@ int suit_coap_get_blockwise_url(const char *url,
|
||||
coap_blksize_t blksize,
|
||||
coap_blockwise_cb_t callback, void *arg)
|
||||
{
|
||||
char hostport[SOCK_HOSTPORT_MAXLEN];
|
||||
char urlpath[SOCK_URLPATH_MAXLEN];
|
||||
char hostport[CONFIG_SOCK_HOSTPORT_MAXLEN];
|
||||
char urlpath[CONFIG_SOCK_URLPATH_MAXLEN];
|
||||
sock_udp_ep_t remote;
|
||||
|
||||
if (strncmp(url, "coap://", 7)) {
|
||||
|
||||
@ -62,8 +62,8 @@
|
||||
#define TEST_STR2EP_INVALID "[2001:db8:a:b:c:d:e:f:1]"
|
||||
#define TEST_STR2EP_INVALID2 "[2001:db8:a:b:c:d:e:f]:66000"
|
||||
|
||||
static char addr[SOCK_URLPATH_MAXLEN];
|
||||
static char urlpath[SOCK_URLPATH_MAXLEN];
|
||||
static char addr[CONFIG_SOCK_URLPATH_MAXLEN];
|
||||
static char urlpath[CONFIG_SOCK_URLPATH_MAXLEN];
|
||||
|
||||
|
||||
static void setup(void)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user