Commit Graph
159 Commits
Author SHA1 Message Date
Jon Shallow b35a66ea3d include/coap/coap.h.in: Remove utlist.h uthash.h includes as not needed 2018-05-17 18:45:26 +01:00
Olaf Bergmann 837917f272 Merge branch 'develop' of https://github.com/nikosft/libcoap-fork into nikosft-develop
Resolved conflicts in file resource.h.
2018-04-20 10:10:08 +02:00
Olaf Bergmann 8c35e7625b net.h: fixed data type option number in coap_register_option()
As option numbers can be up to 16 bit, the function
coap_register_option() for making new options known to libcoap
must also take at least 16 bit numbers. The data type for
argument type therefore has been changed to uint16_t.
2018-04-18 09:21:02 +02:00
Jon Shallow 60fccead90 include/coap/coap_session.h: Add in support for DTLS retry counting 2018-04-13 14:07:51 +01:00
obgm 4cf5ff0c63 Merge pull request #152 from baw-serafin/resource_userdata
resource.h: Introduce new field user_data
2018-04-05 10:27:17 +02:00
Jon Shallow 864ae6df8c resource.h: Add in new Observe functions definitions
Add in

coap_resource_set_get_observable()
coap_resource_notify_observers()
coap_resource_get_uri_path()

Deprecate

coap_resource_set_dirty()
2018-04-04 18:38:14 +01:00
Jon Shallow 1c2d9416fe str.h: Add coap_string_equal() and create coap_string_t as replacement for str
Rename struct str as struct coap_string_t and 'typedef coap_string_t str' for
backwards compatabilty with the intent of removing str at some point to
prevent potential name clashes when compiling application code.

Add in new coap_string_equal() function for consistent comparing of strings.
2018-04-04 16:19:37 +01:00
Jon Shallow b7e1040fac hashkey.[ch]: Files removed as no longer used 2018-04-04 16:19:37 +01:00
Jon Shallow 235a11ebe8 uri.h: remove coap_hash_path() and add coap_get_uri_path()
The old hashed key is no longer used, so coap_hash_path() is obsolete.

coap_get_uri_path() added to build the resource Uri Path from the pdu.
2018-03-14 09:32:58 +00:00
Jon Shallow ff6f8e041c pdu.h: remove COAP_DEFAULT_WKC_HASHKEY as no longer needed 2018-03-14 09:32:58 +00:00
Jon Shallow 5aa31d010c resource.h: Add coap_add_resource_unknown() and hash resource on uri_path
Need to support
"RFC7252: 5.8.3.  PUT
 If no resource exists, then the server MAY create a new resource with that
 URI, resulting in a 2.01 (Created) Response Code."

Add in the function definition for the coap_add_resource_unknown().
Add in 'is_unknown' flag into coap_resource_t.

Make the resource uri_path be the hash lookup key, not the old hashed key, to
stop hash lookup clashes.

*API Change* Update coap_delete_resource() to not use the old hashed key.
Remove coap_get_resource_from_key() function and replace it with
coap_get_resource_from_uri_path().

Make the coap_resource_set_mode() more robust against bad parameters.

Remove #ifdef COAP_RESOURCES_NOHASH logic as no longer required
2018-03-13 14:49:22 +00:00
Serafin Leschke e394ca2953 resource.h: Introduce new field user_data
The library API lacks a way to store context for the handlers. A
LED-handler for example needs to now on which pin the specific LED
is connected in order to control it. Or a higher level API would like to save the
object pointer to the object responsible for the resource.

This change will introduce a void pointer for the user to save context.
He can then retrieve the context in the handler if needed.
2018-03-13 09:29:53 +01:00
Jon Shallow cfe82719d3 net.h: Add in unknown_resource to coap_context_t
Needed to handle
"RFC7252: 5.8.3.  PUT
 If no resource exists, then the server MAY create a new resource with that
 URI, resulting in a 2.01 (Created) Response Code."

Needed for support of PUT requests to an unknown resource.

Remove structure coap_mid_cache_t as it is not used and refers to the now
obsolete coap_key_t.
2018-03-10 16:02:56 +00:00
obgm a674334afc Merge pull request #146 from mrdeep1/COAP_SOCKET_CONNECTED_issue
coap_io.c: Set COAP_SOCKET_CONNECTED before connect() for TCP
2018-03-09 17:44:57 +01:00
Jon Shallow c4bd74040c coap_session.h: Add in last_tx_rst to coap_session_t for RST ratelimiting 2018-03-09 14:53:32 +00:00
obgm bf43c3af6c Merge pull request #137 from mrdeep1/session-retries
Require support for configuring session recovery parameters
2018-03-06 16:43:51 +01:00
Jon Shallow ecf3321c67 net.h: Update and document coap_calc_timeout() function
Include session as one of the parameters to coap_calc_timeout() as it is now
per session, which is renamed from calc_timeout() as it is now a public
function.
2018-03-05 16:12:07 +00:00
Jon Shallow b105a7dea2 coap_session.h: Add definitions/functions to configure session retransmissions
Support is required (RFC7252: 4.8.1.  Changing the Parameters) to support
changing max_retransmit, ack_timeout and ack_random_factor values per
session instead of just using the default values.

Define struct coap_fixed_point_t to handle fixed point parameters

Added functions
coap_session_set_max_retransmit()
coap_session_set_ack_timeout()
coap_session_set_ack_random_factor()
coap_session_get_max_transmit()
coap_session_get_ack_timeout()
coap_session_get_ack_random_factor()

'cc Rate Control' moved from net.c into coap_session.h and updated to use
coap_fixed_point_t values where appropriate.
2018-03-05 12:09:45 +00:00
Olaf Bergmann 7872a80fb4 network I/O: fixed socket creation for multicast communication
This bugfix allows clients to send datagrams to IP multicast groups.
After introducing the concept of client sessions, datagram sockets
have been connected to their remote peer in coap_socket_connect_udp().
As this operation fails for multicast addresses, sending to multicast
groups was not possible anymore.

coap_socket_connect_udp() now checks whether the given server address
is a multicast address. If this is the case, connect() is not called
and the flag COAP_SOCKET_MULTICAST is set in the coap_socket_t
structure while COAP_SOCKET_CONNECTED is cleared.

The flag COAP_SOCKET_CONNECTED is now set by coap_socket_connect_udp()
and coap_socket_connect_tcp1().

coap_read_session() now allows reading from sockets that have either
the flag COAP_SOCKET_CONNECTED or COAP_SOCKET_MULTICAST set.
2018-02-28 15:44:32 +01:00
obgm b6f6cb274c Merge pull request #141 from mrdeep1/coap-log-syntax
Add in GNU compiler checking of parameter syntax for coap_log() functions
2018-02-26 17:35:10 +01:00
obgm fafd4745b7 Merge pull request #136 from mrdeep1/ping-pong-handlers
Ping Pong handlers: Need for applications to see ping requests / pong responses
2018-02-26 17:17:54 +01:00
Jon Shallow b8b1c18ffd net.h: Update coap_context_set_pki() definition 2018-02-14 20:58:15 +00:00
Jon Shallow f820857315 coap_session.h: Move coap_new_client_session_pki() def from coap_dtls.h
Moving coap_dtls_security_setup_t into coap_dtls_pki_t helped with the previous
into its logical place.
2018-02-14 20:54:21 +00:00
Jon Shallow fa6f292997 coap_dtls.h: Move coap_dtls_security_setup_t into coap_dtls_pki_t
Update functions appropriately.
Move coap_new_client_session_pki() back into coap_session.h (its correct place)
Add in enum coap_asn1_privatekey_type_t
2018-02-14 20:50:43 +00:00
Jon Shallow 047c9fb082 Fix coap_notls.c, coap_tinydtls.c: after update merge from obgm/develop
Conficts created by Pull request #134
2018-02-14 19:24:58 +00:00
Jon Shallow 93c8471233 debug.h: Add in parameter format checking to coap_log_impl() for GNUC
For GNUC. make the function

void coap_log_impl(coap_log_t level,
               const char *format, ...) __attribute__ ((format(printf, 2, 3)));
2018-02-12 15:28:24 +00:00
Jon Shallow 0b88e51a88 net.h: Add in new function
New function coap_context_set_pki()

Update function coap_context_set_psk ()to return failure value
2018-02-11 20:04:04 +00:00
Jon Shallow 5b340adfb8 coap_dtls.h: Add support for setting up PKI
Define
coap_dtls_pki_t
coap_dtls_security_setup_t

Functions
coap_new_client_session_pki
coap_dtls_context_set_psk
coap_dtls_context_set_pki
coap_dtls_context_check_keys_enabled
2018-02-11 19:32:15 +00:00
Jon Shallow fbe814d905 net.h: Add function definitions for ping and TCP pong handlers
If the application needs to see CoAP ping requests or CoAP TCP pong responses
then there needs to be a handler that can be set up that is called
appropriately.
2018-02-10 20:54:17 +00:00
Jon Shallow e1fa280d88 coap_dtls.h: Add in TLS library determination support
A new function coap_get_tls_library_version() that returns a pointer to a
coap_tls_version_t structure that contains both the TLS library type libcoap
was compiled against as well as the current TLS library version.
2018-02-10 18:34:42 +00:00
Olaf Bergmann d3b5535960 pdu.[hc]: Export coap_pdu_resize() 2017-12-22 13:55:37 +01:00
Olaf Bergmann 0c837cdc77 pdu.h: increase Max-Message-Size by 256 B
To allow for 8 MiB payloads, the maximum message size value for
TCP has been increased by 256 B option space.
2017-11-11 10:06:16 +01:00
jcmichelou c93f535d4a openssl, session: Fix memory leaks. 2017-11-04 23:38:02 +01:00
Olaf Bergmann a569e16584 coap_time.h: cast COAP_TICKS_PER_SECOND to coap_tick_t for type safety
CID 1458396 detected by Coverity scan points out that integer
arithmetics may lead to an overflow without the typecast to
coap_tick_t.
2017-11-03 14:29:49 +01:00
jcmichelou 3f77c117ea resource: Fix issues #90, #91 and #92
The value of the observe option is kept for each resource rather than being global to the context.
The value of the observe option must wrap to be stay below 2^24.
The value of the observe option must be different from the initial value when a notification is sent.
2017-10-25 20:22:01 +02:00
jcmichelou e125888ded openssl: Handshake can also complete in SSL_accept and SSL_connect. 2017-10-21 19:16:23 +02:00
jcmichelou 68a9ea045d pdu: Use defines for TCP variable header message size constants. 2017-10-21 17:24:56 +02:00
jcmichelou d89c99f5f8 uri: Add coap+tcp:// and coaps+tcp:// schemes. 2017-10-21 16:52:02 +02:00
jcmichelou 75d89ab295 openssl, io: Fix linux compatibility 2017-10-21 16:11:16 +02:00
jcmichelou 854cc3147f openssl, session: Add TLS encryption. 2017-10-21 16:11:14 +02:00
jcmichelou 9bb8396b23 coap_session, net.c: Add debug messages on TCP RX/TX. 2017-10-21 16:11:14 +02:00
jcmichelou 58766a137e coap_dtls.h, openssl: Add function prototypes for TLS support. 2017-10-21 16:11:13 +02:00
jcmichelou 140580f0df session, pdu, option: Use exact message size calculation for TCP PDU. 2017-10-21 16:11:13 +02:00
jcmichelou f81cb43fd3 session, pdu: Enforce maximum message size. 2017-10-21 16:11:12 +02:00
jcmichelou c592c9d11f session, net, debug: Add TCP signaling messages. 2017-10-21 16:11:12 +02:00
jcmichelou dfff930805 io, net: Add TCP accept/connect/read/write 2017-10-21 16:11:12 +02:00
jcmichelou bcfd7a0753 pdu: add support for TCP-style headers
Make coap_pdu-t independent of the header style.
Use C99 sized types when applicable.
Use transaction ids in host byte order in the library.
Make coap_pdu_t payload storage grow on demand.
Add parsing and encoding of PDUs with UDP or TCP style headers.
Adapt examples and unit tests to the new PDU format.
2017-10-21 16:11:11 +02:00
obgm 8a30adefa5 Merge pull request #108 from spinetix/log-handler
Add a log handler callback.
2017-09-09 01:22:13 +02:00
obgm abddc07559 Merge pull request #107 from spinetix/handler-lost-con
Add handler for lost CON messages.
2017-09-09 01:21:32 +02:00
jcmichelou d89159fdb4 debug.[hc]: Add a log handler callback. 2017-09-08 20:12:39 +02:00