22 #warning "assertions are disabled"
29 #ifdef HAVE_NETINET_IN_H
30 #include <netinet/in.h>
35 #ifdef HAVE_SYS_TIME_H
40 #include <lwip/ip_addr.h>
85 const coap_address_t *remote,
90 #define COAP_MID_CACHE_SIZE 3
102 #ifndef WITHOUT_ASYNC
115 struct uip_udp_conn *conn;
117 struct etimer retransmit_timer;
118 struct etimer notify_timer;
122 struct pbuf *pending_package;
123 ip_addr_t pending_address;
126 uint8_t timer_configured;
196 static inline unsigned short
220 const coap_address_t *dst,
254 const coap_address_t *dst,
276 const coap_address_t *dst,
293 const coap_address_t *dst,
309 const coap_address_t *dst,
326 const coap_address_t *dst,
411 const coap_address_t *dst,
412 const unsigned char *token,
413 size_t token_length);
unsigned int observe
The next value to be used for Observe.
unsigned char coap_key_t[4]
coap_tid_t coap_send(coap_context_t *context, const coap_address_t *dst, coap_pdu_t *pdu)
Sends a non-confirmed CoAP message to given destination.
coap_queue_t * coap_pop_next(coap_context_t *context)
Returns the next pdu to send and removes it from the sendqeue.
void coap_transaction_id(const coap_address_t *peer, const coap_pdu_t *pdu, coap_tid_t *id)
Calculates a unique transaction id from given arguments peer and pdu.
unsigned char retransmit_cnt
retransmission counter, will be removed when zero
coap_address_t local
local address
int coap_option_check_critical(coap_context_t *ctx, coap_pdu_t *pdu, coap_opt_filter_t unknown)
Verifies that pdu contains no unknown critical options.
static void coap_register_option(coap_context_t *ctx, unsigned char type)
Registers the option type type with the given context object ctx.
static int coap_remove_transaction(coap_queue_t **queue, coap_tid_t id)
Removes the transaction identified by id from given queue.
coap_address_t remote
remote address
struct coap_context_t coap_context_t
The CoAP stack's global state is stored in a coap_context_t object.
coap_queue_t * coap_find_transaction(coap_queue_t *queue, coap_tid_t id)
Retrieves transaction from queue.
struct coap_async_state_t * async_state
list of asynchronous transactions
helpers for handling options in CoAP PDUs
static int coap_option_setb(coap_opt_filter_t filter, unsigned short type)
Sets the corresponding bit for type in filter.
coap_context_t * coap_new_context(const coap_address_t *listen_addr)
Creates a new coap_context_t object that will hold the CoAP stack status.
unsigned short message_id
The last message id that was used is stored in this field.
coap_tid_t coap_send_confirmed(coap_context_t *context, const coap_address_t *dst, coap_pdu_t *pdu)
Sends a confirmed CoAP message to given destination.
coap_tid_t coap_retransmit(coap_context_t *context, coap_queue_t *node)
Handles retransmissions of confirmable messages.
coap_tid_t id
unique transaction id
static void coap_register_response_handler(coap_context_t *context, coap_response_handler_t handler)
Registers a new message handler that is called whenever a response was received that matches an ongoi...
coap_tid_t coap_send_ack(coap_context_t *context, const coap_address_t *dst, coap_pdu_t *request)
Sends an ACK message with code 0 for the specified request to dst.
coap_tick_t sendqueue_basetime
The time stamp in the first element of the sendqeue is relative to sendqueue_basetime.
coap_pdu_t * pdu
the CoAP PDU to send
coap_tick_t t
when to send PDU for the next time
#define COAP_MID_CACHE_SIZE
void coap_ticks(coap_tick_t *)
Returns the current value of an internal tick counter.
Header structure for CoAP PDUs.
coap_tid_t coap_send_message_type(coap_context_t *context, const coap_address_t *dst, coap_pdu_t *request, unsigned char type)
Helper funktion to create and send a message with type (usually ACK or RST).
unsigned int coap_adjust_basetime(coap_context_t *ctx, coap_tick_t now)
Set sendqueue_basetime in the given context object ctx to now.
coap_response_handler_t response_handler
int coap_can_exit(coap_context_t *context)
Returns 1 if there are no messages to send or to dispatch in the context's queues.
representation of network addresses
struct coap_queue_t * next
coap_pdu_t * coap_new_error_response(coap_pdu_t *request, unsigned char code, coap_opt_filter_t opts)
Creates a new ACK PDU with specified error code.
unsigned int timeout
the randomized timeout value
void coap_cancel_all_messages(coap_context_t *context, const coap_address_t *dst, const unsigned char *token, size_t token_length)
Cancels all outstanding messages for peer dst that have the specified token.
unsigned char coap_opt_filter_t[(COAP_MAX_OPT >> 3)+1]
Fixed-size bit-vector we use for option filtering.
int coap_remove_from_queue(coap_queue_t **queue, coap_tid_t id, coap_queue_t **node)
This function removes the element with given id from the list given list.
int coap_delete_node(coap_queue_t *node)
Destroys specified node.
static coap_tid_t coap_send_rst(coap_context_t *context, const coap_address_t *dst, coap_pdu_t *request)
Sends an RST message with code 0 for the specified request to dst.
coap_queue_t * coap_new_node()
Creates a new node suitable for adding to the CoAP sendqueue.
static unsigned short coap_new_message_id(coap_context_t *context)
Returns a new message id and updates context->message_id accordingly.
coap_queue_t * coap_peek_next(coap_context_t *context)
Returns the next pdu to send without removing from sendqeue.
void coap_dispatch(coap_context_t *context)
Dispatches the PDUs from the receive queue in given context.
int coap_read(coap_context_t *context)
Reads data from the network and tries to parse as CoAP PDU.
void coap_delete_all(coap_queue_t *queue)
Removes all items from given queue and frees the allocated storage.
coap_tid_t coap_send_error(coap_context_t *context, coap_pdu_t *request, const coap_address_t *dst, unsigned char code, coap_opt_filter_t opts)
Sends an error response with code code for request request to dst.
struct coap_queue_t coap_queue_t
void coap_free_context(coap_context_t *context)
void(* coap_response_handler_t)(struct coap_context_t *, const coap_address_t *remote, coap_pdu_t *sent, coap_pdu_t *received, const coap_tid_t id)
Message handler that is used as call-back in coap_context_t.
The CoAP stack's global state is stored in a coap_context_t object.
struct coap_resource_t * resources
hash table or list of known resources
int coap_insert_node(coap_queue_t **queue, coap_queue_t *node)
Adds node to given queue, ordered by node->t.
coap_opt_filter_t known_options