Skip to content

Commit bdb5639

Browse files
zhhyu7xiaoxiang781216
authored andcommitted
netlink: convert lltype to device type
adapts to third-party code compilation. in the process of porting ConnMan, we encounter some situations where the structure is not defined, or the returned data types do not match the expectations. Refer to the common implementation of other systems and add relevant definitions. Signed-off-by: zhanghongyu <[email protected]>
1 parent 06f8875 commit bdb5639

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

net/netlink/netlink_route.c

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
#include "netdev/netdev.h"
4343
#include "arp/arp.h"
44+
#include "net/if_arp.h"
4445
#include "neighbor/neighbor.h"
4546
#include "route/route.h"
4647
#include "netlink/netlink.h"
@@ -246,6 +247,44 @@ static_assert(sizeof(g_ifa_ipv6_policy) / sizeof(g_ifa_ipv6_policy[0]) ==
246247
****************************************************************************/
247248

248249
#ifndef CONFIG_NETLINK_DISABLE_GETLINK
250+
251+
static uint16_t netlink_convert_device_type(uint8_t lltype)
252+
{
253+
switch (lltype)
254+
{
255+
case NET_LL_ETHERNET:
256+
return ARPHRD_ETHER;
257+
258+
case NET_LL_IEEE80211:
259+
return ARPHRD_IEEE80211;
260+
261+
case NET_LL_LOOPBACK:
262+
return ARPHRD_LOOPBACK;
263+
264+
case NET_LL_SLIP:
265+
return ARPHRD_SLIP;
266+
267+
case NET_LL_TUN:
268+
case NET_LL_BLUETOOTH:
269+
case NET_LL_PKTRADIO:
270+
case NET_LL_MBIM:
271+
return ARPHRD_NONE;
272+
273+
case NET_LL_IEEE802154:
274+
return ARPHRD_IEEE802154;
275+
276+
case NET_LL_CAN:
277+
return ARPHRD_CAN;
278+
279+
case NET_LL_CELL:
280+
return ARPHRD_PHONET_PIPE;
281+
282+
default:
283+
nerr("ERROR: invalid lltype %d\n", lltype);
284+
return ARPHRD_VOID;
285+
}
286+
}
287+
249288
static FAR struct netlink_response_s *
250289
netlink_get_device(FAR struct net_driver_s *dev,
251290
FAR const struct nlroute_sendto_request_s *req)
@@ -275,7 +314,7 @@ netlink_get_device(FAR struct net_driver_s *dev,
275314
resp->hdr.nlmsg_pid = req ? req->hdr.nlmsg_pid : 0;
276315

277316
resp->iface.ifi_family = req ? req->gen.rtgen_family : AF_PACKET;
278-
resp->iface.ifi_type = dev->d_lltype;
317+
resp->iface.ifi_type = netlink_convert_device_type(dev->d_lltype);
279318
#ifdef CONFIG_NETDEV_IFINDEX
280319
resp->iface.ifi_index = dev->d_ifindex;
281320
#endif

0 commit comments

Comments
 (0)