automotive-dlt
dlt_shm.c File Reference
#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>
Include dependency graph for dlt_shm.c:

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)
 

Detailed Description

Author
Alexander Wenzel alexa.nosp@m.nder.nosp@m..aw.w.nosp@m.enze.nosp@m.l@bmw.nosp@m..de

Definition in file dlt_shm.c.

Function Documentation

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.

Parameters
bufpointer to shm structure
datapointer to buffer where data is to be written
sizemaximum size to be written into buffer
Returns
negative value if there was an error

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.

Parameters
bufpointer to shm structure
Returns
negative value if there was an error

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.

Parameters
bufpointer to shm structure
Returns
negative value if there was an error

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.

Parameters
bufpointer to shm structure
Returns
size of the shared memory.

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.

Parameters
bufpointer to shm structure
Returns
size of the shared memory.

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.

Parameters
bufpointer to shm structure
Returns
size of the shared memory.

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.

Parameters
bufpointer 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.

Parameters
bufpointer to shm structure
keythe identifier of the shm, must be the same for server and client
Returns
negative value if there was an error

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.

Parameters
bufpointer to shm structure
keythe identifier of the shm, must be the same for server and client
sizethe requested size of the shm
Returns
negative value if there was an error

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().

void dlt_shm_print_hex ( char *  ptr,
int  size 
)

Definition at line 73 of file dlt_shm.c.

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.

Parameters
bufpointer to shm structure
datapointer to buffer where data is to be written
sizemaximum size to be written into buffer
Returns
negative value if there was an error

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.

Parameters
bufpointer to shm structure
data1pointer to first data block to be written, null if not used
size1size in bytes of first data block to be written, 0 if not used
data2pointer to second data block to be written, null if not used
size2size in bytes of second data block to be written, 0 if not used
data3pointer to third data block to be written, null if not used
size3size in bytes of third data block to be written, 0 if not used
Returns
negative value if there was an error

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 
)

Definition at line 87 of file dlt_shm.c.

References dlt_log().

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.

Parameters
bufpointer to shm structure
Returns
negative value if there was an error

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.

Parameters
bufpointer to shm structure

Definition at line 188 of file dlt_shm.c.

References DltShm::buffer, and dlt_buffer_status().