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:
Leandro Lanzieri 2019-12-13 12:04:54 +01:00
parent 26a1348a9a
commit c74fa5367c
5 changed files with 21 additions and 21 deletions

View File

@ -14,7 +14,7 @@ SUIT_NOTIFY_VERSION ?= latest
SUIT_NOTIFY_MANIFEST ?= $(APPLICATION)-riot.suitv4_signed.$(SUIT_NOTIFY_VERSION).bin SUIT_NOTIFY_MANIFEST ?= $(APPLICATION)-riot.suitv4_signed.$(SUIT_NOTIFY_VERSION).bin
# Long manifest names require more buffer space when parsing # 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_VENDOR ?= "riot-os.org"
SUIT_SEQNR ?= $(APP_VER) SUIT_SEQNR ?= $(APP_VER)

View File

@ -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". * "host.name:1234" and "/url/path".
* *
* @note Caller has to make sure hostport and urlpath can hold the results! * @note Caller has to make sure hostport and urlpath can hold the results!
* Make sure to provide space for @ref SOCK_HOSTPORT_MAXLEN respectively * Make sure to provide space for @ref CONFIG_SOCK_HOSTPORT_MAXLEN respectively
* @ref SOCK_URLPATH_MAXLEN bytes, if pointers are not NULL. * @ref CONFIG_SOCK_URLPATH_MAXLEN bytes, if pointers are not NULL.
* Scheme part of the URL is limited to @ref SOCK_SCHEME_MAXLEN length. * Scheme part of the URL is limited to @ref CONFIG_SOCK_SCHEME_MAXLEN length.
* *
* @pre `url != NULL` * @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 * Ensures a hard limit on the string iterator
* */ * */
#ifndef SOCK_SCHEME_MAXLEN #ifndef CONFIG_SOCK_SCHEME_MAXLEN
#define SOCK_SCHEME_MAXLEN (16U) #define CONFIG_SOCK_SCHEME_MAXLEN (16U)
#endif #endif
/** /**
* @brief maximum length of host:port part for sock_urlsplit() * @brief maximum length of host:port part for sock_urlsplit()
*/ */
#ifndef SOCK_HOSTPORT_MAXLEN #ifndef CONFIG_SOCK_HOSTPORT_MAXLEN
#define SOCK_HOSTPORT_MAXLEN (64U) #define CONFIG_SOCK_HOSTPORT_MAXLEN (64U)
#endif #endif
/** /**
* @brief maximum length path for sock_urlsplit() * @brief maximum length path for sock_urlsplit()
*/ */
#ifndef SOCK_URLPATH_MAXLEN #ifndef CONFIG_SOCK_URLPATH_MAXLEN
#define SOCK_URLPATH_MAXLEN (64U) #define CONFIG_SOCK_URLPATH_MAXLEN (64U)
#endif #endif
/** @} */ /** @} */

View File

@ -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) 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 * scheme part
*/ */
size_t remaining = SOCK_SCHEME_MAXLEN + 1; size_t remaining = CONFIG_SOCK_SCHEME_MAXLEN + 1;
char *urlpos = (char*)url; char *urlpos = (char*)url;
while(*urlpos && remaining) { while(*urlpos && remaining) {
remaining--; remaining--;
@ -103,7 +103,7 @@ static char* _find_hoststart(const char *url)
static char* _find_pathstart(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; char *urlpos = (char*)url;
while(*urlpos && remaining) { while(*urlpos && remaining) {
remaining--; remaining--;
@ -127,9 +127,9 @@ int sock_urlsplit(const char *url, char *hostport, char *urlpath)
if (hostport) { if (hostport) {
size_t hostlen = pathstart - hoststart; 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 */ * terminator */
if (hostlen > SOCK_HOSTPORT_MAXLEN - 1) { if (hostlen > CONFIG_SOCK_HOSTPORT_MAXLEN - 1) {
return -EOVERFLOW; return -EOVERFLOW;
} }
memcpy(hostport, hoststart, hostlen); memcpy(hostport, hoststart, hostlen);
@ -138,7 +138,7 @@ int sock_urlsplit(const char *url, char *hostport, char *urlpath)
if (urlpath) { if (urlpath) {
size_t pathlen = strlen(pathstart); size_t pathlen = strlen(pathstart);
if (pathlen > SOCK_URLPATH_MAXLEN - 1) { if (pathlen > CONFIG_SOCK_URLPATH_MAXLEN - 1) {
return -EOVERFLOW; return -EOVERFLOW;
} }
memcpy(urlpath, pathstart, pathlen); 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 *hoststart = (char*)str;
char *hostend; char *hostend;
char hostbuf[SOCK_HOSTPORT_MAXLEN]; char hostbuf[CONFIG_SOCK_HOSTPORT_MAXLEN];
memset(ep_out, 0, sizeof(sock_udp_ep_t)); memset(ep_out, 0, sizeof(sock_udp_ep_t));

View File

@ -268,8 +268,8 @@ int suit_coap_get_blockwise_url(const char *url,
coap_blksize_t blksize, coap_blksize_t blksize,
coap_blockwise_cb_t callback, void *arg) coap_blockwise_cb_t callback, void *arg)
{ {
char hostport[SOCK_HOSTPORT_MAXLEN]; char hostport[CONFIG_SOCK_HOSTPORT_MAXLEN];
char urlpath[SOCK_URLPATH_MAXLEN]; char urlpath[CONFIG_SOCK_URLPATH_MAXLEN];
sock_udp_ep_t remote; sock_udp_ep_t remote;
if (strncmp(url, "coap://", 7)) { if (strncmp(url, "coap://", 7)) {

View File

@ -62,8 +62,8 @@
#define TEST_STR2EP_INVALID "[2001:db8:a:b:c:d:e:f:1]" #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" #define TEST_STR2EP_INVALID2 "[2001:db8:a:b:c:d:e:f]:66000"
static char addr[SOCK_URLPATH_MAXLEN]; static char addr[CONFIG_SOCK_URLPATH_MAXLEN];
static char urlpath[SOCK_URLPATH_MAXLEN]; static char urlpath[CONFIG_SOCK_URLPATH_MAXLEN];
static void setup(void) static void setup(void)