Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Byte alignment improvement #329

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions include/coap2/async.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,26 @@
* the option @c observe.
*/
typedef struct coap_async_state_t {
unsigned char flags; /**< holds the flags to control behaviour */

/**
* Holds the internal time when the object was registered with a
* resource. This field will be updated whenever
* coap_register_async() is called for a specific resource.
*/
coap_tick_t created;

/**
* This field can be used to register opaque application data with the
* asynchronous state object.
*/
void *appdata;
uint16_t message_id; /**< id of last message seen */
coap_session_t *session; /**< transaction session */
coap_tid_t id; /**< transaction id */
struct coap_async_state_t *next; /**< internally used for linking */
size_t tokenlen; /**< length of the token */
uint8_t token[8]; /**< the token to use in a response */
/**
* Holds the internal time when the object was registered with a
* resource. This field will be updated whenever
* coap_register_async() is called for a specific resource.
*/
coap_tick_t created;
coap_tid_t id; /**< transaction id */
uint16_t message_id; /**< id of last message seen */
unsigned char flags; /**< holds the flags to control behaviour */
} coap_async_state_t;

/* Definitions for Async Status Flags These flags can be used to control the
Expand Down
30 changes: 15 additions & 15 deletions include/coap2/coap_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,19 @@ typedef uint8_t coap_session_state_t;

typedef struct coap_session_t {
struct coap_session_t *next;
coap_proto_t proto; /**< protocol used */
coap_session_type_t type; /**< client or server side socket */
coap_session_state_t state; /**< current state of relationaship with peer */
unsigned ref; /**< reference count from queues */
unsigned tls_overhead; /**< overhead of TLS layer */
unsigned mtu; /**< path or CSM mtu */
coap_address_t local_if; /**< optional local interface address */
coap_address_t remote_addr; /**< remote address and port */
coap_address_t local_addr; /**< local address and port */
int ifindex; /**< interface index */
coap_socket_t sock; /**< socket object for the session, if any */
coap_session_type_t type; /**< client or server side socket */
coap_session_state_t state; /**< current state of relationaship with peer */
struct coap_endpoint_t *endpoint; /**< session's endpoint */
struct coap_context_t *context; /**< session's context */
void *tls; /**< security parameters */
uint16_t tx_mid; /**< the last message id that was used in this session */
uint8_t con_active; /**< Active CON request sent */
struct coap_queue_t *delayqueue; /**< list of delayed messages waiting to be sent */
size_t partial_write; /**< if > 0 indicates number of bytes already written from the pdu at the head of sendqueue */
uint8_t read_header[8]; /**< storage space for header of incoming message header */
size_t partial_read; /**< if > 0 indicates number of bytes already read for an incoming message */
uint8_t read_header[8]; /**< storage space for header of incoming message header */
coap_pdu_t *partial_pdu; /**< incomplete incoming pdu */
coap_tick_t last_rx_tx;
coap_tick_t last_tx_rst;
Expand All @@ -86,11 +79,18 @@ typedef struct coap_session_t {
uint8_t *psk_key;
size_t psk_key_len;
void *app; /**< application-specific data */
unsigned int max_retransmit; /**< maximum re-transmit count (default 4) */
coap_fixed_point_t ack_timeout; /**< timeout waiting for ack (default 2 secs) */
coap_fixed_point_t ack_random_factor; /**< ack random factor backoff (default 1.5) */
unsigned ref; /**< reference count from queues */
unsigned tls_overhead; /**< overhead of TLS layer */
unsigned mtu; /**< path or CSM mtu */
unsigned int max_retransmit; /**< maximum re-transmit count (default 4) */
unsigned int dtls_timeout_count; /**< dtls setup retry counter */
int dtls_event; /**< Tracking any (D)TLS events on this sesison */
int ifindex; /**< interface index */
uint16_t tx_mid; /**< the last message id that was used in this session */
uint8_t con_active; /**< Active CON request sent */
coap_proto_t proto; /**< protocol used */
} coap_session_t;

/**
Expand Down Expand Up @@ -301,12 +301,12 @@ coap_session_delay_pdu(coap_session_t *session, coap_pdu_t *pdu,
typedef struct coap_endpoint_t {
struct coap_endpoint_t *next;
struct coap_context_t *context; /**< endpoint's context */
coap_proto_t proto; /**< protocol used on this interface */
uint16_t default_mtu; /**< default mtu for this interface */
coap_socket_t sock; /**< socket object for the interface, if any */
coap_address_t bind_addr; /**< local interface address */
coap_session_t *sessions; /**< list of active sessions */
coap_address_t bind_addr; /**< local interface address */
coap_session_t hello; /**< special session of DTLS hello messages */
coap_socket_t sock; /**< socket object for the interface, if any */
uint16_t default_mtu; /**< default mtu for this interface */
coap_proto_t proto; /**< protocol used on this interface */
} coap_endpoint_t;

/**
Expand Down
35 changes: 17 additions & 18 deletions include/coap2/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ struct coap_queue_t;
*/
typedef struct coap_queue_t {
struct coap_queue_t *next;
coap_session_t *session; /**< the CoAP session */
coap_pdu_t *pdu; /**< the CoAP PDU to send */
coap_tick_t t; /**< when to send PDU for the next time */
unsigned char retransmit_cnt; /**< retransmission counter, will be removed
* when zero */
unsigned int timeout; /**< the randomized timeout value */
coap_session_t *session; /**< the CoAP session */
coap_tid_t id; /**< CoAP transaction id */
coap_pdu_t *pdu; /**< the CoAP PDU to send */
unsigned char retransmit_cnt; /**< retransmission counter, will be removed
* when zero */
} coap_queue_t;

/**
Expand Down Expand Up @@ -172,19 +172,6 @@ typedef struct coap_context_t {
struct etimer notify_timer; /**< used to check resources periodically */
#endif /* WITH_CONTIKI */

#ifdef WITH_LWIP
uint8_t timer_configured; /**< Set to 1 when a retransmission is
* scheduled using lwIP timers for this
* context, otherwise 0. */
#endif /* WITH_LWIP */

/**
* The last message id that was used is stored in this field. The initial
* value is set by coap_new_context() and is usually a random value. A new
* message id can be created with coap_new_message_id().
*/
uint16_t message_id;

coap_response_handler_t response_handler;
coap_nack_handler_t nack_handler;
coap_ping_handler_t ping_handler;
Expand All @@ -209,14 +196,26 @@ typedef struct coap_context_t {
size_t psk_hint_len;
uint8_t *psk_key;
size_t psk_key_len;
void *app; /**< application-specific data */

unsigned int session_timeout; /**< Number of seconds of inactivity after which an unused session will be closed. 0 means use default. */
unsigned int max_idle_sessions; /**< Maximum number of simultaneous unused sessions per endpoint. 0 means no maximum. */
unsigned int max_handshake_sessions; /**< Maximum number of simultaneous negotating sessions per endpoint. 0 means use default. */
unsigned int ping_timeout; /**< Minimum inactivity time before sending a ping message. 0 means disabled. */
unsigned int csm_timeout; /**< Timeout for waiting for a CSM from the remote side. 0 means disabled. */

/**
* The last message id that was used is stored in this field. The initial
* value is set by coap_new_context() and is usually a random value. A new
* message id can be created with coap_new_message_id().
*/
uint16_t message_id;
#ifdef WITH_LWIP
uint8_t timer_configured; /**< Set to 1 when a retransmission is
* scheduled using lwIP timers for this
* context, otherwise 0. */
#endif /* WITH_LWIP */

void *app; /**< application-specific data */
} coap_context_t;

/**
Expand Down