#ifdef SIOCSHWTSTAMP 未找到
#ifdef SIOCSHWTSTAMP not found
我想在网卡上获取硬件时间戳。我从 Solarflare 找到了一些示例代码,它检查是否定义了以下标签:
#ifdef SIOCSHWTSTAMP
struct ifreq ifr;
struct hwtstamp_config hwc;
#else
static_assert(false); // I added this to check whether my system has the label defined
#endif
但是 static_assert
被触发了,所以我的系统中没有定义这个标签。
我包括这些 header:
#include <netinet/in.h>
#include <arpa/inet.h>
#include <time.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
很明显它没有在那些中定义。
我们安装了 linux-libc-dev
,但它似乎没有帮助。
它应该存在于哪个 header 中,以便我查看?
我的内核版本是3.10.0-1062.4.1.el7.x86_64和CentOS 7
在 Linux OS 中,它在用户 API 内核头文件中定义,即在
include/uapi/linux/sockios.h 截至今天的最新 v3.10.y 内核。
对于较新的内核,它仍然存在。
必要的结构和枚举值在include/uapi/linux/net_tstamp.h中定义。
我想在网卡上获取硬件时间戳。我从 Solarflare 找到了一些示例代码,它检查是否定义了以下标签:
#ifdef SIOCSHWTSTAMP
struct ifreq ifr;
struct hwtstamp_config hwc;
#else
static_assert(false); // I added this to check whether my system has the label defined
#endif
但是 static_assert
被触发了,所以我的系统中没有定义这个标签。
我包括这些 header:
#include <netinet/in.h>
#include <arpa/inet.h>
#include <time.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
很明显它没有在那些中定义。
我们安装了 linux-libc-dev
,但它似乎没有帮助。
它应该存在于哪个 header 中,以便我查看?
我的内核版本是3.10.0-1062.4.1.el7.x86_64和CentOS 7
在 Linux OS 中,它在用户 API 内核头文件中定义,即在 include/uapi/linux/sockios.h 截至今天的最新 v3.10.y 内核。 对于较新的内核,它仍然存在。
必要的结构和枚举值在include/uapi/linux/net_tstamp.h中定义。