reactor-c 1.0
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
net_util.h File Reference

Network utility functions for Lingua Franca programs. More...

#include <sys/socket.h>
#include <regex.h>
#include <sys/types.h>
#include <stdbool.h>
#include "low_level_platform.h"
#include "tag.h"
#include "socket_common.h"

Go to the source code of this file.

Data Structures

struct  rti_addr_info_t
 A helper struct for passing rti_addr information between lf_parse_rti_addr and extract_rti_addr_info. More...

Macros

#define HOST_BIG_ENDIAN   2
#define HOST_LITTLE_ENDIAN   1

Typedefs

typedef struct rti_addr_info_t rti_addr_info_t
 A helper struct for passing rti_addr information between lf_parse_rti_addr and extract_rti_addr_info.

Functions

void encode_int32 (int32_t data, unsigned char *buffer)
 Write the specified data as a sequence of bytes starting at the specified address.
void encode_int64 (int64_t data, unsigned char *buffer)
 Write the specified data as a sequence of bytes starting at the specified address.
void encode_tag (unsigned char *buffer, tag_t tag)
 Encode tag information into buffer.
void encode_uint16 (uint16_t data, unsigned char *buffer)
 Write the specified data as a sequence of bytes starting at the specified address.
void encode_uint32 (uint32_t data, unsigned char *buffer)
 Write the specified data as a sequence of bytes starting at the specified address.
void extract_header (unsigned char *buffer, uint16_t *port_id, uint16_t *federate_id, size_t *length)
 Extract the core header information that all messages between federates share.
int32_t extract_int32 (unsigned char *bytes)
 This will swap the order of the bytes if this machine is big endian.
int64_t extract_int64 (unsigned char *bytes)
 This will swap the order of the bytes if this machine is big endian.
bool extract_match_group (const char *rti_addr, char *dest, regmatch_t group, size_t max_len, size_t min_len, const char *err_msg)
 Extract one match group from the rti_addr regex .
bool extract_match_groups (const char *rti_addr, char **rti_addr_strs, bool **rti_addr_flags, regmatch_t *group_array, int *gids, size_t *max_lens, size_t *min_lens, const char **err_msgs)
 Extract match groups from the rti_addr regex.
void extract_rti_addr_info (const char *rti_addr, rti_addr_info_t *rti_addr_info)
 Extract the host, port and user from rti_addr.
tag_t extract_tag (unsigned char *buffer)
 Extract tag information from buffer.
void extract_timed_header (unsigned char *buffer, uint16_t *port_id, uint16_t *federate_id, size_t *length, tag_t *tag)
 Extract the timed header information for timed messages between federates.
uint16_t extract_uint16 (unsigned char *bytes)
 Extract an uint16_t from the specified byte sequence.
int host_is_big_endian (void)
 Return true (1) if the host is big endian.
bool match_regex (const char *str, char *regex)
 Check whether str matches regex.
int32_t swap_bytes_if_big_endian_int32 (int32_t src)
 If this host is little endian, then reverse the order of the bytes of the argument.
int64_t swap_bytes_if_big_endian_int64 (int64_t src)
 If this host is little endian, then reverse the order of the bytes of the argument.
uint16_t swap_bytes_if_big_endian_uint16 (uint16_t src)
 If this host is little endian, then reverse the order of the bytes of the argument.
bool validate_host (const char *host)
 Check whether host is valid.
bool validate_port (char *port)
 Check whether port is valid.
bool validate_user (const char *user)
 Check whether user is valid.

Detailed Description

Network utility functions for Lingua Franca programs.

Author
Edward A. Lee
Soroush Bateni

Header file for network utility functions for Lingua Franca programs. Note that these functions do not acquire any mutexes. To use them, you must ensure either that only one thread ever sends on each socket and one thread receives on each socket (these two can be the same thread) or that the caller handles mutual exclusion to prevent more than one thread from accessing the socket at a time.

Macro Definition Documentation

◆ HOST_BIG_ENDIAN

#define HOST_BIG_ENDIAN   2

◆ HOST_LITTLE_ENDIAN

#define HOST_LITTLE_ENDIAN   1