netlib: correct netlink usage to follow Linux convention

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: Iae98b0a008dc42dddb77f47d79511ae4fb4bbfca
This commit is contained in:
Xiang Xiao 2020-04-09 06:37:04 -04:00 committed by patacongo
parent f5ea28e9ad
commit 300bc2729a
4 changed files with 6 additions and 22 deletions

View File

@ -44,7 +44,6 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <errno.h>
#include <netpacket/netlink.h>
@ -142,7 +141,7 @@ ssize_t netlib_get_arptable(FAR struct arp_entry_s *arptab,
addr.nl_family = AF_NETLINK;
addr.nl_pad = 0;
addr.nl_pid = pid;
addr.nl_groups = RTM_GETNEIGH;
addr.nl_groups = 0;
ret = bind(fd, (FAR const struct sockaddr *)&addr,
sizeof( struct sockaddr_nl));
@ -160,7 +159,7 @@ ssize_t netlib_get_arptable(FAR struct arp_entry_s *arptab,
memset(&req, 0, sizeof(req));
req.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg));
req.hdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT | NLM_F_REQUEST;
req.hdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
req.hdr.nlmsg_seq = thiseq;
req.hdr.nlmsg_type = RTM_GETNEIGH;
req.hdr.nlmsg_pid = pid;

View File

@ -129,7 +129,7 @@ ssize_t netlib_get_devices(FAR struct netlib_device_s *devlist,
addr.nl_family = AF_NETLINK;
addr.nl_pad = 0;
addr.nl_pid = pid;
addr.nl_groups = RTM_GETLINK;
addr.nl_groups = 0;
ret = bind(fd, (FAR const struct sockaddr *)&addr,
sizeof( struct sockaddr_nl));
@ -256,17 +256,6 @@ ssize_t netlib_get_devices(FAR struct netlib_device_s *devlist,
}
break;
/* RTM_NEWROUTE provides routing information for the device
* (address, gateway, etc.)
*/
case RTM_NEWROUTE:
{
fprintf(stderr, "WARNING: RTM_NEWLINK Message type not "
"implemented\n");
}
break;
default:
fprintf(stderr, "ERROR: Message type %u, length %lu\n",
resp.hdr.nlmsg_type, (unsigned long)resp.hdr.nlmsg_len);

View File

@ -44,7 +44,6 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <errno.h>
#include <netpacket/netlink.h>
@ -143,7 +142,7 @@ ssize_t netlib_get_nbtable(FAR struct neighbor_entry_s *nbtab,
addr.nl_family = AF_NETLINK;
addr.nl_pad = 0;
addr.nl_pid = pid;
addr.nl_groups = RTM_GETNEIGH;
addr.nl_groups = 0;
ret = bind(fd, (FAR const struct sockaddr *)&addr,
sizeof( struct sockaddr_nl));
@ -161,7 +160,7 @@ ssize_t netlib_get_nbtable(FAR struct neighbor_entry_s *nbtab,
memset(&req, 0, sizeof(req));
req.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct ndmsg));
req.hdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_ROOT | NLM_F_REQUEST;
req.hdr.nlmsg_flags = NLM_F_REQUEST | NLM_F_DUMP;
req.hdr.nlmsg_seq = thiseq;
req.hdr.nlmsg_type = RTM_GETNEIGH;
req.hdr.nlmsg_pid = pid;

View File

@ -158,7 +158,7 @@ ssize_t netlib_get_route(FAR struct rtentry *rtelist,
addr.nl_family = AF_NETLINK;
addr.nl_pad = 0;
addr.nl_pid = pid;
addr.nl_groups = RTM_GETROUTE;
addr.nl_groups = 0;
ret = bind(fd, (FAR const struct sockaddr *)&addr,
sizeof( struct sockaddr_nl));
@ -247,9 +247,6 @@ ssize_t netlib_get_route(FAR struct rtentry *rtelist,
enddump = true;
break;
case RTM_NEWLINK:
break; /* Ignore any link information */
case RTM_NEWROUTE:
{
FAR struct rtentry *dest;