genl: Provide internal function to resolve name to id
Like genl_ops_resolve() but uses its own socket. Signed-off-by: Thomas Graf <tgraf@suug.ch>
This commit is contained in:
parent
6c9be5a316
commit
aad041c46f
2 changed files with 28 additions and 0 deletions
|
@ -17,4 +17,6 @@
|
||||||
|
|
||||||
#define GENL_HDRSIZE(hdrlen) (GENL_HDRLEN + (hdrlen))
|
#define GENL_HDRSIZE(hdrlen) (GENL_HDRLEN + (hdrlen))
|
||||||
|
|
||||||
|
extern int genl_resolve_id(struct genl_ops *ops);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -302,6 +302,32 @@ static int __genl_ops_resolve(struct nl_cache *ctrl, struct genl_ops *ops)
|
||||||
|
|
||||||
return -NLE_OBJ_NOTFOUND;
|
return -NLE_OBJ_NOTFOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int genl_resolve_id(struct genl_ops *ops)
|
||||||
|
{
|
||||||
|
struct nl_sock *sk;
|
||||||
|
int err = 0;
|
||||||
|
|
||||||
|
/* Check if resolved already */
|
||||||
|
if (ops->o_id != GENL_ID_GENERATE)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (!ops->o_name)
|
||||||
|
return -NLE_INVAL;
|
||||||
|
|
||||||
|
if (!(sk = nl_socket_alloc()))
|
||||||
|
return -NLE_NOMEM;
|
||||||
|
|
||||||
|
if ((err = genl_connect(sk)) < 0)
|
||||||
|
goto errout_free;
|
||||||
|
|
||||||
|
err = genl_ops_resolve(sk, ops);
|
||||||
|
|
||||||
|
errout_free:
|
||||||
|
nl_socket_free(sk);
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
/** @endcond */
|
/** @endcond */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue