40 #define MAX_HOSTNAME_LEN 253
69 if (strnlen(param, size) >= size) {
70 DOCA_LOG_ERR(
"Execute hash map argument too long, must be <=%zu long", size - 1);
94 if (strnlen(param, size) >= size) {
95 DOCA_LOG_ERR(
"System memory regions map argument too long, must be <=%zu long", size - 1);
119 if (strnlen(param, size) >= size) {
120 DOCA_LOG_ERR(
"System VUID argument too long, must be <=%zu long", size - 1);
139 if (strnlen(param, size) >= size) {
140 DOCA_LOG_ERR(
"DMA device name argument too long, must be <=%zu long", size - 1);
159 if (strnlen(param, size) >= size) {
160 DOCA_LOG_ERR(
"System os symbols map argument too long, must be <=%zu long", size - 1);
182 char *str_param = (
char *)param;
184 if (!strcasecmp(str_param,
"windows"))
186 else if (!strcasecmp(str_param,
"linux"))
189 DOCA_LOG_ERR(
"OS type is not windows/linux (case insensitive)");
213 struct doca_argp_param *pid_param, *hash_map_param, *memr_param, *vuid_param, *dma_param, *os_syms_param;
214 struct doca_argp_param *time_param, *os_type_param;
543 struct doca_apsh_process ***
pslist,
544 struct doca_apsh_process **process)
546 struct doca_apsh_process **processes;
548 int proc_count, process_idx;
549 typeof(apsh_conf->
pid) cur_proc_pid = 0;
562 for (process_idx = 0; process_idx < proc_count; process_idx++) {
565 if (apsh_conf->
pid == cur_proc_pid) {
566 *process = processes[process_idx];
570 if (*process ==
NULL) {
593 struct doca_telemetry_exporter_type *
type;
594 struct doca_telemetry_exporter_field *field;
595 const int nb_fields = 5;
600 const char *type_name;
614 for (idx = 0; idx < nb_fields; idx++) {
645 struct doca_telemetry_exporter_source **telemetry_source,
649 struct doca_telemetry_exporter_schema *schema =
NULL;
650 struct doca_telemetry_exporter_source *source =
NULL;
656 DOCA_LOG_ERR(
"Failed to init the doca telemetry schema");
663 DOCA_LOG_ERR(
"Failed to register attestation event in the telemetry schema");
678 DOCA_LOG_ERR(
"Failed to start the doca telemetry schema");
685 DOCA_LOG_ERR(
"Failed to create a source end point to the telemetry");
690 if (gethostname(source_id_buf,
sizeof(source_id_buf)) < 0) {
691 DOCA_LOG_ERR(
"Gethostname failed, can't create a unique source tag and id");
696 strlcpy(source_tag_buf, source_id_buf,
sizeof(source_tag_buf));
697 strlcat(source_tag_buf,
"_tag",
sizeof(source_tag_buf));
704 DOCA_LOG_ERR(
"Failed to establish a source connection to the telemetry");
709 *telemetry_schema = schema;
710 *telemetry_source = source;
721 struct doca_telemetry_exporter_source *telemetry_source)
static doca_error_t time_callback(void *param, void *config)
static doca_error_t os_syms_callback(void *param, void *config)
static doca_error_t os_type_callback(void *param, void *config)
doca_error_t get_process_by_pid(struct apsh_resources *resources, struct apsh_config *apsh_conf, struct doca_apsh_process ***pslist, struct doca_apsh_process **process)
doca_error_t app_shield_agent_init(struct apsh_config *conf, struct apsh_resources *resources)
static doca_error_t memr_callback(void *param, void *config)
static doca_error_t dma_callback(void *param, void *config)
static doca_error_t telemetry_register_attest_event(struct doca_telemetry_exporter_schema *schema, doca_telemetry_exporter_type_index_t *type_index)
static doca_error_t pid_callback(void *param, void *config)
static doca_error_t apsh_ctx_init(struct apsh_config *conf, struct apsh_resources *resources)
doca_error_t telemetry_start(struct doca_telemetry_exporter_schema **telemetry_schema, struct doca_telemetry_exporter_source **telemetry_source, struct event_indexes *indexes)
void app_shield_agent_cleanup(struct apsh_resources *resources)
static doca_error_t apsh_system_init(struct apsh_config *conf, struct apsh_resources *resources)
static doca_error_t vuid_callback(void *param, void *config)
DOCA_LOG_REGISTER(APSH_APP::Core)
doca_error_t register_apsh_params(void)
void telemetry_destroy(struct doca_telemetry_exporter_schema *telemetry_schema, struct doca_telemetry_exporter_source *telemetry_source)
static doca_error_t hash_map_callback(void *param, void *config)
doca_error_t pslist(const char *dma_device_name, const char *pci_vuid, enum doca_apsh_system_os os_type, const char *mem_region, const char *os_symbols)
doca_error_t open_doca_device_rep_with_vuid(struct doca_dev *local, enum doca_devinfo_rep_filter filter, const uint8_t *value, size_t val_size, struct doca_dev_rep **retval)
doca_error_t open_doca_device_with_ibdev_name(const uint8_t *value, size_t val_size, tasks_check func, struct doca_dev **retval)
if(bitoffset % 64+bitlength > 64) result|
struct rdma_resources resources
uint32_t DOCA_APSH_PROCESS_PID_TYPE
process pid type
@ DOCA_APSH_SYSTEM_WINDOWS
DOCA_EXPERIMENTAL doca_error_t doca_apsh_sys_mem_region_set(struct doca_apsh_system *system, const char *system_mem_region_path)
Set system allowed memory regions.
DOCA_EXPERIMENTAL doca_error_t doca_apsh_sys_dev_set(struct doca_apsh_system *system, struct doca_dev_rep *dev)
Set system device.
DOCA_EXPERIMENTAL doca_error_t doca_apsh_processes_get(struct doca_apsh_system *system, struct doca_apsh_process ***processes, int *processes_size)
Get array of current processes running on the system.
DOCA_EXPERIMENTAL doca_error_t doca_apsh_start(struct doca_apsh_ctx *ctx)
Start apsh handler.
DOCA_EXPERIMENTAL doca_error_t doca_apsh_sys_os_type_set(struct doca_apsh_system *system, enum doca_apsh_system_os os_type)
Set system os type.
DOCA_EXPERIMENTAL struct doca_apsh_ctx * doca_apsh_create(void)
Create a new apsh handler.
DOCA_EXPERIMENTAL doca_error_t doca_apsh_dma_dev_set(struct doca_apsh_ctx *ctx, struct doca_dev *dma_dev)
Set apsh dma device.
DOCA_EXPERIMENTAL struct doca_apsh_system * doca_apsh_system_create(struct doca_apsh_ctx *ctx)
Create a new system handler.
DOCA_EXPERIMENTAL doca_error_t doca_apsh_sys_os_symbol_map_set(struct doca_apsh_system *system, const char *system_os_symbol_map_path)
Set system os symbol map.
DOCA_EXPERIMENTAL void doca_apsh_destroy(struct doca_apsh_ctx *ctx)
Free the APSH memory and close connections.
#define doca_apsh_process_info_get(process, attr)
Get attribute value for a process.
DOCA_EXPERIMENTAL void doca_apsh_processes_free(struct doca_apsh_process **processes)
Destroys a process context.
DOCA_EXPERIMENTAL void doca_apsh_system_destroy(struct doca_apsh_system *system)
Destroy system handler.
DOCA_EXPERIMENTAL doca_error_t doca_apsh_system_start(struct doca_apsh_system *system)
Start system handler.
DOCA_EXPERIMENTAL void doca_argp_param_set_description(struct doca_argp_param *param, const char *description)
Set the description of the program param, used during program usage.
DOCA_EXPERIMENTAL void doca_argp_param_set_long_name(struct doca_argp_param *param, const char *name)
Set the long name of the program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_arguments(struct doca_argp_param *param, const char *arguments)
Set the description of the expected arguments of the program param, used during program usage.
DOCA_EXPERIMENTAL void doca_argp_param_set_callback(struct doca_argp_param *param, doca_argp_param_cb_t callback)
Set the callback function of the program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_mandatory(struct doca_argp_param *param)
Mark the program param as mandatory.
DOCA_EXPERIMENTAL doca_error_t doca_argp_param_create(struct doca_argp_param **param)
Create new program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_type(struct doca_argp_param *param, enum doca_argp_type type)
Set the type of the param arguments.
DOCA_EXPERIMENTAL doca_error_t doca_argp_register_version_callback(doca_argp_param_cb_t callback)
Register an alternative version callback.
DOCA_EXPERIMENTAL void doca_argp_param_set_short_name(struct doca_argp_param *param, const char *name)
Set the short name of the program param.
DOCA_EXPERIMENTAL doca_error_t doca_argp_register_param(struct doca_argp_param *input_param)
Register a program flag.
DOCA_STABLE doca_error_t doca_dev_rep_close(struct doca_dev_rep *dev)
Destroy allocated representor device instance.
DOCA_STABLE doca_error_t doca_dev_close(struct doca_dev *dev)
Destroy allocated local device instance.
@ DOCA_DEVINFO_REP_FILTER_NET
enum doca_error doca_error_t
DOCA API return codes.
DOCA_STABLE const char * doca_error_get_descr(doca_error_t error)
Returns the description string of an error code.
@ DOCA_ERROR_INVALID_VALUE
@ DOCA_ERROR_INITIALIZATION
@ DOCA_ERROR_OPERATING_SYSTEM
@ DOCA_ERROR_NOT_SUPPORTED
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_TELEMETRY_EXPORTER_FIELD_TYPE_TIMESTAMP
DOCA telemetry timestamp type.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_schema_init(const char *schema_name, struct doca_telemetry_exporter_schema **doca_schema)
Initialize DOCA schema to prepare it for setting attributes and adding types. DOCA schema is used to ...
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_type_destroy(struct doca_telemetry_exporter_type *type)
Destroy doca telemetry type previously created by doca_telemetry_exporter_type_create()
DOCA_EXPERIMENTAL void doca_telemetry_exporter_field_set_type_name(struct doca_telemetry_exporter_field *field_info, const char *type)
Set doca telemetry field type.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_source_destroy(struct doca_telemetry_exporter_source *doca_source)
Destructor for DOCA source.
DOCA_EXPERIMENTAL void doca_telemetry_exporter_field_set_description(struct doca_telemetry_exporter_field *field_info, const char *desc)
Set doca telemetry field description.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_field_destroy(struct doca_telemetry_exporter_field *field)
Destroy field previously created by doca_telemetry_exporter_field_create()
#define DOCA_TELEMETRY_EXPORTER_FIELD_TYPE_INT32
DOCA telemetry int32 type.
DOCA_EXPERIMENTAL void doca_telemetry_exporter_source_set_id(struct doca_telemetry_exporter_source *doca_source, const char *source_id)
Set source id.
#define DOCA_TELEMETRY_EXPORTER_FIELD_TYPE_UINT64
DOCA telemetry uint64 type.
uint8_t doca_telemetry_exporter_type_index_t
DOCA schema field type index.
DOCA_EXPERIMENTAL void doca_telemetry_exporter_field_set_array_len(struct doca_telemetry_exporter_field *field_info, uint16_t len)
Set doca telemetry field length.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_schema_add_type(struct doca_telemetry_exporter_schema *doca_schema, const char *new_type_name, struct doca_telemetry_exporter_type *type, doca_telemetry_exporter_type_index_t *type_index)
Add user-defined fields to create new type in DOCA schema. The users loses the ownership of the type ...
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_source_create(struct doca_telemetry_exporter_schema *doca_schema, struct doca_telemetry_exporter_source **doca_source)
Creates a single DOCA source from schema.
DOCA_EXPERIMENTAL void doca_telemetry_exporter_field_set_name(struct doca_telemetry_exporter_field *field_info, const char *name)
Set doca telemetry field name.
#define DOCA_TELEMETRY_EXPORTER_FIELD_TYPE_CHAR
DOCA telemetry char type.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_type_create(struct doca_telemetry_exporter_type **type)
Create new telemetry type.
DOCA_EXPERIMENTAL void doca_telemetry_exporter_schema_set_file_write_max_age(struct doca_telemetry_exporter_schema *doca_schema, doca_telemetry_exporter_timestamp_t max_age)
Set file maximum age Default value is 1 hour.
DOCA_EXPERIMENTAL void doca_telemetry_exporter_source_set_tag(struct doca_telemetry_exporter_source *doca_source, const char *source_tag)
Set source tag.
DOCA_EXPERIMENTAL void doca_telemetry_exporter_schema_set_file_write_max_size(struct doca_telemetry_exporter_schema *doca_schema, size_t size)
Set file maximum size Default value is 1MB.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_field_create(struct doca_telemetry_exporter_field **field)
Create new telemetry field.
DOCA_EXPERIMENTAL void doca_telemetry_exporter_schema_set_file_write_enabled(struct doca_telemetry_exporter_schema *doca_schema)
Enable file write file write is disabled by default.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_schema_destroy(struct doca_telemetry_exporter_schema *doca_schema)
Destructor for DOCA schema.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_schema_start(struct doca_telemetry_exporter_schema *doca_schema)
Finalizes schema setup to start creating Doca Sources from the schema.
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_type_add_field(struct doca_telemetry_exporter_type *type, struct doca_telemetry_exporter_field *field)
Add DOCA telemetry field to type. The users loses the ownership of the field after a successful invoc...
DOCA_EXPERIMENTAL doca_error_t doca_telemetry_exporter_source_start(struct doca_telemetry_exporter_source *doca_source)
Applies source attribute and starts DOCA source.
char system_vuid[DOCA_DEVINFO_VUID_SIZE+1]
char exec_hash_map_path[MAX_PATH_LEN]
DOCA_APSH_PROCESS_PID_TYPE pid
char dma_dev_name[DOCA_DEVINFO_IBDEV_NAME_SIZE+1]
char system_mem_region_path[MAX_PATH_LEN]
char system_os_symbol_map_path[MAX_PATH_LEN]
enum doca_apsh_system_os os_type
doca_telemetry_exporter_type_index_t attest_index
size_t strlcat(char *dst, const char *src, size_t size)
size_t strlcpy(char *dst, const char *src, size_t size)
noreturn doca_error_t sdk_version_callback(void *param, void *doca_config)