The kernel can dynamically determine the transmitting interface of the IP package, determined by routing information

xiaoxiao2021-03-05  23

Lzgogogo (STRANGER) 03-11-16 18:45

How to send a packet in the outside of the kernel in the outside?

Reply I wrote a package in the Netfilter framework, now you want to implement a function, you can generate a packet according to your own requirements and send it out. For example, I have to send a packet now, the packet from 192.168.1.154 : 80 Send to 192.168.1.155, SEQ is 3187958690 ACK is 3187958691, SYN ACK sets, etc. I have the idea to refer to some methods of producing SKB structure in the driver, that is, call dev_alloc_skb (), and then carry out its corresponding part Fill. Finally call dev_queue_xmit () to send. I have encountered some questions: I have to determine how to send it with that network interface, I found the function dev_get_by_name (), but this call requires a network interface name (such as Eth0, Eth1 But in advance, it is not certain that it is the network interface. If it can only be specified when the module is inserted, there is a way to determine the network interface? The second question is how the SKB is related to how to Fill? Such as DST, CSUM, SK, STAMP, etc., or do not have to take these parts at all. I don't know if my idea is feasible. Do you need to pay attention to those part? What is the similar function? Is there a ready-made? Example Reference Please advise, thank you for your article: DL_DHT (Member) 03-11-17 10:18

RE: How to send a packet in the outside of the kernel? [Re: lzgogogo]

Reply Use IP_ROUTE_OUTPUT_KEY to determine the use of the interface to send. Article option:

转载请注明原文地址:https://www.9cbs.com/read-32318.html

New Post(0)