|
Robotran C Documentation
|
double NRerr
Definition: mbs_aux.h:24
#define MAX_FRAME_LENGTH
Maximum frame/message length.
Definition: ws.h:58
double * bp
Vector (index starting at 1) of size [Ncons] (or NULL if Ncons==0).
Definition: mbs_aux.h:58
double * BtFv
Definition: mbs_aux.h:71
int ws_sendframe_txt_bcast(uint16_t port, const char *msg)
Sends a broadcast WebSocket text frame.
Definition: ws.c:828
static int next_byte(struct ws_frame_data *wfd)
Read a chunk of bytes and return the next byte belonging to the frame.
Definition: ws.c:1127
double ** mJv
Array (index starting at 1) of size [Ncons x nqv] (or NULL if Ncons==0).
Definition: mbs_aux.h:33
void * ws_get_connection_context(ws_cli_conn_t *cli)
Get connection context.
Definition: ws.c:120
@ shaSuccess
Definition: sha1.h:35
#define TIMEOUT_MS
Timeout in milliseconds.
Definition: ws.h:202
#define UTF8_REJECT
Definition: utf8.h:31
double ** BtMvv
Array (index starting at 1) of size [(nqu + nqc) x nqv].
Definition: mbs_aux.h:70
struct ws_server ws_srv
Definition: ws.c:1765
struct ws_server ws_srv
Definition: ws.c:76
static void * ws_establishconnection(void *vclient)
Establishes to connection with the client and trigger events when occurs one.
Definition: ws.c:1684
#define MAGIC_STRING
Magic string.
Definition: ws.h:74
unsigned char * msg_data
Definition: ws.c:1180
static uint32_t timeout
Timeout to a single send().
Definition: ws.c:133
double norm_h
Definition: mbs_aux.h:23
double * Qc
Vector (index starting at 1) of size [nqc].
Definition: mbs_aux.h:35
size_t cur_pos
Current byte position.
Definition: ws.c:163
double ** Mr
Array (index starting at 1) of size [nqu x nqu].
Definition: mbs_aux.h:76
int is_utf8_len(uint8_t *s, size_t len)
Definition: utf8.c:70
int MAX_NR_ITER
max number of iteration for NR procedure
Definition: mbs_aux.h:25
static void set_client_address(ws_cli_conn_t *client)
Sets the IP address relative to a client connection opened by the server and save inside the client s...
Definition: ws.c:445
int * ind_Jvt
Definition: mbs_aux.h:49
int * ind_mJv
Vector (index starting at 1) of size [Ncons] (or NULL if Ncons==0).
Definition: mbs_aux.h:34
int ws_sendframe_bin_bcast(uint16_t port, const char *msg, uint64_t size)
Sends a broadcast WebSocket binary frame.
Definition: ws.c:856
static int ws_sendframe_internal(ws_cli_conn_t *client, const char *msg, uint64_t size, int type, uint16_t port)
Creates and send an WebSocket frame with some payload data.
Definition: ws.c:522
double * jdqduserc
Definition: mbs_aux.h:56
int get_handshake_response(char *hsrequest, char **hsresponse)
Gets the complete response to accomplish a succesfully handshake.
Definition: handshake.c:87
pthread_t thrd_tout
Definition: ws.c:81
#define SHA1CircularShift(bits, word)
Definition: sha1.c:37
int Computed
Definition: sha1.h:58
uint8_t masks_ctrl[4]
Definition: ws.c:1183
uint64_t msg_idx_data
Definition: ws.c:1184
unsigned char * msg_ctrl
Definition: ws.c:1181
void * connection_context
Definition: ws.c:97
#define MS_TO_NS(x)
Nanoseconds macro converter.
Definition: ws.h:198
#define RECV(fd, buf, len)
Definition: ws.h:221
int * qrot_qv_indvec
vec [ivec_1, njoint] containing 1 or 0, depending on the nature of the joint : if rotational AND qv =...
Definition: mbs_aux.h:53
unsigned char msg_ctrl[125]
Control frame payload.
Definition: ws.c:159
uint8_t masks_data[4]
Definition: ws.c:1182
#define WS_FR_OP_PING
Ping frame.
Definition: ws.h:138
static int do_pong(struct ws_frame_data *wfd, uint64_t frame_size)
Send a pong frame in response to a ping frame.
Definition: ws.c:1104
int state
WebSocket current state.
Definition: ws.c:73
int * iquc
Definition: mbs_aux.h:40
uint32_t is_utf8_len_state(uint8_t *s, size_t len, uint32_t state)
Definition: utf8.c:80
static const uint8_t utf8d[]
Copyright (c) 2008-2009 Bjoern Hoehrmann bjoern@hoehrmann.de
Definition: utf8.c:32
static ws_cli_conn_t * client
Definition: visu_websocket.cc:49
#define WS_STATE_CONNECTING
Connection not established yet.
Definition: ws.h:176
#define MESSAGE_LENGTH
Message buffer length.
Definition: ws.h:54
static void * ws_accept(void *data)
Main loop that keeps accepting new connections.
Definition: ws.c:1780
Accept parameters.
Definition: ws.c:1762
void * ws_get_server_context(ws_cli_conn_t *cli)
Get server context.
Definition: ws.c:104
int nquc
store nqu+nqc
Definition: mbs_aux.h:39
static void int32_to_ping_msg(int32_t ping_id, uint8_t *msg)
Given a PING id, encodes the content to be sent as payload of a PING frame.
Definition: ws.c:711
#define WS_STATE_CLOSING
Closing state.
Definition: ws.h:184
int SHA1Input(SHA1Context *, const uint8_t *, unsigned int)
static struct ws_connection client_socks[MAX_CLIENTS]
Clients list.
Definition: ws.c:128
double ** BtMvu
Definition: mbs_aux.h:69
uint64_t frame_length
Definition: ws.c:1186
double * MBMb
Vectors (index starting at 1) of size [nqu].
Definition: mbs_aux.h:71
uint64_t frame_size
Definition: ws.c:1187
static int32_t pong_msg_to_int32(uint8_t *msg)
Given a PONG message, decodes the content as a int32_t number that corresponds to our PONG id.
Definition: ws.c:696
int thread_loop
Whether if the ws_socket() should create a new thread and be non-blocking (1) or not (0).
Definition: ws.h:287
static int skip_frame(struct ws_frame_data *wfd, uint64_t frame_size)
Skips frame_size bytes of the current frame.
Definition: ws.c:1158
char port[32]
Definition: ws.c:89
static int read_single_frame(struct ws_frame_data *wfd, struct frame_state_data *fsd)
Reads the current frame isolating data from control frames.
Definition: ws.c:1359
static void close_socket(int fd)
Shutdown and close a given socket.
Definition: ws.c:211
static int do_handshake(struct ws_frame_data *wfd)
Do the handshake process.
Definition: ws.c:972
void ws_set_connection_context(ws_cli_conn_t *cli, void *ptr)
Set connection context.
Definition: ws.c:112
int * ind_A
Vector (index starting at 1) of size [njoint].
Definition: mbs_aux.h:85
char ip[1025]
Definition: ws.c:88
uint8_t opcode
Definition: ws.c:1192
int SHA1Input(SHA1Context *context, const uint8_t *message_array, unsigned length)
Definition: sha1.c:159
char * ws_getaddress(ws_cli_conn_t *client)
Gets the IP address relative to a client connection opened by the server.
Definition: ws.c:475
int SHA1Reset(SHA1Context *)
Definition: sha1.c:59
#define WS_HS_REQ
Alias for 'Sec-WebSocket-Key'.
Definition: ws.h:84
char * ws_getport(ws_cli_conn_t *client)
Gets the IP port relative to a client connection opened by the server.
Definition: ws.c:493
static void * close_timeout(void *p)
Close time-out thread.
Definition: ws.c:367
double * Qa
Vector (index starting at 1) of size [njoint].
Definition: mbs_aux.h:82
uint64_t frame_size
Frame size.
Definition: ws.c:175
static int handle_pong_frame(struct ws_frame_data *wfd, struct frame_state_data *fsd)
Handle PONG frames in response to our PING (or not, unsolicited is possible too).
Definition: ws.c:1261
int client_sock
Client socket FD.
Definition: ws.c:72
double * Rruc
vector of size [nqu+nqc x 1] that contains the reduced residue for the equations of motions after the...
Definition: mbs_aux.h:95
void SHA1ProcessMessageBlock(SHA1Context *)
Definition: sha1.c:232
double * p_Mr
Vector (index starting at 1) of size [nqu].
Definition: mbs_aux.h:79
uint32_t is_utf8_len_state(uint8_t *s, size_t len, uint32_t state)
Definition: utf8.c:80
MbsSensor * psens
Definition: mbs_aux.h:60
#define WS_HS_ACCEPT
Handshake accept message.
Definition: ws.h:94
#define WS_FIN
Frame FIN.
Definition: ws.h:108
static int validate_utf8_txt(struct ws_frame_data *wfd, struct frame_state_data *fsd)
Validates TXT frames if UTF8 validation is enabled.
Definition: ws.c:1210
uint64_t msg_idx_ctrl
Definition: ws.c:1185
#define UTF8_ACCEPT
Copyright (c) 2008-2009 Bjoern Hoehrmann bjoern@hoehrmann.de
Definition: utf8.h:30
static int do_close(struct ws_frame_data *wfd, int close_code)
Sends a close frame, accordingly with the close_code or the message inside wfd.
Definition: ws.c:1035
int Corrupted
Definition: sha1.h:59
double ** Juserc
Array (index starting at 1) of size [Nuserc x njoint] (or NULL if Nuserc==0).
Definition: mbs_aux.h:32
#define DEBUG(...)
Debug.
Definition: ws.h:215
int ws_sendframe_bin(ws_cli_conn_t *client, const char *msg, uint64_t size)
Sends a WebSocket binary frame.
Definition: ws.c:842
double ** M
Array (index starting at 1) of size [njoint x njoint].
Definition: mbs_aux.h:65
#define WS_HS_ACCLEN
Handshake accept message length.
Definition: ws.h:89
#define SHA1HashSize
Definition: sha1.h:41
static void send_ping_close(ws_cli_conn_t *cli, int threshold, int lock)
Send a ping message and close if the client surpasses the threshold imposed.
Definition: ws.c:731
double * h
Vector (index starting at 1) of size [Ncons] (or NULL if Ncons==0).
Definition: mbs_aux.h:29
uint8_t mask
Definition: ws.c:1194
unsigned char frm[MESSAGE_LENGTH]
Frame read.
Definition: ws.c:151
#define WS_FR_OP_CONT
Continuation frame.
Definition: ws.h:118
uint16_t port
Listening port.
Definition: ws.h:282
double ** A
Array (index starting at 1) of size [nqu x njoint].
Definition: mbs_aux.h:84
int is_utf8(uint8_t *s)
Definition: utf8.c:61
static uint32_t decode(uint32_t *state, uint32_t *codep, uint32_t byte)
Definition: utf8.c:50
void SHA1PadMessage(SHA1Context *)
Definition: sha1.c:343
static int is_valid_frame(int opcode)
Checks is a given opcode opcode is valid or not.
Definition: ws.c:953
double ** BtMB
Arrays (index starting at 1) of size [(nqu + nqc) x (nqu + nqc)].
Definition: mbs_aux.h:69
static const unsigned char base64_table[65]
Definition: base64.c:14
int freeMbsAux(MbsAux *mbs_aux, MbsData *mbs_data)
Free the structure and its content.
Definition: mbs_aux.c:178
double * huserc
Vector (index starting at 1) of size [Nuserc] (or NULL if Nuserc==0).
Definition: mbs_aux.h:31
int ws_get_state(ws_cli_conn_t *client)
For a given client, gets the current state for the connection, or -1 if invalid.
Definition: ws.c:875
double * Fruc
Vector (index starting at 1) of size [nqu + nqc].
Definition: mbs_aux.h:74
double * Jvtlambda
Intermediate array to store and compute lambda.
Definition: mbs_aux.h:45
static void close_client(ws_cli_conn_t *client, int lock)
Close client connection (no close handshake, this should be done earlier), set appropriate state and ...
Definition: ws.c:330
@ shaNull
Definition: sha1.h:36
static int handle_ping_frame(struct ws_frame_data *wfd, struct frame_state_data *fsd)
Handle PING frames sending a PONG response.
Definition: ws.c:1300
int * qrot_qc_indvec
vec [ivec_1, njoint] containing 1 or 0, depending on the nature of the joint : if rotational AND qc =...
Definition: mbs_aux.h:52
double ** Jac
Array (index starting at 1) of size [Ncons x njoint] (or NULL if Ncons==0).
Definition: mbs_aux.h:30
double ** Mruc
Array (index starting at 1) of size [(nqu + nqc) x (nqu + nqc)].
Definition: mbs_aux.h:73
int ws_close_client(ws_cli_conn_t *client)
Close the client connection for the given client with normal close code (1000) and no reason string.
Definition: ws.c:893
int sock
Definition: ws.c:1764
#define WS_FR_OP_CLSE
Close frame.
Definition: ws.h:133
unsigned char * msg
Processed message at the moment.
Definition: ws.c:155
double * w
Vector (index starting at 1) of size [njoint].
Definition: mbs_aux.h:88
int ws_socket(struct ws_server *ws_srv)
Main loop for the server.
Definition: ws.c:1940
int frame_type
Frame type, like text or binary.
Definition: ws.c:171
double * Rred
vector of size [nqu x 1] that contains the reduced residue of the equations of motion after the secon...
Definition: mbs_aux.h:96
int SHA1Result(SHA1Context *context, uint8_t Message_Digest[SHA1HashSize])
Definition: sha1.c:101
static ssize_t send_all(ws_cli_conn_t *client, const void *buf, size_t len, int flags)
Send a given message buf on a socket sockfd.
Definition: ws.c:287
Client socks.
Definition: ws.c:70
double * jdqd
Vector (index starting at 1) of size [Ncons].
Definition: mbs_aux.h:55
#define WS_STATE_OPEN
Communicating.
Definition: ws.h:180
double ** Juct
Definition: mbs_aux.h:41
#define CLIENT_VALID(cli)
Client validity macro.
Definition: ws.c:138
uint32_t Length_Low
Definition: sha1.h:51
int n_iter_close_loop
number of iterations after closing loop procedure in mbs_close_geo
Definition: mbs_aux.h:26
int close_anim
Definition: mbs_aux.h:63
double ** Jvt
Definition: mbs_aux.h:48
#define WS_CLSE_NORMAL
Normal close.
Definition: ws.h:158
int ws_sendframe_bcast(uint16_t port, const char *msg, uint64_t size, int type)
Send an WebSocket frame with some payload data to all clients connected into the same port.
Definition: ws.c:682
MbsAux * initMbsAux(MbsData *mbs_data)
Definition: mbs_aux.c:22
int ws_sendframe_txt(ws_cli_conn_t *client, const char *msg)
Sends a WebSocket text frame.
Definition: ws.c:815
#define WS_KEYMS_LEN
Accept message response length.
Definition: ws.h:70
double * R
vector of size [njoint x 1] that contains R=phi-c; (unconstrained equations of motion for the mbs on ...
Definition: mbs_aux.h:94
ws_cli_conn_t * client
Client connection structure.
Definition: ws.c:183
int error
Error flag, set when a read was not possible.
Definition: ws.c:179
int get_handshake_response(char *hsrequest, char **hsresponse)
Gets the complete response to accomplish a succesfully handshake.
Definition: handshake.c:87
int32_t last_pong_id
Definition: ws.c:92
int32_t pong_id
Definition: ws.c:1191
double * Fr
Vector (index starting at 1) of size [nqu].
Definition: mbs_aux.h:77
int SHA1Reset(SHA1Context *context)
Definition: sha1.c:59
#define WS_MS_LEN
Magic string length.
Definition: ws.h:66
#define MAX_CLIENTS
Max clients connected simultaneously.
Definition: ws.h:44
int ws_sendframe(ws_cli_conn_t *client, const char *msg, uint64_t size, int type)
Send an WebSocket frame with some payload data.
Definition: ws.c:663
int get_handshake_accept(char *wsKey, unsigned char **dest)
Gets the field Sec-WebSocket-Accept on response, by an previously informed key.
Definition: handshake.c:47
uint8_t Message_Block[64]
Definition: sha1.h:56
#define WS_KEY_LEN
WebSocket key length.
Definition: ws.h:62
double ** Bvuc
Array (index starting at 1) of size [nqv x nquc] (or NULL if Nuserc==0).
Definition: mbs_aux.h:43
@ shaStateError
Definition: sha1.h:38
static int start_close_timeout(ws_cli_conn_t *client)
For a valid client index client, starts the timeout thread and set the current state to 'CLOSING'.
Definition: ws.c:416
pthread_mutex_t mtx_ping
Definition: ws.c:94
Definition: mbs_data.h:247
uint32_t Intermediate_Hash[SHA1HashSize/4]
Definition: sha1.h:49
static int is_control_frame(int frame)
Checks is a given opcode frame belongs to a control frame or not.
Definition: ws.c:937
static int get_client_state(ws_cli_conn_t *client)
Returns the current client state for a given client client.
Definition: ws.c:232
#define SEND(client, buf, len)
Definition: ws.h:220
int_least16_t Message_Block_Index
Definition: sha1.h:55
wsServer constants and functions.
double * mJv_h
Value of the independant constraints ( )
Definition: mbs_aux.h:37
Definition: mbs_sensor_struct.h:18
uint32_t timeout_ms
Ping timeout in milliseconds.
Definition: ws.h:291
unsigned char * base64_decode(const unsigned char *src, size_t len, size_t *out_len)
base64_decode - Base64 decode @src: Data to be decoded @len: Length of the data to be decoded @out_le...
Definition: base64.c:97
double * c
Vector (index starting at 1) of size [njoint].
Definition: mbs_aux.h:66
#define WS_STATE_CLOSED
Closed.
Definition: ws.h:188
double * phi
vector of size [njoint x 1] that contains the results of symbolic file invdyna.
Definition: mbs_aux.h:93
WebSocket frame data.
Definition: ws.c:146
int * compute_Qc_vec
Vector (index starting at 1) of size [njoint].
Definition: mbs_aux.h:80
#define WS_FR_OP_BIN
Binary frame.
Definition: ws.h:128
bool close_thrd
Definition: ws.c:82
double * q_save
Vector (index starting at 1) of size [njoint].
Definition: mbs_aux.h:62
int * qrot_qu_indvec
vec [ivec_1, njoint] containing 1 or 0, depending on the nature of the joint : if rotational AND qu =...
Definition: mbs_aux.h:51
#define WS_FIN_SHIFT
Frame FIN shift.
Definition: ws.h:113
#define WS_FR_OP_TXT
Text frame.
Definition: ws.h:123
static int set_client_state(ws_cli_conn_t *client, int state)
Set a state state to the client index client.
Definition: ws.c:257
double ** v
Array (index starting at 1) of size [njoint x njoint].
Definition: mbs_aux.h:90
events Web Socket events types.
Definition: ws.h:252
int32_t current_ping_id
Definition: ws.c:93
double * F
vector of size [njoint] that containts c(q,qd)-Q(q,qd)
Definition: mbs_aux.h:67
#define WS_FR_OP_PONG
Pong frame.
Definition: ws.h:143
static int handle_close_frame(struct ws_frame_data *wfd, struct frame_state_data *fsd)
Handle close frames while checking for UTF8 in the close reason.
Definition: ws.c:1323
#define WS_CLSE_PROTERR
Protocol error.
Definition: ws.h:162
uint8_t is_fin
Definition: ws.c:1193
static int next_complete_frame(struct ws_frame_data *wfd)
Reads the next frame, whether if a TXT/BIN/CLOSE of arbitrary size.
Definition: ws.c:1514
void ws_ping(ws_cli_conn_t *cli, int threshold)
Sends a PING frame to the client cli with threshold threshold.
Definition: ws.c:783
pthread_cond_t cnd_state_close
Definition: ws.c:80
#define panic(s)
Issues an error message and aborts the program.
Definition: ws.c:196
pthread_mutex_t mtx_state
Definition: ws.c:79
unsigned char * base64_encode(const unsigned char *src, size_t len, size_t *out_len)
base64_encode - Base64 encode @src: Data to be encoded @len: Length of the data to be encoded @out_le...
Definition: base64.c:29
int cur_byte
Definition: ws.c:1195
Frame state data.
Definition: ws.c:1178
uint32_t Length_High
Definition: sha1.h:52
server Web Socket server parameters
Definition: ws.h:273
const char * host
Required hostname that the wsServer will bind to.
Definition: ws.h:278
size_t amt_read
Amount of read bytes.
Definition: ws.c:167
static int do_bind_socket(struct ws_server *ws_srv)
By using the server parameters provided in ws_srv, create a socket and bind it accordingly with the s...
Definition: ws.c:1877
double * b
Vector (index starting at 1) of size [njoint].
Definition: mbs_aux.h:86
#define WS_CLSE_INVUTF8
Inconsistent message (invalid utf-8)
Definition: ws.h:167
int is_utf8_len(uint8_t *s, size_t len)
Definition: utf8.c:70
pthread_mutex_t mtx_snd
Definition: ws.c:85
unsigned char * base64_encode(const unsigned char *src, size_t len, size_t *out_len)
base64_encode - Base64 encode @src: Data to be encoded @len: Length of the data to be encoded @out_le...
Definition: base64.c:29
static pthread_mutex_t mutex
Global mutex.
Definition: ws.c:189
int SHA1Result(SHA1Context *, uint8_t Message_Digest[SHA1HashSize])
Definition: sha1.c:101