tizen 2.3 release
[framework/system/deviced.git] / src / logd / src / shared / netlink.h
1 #ifndef _LOGD_NETLINK_H_
2 #define _LOGD_NETLINK_H_
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #include <sys/socket.h>
9 #include <sys/types.h>
10 #include <linux/genetlink.h>
11 /* TODO: replace "logd-taskstats.h" on " <linux/taskstats.h>
12  * if the build system will contains kernel-headers from tizen.
13  * Now it's necessary due to build system using 2.6.36 kernel and
14  * struct taskstats not contains ac_stime_power_cons, ac_utime_power_cons
15  * variables.
16  */
17 #include "logd-taskstats.h"
18 #include <linux/netlink.h>
19
20 #define GENLMSG_DATA(glh)       ((void *)(NLMSG_DATA(glh) + GENL_HDRLEN))
21 #define GENLMSG_PAYLOAD(glh)    (NLMSG_PAYLOAD(glh, 0) - GENL_HDRLEN)
22 #define NLA_DATA(na)            ((void *)((char*)(na) + NLA_HDRLEN))
23 #define NLA_PAYLOAD(len)        (len - NLA_HDRLEN)
24
25 #define MAX_MSG_SIZE            1024
26
27 struct msgtemplate {
28         struct nlmsghdr n;
29         struct genlmsghdr g;
30         char buf[MAX_MSG_SIZE];
31 };
32
33 int create_netlink_socket(int protocol, int groups, int pid);
34 int send_cmd(int sock, unsigned short family_id, pid_t pid, __u8 cmd,
35          unsigned short nl_type, void *nl_data, int nl_len);
36 int get_family_id(int sock, const char *n);
37
38 #ifdef __cplusplus
39 }
40 #endif
41
42 #endif /* _LOGD_NETLINK_H_ */