Files
libcoap/include/coap3/libcoap.h
T
fj-blanco 4fa3dfa0c7 Zephyr: add POSIX API support
Changes:
- Remove duplicate OBSERVE_PERSIST configuration block

Improve example build:

- Make virtual environment activation optional in Makefile
- Remove --fresh flag unsupported in newer west versions
- Copy mbedTLS config header to workspace include directory
- Add TARGET check for mbedTLS before configuring include directories
- Add mbedTLS linking to coap-3 target

Add POSIX API support:

- Enable CONFIG_POSIX_API=y in examples/zephyr
- Replace direct Linux/Windows system calls with Zephyr POSIX API
equivalents
- Add Zephyr's sys_rand_get() to coap_prng_default()
- Define missing network macros (IN_MULTICAST, IN6_IS_ADDR_MULTICAST,
etc.)
- Add FIONBIO and OPTVAL_T/OPTVAL_GT macro definitions for Zephyr
- Add native Zephyr timing functions to replace missing mbedTLS timing
support
- Fix fd_set mapping using zephyr/net/socket_select.h
- Exclude strnlen redefinition conflicts for Zephyr
- Add proper IPv6 packet info and address mapped definitions

(Patch) Add DNS resolution and net setup to example client:
- Enable CONFIG_DNS_RESOLVER for hostname resolution
- Add Linux networking setup instructions for native_sim board
- Configure static IP gateway and DNS server (8.8.8.8)
- Add DHCP vs static IP configuration documentation
Co-authored-by: mrdeep1
2025-06-26 15:23:23 +01:00

95 lines
2.4 KiB
C

/*
* libcoap.h -- platform specific header file for CoAP stack
*
* Copyright (C) 2015 Carsten Schoenert <c.schoenert@t-online.de>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
*/
/**
* @file libcoap.h
* @brief Platform specific header file for CoAP stack
*/
#ifndef COAP_LIBCOAP_H_
#define COAP_LIBCOAP_H_
/* The non posix embedded platforms like Contiki-NG, TinyOS, RIOT, ... don't have
* a POSIX compatible header structure so we have to slightly do some platform
* related things. Currently there is only Contiki-NG available so we check for a
* CONTIKI environment and do *not* include the POSIX related network stuff. If
* there are other platforms in future there need to be analogous environments.
*
* The CONTIKI variable is within the Contiki-NG build environment! */
#if defined(_WIN32)
#include <ws2tcpip.h>
#if !defined(__MINGW32__)
#pragma comment(lib,"Ws2_32.lib")
#ifndef _SSIZE_T_DECLARED
typedef SSIZE_T ssize_t;
#define _SSIZE_T_DECLARED
#endif
#ifndef _IN_PORT_T_DECLARED
typedef USHORT in_port_t;
#define _IN_PORT_T_DECLARED
#endif
#endif /* !defined(__MINGW32__) */
#elif defined(__ZEPHYR__)
#include <zephyr/net/socket.h>
#elif !defined (CONTIKI) && !defined (WITH_LWIP) && !defined (RIOT_VERSION)
#include <netinet/in.h>
#include <sys/socket.h>
#endif /* ! CONTIKI && ! WITH_LWIP && ! RIOT_VERSION */
#ifndef COAP_STATIC_INLINE
# if defined(__cplusplus)
# define COAP_STATIC_INLINE inline
# else
# if defined(_MSC_VER)
# define COAP_STATIC_INLINE static __inline
# else
# define COAP_STATIC_INLINE static inline
# endif
# endif
#endif
#ifndef COAP_DEPRECATED
# if defined(_MSC_VER)
# define COAP_DEPRECATED __declspec(deprecated)
# else
# define COAP_DEPRECATED __attribute__ ((deprecated))
# endif
#endif
#ifndef COAP_UNUSED
# ifdef __GNUC__
# define COAP_UNUSED __attribute__((unused))
# else /* __GNUC__ */
# define COAP_UNUSED
# endif /* __GNUC__ */
#endif /* COAP_UNUSED */
#ifndef COAP_THREAD_LOCAL_VAR
# ifdef __GNUC__
# define COAP_THREAD_LOCAL_VAR __thread
# elif defined(_MSC_VER)
# define COAP_THREAD_LOCAL_VAR __declspec(thread)
# else /* ! __GNUC__ && ! _MSC_VER */
# define COAP_THREAD_LOCAL_VAR
# endif
#endif
#ifndef COAP_API
#define COAP_API
#endif
void coap_startup(void);
void coap_cleanup(void);
#endif /* COAP_LIBCOAP_H_ */