Basic NETLINK_FIREWALL support. Highlights need for struct alignment

This commit is contained in:
Brian Candler
2011-05-01 12:32:22 +01:00
parent aefd94093c
commit b78327c3b6
7 changed files with 297 additions and 7 deletions

18
examples/firewall.rb Normal file
View File

@@ -0,0 +1,18 @@
LIBDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift LIBDIR
require 'pp'
require 'netlink/firewall'
# Example of using Netlink::Firewall to capture all outbound packets
# to TCP port 7551. Use "telnet 127.0.0.1 7551" to test.
#system("modprobe ip_queue")
#system("modprobe iptable_filter")
#system("iptables -I OUTPUT -j QUEUE -p tcp --destination-port 7551")
nl = Netlink::Firewall::Socket.new
nl.set_mode(Netlink::IPQ_COPY_PACKET, 128)
nl.dequeue_packets do |pkt|
p pkt
Netlink::NF_ACCEPT # Netlink::NF_DROP
end