mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
add generic lookup of af_name mappings
Signed-off-by: John Johansen <john.johansen@canonical.com> Acked-by: Seth Arnold <seth.arnold@canonical.com>
This commit is contained in:
parent
f5704761b5
commit
bccca11bf6
2 changed files with 21 additions and 0 deletions
|
@ -305,6 +305,25 @@ static const char *network_families[] = {
|
|||
#include "af_names.h"
|
||||
};
|
||||
|
||||
int net_find_af_val(const char *af)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; network_families[i]; i++) {
|
||||
if (strcmp(network_families[i], af) == 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char *net_find_af_name(unsigned int af)
|
||||
{
|
||||
if (af < 0 || af > get_af_max())
|
||||
return NULL;
|
||||
|
||||
return network_families[af];
|
||||
}
|
||||
|
||||
void __debug_network(unsigned int *array, const char *name)
|
||||
{
|
||||
unsigned int count = sizeof(sock_types)/sizeof(sock_types[0]);
|
||||
|
|
|
@ -77,5 +77,7 @@ struct network {
|
|||
|
||||
int net_find_type_val(const char *type);
|
||||
const char *net_find_type_name(int type);
|
||||
int net_find_af_val(const char *af);
|
||||
const char *net_find_af_name(unsigned int af);
|
||||
|
||||
#endif /* __AA_NETWORK_H */
|
||||
|
|
Loading…
Add table
Reference in a new issue