Commit b0fedea2 authored by Carsten Schoenert's avatar Carsten Schoenert

New upstream version 4.2.0

parent f43d44de
......@@ -120,7 +120,7 @@ file(s).
the source file:
--8<----
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 * -*- */
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
--->8--
* Single lines within the source code should not be longer then 78
......@@ -198,14 +198,13 @@ maybe you can improve the doxygen documentation.
Also a good documentation on the usage of the libcoap and the example
binaries is always improvable. So we appreciate any help on this.
* Man Pages
* Manual Pages
The source is providing some example binaries which originally just should show
how the libcoap can be used. Right now these binaries are fully usable and
quite more than simple examples on a system. There are man pages for these
binaries available, if you found there is a improvement needed please do so and
write to the mailing list explained in section 2.
Maybe you can write up some good HowTo's on the usage for these binaries. A man
page for the library itself would be also a improvement.
Maybe you can write up some good HowTo's on the usage for these binaries.
* HowTo's
The libcoap library has now a lot of functions you can use.
......@@ -213,7 +212,7 @@ Unfortunately there is no good user guide on how to use the libcoap in
any external project. This means there is no HowTo or CheatSheet for a
programming person available. You want to write up something?
* missed Functionality
* Missing functionality
There are some features that are still missing inside the libcoap. For
example some DTLS implementations and proxy functionality.
2019-02-11 Olaf Bergmann <bergmann@tzi.org>
Change summary for version 4.2.0:
* DTLS support improvements (OpenSSL, GnuTLS, tinydtls)
* Pre-shared keys, X.509 certificates
* new session abstraction
* TCP and TLS support
* improved documentation; manual pages
* changes in internal PDU structure
* improved examples (DTLS usage, block-wise transfer)
* docker images for continuous integration
* support for Google OSS fuzzer
* MS Visual Studio project for Windows builds
2017-07-10 Olaf Bergmann <bergmann@tzi.org>
* DTLS support (OpenSSL, tinyDTLS) by Jean-Claude Michelou
......
......@@ -3,7 +3,7 @@
[![Build Status](https://travis-ci.org/obgm/libcoap.svg?branch=master)](https://travis-ci.org/obgm/libcoap)
[![Static Analysis](https://scan.coverity.com/projects/10970/badge.svg?flat=1)](https://scan.coverity.com/projects/obgm-libcoap)
Copyright (C) 2010--2018 by Olaf Bergmann <bergmann@tzi.org> and others
Copyright (C) 2010—2019 by Olaf Bergmann <bergmann@tzi.org> and others
ABOUT LIBCOAP
=============
......
......@@ -11,13 +11,7 @@ Classification of issues:
=================
* CRITICAL ISSUES
=================
-> Remove the #include "coap_config.h" directive from the public header files.
-> Remove #ifdef HAVE_ASSERT_H and so on from the public headers.
-> Use coap.h as the only header to include from the public view.
-> DTLS functionality
-> Adding DTLS functions based on openssl
-> Bill Benett has starting some improvements here, please contact him
first before starting something
-> Proxy functionality
-> A coap-server should be able to act as proxy server
......@@ -27,35 +21,10 @@ Classification of issues:
-> Create some development rules like:
--> How to submit patches? What about pull requests?
--> How to implement/change platform related code?
-> Adding some documentation for classical users on how to use the libcoap
-> Clean up the various inclusion for #ifdef __cplusplus #extern "C" {}
-> Adding additional config options (like --with-pdu-size)
-> Split of the platform related code into [foo]_platform.c files
-> In general, improving the online doxygen documentation like creating some
additional information for doxygen (startpage, development information,
...)
-> In special, improving ...
Adding prams and return explanation in:
include/coap/coap_io.h
include/coap/option.h
include/coap/net.h
include/coap/resource.h
include/coap/str.h
include/coap/subscribe.h
include/coap/uri.h
Adding @brief directive
include/coap/block.h
include/coap/coap_io.h
include/coap/debug.h
include/coap/encode.h
include/coap/net.h
include/coap/str.h
include/coap/subscribe.h
include/coap/uri.h
-> Further improve the API documentation
==============
* MINOR ISSUES
==============
-> Remove the not needed Makefile.in.old files
-> Adding a logo for libcoap
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for libcoap 4.2.0rc4.
# Generated by GNU Autoconf 2.69 for libcoap 4.2.0.
#
# Report bugs to <libcoap-developers@lists.sourceforge.net>.
#
......@@ -650,8 +650,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libcoap'
PACKAGE_TARNAME='libcoap'
PACKAGE_VERSION='4.2.0rc4'
PACKAGE_STRING='libcoap 4.2.0rc4'
PACKAGE_VERSION='4.2.0'
PACKAGE_STRING='libcoap 4.2.0'
PACKAGE_BUGREPORT='libcoap-developers@lists.sourceforge.net'
PACKAGE_URL='https://libcoap.net/'
......@@ -1447,7 +1447,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures libcoap 4.2.0rc4 to adapt to many kinds of systems.
\`configure' configures libcoap 4.2.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1518,7 +1518,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of libcoap 4.2.0rc4:";;
short | recursive ) echo "Configuration of libcoap 4.2.0:";;
esac
cat <<\_ACEOF
......@@ -1658,7 +1658,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
libcoap configure 4.2.0rc4
libcoap configure 4.2.0
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
......@@ -2081,7 +2081,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by libcoap $as_me 4.2.0rc4, which was
It was created by libcoap $as_me 4.2.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
......@@ -2945,7 +2945,7 @@ fi
# Define the identity of the package.
PACKAGE='libcoap'
VERSION='4.2.0rc4'
VERSION='4.2.0'
# Some tools Automake needs.
......@@ -13751,7 +13751,7 @@ $as_echo "$as_me: Using auto selected library OpenSSL for DTLS support!" >&6;}
# Note that tinyDTLS is used only when explicitly requested.
# Giving out an error message if we haven't found at least one crypto library.
if test "x$have_gnutls" = "xno" -a "x$have_openssl" = "xno" -a "x$have_tinydtls" != "xno"; then
if test "x$have_gnutls" = "xno" -a "x$have_openssl" = "xno" -a "x$have_tinydtls" = "xno"; then
as_fn_error $? "==> Option '--enable-dtls' is set but one of the needed cryptography library GnuTLS nor OpenSSL nor tinyDTLS could be found!
Install at least one of the package(s) that contains the development files for GnuTLS (>= $gnutls_version_required) or OpenSSL(>= $openssl_version_required)
or disable the DTLS support using '--disable-dtls'." "$LINENO" 5
......@@ -15031,7 +15031,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by libcoap $as_me 4.2.0rc4, which was
This file was extended by libcoap $as_me 4.2.0, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -15098,7 +15098,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
libcoap config.status 4.2.0rc4
libcoap config.status 4.2.0
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
......
......@@ -13,7 +13,7 @@ m4_define([libcoap_micro_version], [0])
# define an appending release state if needed, for example for pre-releases
# like 'alpha' or 'rc1', for a full release keep the value empty!
m4_define([libcoap_release_state], [rc4])
m4_define([libcoap_release_state], [])
# concatenate the full libcoap version string
m4_define([libcoap_version], [m4_format([%s.%s.%s%s], libcoap_major_version, libcoap_minor_version, libcoap_micro_version, libcoap_release_state)])
......@@ -428,7 +428,7 @@ if test "x$build_dtls" = "xyes"; then
# Note that tinyDTLS is used only when explicitly requested.
# Giving out an error message if we haven't found at least one crypto library.
if test "x$have_gnutls" = "xno" -a "x$have_openssl" = "xno" -a "x$have_tinydtls" != "xno"; then
if test "x$have_gnutls" = "xno" -a "x$have_openssl" = "xno" -a "x$have_tinydtls" = "xno"; then
AC_MSG_ERROR([==> Option '--enable-dtls' is set but one of the needed cryptography library GnuTLS nor OpenSSL nor tinyDTLS could be found!
Install at least one of the package(s) that contains the development files for GnuTLS (>= $gnutls_version_required) or OpenSSL(>= $openssl_version_required)
or disable the DTLS support using '--disable-dtls'.])
......
......@@ -402,8 +402,8 @@ distclean-generic:
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
@HAVE_DOXYGEN_FALSE@clean-local:
@HAVE_DOXYGEN_FALSE@distclean-local:
@HAVE_DOXYGEN_FALSE@clean-local:
clean: clean-am
clean-am: clean-generic clean-libtool clean-local mostlyclean-am
......
......@@ -2,7 +2,7 @@
/* coap-client -- simple CoAP client
*
* Copyright (C) 2010--2016 Olaf Bergmann <bergmann@tzi.org> and others
* Copyright (C) 2010--2019 Olaf Bergmann <bergmann@tzi.org> and others
*
* This file is part of the CoAP library libcoap. Please see README for terms of
* use.
......@@ -307,6 +307,23 @@ check_token(coap_pdu_t *received) {
memcmp(received->token, the_token.s, the_token.length) == 0;
}
static int
event_handler(coap_context_t *ctx UNUSED_PARAM,
coap_event_t event,
struct coap_session_t *session UNUSED_PARAM) {
switch(event) {
case COAP_EVENT_DTLS_CLOSED:
case COAP_EVENT_TCP_CLOSED:
case COAP_EVENT_SESSION_CLOSED:
quit = 1;
break;
default:
break;
}
return 0;
}
static void
message_handler(struct coap_context_t *ctx,
coap_session_t *session,
......@@ -554,7 +571,7 @@ usage( const char *program, const char *version) {
program = ++p;
fprintf( stderr, "%s v%s -- a small CoAP implementation\n"
"(c) 2010-2018 Olaf Bergmann <bergmann@tzi.org> and others\n\n"
"Copyright (C) 2010-2019 Olaf Bergmann <bergmann@tzi.org> and others\n\n"
"%s\n\n"
"Usage: %s [-a addr] [-b [num,]size] [-e text] [-f file] [-l loss]\n"
"\t\t[-m method] [-o file] [-p port] [-r] [-s duration] [-t type]\n"
......@@ -1074,17 +1091,31 @@ verify_cn_callback(const char *cn,
}
static coap_dtls_pki_t *
setup_pki(void) {
setup_pki(coap_context_t *ctx) {
static coap_dtls_pki_t dtls_pki;
static char client_sni[256];
/* If general root CAs are defined */
if (root_ca_file) {
struct stat stbuf;
if ((stat(root_ca_file, &stbuf) == 0) && S_ISDIR(stbuf.st_mode)) {
coap_context_set_pki_root_cas(ctx, NULL, root_ca_file);
} else {
coap_context_set_pki_root_cas(ctx, root_ca_file, NULL);
}
}
memset (&dtls_pki, 0, sizeof(dtls_pki));
dtls_pki.version = COAP_DTLS_PKI_SETUP_VERSION;
if (ca_file) {
if (ca_file || root_ca_file) {
/*
* Add in additional certificate checking.
* This list of enabled can be tuned for the specific
* requirements - see 'man coap_encryption'.
*
* Note: root_ca_file is setup separately using
* coap_context_set_pki_root_cas(), but this is used to define what
* checking actually takes place.
*/
dtls_pki.verify_peer_cert = 1;
dtls_pki.require_peer_cert = 1;
......@@ -1130,16 +1161,6 @@ get_session(
) {
coap_session_t *session = NULL;
/* If general root CAs are defined */
if (root_ca_file) {
struct stat stbuf;
if ((stat(root_ca_file, &stbuf) == 0) && S_ISDIR(stbuf.st_mode)) {
coap_context_set_pki_root_cas(ctx, NULL, root_ca_file);
} else {
coap_context_set_pki_root_cas(ctx, root_ca_file, NULL);
}
}
if ( local_addr ) {
int s;
struct addrinfo hints;
......@@ -1163,8 +1184,9 @@ get_session(
coap_address_init( &bind_addr );
bind_addr.size = rp->ai_addrlen;
memcpy( &bind_addr.addr, rp->ai_addr, rp->ai_addrlen );
if (cert_file && (proto == COAP_PROTO_DTLS || proto == COAP_PROTO_TLS)) {
coap_dtls_pki_t *dtls_pki = setup_pki();
if ((root_ca_file || ca_file || cert_file) &&
(proto == COAP_PROTO_DTLS || proto == COAP_PROTO_TLS)) {
coap_dtls_pki_t *dtls_pki = setup_pki(ctx);
session = coap_new_client_session_pki(ctx, &bind_addr, dst, proto, dtls_pki);
}
else if ((identity || key) &&
......@@ -1181,8 +1203,9 @@ get_session(
}
freeaddrinfo( result );
} else {
if (cert_file && (proto == COAP_PROTO_DTLS || proto == COAP_PROTO_TLS)) {
coap_dtls_pki_t *dtls_pki = setup_pki();
if ((root_ca_file || ca_file || cert_file) &&
(proto == COAP_PROTO_DTLS || proto == COAP_PROTO_TLS)) {
coap_dtls_pki_t *dtls_pki = setup_pki(ctx);
session = coap_new_client_session_pki(ctx, NULL, dst, proto, dtls_pki);
}
else if ((identity || key) &&
......@@ -1399,6 +1422,7 @@ main(int argc, char **argv) {
coap_register_option(ctx, COAP_OPTION_BLOCK2);
coap_register_response_handler(ctx, message_handler);
coap_register_event_handler(ctx, event_handler);
/* construct CoAP message */
......
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 * -*- */
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* coap -- simple implementation of the Constrained Application Protocol (CoAP)
* as defined in RFC 7252
*
* Copyright (C) 2010--2018 Olaf Bergmann <bergmann@tzi.org> and others
* Copyright (C) 2010--2019 Olaf Bergmann <bergmann@tzi.org> and others
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
......@@ -56,6 +56,7 @@ static int resource_flags = COAP_RESOURCE_FLAGS_NOTIFY_CON;
static char *cert_file = NULL; /* Combined certificate and private key in PEM */
static char *ca_file = NULL; /* CA for cert_file - for cert checking in PEM */
static char *root_ca_file = NULL; /* List of trusted Root CAs in PEM */
static int require_peer_cert = 1; /* By default require peer cert */
#define MAX_KEY 64 /* Maximum length of a key (i.e., PSK) in bytes. */
static uint8_t key[MAX_KEY];
static ssize_t key_length = 0;
......@@ -82,7 +83,7 @@ handle_sigint(int signum UNUSED_PARAM) {
}
#define INDEX "This is a test server made with libcoap (see https://libcoap.net)\n" \
"Copyright (C) 2010--2018 Olaf Bergmann <bergmann@tzi.org>\n\n"
"Copyright (C) 2010--2019 Olaf Bergmann <bergmann@tzi.org> and others\n\n"
static void
hnd_get_index(coap_context_t *ctx UNUSED_PARAM,
......@@ -683,7 +684,7 @@ fill_keystore(coap_context_t *ctx) {
* requirements - see 'man coap_encryption'.
*/
dtls_pki.verify_peer_cert = 1;
dtls_pki.require_peer_cert = 1;
dtls_pki.require_peer_cert = require_peer_cert;
dtls_pki.allow_self_signed = 1;
dtls_pki.allow_expired_certs = 1;
dtls_pki.cert_chain_validation = 1;
......@@ -737,7 +738,7 @@ usage( const char *program, const char *version) {
"Usage: %s [-d max] [-g group] [-l loss] [-p port] [-v num]\n"
"\t\t[-A address] [-N]\n"
"\t\t[[-k key] [-h hint]]\n"
"\t\t[[-c certfile][-C cafile] [-R root_cafile]]\n"
"\t\t[[-c certfile][-C cafile] [-n] [-R root_cafile]]\n"
"General Options\n"
"\t-d max \t\tAllow dynamic creation of up to a total of max\n"
"\t \t\tresources. If max is reached, a 4.06 code is returned\n"
......@@ -765,6 +766,8 @@ usage( const char *program, const char *version) {
"PKI Options (if supported by underlying (D)TLS library)\n"
"\t-c certfile\tPEM file containing both CERTIFICATE and PRIVATE KEY\n"
"\t \t\tThis argument requires (D)TLS with PKI to be available\n"
"\t-n \t\tDisable the requirement for clients to have defined\n"
"\t \t\tclient certificates\n"
"\t-C cafile\tPEM file containing the CA Certificate that was used to\n"
"\t \t\tsign the certfile. If defined, then the client will be\n"
"\t \t\tgiven this CA Certificate during the TLS set up.\n"
......@@ -952,7 +955,7 @@ main(int argc, char **argv) {
clock_offset = time(NULL);
while ((opt = getopt(argc, argv, "A:d:c:C:g:h:k:l:Np:R:v:")) != -1) {
while ((opt = getopt(argc, argv, "A:d:c:C:g:h:k:l:nNp:R:v:")) != -1) {
switch (opt) {
case 'A' :
strncpy(addr_str, optarg, NI_MAXHOST-1);
......@@ -991,6 +994,9 @@ main(int argc, char **argv) {
exit(1);
}
break;
case 'n':
require_peer_cert = 0;
break;
case 'N':
resource_flags = COAP_RESOURCE_FLAGS_NOTIFY_NON;
break;
......
......@@ -25,8 +25,8 @@
* of coap-client
*/
#ifndef _COAP_LIST_H_
#define _COAP_LIST_H_
#ifndef COAP_LIST_H_
#define COAP_LIST_H_
#include <coap2/utlist.h>
......@@ -47,4 +47,4 @@ int coap_delete(coap_list_t *node);
/* removes all items from given queue and frees the allocated storage */
void coap_delete_list(coap_list_t *queue);
#endif /* _COAP_LIST_H_ */
#endif /* COAP_LIST_H_ */
......@@ -12,8 +12,8 @@
* @brief Representation of network addresses
*/
#ifndef _COAP_ADDRESS_H_
#define _COAP_ADDRESS_H_
#ifndef COAP_ADDRESS_H_
#define COAP_ADDRESS_H_
#include <assert.h>
#include <stdint.h>
......@@ -174,4 +174,4 @@ coap_is_mcast(const coap_address_t *a) {
}
#endif /* !WITH_LWIP && !WITH_CONTIKI */
#endif /* _COAP_ADDRESS_H_ */
#endif /* COAP_ADDRESS_H_ */
......@@ -12,8 +12,8 @@
* @brief State management for asynchronous messages
*/
#ifndef _COAP_ASYNC_H_
#define _COAP_ASYNC_H_
#ifndef COAP_ASYNC_H_
#define COAP_ASYNC_H_
#include "net.h"
......@@ -146,4 +146,4 @@ coap_touch_async(coap_async_state_t *s) { coap_ticks(&s->created); }
#endif /* WITHOUT_ASYNC */
#endif /* _COAP_ASYNC_H_ */
#endif /* COAP_ASYNC_H_ */
......@@ -12,8 +12,8 @@
* @brief Bit vector manipulation
*/
#ifndef _COAP_BITS_H_
#define _COAP_BITS_H_
#ifndef COAP_BITS_H_
#define COAP_BITS_H_
#include <stdint.h>
......@@ -75,4 +75,4 @@ bits_getb(const uint8_t *vec, size_t size, uint8_t bit) {
return (*(vec + (bit >> 3)) & (1 << (bit & 0x07))) != 0;
}
#endif /* _COAP_BITS_H_ */
#endif /* COAP_BITS_H_ */
......@@ -7,8 +7,8 @@
* of use.
*/
#ifndef _COAP_BLOCK_H_
#define _COAP_BLOCK_H_
#ifndef COAP_BLOCK_H_
#define COAP_BLOCK_H_
#include "encode.h"
#include "option.h"
......@@ -170,4 +170,4 @@ coap_add_data_blocked_response(struct coap_resource_t *resource,
/**@}*/
#endif /* _COAP_BLOCK_H_ */
#endif /* COAP_BLOCK_H_ */
......@@ -8,8 +8,8 @@
* of use.
*/
#ifndef _COAP_H_
#define _COAP_H_
#ifndef COAP_H_
#define COAP_H_
/* Define the address where bug reports for libcoap should be sent. */
#define LIBCOAP_PACKAGE_BUGREPORT "libcoap-developers@lists.sourceforge.net"
......@@ -18,13 +18,13 @@
#define LIBCOAP_PACKAGE_NAME "libcoap"
/* Define the full name and version of libcoap. */
#define LIBCOAP_PACKAGE_STRING "libcoap 4.2.0rc4"
#define LIBCOAP_PACKAGE_STRING "libcoap 4.2.0"
/* Define the home page for libcoap. */
#define LIBCOAP_PACKAGE_URL "https://libcoap.net/"
/* Define the version of libcoap this file belongs to. */
#define LIBCOAP_PACKAGE_VERSION "4.2.0rc4"
#define LIBCOAP_PACKAGE_VERSION "4.2.0"
#ifdef __cplusplus
extern "C" {
......@@ -56,4 +56,4 @@ extern "C" {
}
#endif
#endif /* _COAP_H_ */
#endif /* COAP_H_ */
......@@ -8,8 +8,8 @@
* of use.
*/
#ifndef _COAP_H_
#define _COAP_H_
#ifndef COAP_H_
#define COAP_H_
/* Define the address where bug reports for libcoap should be sent. */
#define LIBCOAP_PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
......@@ -56,4 +56,4 @@ extern "C" {
}
#endif
#endif /* _COAP_H_ */
#endif /* COAP_H_ */
......@@ -7,8 +7,8 @@
* of use.
*/
#ifndef _COAP_DEBUG_H_
#define _COAP_DEBUG_H_
#ifndef COAP_DEBUG_H_
#define COAP_DEBUG_H_
/**
* @defgroup logging Logging Support
......@@ -206,4 +206,4 @@ int coap_debug_set_packet_loss(const char *loss_level);
int coap_debug_send_packet(void);
#endif /* _COAP_DEBUG_H_ */
#endif /* COAP_DEBUG_H_ */
......@@ -8,8 +8,8 @@
* of use.
*/
#ifndef _COAP_DTLS_H_
#define _COAP_DTLS_H_
#ifndef COAP_DTLS_H_
#define COAP_DTLS_H_
#include "net.h"
#include "coap_session.h"
......@@ -129,7 +129,7 @@ typedef enum coap_asn1_privatekey_type_t {
* The enum used for determining the PKI key formats.
*/
typedef enum coap_pki_key_t {
COAP_PKI_KEY_PEM, /**< The PKI key type is PEM */
COAP_PKI_KEY_PEM = 0, /**< The PKI key type is PEM */
COAP_PKI_KEY_ASN1, /**< The PKI key type is ASN.1 (DER) */
} coap_pki_key_t;
......@@ -226,7 +226,7 @@ typedef struct coap_dtls_pki_t {
coap_dtls_sni_callback_t validate_sni_call_back;
void *sni_call_back_arg; /**< Passed in to the sni call-back function */
/** Addtional Security call-back handler that is invoked when libcoap has
/** Additional Security call-back handler that is invoked when libcoap has
* done the standerd, defined validation checks at the TLS level,
* If not @p NULL, called from within the TLS Client Hello connection
* setup.
......@@ -261,8 +261,10 @@ typedef struct coap_dtls_pki_t {
void *
coap_dtls_new_context(struct coap_context_t *coap_context);
#define COAP_DTLS_ROLE_CLIENT 0 /**< Internal function invoked for client */
#define COAP_DTLS_ROLE_SERVER 1 /**< Internal function invoked for server */
typedef enum coap_dtls_role_t {
COAP_DTLS_ROLE_CLIENT, /**< Internal function invoked for client */
COAP_DTLS_ROLE_SERVER /**< Internal function invoked for server */
} coap_dtls_role_t;
/**
* Set the DTLS context's default PSK information.
......@@ -288,7 +290,7 @@ coap_dtls_new_context(struct coap_context_t *coap_context);
int
coap_dtls_context_set_psk(struct coap_context_t *coap_context,
const char *identity_hint,
int role);
coap_dtls_role_t role);
/**
* Set the DTLS context's default server PKI information.
......@@ -312,7 +314,7 @@ coap_dtls_context_set_psk(struct coap_context_t *coap_context,
int
coap_dtls_context_set_pki(struct coap_context_t *coap_context,
coap_dtls_pki_t *setup_data,
int role);
coap_dtls_role_t role);
/**
* Set the dtls context's default Root CA information for a client or server.
......
......@@ -7,8 +7,8 @@
* of use.
*/
#ifndef _COAP_EVENT_H_
#define _COAP_EVENT_H_
#ifndef COAP_EVENT_H_
#define COAP_EVENT_H_
#include "libcoap.h"
......
......@@ -12,8 +12,8 @@
* @brief definition of hash key type and helper functions
*/
#ifndef _COAP_HASHKEY_H_
#define _COAP_HASHKEY_H_
#ifndef COAP_HASHKEY_H_
#define COAP_HASHKEY_H_
#include "libcoap.h"
#include "uthash.h"
......@@ -37,9 +37,9 @@ void coap_hash_impl(const unsigned char *s, unsigned int len, coap_key_t h);
coap_hash_impl((String),(Length),(Result))
/* This is used to control the pre-set hash-keys for resources. */
#define __COAP_DEFAULT_HASH
#define COAP_DEFAULT_HASH
#else
#undef __COAP_DEFAULT_HASH
#undef COAP_DEFAULT_HASH
#endif /* coap_hash */
/**
......@@ -56,4 +56,4 @@ void coap_hash_impl(const unsigned char *s, unsigned int len, coap_key_t h);
coap_hash((Str)->s, (Str)->length, (H)); \
}
#endif /* _COAP_HASHKEY_H_ */
#endif /* COAP_HASHKEY_H_ */
......@@ -7,8 +7,8 @@
* of use.
*/
#ifndef _COAP_IO_H_
#define _COAP_IO_H_
#ifndef COAP_IO_H_
#define COAP_IO_H_
#include <assert.h>
#include <sys/types.h>
......@@ -210,4 +210,4 @@ typedef enum {
COAP_NACK_TLS_FAILED
} coap_nack_reason_t;
#endif /* _COAP_IO_H_ */
#endif /* COAP_IO_H_ */
......@@ -6,8 +6,8 @@
* README for terms of use.
*/
#ifndef _SESSION_H_
#define _SESSION_H_
#ifndef COAP_SESSION_H_
#define COAP_SESSION_H_
#include "coap_io.h"
......@@ -160,7 +160,7 @@ void coap_session_set_mtu(coap_session_t *session, unsigned mtu);
* @param session The CoAP session.
* @return maximum PDU size, not including header (but including token).
*/
size_t coap_session_max_pdu_size(coap_session_t *session);
size_t coap_session_max_pdu_size(const coap_session_t *session);
/**
* Creates a new client session to the designated server.
......@@ -490,4 +490,4 @@ coap_fixed_point_t coap_session_get_ack_random_factor(coap_session_t *session);
*/
coap_tid_t coap_session_send_ping(coap_session_t *session);
#endif /* _SESSION_H */
#endif /* COAP_SESSION_H */
/*
* coap_time.h -- Clock Handling
*
* Copyright (C) 2010-2013 Olaf Bergmann <bergmann@tzi.org>
* Copyright (C) 2010-2019 Olaf Bergmann <bergmann@tzi.org>
*
* This file is part of the CoAP library libcoap. Please see README for terms
* of use.
......@@ -12,8 +12,8 @@
* @brief Clock Handling
*/
#ifndef _COAP_TIME_H_
#define _COAP_TIME_H_
#ifndef COAP_TIME_H_
#define COAP_TIME_H_
/**
* @defgroup clock Clock Handling
......@@ -159,4 +159,4 @@ COAP_STATIC_INLINE int coap_time_le(coap_tick_t a, coap_tick_t b) {
/** @} */
#endif /* _COAP_TIME_H_ */
#endif /* COAP_TIME_H_ */
......@@ -7,8 +7,8 @@
* of use.
*/
#ifndef _COAP_ENCODE_H_
#define _COAP_ENCODE_H_
#ifndef COAP_ENCODE_H_
#define COAP_ENCODE_H_
#if (BSD >= 199103) || defined(WITH_CONTIKI) || defined(_WIN32)
# include <string.h>
......@@ -93,4 +93,4 @@ coap_encode_var_bytes(uint8_t *buf, unsigned int value
return (int)coap_encode_var_safe(buf, sizeof(value), value);
}
#endif /* _COAP_ENCODE_H_ */
#endif /* COAP_ENCODE_H_ */
......@@ -7,8 +7,8 @@
* of use.
*/
#ifndef _LIBCOAP_H_
#define _LIBCOAP_H_