rte_kvargs.h(3)
π rte_kvargs.h β the DPDK argument-parsing bestie π
okay so bestie, welcome to rte_kvargs.h, a manual page from the DPDK family (that's a Library Functions Manual, the cultured kind). This little file is the group chat where your key1=value1,key2=value2,... strings come to get sorted out. Let's get into it, no cap. β¨
πΈ SYNOPSIS πΈ
Here's everything this file hands you, bestie. Skim it, screenshot it, whatever.
π Data Structures
struct rte_kvargs_pairstruct rte_kvargs
π Macros
#define RTE_KVARGS_MAX 32#define RTE_KVARGS_PAIRS_DELIM ','#define RTE_KVARGS_KV_DELIM '='
π Typedefs
typedef int(*arg_handler_t) (const char *key, const char *value, void *opaque)
π Functions
struct rte_kvargs * rte_kvargs_parse (const char *args, const char
*const valid_keys[])
struct rte_kvargs * rte_kvargs_parse_delim (const char *args, const char
*const valid_keys[], const char *valid_ends)
void rte_kvargs_free (struct rte_kvargs *kvlist)
const char * rte_kvargs_get (const struct rte_kvargs *kvlist, const char
*key)
const char * rte_kvargs_get_with_value (const struct rte_kvargs *kvlist,
const char *key, const char *value)
int rte_kvargs_process (const struct rte_kvargs *kvlist, const char
*key_match, arg_handler_t handler, void *opaque_arg)
int rte_kvargs_process_opt (const struct rte_kvargs *kvlist, const char
*key_match, arg_handler_t handler, void *opaque_arg)
unsigned rte_kvargs_count (const struct rte_kvargs *kvlist, const char
*key_match)
β¨ Detailed Description β¨
RTE Argument parsing β that's the whole vibe. This module parses arguments shaped like:
key1=value1,key2=value2,key3=value3,...
and here's the tea π: the same key can show up several times, with the same value or a different one. That's because these arguments are stored as a list of key/value associations, not as a dictionary. Very "my notes app has the same reminder five times" of it.
This file also provides some helpers that get used especially by virtual ethernet devices at initialization, for arguments parsing. iykyk. π¦
Definition in file rte_kvargs.h.
π§ Macro Definition Documentation π§
#define RTE_KVARGS_MAX 32
Maximum number of key/value associations. That's your cap, bestie β 32, periodt.
Definition at line 29 of file rte_kvargs.h.
#define RTE_KVARGS_PAIRS_DELIM ','
separator character used between each pair. It's the comma doing cardio between your pairs. πβοΈ
Definition at line 32 of file rte_kvargs.h.
#define RTE_KVARGS_KV_DELIM '='
separator character used between key and value. The = is the little bridge, iconic, no notes. π
Definition at line 35 of file rte_kvargs.h.
π Typedef Documentation π
typedef int(*arg_handler_t) (const char *key, const char *value, void *opaque)
Callback prototype used by rte_kvargs_process(). So when that function is like "hey, I found a match", this is the shape of the function it calls back. π
Parameters
- key β The key to consider, it will not be
NULL. - value β The value corresponding to the key, it may be
NULL(e.g. only with key). - opaque β An opaque pointer coming from the caller.
Returns
>=0handle key success.<0on error.
Definition at line 50 of file rte_kvargs.h.
π₯ Function Documentation π₯
struct rte_kvargs * rte_kvargs_parse (const char * args, const char *const valid_keys[])
Allocate a rte_kvargs and store key/value associations from a string.
The function allocates and fills a rte_kvargs structure from a given string whose format is key1=value1,key2=value2,....
The structure can be freed with rte_kvargs_free(). (Yes bestie, you gotta free it. π«Ά)
Parameters
- args β The input string containing the key/value associations.
- valid_keys β A list of valid keys (table of
const char *, the last must beNULL). This argument is ignored ifNULL.
Returns
- A pointer to an allocated
rte_kvargsstructure on success. NULLon error.
struct rte_kvargs * rte_kvargs_parse_delim (const char * args, const char *const valid_keys[], const char * valid_ends)
Allocate a rte_kvargs and store key/value associations from a string. This version will consider any byte from valid_ends as a possible terminating character, and will not parse beyond any of their occurrence. Like a bouncer at the door of your string. πͺ
The function allocates and fills an rte_kvargs structure from a given string whose format is key1=value1,key2=value2,....
The structure can be freed with rte_kvargs_free().
Parameters
- args β The input string containing the key/value associations.
- valid_keys β A list of valid keys (table of
const char *, the last must beNULL). This argument is ignored ifNULL. - valid_ends β Acceptable terminating characters. If
NULL, the behavior is the same asrte_kvargs_parse.
Returns
- A pointer to an allocated
rte_kvargsstructure on success. NULLon error.
void rte_kvargs_free (struct rte_kvargs * kvlist)
Free a rte_kvargs structure.
Free a rte_kvargs structure previously allocated with rte_kvargs_parse().
Parameters
- kvlist β The
rte_kvargsstructure. No error ifNULL.
const char * rte_kvargs_get (const struct rte_kvargs * kvlist, const char * key)
Get the value associated with a given key.
If multiple keys match, the value of the first one is returned. First come, first served, bestie. π
The memory returned is allocated as part of the rte_kvargs structure, it must never be modified.
Parameters
- kvlist β A list of
rte_kvargspair of'key=value'. - key β The matching key.
Returns
NULLif no key matches the input, a value associated with a matching key otherwise.
const char * rte_kvargs_get_with_value (const struct rte_kvargs * kvlist, const char * key, const char * value)
Get the value associated with a given key and value.
Find the first entry in the kvlist whose key and value match the ones passed as argument.
The memory returned is allocated as part of the rte_kvargs structure, it must never be modified.
Parameters
- kvlist β A list of
rte_kvargspair of'key=value'. - key β The matching key. If
NULL, any key will match. - value β The matching value. If
NULL, any value will match.
Returns
NULLif no key matches the input, a value associated with a matching key otherwise.
int rte_kvargs_process (const struct rte_kvargs * kvlist, const char * key_match, arg_handler_t handler, void * opaque_arg)
Call a handler function for each key=value matching the key.
For each key=value association that matches the given key, calls the handler function with the for a given arg_name passing the value on the dictionary for that key and a given extra argument.
Note: Compared to
See also: rte_kvargs_process_opt, this API will return -1 when handle only-key case (that is the matched key's value is NULL). π so watch out for that one.
Parameters
- kvlist β The
rte_kvargsstructure. - key_match β The key on which the handler should be called, or
NULLto process handler on all associations. - handler β The function to call for each matching key.
- opaque_arg β A pointer passed unchanged to the handler.
Returns
0on success.- Negative on error.
int rte_kvargs_process_opt (const struct rte_kvargs * kvlist, const char * key_match, arg_handler_t handler, void * opaque_arg)
Call a handler function for each key=value or only-key matching the key.
For each key=value or only-key association that matches the given key, calls the handler function with the for a given arg_name passing the value on the dictionary for that key and a given extra argument. This is the lenient one β it handles the only-key case too. π
Parameters
- kvlist β The
rte_kvargsstructure. - key_match β The key on which the handler should be called, or
NULLto process handler on all associations. - handler β The function to call for each matching key.
- opaque_arg β A pointer passed unchanged to the handler.
Returns
0on success.- Negative on error.
unsigned rte_kvargs_count (const struct rte_kvargs * kvlist, const char * key_match)
Count the number of associations matching the given key.
Parameters
- kvlist β The
rte_kvargsstructure. - key_match β The key that should match, or
NULLto count all associations.
Returns
- The number of entries.
π¦ Author π¦
Generated automatically by Doxygen for DPDK from the source code. (Not a human author, it's giving "authored by a very diligent robot" π€β¨)
and that's the whole page bestie, you ate that. this was DPDK, Version 25.11.3, and the page itself is rte_kvargs.h(3). go forth and parse responsibly πππΈ
π¦ where this page comes from
- ubuntu resolute: dpdk-doc 25.11.3-0ubuntu0.26.04.1 Β· BSD-3-Clause
- ubuntu stonking: dpdk-doc 25.11.3-1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms