1
2
3
4
5
6
7
8
9
10
11
12#include <stdio.h>
13#include <time.h>
14#include <errno.h>
15
16#include <libmnl/libmnl.h>
17
18#include "mnl_utils.h"
19#include "msg.h"
20
21extern struct mnlu_gen_socket tipc_nlg;
22
23int parse_attrs(const struct nlattr *attr, void *data)
24{
25 const struct nlattr **tb = data;
26 int type = mnl_attr_get_type(attr);
27
28 tb[type] = attr;
29
30 return MNL_CB_OK;
31}
32
33int msg_doit(struct nlmsghdr *nlh, mnl_cb_t callback, void *data)
34{
35 nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
36 return mnlu_gen_socket_sndrcv(&tipc_nlg, nlh, callback, data);
37}
38
39int msg_dumpit(struct nlmsghdr *nlh, mnl_cb_t callback, void *data)
40{
41 nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
42 return mnlu_gen_socket_sndrcv(&tipc_nlg, nlh, callback, data);
43}
44
45struct nlmsghdr *msg_init(int cmd)
46{
47 struct nlmsghdr *nlh;
48
49 nlh = mnlu_gen_socket_cmd_prepare(&tipc_nlg, cmd, 0);
50
51 return nlh;
52}
53