Crinit -- Configurable Rootfs Init
Loading...
Searching...
No Matches
elos-common.h File Reference

(/usr/bin/git 2025-01-08, commit: 2f2c23e)

Implementation file related to elos connection. More...

#include <pthread.h>
#include <safu/common.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include "logio.h"
#include "thrpool.h"
Include dependency graph for elos-common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  crinitElosSession
 
struct  crinitElosEventSource
 
struct  crinitElosEvent
 
struct  crinitElosEventVector
 
struct  crinitElosVirtualTable
 

Macros

#define LIBELOS_SO_FILENAME   "libelos.so.1"
 Elos shared library filename for dlopen()
 
#define CRINIT_ELOS_CONNECTION_RETRIES   10uL
 
#define CRINIT_ELOS_CONNECTION_RETRY_INTERVAL_US   500000
 
#define ELOS_ID_INVALID   0
 Invalid elos event queue ID constant.
 
#define ELOS_CLASSIFICATION_ELOS_MASK   0x00000000FFFFFFFFuLL
 
#define ELOS_CLASSIFICATION_USER_MASK   0x000000FF00000000uLL
 
#define ELOS_CLASSIFICATION_RESERVED_MASK   0xFFFFFF0000000000uLL
 
#define ELOS_CLASSIFICATION_UNDEFINED   0x0000000000000000uLL
 
#define ELOS_CLASSIFICATION_KERNEL   0x0000000000000001uLL
 
#define ELOS_CLASSIFICATION_NETWORK   0x0000000000000002uLL
 
#define ELOS_CLASSIFICATION_SECURITY   0x0000000000000004uLL
 
#define ELOS_CLASSIFICATION_POWER   0x0000000000000008uLL
 
#define ELOS_CLASSIFICATION_STORAGE   0x0000000000000010uLL
 
#define ELOS_CLASSIFICATION_PROCESS   0x0000000000000020uLL
 
#define ELOS_CLASSIFICATION_IPC   0x0000000000000040uLL
 
#define ELOS_CLASSIFICATION_HARDWARE   0x0000000000000080uLL
 
#define ELOS_CLASSIFICATION_ELOS   0x0000000000000100uLL
 
#define ELOS_CLASSIFICATION_PROCESS_ERRORS   0x0000000000000200uLL
 
#define ELOS_CLASSIFICATION_USER_0   0x0000000100000000uLL
 
#define ELOS_CLASSIFICATION_USER_1   0x0000000200000000uLL
 
#define ELOS_CLASSIFICATION_USER_2   0x0000000400000000uLL
 
#define ELOS_CLASSIFICATION_USER_3   0x0000000800000000uLL
 
#define ELOS_CLASSIFICATION_USER_4   0x0000001000000000uLL
 
#define ELOS_CLASSIFICATION_USER_5   0x0000002000000000uLL
 
#define ELOS_CLASSIFICATION_USER_6   0x0000004000000000uLL
 
#define ELOS_CLASSIFICATION_USER_7   0x0000008000000000uLL
 
#define crinitElosTryExec(session, sessionLock, func, err_msg, ...)
 

Typedefs

typedef uint32_t crinitElosEventQueueId_t
 
typedef struct crinitElosSession crinitElosSession_t
 
typedef struct crinitElosEventSource crinitElosEventSource_t
 
typedef enum crinitElosSeverityE_t crinitElosSeverityE_t
 
typedef enum crinitElosEventMessageCodeE_t crinitElosEventMessageCodeE_t
 
typedef struct crinitElosEvent crinitElosEvent_t
 
typedef struct crinitElosEventVector crinitElosEventVector_t
 
typedef struct crinitElosVirtualTable crinitElosVirtualTable_t
 

Enumerations

enum  crinitElosSeverityE_t {
  ELOS_SEVERITY_OFF = 0 , ELOS_SEVERITY_FATAL , ELOS_SEVERITY_ERROR , ELOS_SEVERITY_WARN ,
  ELOS_SEVERITY_INFO , ELOS_SEVERITY_DEBUG , ELOS_SEVERITY_VERBOSE
}
 
enum  crinitElosEventMessageCodeE_t {
  ELOS_MSG_CODE_INFO_LOG = 1102 , ELOS_MSG_CODE_PROCESS_CREATED = 2001 , ELOS_MSG_CODE_PROCESS_EXITED = 2002 , ELOS_MSG_CODE_FILE_OPENED = 2003 ,
  ELOS_MSG_CODE_IPC_NOT_AUTHORIZED = 4001 , ELOS_MSG_CODE_EXIT_FAILURE = 5006
}
 

Functions

int crinitElosInit (void)
 
crinitElosVirtualTable_tcrinitElosGetVTable (void)
 
int crinitElosDisconnect (crinitElosSession_t *session, pthread_mutex_t *sessionLock)
 

Detailed Description

Implementation file related to elos connection.

Header related to elos connection.

Macro Definition Documentation

◆ CRINIT_ELOS_CONNECTION_RETRIES

#define CRINIT_ELOS_CONNECTION_RETRIES   10uL

◆ CRINIT_ELOS_CONNECTION_RETRY_INTERVAL_US

#define CRINIT_ELOS_CONNECTION_RETRY_INTERVAL_US   500000

◆ crinitElosTryExec

#define crinitElosTryExec (   session,
  sessionLock,
  func,
  err_msg,
  ... 
)

Macro to simplify checking for a valid elos session.

Will print an error message and return from the calling function with an error code if the session pointer is either null or the conn.

HINT: This uses a GNU extension of gcc to define a compound statement enclosed in parentheses.

Parameters
sessionElos session to be used.
sessionLockThe session lock.
funcElos function to be called.
err_msgError message to be returned on error.

◆ ELOS_CLASSIFICATION_ELOS

#define ELOS_CLASSIFICATION_ELOS   0x0000000000000100uLL

◆ ELOS_CLASSIFICATION_ELOS_MASK

#define ELOS_CLASSIFICATION_ELOS_MASK   0x00000000FFFFFFFFuLL

◆ ELOS_CLASSIFICATION_HARDWARE

#define ELOS_CLASSIFICATION_HARDWARE   0x0000000000000080uLL

◆ ELOS_CLASSIFICATION_IPC

#define ELOS_CLASSIFICATION_IPC   0x0000000000000040uLL

◆ ELOS_CLASSIFICATION_KERNEL

#define ELOS_CLASSIFICATION_KERNEL   0x0000000000000001uLL

◆ ELOS_CLASSIFICATION_NETWORK

#define ELOS_CLASSIFICATION_NETWORK   0x0000000000000002uLL

◆ ELOS_CLASSIFICATION_POWER

#define ELOS_CLASSIFICATION_POWER   0x0000000000000008uLL

◆ ELOS_CLASSIFICATION_PROCESS

#define ELOS_CLASSIFICATION_PROCESS   0x0000000000000020uLL

◆ ELOS_CLASSIFICATION_PROCESS_ERRORS

#define ELOS_CLASSIFICATION_PROCESS_ERRORS   0x0000000000000200uLL

◆ ELOS_CLASSIFICATION_RESERVED_MASK

#define ELOS_CLASSIFICATION_RESERVED_MASK   0xFFFFFF0000000000uLL

◆ ELOS_CLASSIFICATION_SECURITY

#define ELOS_CLASSIFICATION_SECURITY   0x0000000000000004uLL

◆ ELOS_CLASSIFICATION_STORAGE

#define ELOS_CLASSIFICATION_STORAGE   0x0000000000000010uLL

◆ ELOS_CLASSIFICATION_UNDEFINED

#define ELOS_CLASSIFICATION_UNDEFINED   0x0000000000000000uLL

◆ ELOS_CLASSIFICATION_USER_0

#define ELOS_CLASSIFICATION_USER_0   0x0000000100000000uLL

◆ ELOS_CLASSIFICATION_USER_1

#define ELOS_CLASSIFICATION_USER_1   0x0000000200000000uLL

◆ ELOS_CLASSIFICATION_USER_2

#define ELOS_CLASSIFICATION_USER_2   0x0000000400000000uLL

◆ ELOS_CLASSIFICATION_USER_3

#define ELOS_CLASSIFICATION_USER_3   0x0000000800000000uLL

◆ ELOS_CLASSIFICATION_USER_4

#define ELOS_CLASSIFICATION_USER_4   0x0000001000000000uLL

◆ ELOS_CLASSIFICATION_USER_5

#define ELOS_CLASSIFICATION_USER_5   0x0000002000000000uLL

◆ ELOS_CLASSIFICATION_USER_6

#define ELOS_CLASSIFICATION_USER_6   0x0000004000000000uLL

◆ ELOS_CLASSIFICATION_USER_7

#define ELOS_CLASSIFICATION_USER_7   0x0000008000000000uLL

◆ ELOS_CLASSIFICATION_USER_MASK

#define ELOS_CLASSIFICATION_USER_MASK   0x000000FF00000000uLL

◆ ELOS_ID_INVALID

#define ELOS_ID_INVALID   0

Invalid elos event queue ID constant.

◆ LIBELOS_SO_FILENAME

#define LIBELOS_SO_FILENAME   "libelos.so.1"

Elos shared library filename for dlopen()

Typedef Documentation

◆ crinitElosEvent_t

Event send to elos.

◆ crinitElosEventMessageCodeE_t

Relevant elos message codes for crinit.

◆ crinitElosEventQueueId_t

typedef uint32_t crinitElosEventQueueId_t

Type defition for elos event queue IDs.

◆ crinitElosEventSource_t

Information of the sender sending an event to elos.

◆ crinitElosEventVector_t

Elos event vector type.

◆ crinitElosSession_t

Elos session type.

◆ crinitElosSeverityE_t

Possible severities an elos event can have.

◆ crinitElosVirtualTable_t

Elos virtual table and connection data.

Enumeration Type Documentation

◆ crinitElosEventMessageCodeE_t

Relevant elos message codes for crinit.

Enumerator
ELOS_MSG_CODE_INFO_LOG 

General events, not related to other codes.

ELOS_MSG_CODE_PROCESS_CREATED 

When a task is started.

ELOS_MSG_CODE_PROCESS_EXITED 

When a task was successfully completed.

ELOS_MSG_CODE_FILE_OPENED 

When a task has been added.

ELOS_MSG_CODE_IPC_NOT_AUTHORIZED 

When a client asked crinit for something without proper privileges.

ELOS_MSG_CODE_EXIT_FAILURE 

When a task has failed.

◆ crinitElosSeverityE_t

Possible severities an elos event can have.

Enumerator
ELOS_SEVERITY_OFF 
ELOS_SEVERITY_FATAL 
ELOS_SEVERITY_ERROR 
ELOS_SEVERITY_WARN 
ELOS_SEVERITY_INFO 
ELOS_SEVERITY_DEBUG 
ELOS_SEVERITY_VERBOSE 

Function Documentation

◆ crinitElosDisconnect()

int crinitElosDisconnect ( crinitElosSession_t session,
pthread_mutex_t *  sessionLock 
)

Disconnect from elos daemon.

Parameters
sessionSession to disconnect.
sessionLockThe session lock.
Returns
Returns 0 on success, -1 otherwise.

◆ crinitElosGetVTable()

crinitElosVirtualTable_t * crinitElosGetVTable ( void  )

Returns the internal elos virtual table.

◆ crinitElosInit()

int crinitElosInit ( void  )

Initializes the elos vtable.

Returns
Returns 0 on success, -1 otherwise.