简体   繁体   English

ARM64上的多播“没有这样的设备”?

[英]Multicast 'no such device' on ARM64?

This is from a working legacy code base that has already been ported to and is still shared by several other hardware platforms so making a major change to this method is not a good solution.这来自一个已经被移植到并且仍然由其他几个硬件平台共享的工作遗留代码库,因此对这种方法进行重大更改并不是一个好的解决方案。 This is a new port to a ZCU111 ARM64.这是 ZCU111 ARM64 的新端口。 The Linux kernel has been built with multicast support (CONFIG_IP_MULTICAST=y). Linux kernel 已构建支持多播 (CONFIG_IP_MULTICAST=y)。

This is a summary of the code:这是代码的摘要:

const char *const MULTICAST_IP = "224.0.0.26";
const unsigned int BCAST_PORT = 35001;
struct ip_mreq mreq;
int optval = 1;
int optlen = sizeof(int);
int fd = socket(AF_INET,SOCK_DGRAM,0);
int flags = fcntl(fd,F_GETFL,0);
fcntl(fd,F_SETFL,flags|O_NONBLOCK);
setsockopt(fd,SOL_SOCKET,SO_REUSEADDR,&optval,optlen);
bzero(&sock_addr,sizeof(sock_addr));
sock_addr.sin_family=AF_INET;
sock_addr.sin_addr.s_addr=htonl(INADDR_ANY);
sock_addr.sin_port=htons(BCAST_PORT);
bind(fd,reinterpret_cast<const sockaddr *>(&sock_addr),sizeof(struct sockaddr_in));
mreq.imr_multiaddr.s_addr = inet_addr(MULTICAST_IP);
mreq.imr_interface.s_addr = htonl(INADDR_ANY);
if (setsockopt(fd,IPPROTO_IP,IP_ADD_MEMBERSHIP,&mreq,sizeof(mreq))<0) PRINTF_ERROR;

PRINTF_ERROR is used to print the FILE, LINE, func, strerror, and errno like this: PRINTF_ERROR 用于打印 FILE、LINE、func、strerror 和 errno,如下所示:

gps.cpp:93 (GetFileDescriptor) ERROR No such device 19

Changing IPPROTO_IP to IPPROTO_UDP causes the following error:将 IPPROTO_IP 更改为 IPPROTO_UDP 会导致以下错误:

gps.cpp:93 (GetFileDescriptor) ERROR Protocol not available 92

I already looked at these solutions but not sure how they apply in this case.我已经看过这些解决方案,但不确定它们在这种情况下如何应用。 Any idea how to fix the 'No such device' error?知道如何解决“没有这样的设备”错误吗?

I do not claim credit for this answer (found it online ), but in the interest of keeping shared knowledge, will post the solution here.我不主张这个答案的功劳(在网上找到),但为了保持共享知识,将在此处发布解决方案。

The problem seems to be essentially a broken route for multicast group, and it can be fixed with following command:该问题似乎本质上是多播组的路由中断,可以使用以下命令修复:

route add -net 224.0.0.0 netmask 224.0.0.0 eth0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM