【问题标题】:Dereferencing Pointer Error when processing Ip header from raw Sockets处理来自原始套接字的 Ip 标头时取消引用指针错误
【发布时间】:2012-02-27 09:53:20
【问题描述】:

void parse_message(char *buffer, int len) {

struct iphrd *ip_header = (struct iphrd *)buffer;

int recv_hopcount = (unsigned int)(ip_header->ttl);

//hops[recv_hopcount]++;

}

错误:取消引用指向不完整类型的指针

我在头文件中包含了 netinet/ip.h。上面的代码是为了访问 IP 头中包含的 ttl 值而编写的。使用原始套接字。

【问题讨论】:

    标签: sockets raw-sockets incomplete-type


    【解决方案1】:

    看起来 iphrd 结构没有在任何地方定义。是iphdr的错字吗?您的问题看起来没有名为 iphrd 的结构...

    【讨论】:

    • 非常感谢。是的,它是 iphdr
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-11
    • 2018-06-01
    • 2022-01-19
    相关资源
    最近更新 更多