coap_message.h File Reference

CoAP message formatting and parsing. More...

#include "core/net.h"
#include "coap/coap_common.h"

Go to the source code of this file.

Data Structures

struct  CoapMessage
 CoAP message. More...
 

Macros

#define COAP_MAX_MSG_SIZE   1024
 

Functions

error_t coapClientParseMessage (const CoapMessage *message)
 Parse CoAP message. More...
 
error_t coapParseMessageHeader (const uint8_t *p, size_t length, size_t *consumed)
 Parse CoAP message header. More...
 
error_t coapSetType (CoapMessage *message, CoapMessageType type)
 Set message type. More...
 
error_t coapGetType (const CoapMessage *message, CoapMessageType *type)
 Get message type. More...
 
error_t coapSetCode (CoapMessage *message, CoapCode code)
 Set method or response code. More...
 
error_t coapGetCode (const CoapMessage *message, CoapCode *code)
 Get method or response code. More...
 
error_t coapSetPayload (CoapMessage *message, const void *payload, size_t payloadLen)
 Set CoAP message payload. More...
 
error_t coapGetPayload (const CoapMessage *message, const uint8_t **payload, size_t *payloadLen)
 Get CoAP message payload. More...
 
error_t coapWritePayload (CoapMessage *message, const void *data, size_t length)
 Write payload data. More...
 
error_t coapReadPayload (CoapMessage *message, void *data, size_t size, size_t *length)
 Read payload data. More...
 
bool_t coapCompareToken (const CoapMessageHeader *header1, const CoapMessageHeader *header2)
 Token comparison. More...
 

Detailed Description

CoAP message formatting and parsing.

License

Copyright (C) 2010-2018 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.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
1.9.0

Definition in file coap_message.h.

Macro Definition Documentation

◆ COAP_MAX_MSG_SIZE

#define COAP_MAX_MSG_SIZE   1024

Definition at line 38 of file coap_message.h.

Function Documentation

◆ coapClientParseMessage()

error_t coapClientParseMessage ( const CoapMessage message)

Parse CoAP message.

Parameters
[in]messagePointer to the CoAP message
Returns
Error code

Definition at line 49 of file coap_message.c.

◆ coapCompareToken()

bool_t coapCompareToken ( const CoapMessageHeader header1,
const CoapMessageHeader header2 
)

Token comparison.

Parameters
[in]header1Pointer to the first CoAP message header
[in]header2Pointer to the second CoAP message header
Returns
TRUE if the tokens match, else FALSE

Definition at line 545 of file coap_message.c.

◆ coapGetCode()

error_t coapGetCode ( const CoapMessage message,
CoapCode code 
)

Get method or response code.

Parameters
[in]messagePointer to the CoAP message
[out]codeMethod or response code
Returns
Error code

Definition at line 224 of file coap_message.c.

◆ coapGetPayload()

error_t coapGetPayload ( const CoapMessage message,
const uint8_t **  payload,
size_t *  payloadLen 
)

Get CoAP message payload.

Parameters
[in]messagePointer to the CoAP message
[out]payloadPointer to the first byte of the payload
[out]payloadLenLength of the payload, in bytes
Returns
Error code

Definition at line 322 of file coap_message.c.

◆ coapGetType()

error_t coapGetType ( const CoapMessage message,
CoapMessageType type 
)

Get message type.

Parameters
[in]messagePointer to the CoAP message
[out]typeMessage type
Returns
Error code

Definition at line 174 of file coap_message.c.

◆ coapParseMessageHeader()

error_t coapParseMessageHeader ( const uint8_t *  p,
size_t  length,
size_t *  consumed 
)

Parse CoAP message header.

Parameters
[in]pInput stream where to read the CoAP message header
[in]lengthNumber of bytes available in the input stream
[out]consumedTotal number of bytes that have been consumed
Returns
Error code

Definition at line 110 of file coap_message.c.

◆ coapReadPayload()

error_t coapReadPayload ( CoapMessage message,
void *  data,
size_t  size,
size_t *  length 
)

Read payload data.

Parameters
[in]messagePointer to the CoAP message
[out]dataBuffer into which received data will be placed
[in]sizeMaximum number of bytes that can be received
[out]lengthNumber of bytes that have been received
Returns
Error code

Definition at line 466 of file coap_message.c.

◆ coapSetCode()

error_t coapSetCode ( CoapMessage message,
CoapCode  code 
)

Set method or response code.

Parameters
[in]messagePointer to the CoAP message
[in]codeMethod or response code
Returns
Error code

Definition at line 199 of file coap_message.c.

◆ coapSetPayload()

error_t coapSetPayload ( CoapMessage message,
const void *  payload,
size_t  payloadLen 
)

Set CoAP message payload.

Parameters
[in]messagePointer to the CoAP message
[out]payloadPointer to payload data
[out]payloadLenLength of the payload, in bytes
Returns
Error code

Definition at line 250 of file coap_message.c.

◆ coapSetType()

error_t coapSetType ( CoapMessage message,
CoapMessageType  type 
)

Set message type.

Parameters
[in]messagePointer to the CoAP message
[in]typeMessage type (Confirmable or Non-confirmable)
Returns
Error code

Definition at line 149 of file coap_message.c.

◆ coapWritePayload()

error_t coapWritePayload ( CoapMessage message,
const void *  data,
size_t  length 
)

Write payload data.

Parameters
[in]messagePointer to the CoAP message
[in]dataPointer to a buffer containing the data to be written
[in]lengthNumber of bytes to written
Returns
Error code

Definition at line 384 of file coap_message.c.