提问人:Pedro Henrique 提问时间:11/15/2023 最后编辑:user207421Pedro Henrique 更新时间:11/15/2023 访问量:56
如何向 ipv4 数据包添加选项?
How do I add options to the ipv4 packet?
问:
我正在用 C 语言开发一个网络工具,它允许我向主机发送自定义数据包。到目前为止,一切都很好,但我决定实施 IPv4 选项,但我没有找到任何关于如何做到这一点的信息。
我找到了,但我不知道如何使用它来实现它:struct options
struct iphdr
struct options {
__u32 faddr; /* Saved first hop address */
unsigned char optlen;
unsigned char srr;
unsigned char rr;
unsigned char ts;
unsigned char is_setbyuser:1, /* Set by setsockopt? */
is_data:1, /* Options in __data, rather than skb */
is_strictroute:1, /* Strict source route */
srr_is_hit:1, /* Packet destination addr was our one */
is_changed:1, /* IP checksum more not valid */
rr_needaddr:1, /* Need to record addr of outgoing dev */
ts_needtime:1, /* Need to record timestamp */
ts_needaddr:1; /* Need to record addr of outgoing dev */
unsigned char __pad1;
unsigned char __pad2;
unsigned char __pad3;
unsigned char __data[0];
};
答: 暂无答案
评论
setsockopt()
IP_HDRINCL
IP_OPTIONS