reactor-c
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
net_util.h
Go to the documentation of this file.
1
38#ifndef NET_UTIL_H
39#define NET_UTIL_H
40
41#ifdef PLATFORM_ARDUINO
42#error To be implemented. No support for federation on Arduino yet.
43#else
44#include <sys/socket.h>
45#include <regex.h>
46#endif
47
48#include <sys/types.h>
49#include <stdbool.h>
50
51#include "low_level_platform.h"
52#include "tag.h"
53
54#ifdef FEDERATED
55#include "socket_common.h"
56#endif
57
58#define HOST_LITTLE_ENDIAN 1
59#define HOST_BIG_ENDIAN 2
60
65int host_is_big_endian(void);
66
74void encode_int64(int64_t data, unsigned char* buffer);
75
83void encode_int32(int32_t data, unsigned char* buffer);
84
92void encode_uint32(uint32_t data, unsigned char* buffer);
93
101void encode_uint16(uint16_t data, unsigned char* buffer);
102
114int32_t swap_bytes_if_big_endian_int32(int32_t src);
115
127int64_t swap_bytes_if_big_endian_int64(int64_t src);
128
140uint16_t swap_bytes_if_big_endian_uint16(uint16_t src);
141
146int32_t extract_int32(unsigned char* bytes);
147
152int64_t extract_int64(unsigned char* bytes);
153
159uint16_t extract_uint16(unsigned char* bytes);
160
161#ifdef FEDERATED
162
173void extract_header(unsigned char* buffer, uint16_t* port_id, uint16_t* federate_id, size_t* length);
174
187void extract_timed_header(unsigned char* buffer, uint16_t* port_id, uint16_t* federate_id, size_t* length, tag_t* tag);
188
198tag_t extract_tag(unsigned char* buffer);
199
208void encode_tag(unsigned char* buffer, tag_t tag);
209
213typedef struct rti_addr_info_t {
214 char rti_host_str[256];
215 char rti_port_str[6];
216 char rti_user_str[256];
217 bool has_host;
218 bool has_port;
219 bool has_user;
220} rti_addr_info_t;
221
226bool match_regex(const char* str, char* regex);
227
232bool validate_port(char* port);
233
238bool validate_host(const char* host);
239
244bool validate_user(const char* user);
245
250bool extract_match_group(const char* rti_addr, char* dest, regmatch_t group, size_t max_len, size_t min_len,
251 const char* err_msg);
252
257bool extract_match_groups(const char* rti_addr, char** rti_addr_strs, bool** rti_addr_flags, regmatch_t* group_array,
258 int* gids, size_t* max_lens, size_t* min_lens, const char** err_msgs);
259
263void extract_rti_addr_info(const char* rti_addr, rti_addr_info_t* rti_addr_info);
264
265#endif // FEDERATED
266
267#endif /* NET_UTIL_H */
Platform API support for the C target of Lingua Franca.
uint16_t extract_uint16(unsigned char *bytes)
Definition net_util.c:220
uint16_t swap_bytes_if_big_endian_uint16(uint16_t src)
Definition net_util.c:171
int64_t extract_int64(unsigned char *bytes)
Definition net_util.c:210
int32_t extract_int32(unsigned char *bytes)
Definition net_util.c:190
void encode_uint32(uint32_t data, unsigned char *buffer)
Definition net_util.c:69
int64_t swap_bytes_if_big_endian_int64(int64_t src)
Definition net_util.c:143
int host_is_big_endian(void)
Definition net_util.c:85
void encode_int64(int64_t data, unsigned char *buffer)
Definition net_util.c:50
int32_t swap_bytes_if_big_endian_int32(int32_t src)
Definition net_util.c:99
void encode_uint16(uint16_t data, unsigned char *buffer)
Definition net_util.c:78
void encode_int32(int32_t data, unsigned char *buffer)
Definition net_util.c:60
Definition tag.h:78
Time and tag definitions and functions for Lingua Franca.
char buffer[BUFFER_SIZE]
Definition trace_util.c:42