Generic communication module.
More...
#include <sys/types.h>
#include <inttypes.h>
#include <pthread.h>
#include <stdarg.h>
Go to the source code of this file.
|
enum | comm_mode_enum { COMM_MODE_IPUT = 0,
COMM_MODE_OPUT,
COMM_MODE_MAX
} |
|
|
int | comm_module_open (log_ctx_t *log_ctx) |
|
void | comm_module_close () |
|
int | comm_module_opt (const char *tag,...) |
|
comm_ctx_t * | comm_open (const char *url, const char *local_url, comm_mode_t comm_mode, log_ctx_t *log_ctx,...) |
|
void | comm_close (comm_ctx_t **ref_comm_ctx) |
|
int | comm_send (comm_ctx_t *comm_ctx, const void *buf, size_t count, struct timeval *timeout) |
|
int | comm_recv (comm_ctx_t *comm_ctx, void **ref_buf, size_t *ref_count, char **ref_from, struct timeval *timeout) |
|
int | comm_unblock (comm_ctx_t *comm_ctx) |
|
int | comm_open_external (pthread_mutex_t *comm_ctx_mutex_external, const char *url, const char *local_url, comm_mode_t comm_mode, log_ctx_t *log_ctx, comm_ctx_t **ref_comm_ctx,...) |
|
void | comm_close_external (pthread_mutex_t *comm_ctx_mutex_external, comm_ctx_t **ref_comm_ctx, log_ctx_t *log_ctx) |
|
int | comm_reset_external (pthread_mutex_t *comm_ctx_mutex_external, const char *new_url, const char *local_url, comm_mode_t comm_mode, log_ctx_t *log_ctx, comm_ctx_t **ref_comm_ctx_curr,...) |
|
int | comm_recv_external (pthread_mutex_t *comm_ctx_mutex_external, comm_ctx_t **ref_comm_ctx, void **ref_buf, size_t *ref_count, char **ref_from, struct timeval *timeout, log_ctx_t *log_ctx) |
|
Generic communication module.
- Author
- Rafael Antoniello
Definition in file comm.h.
Communication module instance context structure ('handler').
Definition at line 48 of file comm.h.
Communication protocol interface structure prototype. Each specific communication module implementation will define a static and unambiguous interface of this type.
Indicates the communication module instance mode: input or output.
Indicates the communication module instance mode: input or output.
Definition at line 53 of file comm.h.
void comm_module_close |
( |
| ) |
|
Close communication module. This is a global function and should be called only once at the end of the life of the application.
Definition at line 129 of file comm.c.
Open communication module. This is a global function and should be called only once at the very beginning and during the life of the application.
- Parameters
-
log_ctx | Pointer to a externally defined LOG module context structure. |
- Returns
- Status code (STAT_SUCCESS code in case of success, for other code values please refer to .stat_codes.h).
Definition at line 101 of file comm.c.
int comm_module_opt |
( |
const char * |
tag, |
|
|
|
... |
|
) |
| |
Communication module options. This function represents the API of the communication module. This function is thread-safe and can be called concurrently.
- Parameters
-
tag | Option tag, namely, option identifier string. The following options are available:
- "COMM_REGISTER_PROTO"
- "COMM_UNREGISTER_PROTO"
|
... | Variable list of parameters according to selected option. Refer to Tags description below to see the different additional parameters corresponding to each option tag. |
- Returns
- Status code (STAT_SUCCESS code in case of success, for other code values please refer to .stat_codes.h).
Tags description (additional variable arguments per tag)
-
Tag "COMM_REGISTER_PROTO":
Register the interface of an specific communication protocol.
Additional variable arguments for function comm_module_opt() are:
- Parameters
-
comm_if | Pointer to the protocol interface structure (static and unambiguous interface implementation of the type 'comm_if_t'). Code example: 2 const comm_if_t comm_if_udp= { 11 ret_code= comm_module_opt("COMM_REGISTER_PROTO", &comm_if_udp); |
-
Tag "COMM_UNREGISTER_PROTO":
Unregister the interface of an specific communication protocol.
Additional variable arguments for function comm_module_opt() are:
- Parameters
-
scheme | Pointer to a character string with the unambiguous protocol scheme name (for example: "udp", "file", ...). Code example: 1 ret_code= comm_module_opt("COMM_UNREGISTER_PROTO", "udp"); |
Definition at line 150 of file comm.c.