monitor: Provide a helper function

Provide a helper function to convert NLMSG type to string.
This commit is contained in:
Ravi kumar Veeramally 2015-01-19 13:55:18 +02:00 committed by Denis Kenzior
parent 275d067123
commit 0922ce9817
1 changed files with 56 additions and 48 deletions

View File

@ -1920,22 +1920,11 @@ static void genl_ctrl(struct nlmon *nlmon, const void *data, uint32_t len)
nlmon->id = id;
}
void nlmon_print_rtnl(struct nlmon *nlmon, const struct timeval *tv,
const void *data, uint32_t size)
static const char *nlmsg_type_to_str(uint32_t msg_type)
{
uint32_t aligned_size = NLMSG_ALIGN(size);
const struct nlmsghdr *nlmsg;
const char *str = NULL;
update_time_offset(tv);
for (nlmsg = data; NLMSG_OK(nlmsg, aligned_size);
nlmsg = NLMSG_NEXT(nlmsg, aligned_size)) {
const struct ifinfomsg *ifi;
char extra_str[32];
const char *str;
bool out;
switch (nlmsg->nlmsg_type) {
switch (msg_type) {
case NLMSG_NOOP:
str = "Noop";
break;
@ -1983,6 +1972,25 @@ void nlmon_print_rtnl(struct nlmon *nlmon, const struct timeval *tv,
break;
}
return str;
}
void nlmon_print_rtnl(struct nlmon *nlmon, const struct timeval *tv,
const void *data, uint32_t size)
{
uint32_t aligned_size = NLMSG_ALIGN(size);
const struct nlmsghdr *nlmsg;
update_time_offset(tv);
for (nlmsg = data; NLMSG_OK(nlmsg, aligned_size);
nlmsg = NLMSG_NEXT(nlmsg, aligned_size)) {
const struct ifinfomsg *ifi;
char extra_str[32];
const char *str;
bool out;
str = nlmsg_type_to_str(nlmsg->nlmsg_type);
out = !!(nlmsg->nlmsg_flags & NLM_F_REQUEST);
netlink_str(extra_str, sizeof(extra_str),