Skip to content

Commit a08a081

Browse files
committed
sys/net/sockutil: Do not use undefined structs
sock_tcp_ep_t may not be defined if sock_tcp is not used.
1 parent bb0c38a commit a08a081

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

sys/include/net/sock/util.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131

3232
#if MODULE_GNRC_SOCK_UDP || MODULE_LWIP_SOCK_UDP || DOXYGEN
3333
# include "net/sock/udp.h"
34+
# define SOCK_HAS_UDP 1 /**< UDP support is enabled */
3435
#endif
3536
#if MODULE_GNRC_SOCK_TCP || MODULE_LWIP_SOCK_TCP || DOXYGEN
3637
# include "net/sock/tcp.h"
38+
# define SOCK_HAS_TCP 1 /**< TCP support is enabled */
3739
#endif
3840
#ifdef MODULE_SOCK_DTLS
3941
# include "net/credman.h"
@@ -94,6 +96,7 @@ const char *sock_urlpath(const char *url);
9496
int sock_tl_ep_fmt(const struct _sock_tl_ep *endpoint,
9597
char *addr_str, uint16_t *port);
9698

99+
#if IS_ACTIVE(SOCK_HAS_TCP) || DOXYGEN
97100
/**
98101
* @brief Format TCP endpoint to string and port
99102
*
@@ -109,7 +112,9 @@ static inline int sock_tcp_ep_fmt(const sock_tcp_ep_t *endpoint,
109112
{
110113
return sock_tl_ep_fmt(endpoint, addr_str, port);
111114
}
115+
#endif
112116

117+
#if IS_ACTIVE(SOCK_HAS_UDP) || DOXYGEN
113118
/**
114119
* @brief Format UDP endpoint to string and port
115120
*
@@ -125,6 +130,7 @@ static inline int sock_udp_ep_fmt(const sock_udp_ep_t *endpoint,
125130
{
126131
return sock_tl_ep_fmt(endpoint, addr_str, port);
127132
}
133+
#endif
128134

129135
/**
130136
* @brief Convert string to common IP-based transport layer endpoint
@@ -156,6 +162,7 @@ int sock_tl_str2ep(struct _sock_tl_ep *ep_out, const char *str);
156162
*/
157163
int sock_tl_name2ep(struct _sock_tl_ep *ep_out, const char *str);
158164

165+
#if IS_ACTIVE(SOCK_HAS_TCP) || DOXYGEN
159166
/**
160167
* @brief Convert string to TCP endpoint
161168
*
@@ -191,7 +198,9 @@ static inline int sock_tcp_name2ep(sock_tcp_ep_t *ep_out, const char *str)
191198
{
192199
return sock_tl_name2ep(ep_out, str);
193200
}
201+
#endif
194202

203+
#if IS_ACTIVE(SOCK_HAS_UDP) || DOXYGEN
195204
/**
196205
* @brief Convert string to UDP endpoint
197206
*
@@ -227,6 +236,7 @@ static inline int sock_udp_name2ep(sock_udp_ep_t *ep_out, const char *str)
227236
{
228237
return sock_tl_name2ep(ep_out, str);
229238
}
239+
#endif
230240

231241
/**
232242
* @brief Compare the two given common IP-based transport layer endpoints
@@ -244,6 +254,7 @@ static inline int sock_udp_name2ep(sock_udp_ep_t *ep_out, const char *str)
244254
bool sock_tl_ep_equal(const struct _sock_tl_ep *a,
245255
const struct _sock_tl_ep *b);
246256

257+
#if IS_ACTIVE(SOCK_HAS_TCP) || DOXYGEN
247258
/**
248259
* @brief Compare the two given TCP endpoints
249260
*
@@ -262,7 +273,9 @@ static inline bool sock_tcp_ep_equal(const sock_tcp_ep_t *a,
262273
{
263274
return sock_tl_ep_equal(a, b);
264275
}
276+
#endif
265277

278+
#if IS_ACTIVE(SOCK_HAS_UDP) || DOXYGEN
266279
/**
267280
* @brief Compare the two given UDP endpoints
268281
*
@@ -282,6 +295,7 @@ static inline bool sock_udp_ep_equal(const sock_udp_ep_t *a,
282295
return sock_tl_ep_equal(a, b);
283296
}
284297
#endif
298+
#endif
285299

286300
#if defined(MODULE_SOCK_DTLS) || DOXYGEN
287301
/**

0 commit comments

Comments
 (0)