coap_server.h File Reference

CoAP server. More...

#include "core/net.h"
#include "coap/coap_common.h"
#include "coap/coap_message.h"
#include "coap/coap_option.h"
#include "core/crypto.h"
#include "tls.h"

Go to the source code of this file.

Data Structures

struct  CoapServerSettings
 CoAP server settings. More...
struct  _CoapDtlsSession
 DTLS session. More...
struct  _CoapServerContext
 CoAP server context. More...


#define CoapServerContext   struct _CoapServerContext
#define CoapDtlsSession   struct _CoapDtlsSession


typedef error_t(* CoapServerUdpInitCallback) (CoapServerContext *context, Socket *socket)
 UDP initialization callback function. More...
typedef error_t(* CoapServerDtlsInitCallback) (CoapServerContext *context, TlsContext *dtlsContext)
 DTLS initialization callback. More...
typedef error_t(* CoapServerRequestCallback) (CoapServerContext *context, CoapCode method, const char_t *uri)
 CoAP request callback function. More...


void coapServerGetDefaultSettings (CoapServerSettings *settings)
 Initialize settings with default values. More...
error_t coapServerInit (CoapServerContext *context, const CoapServerSettings *settings)
 CoAP server initialization. More...
error_t coapServerSetCookieSecret (CoapServerContext *context, const uint8_t *cookieSecret, size_t cookieSecretLen)
 Set cookie secret. More...
error_t coapServerStart (CoapServerContext *context)
 Start CoAP server. More...
error_t coapServerStop (CoapServerContext *context)
 Stop CoAP server. More...
void coapServerTask (CoapServerContext *context)
 CoAP server task. More...
void coapServerDeinit (CoapServerContext *context)
 Release CoAP server context. More...

Detailed Description

CoAP server.


SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Oryx Embedded SARL (

Definition in file coap_server.h.

Macro Definition Documentation



Definition at line 84 of file coap_server.h.



Definition at line 49 of file coap_server.h.



Definition at line 91 of file coap_server.h.



Definition at line 63 of file coap_server.h.



Definition at line 98 of file coap_server.h.



Definition at line 105 of file coap_server.h.



Definition at line 110 of file coap_server.h.



Definition at line 77 of file coap_server.h.



Definition at line 56 of file coap_server.h.



Definition at line 42 of file coap_server.h.



Definition at line 70 of file coap_server.h.

◆ CoapDtlsSession

#define CoapDtlsSession   struct _CoapDtlsSession

Definition at line 125 of file coap_server.h.

◆ CoapServerContext

#define CoapServerContext   struct _CoapServerContext

Definition at line 121 of file coap_server.h.

Typedef Documentation

◆ CoapServerDtlsInitCallback

typedef error_t(* CoapServerDtlsInitCallback) (CoapServerContext *context, TlsContext *dtlsContext)

DTLS initialization callback.

Definition at line 148 of file coap_server.h.

◆ CoapServerRequestCallback

typedef error_t(* CoapServerRequestCallback) (CoapServerContext *context, CoapCode method, const char_t *uri)

CoAP request callback function.

Definition at line 158 of file coap_server.h.

◆ CoapServerUdpInitCallback

typedef error_t(* CoapServerUdpInitCallback) (CoapServerContext *context, Socket *socket)

UDP initialization callback function.

Definition at line 137 of file coap_server.h.

Function Documentation

◆ coapServerDeinit()

void coapServerDeinit ( CoapServerContext context)

Release CoAP server context.

[in]contextPointer to the CoAP server context

Definition at line 397 of file coap_server.c.

◆ coapServerGetDefaultSettings()

void coapServerGetDefaultSettings ( CoapServerSettings settings)

Initialize settings with default values.

[out]settingsStructure that contains CoAP server settings

Definition at line 51 of file coap_server.c.

◆ coapServerInit()

error_t coapServerInit ( CoapServerContext context,
const CoapServerSettings settings 

CoAP server initialization.

[in]contextPointer to the CoAP server context
[in]settingsCoAP server specific settings
Error code

Definition at line 84 of file coap_server.c.

◆ coapServerSetCookieSecret()

error_t coapServerSetCookieSecret ( CoapServerContext context,
const uint8_t *  cookieSecret,
size_t  cookieSecretLen 

Set cookie secret.

This function specifies the cookie secret used while generating and verifying a cookie during the DTLS handshake

[in]contextPointer to the CoAP server context
[in]cookieSecretPointer to the secret key
[in]cookieSecretLenLength of the secret key, in bytes
Error code

Definition at line 140 of file coap_server.c.

◆ coapServerStart()

error_t coapServerStart ( CoapServerContext context)

Start CoAP server.

[in]contextPointer to the CoAP server context
Error code

Definition at line 170 of file coap_server.c.

◆ coapServerStop()

error_t coapServerStop ( CoapServerContext context)

Stop CoAP server.

[in]contextPointer to the CoAP server context
Error code

Definition at line 268 of file coap_server.c.

◆ coapServerTask()

void coapServerTask ( CoapServerContext context)

CoAP server task.

[in]contextPointer to the CoAP server context

Definition at line 319 of file coap_server.c.