mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-10-05 03:59:55 +00:00

All users of genl have the same code to open a genl socket and resolve the family for their specific protocol. Introduce a helper to initialize the handle, and use it in all the genl code. Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
28 lines
728 B
C
28 lines
728 B
C
#ifndef __LIBGENL_H__
|
|
#define __LIBGENL_H__
|
|
|
|
#include "libnetlink.h"
|
|
|
|
#define GENL_REQUEST(_req, _bufsiz, _family, _hdrsiz, _ver, _cmd, _flags) \
|
|
struct { \
|
|
struct nlmsghdr n; \
|
|
struct genlmsghdr g; \
|
|
char buf[NLMSG_ALIGN(_hdrsiz) + (_bufsiz)]; \
|
|
} _req = { \
|
|
.n = { \
|
|
.nlmsg_type = (_family), \
|
|
.nlmsg_flags = (_flags), \
|
|
.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN + (_hdrsiz)), \
|
|
}, \
|
|
.g = { \
|
|
.cmd = (_cmd), \
|
|
.version = (_ver), \
|
|
}, \
|
|
}
|
|
|
|
extern int genl_resolve_family(struct rtnl_handle *grth, const char *family);
|
|
extern int genl_init_handle(struct rtnl_handle *grth, const char *family,
|
|
int *genl_family);
|
|
|
|
#endif /* __LIBGENL_H__ */
|