libcoap 4.3.4-develop-e521eab
WebSockets Support

Internal API for WebSockets Support (RFC8323) More...

+ Collaboration diagram for WebSockets Support:

Data Structures

struct  coap_ws_state_t
 WebSockets session state. More...
 

Macros

#define COAP_MAX_FS   (2 + 8 + 4)
 
#define WS_B0_FIN_BIT   0x80
 
#define WS_B0_RSV_MASK   0x70
 
#define WS_B0_OP_MASK   0x0f
 
#define WS_B1_MASK_BIT   0x80
 
#define WS_B1_LEN_MASK   0x7f
 

Typedefs

typedef struct coap_ws_state_t coap_ws_state_t
 WebSockets session state. More...
 

Enumerations

enum  coap_ws_opcode_t {
  WS_OP_CONT = 0x0 , WS_OP_TEXT , WS_OP_BINARY , WS_OP_CLOSE = 0x8 ,
  WS_OP_PING , WS_OP_PONG
}
 

Functions

ssize_t coap_ws_write (coap_session_t *session, const uint8_t *data, size_t datalen)
 Function interface for websockets data transmission. More...
 
ssize_t coap_ws_read (coap_session_t *session, uint8_t *data, size_t datalen)
 Function interface for websockets data receiving. More...
 
void coap_ws_establish (coap_session_t *session)
 Layer function interface for layer below WebSockets accept/connect being established. More...
 
void coap_ws_close (coap_session_t *session)
 Layer function interface for WebSockets close for a session. More...
 

Detailed Description

Internal API for WebSockets Support (RFC8323)

Macro Definition Documentation

◆ COAP_MAX_FS

#define COAP_MAX_FS   (2 + 8 + 4)

Definition at line 32 of file coap_ws_internal.h.

◆ WS_B0_FIN_BIT

#define WS_B0_FIN_BIT   0x80

Definition at line 84 of file coap_ws_internal.h.

◆ WS_B0_OP_MASK

#define WS_B0_OP_MASK   0x0f

Definition at line 86 of file coap_ws_internal.h.

◆ WS_B0_RSV_MASK

#define WS_B0_RSV_MASK   0x70

Definition at line 85 of file coap_ws_internal.h.

◆ WS_B1_LEN_MASK

#define WS_B1_LEN_MASK   0x7f

Definition at line 89 of file coap_ws_internal.h.

◆ WS_B1_MASK_BIT

#define WS_B1_MASK_BIT   0x80

Definition at line 88 of file coap_ws_internal.h.

Typedef Documentation

◆ coap_ws_state_t

WebSockets session state.

Enumeration Type Documentation

◆ coap_ws_opcode_t

Enumerator
WS_OP_CONT 
WS_OP_TEXT 
WS_OP_BINARY 
WS_OP_CLOSE 
WS_OP_PING 
WS_OP_PONG 

Definition at line 91 of file coap_ws_internal.h.

Function Documentation

◆ coap_ws_close()

void coap_ws_close ( coap_session_t session)

Layer function interface for WebSockets close for a session.

Parameters
sessionSession to do the WebSockets close on.

◆ coap_ws_establish()

void coap_ws_establish ( coap_session_t session)

Layer function interface for layer below WebSockets accept/connect being established.

This function initiates the WebSockets layer.

If this layer is properly established on invocation, then the next layer must get called by calling session->lfunc[COAP_LAYER_WS].establish(session) (or done at any point when WebSockets is established).

Parameters
sessionSession that the lower layer accept/connect was done on.

◆ coap_ws_read()

ssize_t coap_ws_read ( coap_session_t session,
uint8_t *  data,
size_t  datalen 
)

Function interface for websockets data receiving.

This function returns the number of bytes that have been read, or a value less than zero on error. The number of bytes read may be less than datalen because of congestion control.

Parameters
sessionSession to receive data on.
dataThe data to receive.
datalenThe maximum length of data.
Returns
The number of bytes read on success, or a value less than zero on error.

◆ coap_ws_write()

ssize_t coap_ws_write ( coap_session_t session,
const uint8_t *  data,
size_t  datalen 
)

Function interface for websockets data transmission.

This function returns the number of bytes that have been transmitted, or a value less than zero on error. The number of bytes written may be less than datalen because of congestion control.

Parameters
sessionSession to send data on.
dataThe data to send.
datalenThe actual length of data.
Returns
The number of bytes written on success, or a value less than zero on error.