CNDP
22.08.0
|
#include <pthread.h>
#include <sched.h>
#include <stdint.h>
#include <sys/socket.h>
#include <sys/queue.h>
#include <sys/un.h>
#include <bsd/sys/bitstring.h>
#include <json-c/json_object.h>
#include <json-c/json_tokener.h>
#include <json-c/json_util.h>
#include <json-c/json_visit.h>
#include <json-c/linkhash.h>
#include <cne_common.h>
#include <cne_log.h>
#include <cne_mmap.h>
#include <cne_thread.h>
#include <pktmbuf.h>
Go to the source code of this file.
Data Structures | |
struct | obj_value |
struct | jcfg_hdr |
struct | jcfg_opt |
struct | jcfg_umem |
struct | jcfg_lport |
struct | jcfg_lgroup |
struct | jcfg_thd |
struct | jcfg_lport_group |
struct | jcfg_user |
struct | jcfg_list |
struct | jcfg_data |
union | jcfg_obj_t |
struct | jcfg_info_s |
Macros | |
#define | APP_TAG "application" |
#define | JCFG_TAG_NAMES |
#define | JCFG_COMMON_HDR(_t) |
#define | JCFG_LPORT_PMD_NAME "pmd" |
#define | JCFG_LPORT_GROUP_NETDEV_NAMES_NAME "netdevs" |
#define | jcfg_application_foreach(j, f, a) jcfg_object_foreach(j, JCFG_APPLICATION_TYPE, f, a) |
#define | jcfg_num_applications(j) jcfg_num_objects(j, JCFG_APPLICATION_TYPE) |
Typedefs | |
typedef struct obj_value | obj_value_t |
typedef struct jcfg_hdr | jcfg_hdr_t |
typedef struct jcfg_opt | jcfg_opt_t |
typedef struct jcfg_umem | jcfg_umem_t |
typedef struct jcfg_lport | jcfg_lport_t |
typedef struct jcfg_lgroup | jcfg_lgroup_t |
typedef struct jcfg_thd | jcfg_thd_t |
typedef struct jcfg_lport_group | jcfg_lport_group_t |
typedef struct jcfg_user | jcfg_user_t |
typedef struct jcfg_list | jcfg_list_t |
typedef struct jcfg_data | jcfg_data_t |
typedef int | jcfg_parse_cb_t(struct jcfg_info_s *jinfo, void *obj, void *arg, int idx) |
typedef struct jcfg_info_s | jcfg_info_t |
typedef int | jcfg_cb_t(jcfg_info_t *jinfo, void *obj, void *arg, int idx) |
Enumerations | |
enum | jcfg_cb_type_t { JCFG_APPLICATION_TYPE , JCFG_DEFAULT_TYPE , JCFG_OPTION_TYPE , JCFG_UMEM_TYPE , JCFG_LPORT_TYPE , JCFG_LGROUP_TYPE , JCFG_THREAD_TYPE , JCFG_LPORT_GROUP_TYPE , JCFG_USER_TYPE , JCFG_MAX_TYPES } |
enum | obj_type_t |
enum | { } |
Functions | |
CNDP_API int | jcfg_object_foreach (jcfg_info_t *jinfo, jcfg_cb_type_t cbtype, jcfg_cb_t *func, void *arg) |
CNDP_API void * | jcfg_object_lookup (jcfg_info_t *jinfo, jcfg_cb_type_t cbtype, const char *name) |
CNDP_API int | jcfg_num_objects (jcfg_info_t *jinfo, jcfg_cb_type_t cbtype) |
CNDP_API int | jcfg_default_get (jcfg_info_t *jinfo, const char *name, uint64_t *val) |
CNDP_API int | jcfg_default_array_get (jcfg_info_t *jinfo, const char *name, obj_value_t **val_arr) |
static int | jcfg_default_get_bool (jcfg_info_t *jinfo, const char *name, uint32_t *v) |
static int | jcfg_default_get_u32 (jcfg_info_t *jinfo, const char *name, uint32_t *v) |
static int | jcfg_default_get_u16 (jcfg_info_t *jinfo, const char *name, uint16_t *v) |
static int | jcfg_default_get_string (jcfg_info_t *jinfo, const char *name, char **v) |
CNDP_API int | jcfg_option_get (jcfg_info_t *jinfo, const char *name, uint64_t *val) |
CNDP_API int | jcfg_option_array_get (jcfg_info_t *jinfo, const char *name, obj_value_t **val_arr) |
static int | jcfg_option_get_string (jcfg_info_t *jinfo, const char *name, char **v) |
CNDP_API jcfg_info_t * | jcfg_parser (int flags, const char *s) |
CNDP_API void | jcfg_destroy (jcfg_info_t *jinfo) |
CNDP_API int | jcfg_decode (jcfg_info_t *jinfo, const char *key, void *arg) |
CNDP_API int | jcfg_socket_create (jcfg_info_t *jinfo, const char *runtime_dir) |
CNDP_API void | jcfg_socket_destroy (jcfg_info_t *jinfo) |
CNDP_API int | jcfg_add_decoder (const char *section, json_c_visit_userfunc *func) |
CNDP_API int | jcfg_del_decoder (const char *section) |
CNDP_API json_c_visit_userfunc * | jcfg_get_decoder (const char *section) |
CNDP_API jcfg_data_t * | jcfg_get_data (jcfg_info_t *jinfo) |
CNDP_API jcfg_umem_t * | jcfg_umem_by_index (jcfg_info_t *jinfo, int idx) |
CNDP_API char * | jcfg_lport_region (jcfg_lport_t *lport, uint32_t *objcnt) |
CNDP_API int | jcfg_json_string_set (jcfg_info_t *jinfo, const char *str) |
CNDP_API struct json_object * | jcfg_object_by_name (jcfg_info_t *jinfo, const char *key) |
CNDP_API jcfg_lport_t * | jcfg_lport_by_index (jcfg_info_t *jinfo, int idx) |
CNDP_API jcfg_thd_t * | jcfg_thd_by_index (jcfg_info_t *jinfo, int idx) |
CNDP_API int | jcfg_dump_object (struct json_object *obj) |
CNDP_API int | jcfg_dump_at (jcfg_info_t *jinfo, const char *key) |
CNDP_API int | jcfg_dump (jcfg_info_t *jinfo) |
CNDP_API void | jcfg_dump_info (void) |
JSON configuration using json-c
Definition in file jcfg.h.
#define APP_TAG "application" |
#define JCFG_TAG_NAMES |
Macro to initialize a const char *tags[] type array for indexing with jcfg_tag_t.
#define JCFG_COMMON_HDR | ( | _t | ) |
#define JCFG_LPORT_PMD_NAME "pmd" |
#define JCFG_LPORT_GROUP_NETDEV_NAMES_NAME "netdevs" |
#define jcfg_application_foreach | ( | j, | |
f, | |||
a | |||
) | jcfg_object_foreach(j, JCFG_APPLICATION_TYPE, f, a) |
#define jcfg_num_applications | ( | j | ) | jcfg_num_objects(j, JCFG_APPLICATION_TYPE) |
typedef struct obj_value obj_value_t |
JCFG Object information
typedef struct jcfg_hdr jcfg_hdr_t |
A template structure to be used as a generic overlay to the jcfg objects.
typedef struct jcfg_opt jcfg_opt_t |
JCFG option structure
typedef struct jcfg_umem jcfg_umem_t |
UMEM information for JCFG
typedef struct jcfg_lport jcfg_lport_t |
JCFG lport information
typedef struct jcfg_lgroup jcfg_lgroup_t |
JCFG lgroup for lcore allocations
typedef struct jcfg_thd jcfg_thd_t |
JCFG Thread information
typedef struct jcfg_lport_group jcfg_lport_group_t |
JCFG lport group information
typedef struct jcfg_user jcfg_user_t |
A user defined object type
typedef struct jcfg_list jcfg_list_t |
Simple structure to hold an array of object in a list.
The list array uses realloc() to grow the list.
typedef struct jcfg_data jcfg_data_t |
Main structure to hold all of the jcfg configuration information
typedef int jcfg_parse_cb_t(struct jcfg_info_s *jinfo, void *obj, void *arg, int idx) |
JCFG Parser callback function prototype. Called once for each parsed object in the JSON file.
jinfo | The jcfg information structure pointer |
obj | The object (application, thread, lport, ...) pointer |
arg | The argument for the callback passed in by the user. |
idx | The index pointer in the JSON configuration relative to the group being parsed. |
typedef struct jcfg_info_s jcfg_info_t |
The JCFG basic information structure
typedef int jcfg_cb_t(jcfg_info_t *jinfo, void *obj, void *arg, int idx) |
Object callback functions
jinfo | The jcfg information structure pointer |
obj | The object (application, thread, lport, ...) pointer |
arg | The argument for the callback passed in by the user. |
idx | The index pointer in the JSON configuration relative to the group being parsed. |
enum jcfg_cb_type_t |
Enumeration of jcfg process callback types
enum obj_type_t |
anonymous enum |
Flags used for jcfg_info_t.flags value
CNDP_API int jcfg_object_foreach | ( | jcfg_info_t * | jinfo, |
jcfg_cb_type_t | cbtype, | ||
jcfg_cb_t * | func, | ||
void * | arg | ||
) |
Foreach routines for each object type.
jinfo | The jcfg information structure pointer |
cbtype | The jcfg_cb_type_t enum value. |
func | The function to callback for each object. |
arg | The user supplied argument passed to the func function |
CNDP_API void* jcfg_object_lookup | ( | jcfg_info_t * | jinfo, |
jcfg_cb_type_t | cbtype, | ||
const char * | name | ||
) |
Object section lookup by name routines.
jinfo | The jcfg information structure pointer |
cbtype | The JCFG Tag Type enum value |
name | The name string for the object in the JSON group being searched. |
CNDP_API int jcfg_num_objects | ( | jcfg_info_t * | jinfo, |
jcfg_cb_type_t | cbtype | ||
) |
Count the number of objects in a given group or type (lport, thread, ...)
jinfo | The jcfg information structure pointer |
cbtype | The type of the object to count |
CNDP_API int jcfg_default_get | ( | jcfg_info_t * | jinfo, |
const char * | name, | ||
uint64_t * | val | ||
) |
Get the value of the defaults section given of the same name
jinfo | The jcfg information structure pointer |
name | The string name of the object to search for in the default list. |
val | Location to place the found object data. |
CNDP_API int jcfg_default_array_get | ( | jcfg_info_t * | jinfo, |
const char * | name, | ||
obj_value_t ** | val_arr | ||
) |
Get the array of the defaults section given of the same name
jinfo | The jcfg information structure pointer |
name | The string name of the array to search for in the default list. |
val_arr | Location to place the found object data array. |
|
inlinestatic |
Get the value of the default section given of the same name for a boolean value
jinfo | The jcfg information structure pointer |
name | The string name of the object to search for in the default list. |
v | Location to place the found object data. |
|
inlinestatic |
Get the value of the default section given of the same name for a u32 bit value
jinfo | The jcfg information structure pointer |
name | The string name of the object to search for in the default list. |
v | Location to place the found object data. |
|
inlinestatic |
Get the value of the default section given the name for a u16 bit value
jinfo | The jcfg information structure pointer |
name | The string name of the object to search for in the default list. |
v | Location to place the found object data. |
|
inlinestatic |
Get the value of the default section given of the same name for a string value
jinfo | The jcfg information structure pointer |
name | The string name of the object to search for in the default list. |
v | Location to place the found object data. |
CNDP_API int jcfg_option_get | ( | jcfg_info_t * | jinfo, |
const char * | name, | ||
uint64_t * | val | ||
) |
Get the value of the options section given of the same name
jinfo | The jcfg information structure pointer |
name | The string name of the object to search for in the default list. |
val | Location to place the found object data. |
CNDP_API int jcfg_option_array_get | ( | jcfg_info_t * | jinfo, |
const char * | name, | ||
obj_value_t ** | val_arr | ||
) |
Get the array of the options section given of the same name
jinfo | The jcfg information structure pointer |
name | The string name of the array to search for in the default list. |
val_arr | Location to place the found object data array. |
|
inlinestatic |
Get the value of the options section given of the same name for a string value
jinfo | The jcfg information structure pointer |
name | The string name of the object to search for in the default list. |
v | Location to place the found object data. |
CNDP_API jcfg_info_t* jcfg_parser | ( | int | flags, |
const char * | s | ||
) |
Load and parse a json-c or json file, socket or string.
flags | Flags used to configure jcfg JSON parsing. |
s | The json-c or json file or string to load and parse. |
CNDP_API void jcfg_destroy | ( | jcfg_info_t * | jinfo | ) |
Free the jcfg structure
jinfo | Pointer to jcfg_info_t structure to free. |
CNDP_API int jcfg_decode | ( | jcfg_info_t * | jinfo, |
const char * | key, | ||
void * | arg | ||
) |
Decode the Application JSON file.
jinfo | The jcfg_info_t pointer from jcfg_create() |
key | The key to search for in the JSON data, if NULL use the root JSON object If Key is given then a user defined function must be provided. |
arg | Argument to use in func callback. If arg is NULL then jinfo is passed to callback. |
CNDP_API int jcfg_socket_create | ( | jcfg_info_t * | jinfo, |
const char * | runtime_dir | ||
) |
Create the thread and socket to listen for json configuration
jinfo | The struct jcfg_info pointer from jcfg_create(). |
runtime_dir | The path to the runtime directory can be NULL to use the default path |
CNDP_API void jcfg_socket_destroy | ( | jcfg_info_t * | jinfo | ) |
Destroy the thread which is waiting for json configuration
jinfo | The struct jcfg_info pointer |
CNDP_API int jcfg_add_decoder | ( | const char * | section, |
json_c_visit_userfunc * | func | ||
) |
Add a decoder for the user part of the json-C file.
section | The section name to use for locating the JSON section to decode. |
func | The json_c_visit_userfunc pointer |
CNDP_API int jcfg_del_decoder | ( | const char * | section | ) |
Delete a decoder from the list
section | The section name to use for locating the JSON section to decode. |
CNDP_API json_c_visit_userfunc* jcfg_get_decoder | ( | const char * | section | ) |
Get a decoder by section name
section | The section name to use for locating the JSON section to decode. |
CNDP_API jcfg_data_t* jcfg_get_data | ( | jcfg_info_t * | jinfo | ) |
Return the internal data pointer in struct jcfg.
jinfo | The jcfg_info_t pointer for the JCFG configuration |
CNDP_API jcfg_umem_t* jcfg_umem_by_index | ( | jcfg_info_t * | jinfo, |
int | idx | ||
) |
Return the UMEM pointer for the given ID value.
jinfo | The jcfg information structure pointer. |
idx | The ID or index value to locate. |
CNDP_API char* jcfg_lport_region | ( | jcfg_lport_t * | lport, |
uint32_t * | objcnt | ||
) |
Return the memory address of the region in UMEM area.
lport | The jcfg_lport_t pointer for the lport. |
objcnt | The uint32_t variable to place the number of objcnt in the region. |
CNDP_API int jcfg_json_string_set | ( | jcfg_info_t * | jinfo, |
const char * | str | ||
) |
Set the JSON string data for parsing later
jinfo | The pointer created from jcfg_create(). |
str | The pointer to JSON text, can be NULL to free resources. |
CNDP_API struct json_object* jcfg_object_by_name | ( | jcfg_info_t * | jinfo, |
const char * | key | ||
) |
Return the JSON object pointer for the given jcfg_info_t pointer.
jinfo | The jcfg_info_t pointer containing the JSON root object |
key | The key to search for in the JOSN object, can be NULL. |
CNDP_API jcfg_lport_t* jcfg_lport_by_index | ( | jcfg_info_t * | jinfo, |
int | idx | ||
) |
Return the lport pointer for the given ID value.
jinfo | The jcfg information structure pointer. |
idx | The ID or index value to locate. |
CNDP_API jcfg_thd_t* jcfg_thd_by_index | ( | jcfg_info_t * | jinfo, |
int | idx | ||
) |
Return the thread pointer for the given ID value.
jinfo | The jcfg information structure pointer. |
idx | The ID or index value to locate. |
CNDP_API int jcfg_dump_object | ( | struct json_object * | obj | ) |
Dump out the json_object, by walking the object tree.
obj | Start dumping at this object |
CNDP_API int jcfg_dump_at | ( | jcfg_info_t * | jinfo, |
const char * | key | ||
) |
Dump out the json_object by key, by walking the object tree.
jinfo | The jcfg_info_t pointer holding the json root object |
key | Start dumping at this key |
CNDP_API int jcfg_dump | ( | jcfg_info_t * | jinfo | ) |
Dump out the json_object from the root, by walking the object tree.
jinfo | The jcfg_info_t pointer holding the json root object |
CNDP_API void jcfg_dump_info | ( | void | ) |
Dump out some information about jcfg structures