dect
/
libnl
Archived
13
0
Fork 0

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:
Thomas Graf 2013-04-01 11:14:49 +02:00
parent 6c9be5a316
commit aad041c46f
2 changed files with 28 additions and 0 deletions

View File

@ -17,4 +17,6 @@
#define GENL_HDRSIZE(hdrlen) (GENL_HDRLEN + (hdrlen))
extern int genl_resolve_id(struct genl_ops *ops);
#endif

View File

@ -302,6 +302,32 @@ static int __genl_ops_resolve(struct nl_cache *ctrl, struct genl_ops *ops)
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 */
/**