automotive-dlt
|
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <syslog.h>
#include <dlt_shm.h>
#include <dlt_common.h>
Go to the source code of this file.
Functions | |
void | dlt_shm_print_hex (char *ptr, int size) |
void | dlt_shm_pv (int id, int operation) |
int | dlt_shm_init_server (DltShm *buf, int key, int size) |
DltReturnValue | dlt_shm_init_client (DltShm *buf, int key) |
void | dlt_shm_info (DltShm *buf) |
void | dlt_shm_status (DltShm *buf) |
int | dlt_shm_get_total_size (DltShm *buf) |
int | dlt_shm_get_used_size (DltShm *buf) |
int | dlt_shm_get_message_count (DltShm *buf) |
int | dlt_shm_push (DltShm *buf, const unsigned char *data1, unsigned int size1, const unsigned char *data2, unsigned int size2, const unsigned char *data3, unsigned int size3) |
int | dlt_shm_pull (DltShm *buf, unsigned char *data, int max_size) |
int | dlt_shm_copy (DltShm *buf, unsigned char *data, int max_size) |
int | dlt_shm_remove (DltShm *buf) |
DltReturnValue | dlt_shm_free_server (DltShm *buf) |
DltReturnValue | dlt_shm_free_client (DltShm *buf) |
Definition in file dlt_shm.c.
int dlt_shm_copy | ( | DltShm * | buf, |
unsigned char * | data, | ||
int | size | ||
) |
Copy message from shm. This function should be called from server. Data is not deleted from shm after this call.
buf | pointer to shm structure |
data | pointer to buffer where data is to be written |
size | maximum size to be written into buffer |
Definition at line 248 of file dlt_shm.c.
References DltShm::buffer, dlt_buffer_copy(), DLT_SHM_SEM_FREE, DLT_SHM_SEM_GET, DltBuffer::mem, and DltShm::semid.
Referenced by dlt_daemon_process_user_message_log().
DltReturnValue dlt_shm_free_client | ( | DltShm * | buf | ) |
Deinitialise the shared memory on the client side.
buf | pointer to shm structure |
Definition at line 303 of file dlt_shm.c.
References DltShm::buffer, dlt_buffer_free_static(), dlt_log(), DLT_RETURN_ERROR, DltShm::semid, DltBuffer::shm, and DltShm::shmid.
Referenced by dlt_free(), and dlt_user_log_send_log().
DltReturnValue dlt_shm_free_server | ( | DltShm * | buf | ) |
Deinitialise the shared memory on the server side.
buf | pointer to shm structure |
Definition at line 278 of file dlt_shm.c.
References DltShm::buffer, dlt_buffer_free_static(), dlt_log(), DLT_RETURN_ERROR, NULL, DltShm::semid, DltBuffer::shm, and DltShm::shmid.
Referenced by dlt_daemon_local_cleanup().
int dlt_shm_get_message_count | ( | DltShm * | buf | ) |
Returns the number of messages in the shm.
buf | pointer to shm structure |
Definition at line 213 of file dlt_shm.c.
References DltShm::buffer, and dlt_buffer_get_message_count().
int dlt_shm_get_total_size | ( | DltShm * | buf | ) |
Returns the total size of the shm.
buf | pointer to shm structure |
Definition at line 193 of file dlt_shm.c.
References DltShm::buffer, and dlt_buffer_get_total_size().
Referenced by dlt_user_check_buffer().
int dlt_shm_get_used_size | ( | DltShm * | buf | ) |
Returns the used size in the shm.
buf | pointer to shm structure |
Definition at line 198 of file dlt_shm.c.
References DltShm::buffer, dlt_buffer_get_used_size(), DLT_SHM_SEM_FREE, DLT_SHM_SEM_GET, DltBuffer::mem, and DltShm::semid.
Referenced by dlt_user_check_buffer().
void dlt_shm_info | ( | DltShm * | buf | ) |
Print information about shm.
buf | pointer to shm structure |
Definition at line 183 of file dlt_shm.c.
References DltShm::buffer, and dlt_buffer_info().
DltReturnValue dlt_shm_init_client | ( | DltShm * | buf, |
int | key | ||
) |
Initialise the shared memory on the client side. This function must be called before using further shm functions.
buf | pointer to shm structure |
key | the identifier of the shm, must be the same for server and client |
Definition at line 144 of file dlt_shm.c.
References DltShm::buffer, dlt_buffer_init_static_client(), dlt_log(), DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_SHM_SEM, NULL, DltShm::semid, and DltShm::shmid.
Referenced by dlt_init(), and dlt_user_log_reattach_to_daemon().
int dlt_shm_init_server | ( | DltShm * | buf, |
int | key, | ||
int | size | ||
) |
Initialise the shared memory on the server side. This function must be called before using further shm functions.
buf | pointer to shm structure |
key | the identifier of the shm, must be the same for server and client |
size | the requested size of the shm |
Definition at line 99 of file dlt_shm.c.
References DltShm::buffer, dlt_buffer_init_static_server(), dlt_log(), DLT_RETURN_ERROR, DLT_RETURN_OK, DLT_SHM_SEM, NULL, DltShm::semid, and DltShm::shmid.
Referenced by dlt_daemon_local_init_p2().
int dlt_shm_pull | ( | DltShm * | buf, |
unsigned char * | data, | ||
int | size | ||
) |
Pull data from shm. This function should be called from client. Data is deleted from shm after this call.
buf | pointer to shm structure |
data | pointer to buffer where data is to be written |
size | maximum size to be written into buffer |
Definition at line 233 of file dlt_shm.c.
References DltShm::buffer, dlt_buffer_pull(), DLT_SHM_SEM_FREE, DLT_SHM_SEM_GET, DltBuffer::mem, and DltShm::semid.
int dlt_shm_push | ( | DltShm * | buf, |
const unsigned char * | data1, | ||
unsigned int | size1, | ||
const unsigned char * | data2, | ||
unsigned int | size2, | ||
const unsigned char * | data3, | ||
unsigned int | size3 | ||
) |
Push data from client onto the shm.
buf | pointer to shm structure |
data1 | pointer to first data block to be written, null if not used |
size1 | size in bytes of first data block to be written, 0 if not used |
data2 | pointer to second data block to be written, null if not used |
size2 | size in bytes of second data block to be written, 0 if not used |
data3 | pointer to third data block to be written, null if not used |
size3 | size in bytes of third data block to be written, 0 if not used |
Definition at line 218 of file dlt_shm.c.
References DltShm::buffer, dlt_buffer_push3(), DLT_SHM_SEM_FREE, DLT_SHM_SEM_GET, DltBuffer::mem, and DltShm::semid.
Referenced by dlt_user_log_resend_buffer(), and dlt_user_log_send_log().
void dlt_shm_pv | ( | int | id, |
int | operation | ||
) |
int dlt_shm_remove | ( | DltShm * | buf | ) |
Delete message from shm. This function should be called from server. This function should be called after each succesful copy.
buf | pointer to shm structure |
Definition at line 263 of file dlt_shm.c.
References DltShm::buffer, dlt_buffer_remove(), DLT_SHM_SEM_FREE, DLT_SHM_SEM_GET, DltBuffer::mem, and DltShm::semid.
Referenced by dlt_daemon_process_user_message_log().
void dlt_shm_status | ( | DltShm * | buf | ) |
Print status about shm.
buf | pointer to shm structure |
Definition at line 188 of file dlt_shm.c.
References DltShm::buffer, and dlt_buffer_status().