linux - netlink 和大端格式

标签 linux networking linux-kernel netlink

我没有在内核中找到任何文档/说明,要求以网络字节顺序将 netlink 消息中的 16/32-bit 值传递给内核。所以我的问题是在填充网络链接消息时是否必须使用 htonl/htons 函数。有这样的要求吗?

最佳答案

根据 this article这可以在每个属性的基础上进行控制

There are two special flags which may be present in netlink attributes, though I have yet to encounter them in my work.

NLA_F_NESTED: specifies a nested attribute; used as a hint for parsing. Doesn’t always appear to be used, even if nested attributes are present. NLA_F_NET_BYTEORDER: attribute data is stored in network byte order (big endian) instead of host endianness

UPD:看起来 native (小)字节序在某些情况下不能很好地工作:我得到 errno 4097 试图使用它传递 IPSET CREATE 超时。网络字节顺序工作正常。

关于linux - netlink 和大端格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43370845/

相关文章:

android - BusyBox 帮助,ip 命令

Java: "Listening"到数据流

C++ - 发送的请求未到达其他计算机

java - 在 Google Android 中以编程方式连接到 WiFi?

linux - 如何增加内核内部的进程能力?

linux - 如何在Linux中的文件中添加内容而不使用vi或cat命令打开文件

linux - Hadoop Streaming 没有正确编码字符

php - 如何从命令行正确运行 php

c - 如何使用 C 系统调用和管道处理文件 I/O?

linux - systemtap 脚本错误