我有这些结构:
typedef struct dnsQuery {
char header[12];
struct TdnsQuerySection *querySection;
} TdnsQuery;
typedef struct dnsQuerySection {
unsigned char *name;
struct TdnsQueryQuestion *question;
} TdnsQuerySection;
typedef struct dnsQueryQuestion {
unsigned short qtype;
unsigned short qclass;
} TdnsQueryQuestion;
我在字节数组中有 dns 查询recvfrom
。我正在尝试从字节数组中获取结构,如下所示:
TdnsQuery* dnsQuery = (TdnsQuery*)buf;
printf("%u", dnsQuery->querySection->question.qtype);
为什么我收到错误取消引用指向不完整类型的指针?我这样做对吗?或者如何从该数组中获取 dns 查询结构?我需要那个 dns 查询问题和类型。