如何在C中更改来自NIC的传入数据包? [英] How do I change incoming packet from NIC in C?

查看:88
本文介绍了如何在C中更改来自NIC的传入数据包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

libpcap仅能读取数据包,如何更改?

libpcap can only read the packets, how can I change it?

基本上我想注册一个对所有传入数据包都起作用的回调函数,

Basically I want to register a callback function that operates on all incoming packets,

这怎么办?

推荐答案

这是什么类型的流量?您要如何修改?什么操作系统?

What kind of traffic is this? How do you want to modify it? What OS?

在Linux上,您也许可以使用iptables来让内核为您修改数据包.

On linux, you may be able to use iptables to have the kernel modify the packets for you.

如果这不能满足您的要求(即,需要将数据包放入用户空间),则可以查看

If that can't do what you want (i.e., you need to get the packets into user space), you could look at netfilter_queue. Or as a simpler alternative, use an iptables REDIRECT rule to send all the packets to a single port, and write an application to listen on that port.

这篇关于如何在C中更改来自NIC的传入数据包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆