Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
coap-transactions.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2013, Institute for Pervasive Computing, ETH Zurich
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of the Institute nor the names of its contributors
14
* may be used to endorse or promote products derived from this software
15
* without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
* SUCH DAMAGE.
28
*
29
* This file is part of the Contiki operating system.
30
*/
31
32
/**
33
* \file
34
* CoAP module for reliable transport
35
* \author
36
* Matthias Kovatsch <kovatsch@inf.ethz.ch>
37
*/
38
39
/**
40
* \addtogroup coap
41
* @{
42
*/
43
44
#ifndef COAP_TRANSACTIONS_H_
45
#define COAP_TRANSACTIONS_H_
46
47
#include "
coap.h
"
48
#include "
coap-engine.h
"
49
#include "
coap-timer.h
"
50
51
/*
52
* Modulo mask (thus +1) for a random number to get the tick number for the random
53
* retransmission time between COAP_RESPONSE_TIMEOUT and COAP_RESPONSE_TIMEOUT*COAP_RESPONSE_RANDOM_FACTOR.
54
*/
55
#define COAP_RESPONSE_TIMEOUT_TICKS (1000 * COAP_RESPONSE_TIMEOUT)
56
#define COAP_RESPONSE_TIMEOUT_BACKOFF_MASK (uint32_t)(((1000 * COAP_RESPONSE_TIMEOUT * ((float)COAP_RESPONSE_RANDOM_FACTOR - 1.0)) + 0.5) + 1)
57
58
/* container for transactions with message buffer and retransmission info */
59
typedef
struct
coap_transaction {
60
struct
coap_transaction *next;
/* for LIST */
61
62
uint16_t mid;
63
coap_timer_t retrans_timer;
64
uint32_t retrans_interval;
65
uint8_t retrans_counter;
66
67
coap_endpoint_t endpoint;
68
69
coap_resource_response_handler_t callback;
70
void
*callback_data;
71
72
uint16_t message_len;
73
uint8_t message[
COAP_MAX_PACKET_SIZE
+ 1];
/* +1 for the terminating '\0' which will not be sent
74
* Use snprintf(buf, len+1, "", ...) to completely fill payload */
75
} coap_transaction_t;
76
77
coap_transaction_t *coap_new_transaction(uint16_t mid,
const
coap_endpoint_t *ep);
78
void
coap_send_transaction(coap_transaction_t *t);
79
void
coap_clear_transaction(coap_transaction_t *t);
80
coap_transaction_t *coap_get_transaction_by_mid(uint16_t mid);
81
82
#endif
/* COAP_TRANSACTIONS_H_ */
83
/** @} */
coap-engine.h
CoAP engine implementation.
coap-timer.h
CoAP timer API.
coap.h
An implementation of the Constrained Application Protocol (RFC 7252).
COAP_MAX_PACKET_SIZE
#define COAP_MAX_PACKET_SIZE
The max size of the CoAP messages.
Definition
coap.h:60
os
net
app-layer
coap
coap-transactions.h
Generated on
for Contiki-NG by
1.17.0