Reorganise under Linux::
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
LIBDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||
$LOAD_PATH.unshift LIBDIR
|
||||
|
||||
require 'netlink/route'
|
||||
require 'linux/netlink/route'
|
||||
|
||||
ip = Netlink::Route::Socket.new
|
||||
ip = Linux::Netlink::Route::Socket.new
|
||||
puts "\n*** Before adding address"
|
||||
ip.addr.list(:index=>"lo", :family=>Socket::AF_INET) { |x| puts x.address }
|
||||
|
||||
|
@@ -1,11 +1,11 @@
|
||||
LIBDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||
$LOAD_PATH.unshift LIBDIR
|
||||
|
||||
require 'netlink/route'
|
||||
require 'linux/netlink/route'
|
||||
|
||||
ip = Netlink::Route::Socket.new
|
||||
ip = Linux::Netlink::Route::Socket.new
|
||||
puts "\n*** Before adding route"
|
||||
ip.route.list(:family=>Socket::AF_INET, :table=>Netlink::RT_TABLE_MAIN) { |x| p x }
|
||||
ip.route.list(:family=>Socket::AF_INET, :table=>Linux::RT_TABLE_MAIN) { |x| p x }
|
||||
|
||||
puts "\n*** After adding route"
|
||||
begin
|
||||
@@ -13,9 +13,9 @@ begin
|
||||
rescue Errno::EEXIST
|
||||
puts "Already exists"
|
||||
end
|
||||
ip.route.list(:family=>Socket::AF_INET, :table=>Netlink::RT_TABLE_MAIN) { |x| p x }
|
||||
ip.route.list(:family=>Socket::AF_INET, :table=>Linux::RT_TABLE_MAIN) { |x| p x }
|
||||
|
||||
puts "\n*** After deleting route"
|
||||
ip.route.delete(:oif=>"lo", :dst=>"1.2.3.4", :dst_len=>32, :gateway=>"127.0.0.1")
|
||||
ip.route.list(:family=>Socket::AF_INET, :table=>Netlink::RT_TABLE_MAIN) { |x| p x }
|
||||
ip.route.list(:family=>Socket::AF_INET, :table=>Linux::RT_TABLE_MAIN) { |x| p x }
|
||||
|
||||
|
@@ -1,10 +1,10 @@
|
||||
LIBDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||
$LOAD_PATH.unshift LIBDIR
|
||||
|
||||
require 'netlink/route'
|
||||
require 'linux/netlink/route'
|
||||
require 'pp'
|
||||
|
||||
ip = Netlink::Route::Socket.new
|
||||
ip = Linux::Netlink::Route::Socket.new
|
||||
puts "\n*** Before adding VLAN"
|
||||
pp ip.vlan.list(:link=>"lo").to_a
|
||||
|
||||
@@ -16,6 +16,6 @@ rescue Errno::EEXIST
|
||||
end
|
||||
pp ip.vlan.list(:link=>"lo").to_a
|
||||
|
||||
puts "\n*** After deleting VLANs from lo"
|
||||
puts "\n*** After deleting VLAN from lo"
|
||||
ip.vlan.delete(:link=>"lo", :vlan_id=>1234)
|
||||
pp ip.vlan.list(:link=>"lo").to_a
|
||||
|
@@ -2,7 +2,7 @@ LIBDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||
$LOAD_PATH.unshift LIBDIR
|
||||
|
||||
require 'pp'
|
||||
require 'netlink/firewall'
|
||||
require 'linux/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.
|
||||
@@ -10,9 +10,9 @@ require 'netlink/firewall'
|
||||
#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 = Linux::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
|
||||
Linux::NF_ACCEPT # Linux::NF_DROP
|
||||
end
|
||||
|
@@ -2,13 +2,13 @@ LIBDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||
$LOAD_PATH.unshift LIBDIR
|
||||
|
||||
require 'pp'
|
||||
require 'netlink/nflog'
|
||||
require 'linux/netlink/nflog'
|
||||
|
||||
# Example of using Netlink::NFLog to capture all outbound packets
|
||||
# Example of using Linux::Netlink::NFLog to capture all outbound packets
|
||||
# to TCP port 7551. Use "telnet 127.0.0.1 7551" to test.
|
||||
|
||||
#system("iptables -I OUTPUT -j ULOG --ulog-nlgroup 1 -p tcp --destination-port 7551")
|
||||
nl = Netlink::NFLog::Socket.new(:group => 1)
|
||||
nl = Linux::Netlink::NFLog::Socket.new(:group => 1)
|
||||
nl.dequeue_packets do |pkt|
|
||||
p pkt
|
||||
end
|
||||
|
@@ -2,13 +2,13 @@ LIBDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||
$LOAD_PATH.unshift LIBDIR
|
||||
|
||||
require 'pp'
|
||||
require 'netlink/route'
|
||||
require 'linux/netlink/route'
|
||||
|
||||
# Example of use of high-level API for NETLINK_ROUTE socket.
|
||||
# The data is memoized - that is, it's downloaded from the kernel once
|
||||
# and then manipulated internally.
|
||||
|
||||
ip = Netlink::Route::Socket.new
|
||||
ip = Linux::Netlink::Route::Socket.new
|
||||
|
||||
puts "\nInterface eth0:"
|
||||
pp ip.link["eth0"]
|
||||
@@ -17,10 +17,10 @@ puts "\nAddresses on interface eth0:"
|
||||
pp ip.addr.list(:index=>"eth0").to_a
|
||||
|
||||
puts "\nAll routes in main routing table:"
|
||||
pp ip.route.list(:table=>Netlink::RT_TABLE_MAIN).to_a
|
||||
pp ip.route.list(:table=>Linux::RT_TABLE_MAIN).to_a
|
||||
|
||||
puts "\nV4 default route is probably:"
|
||||
pp ip.route.list(:family=>Socket::AF_INET, :table=>Netlink::RT_TABLE_MAIN).
|
||||
pp ip.route.list(:family=>Socket::AF_INET, :table=>Linux::RT_TABLE_MAIN).
|
||||
min_by { |route| route.dst_len }
|
||||
|
||||
puts "\nTraffic to 192.168.1.1 goes out via:"
|
||||
|
@@ -2,12 +2,12 @@ LIBDIR = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
||||
$LOAD_PATH.unshift LIBDIR
|
||||
|
||||
require 'pp'
|
||||
require 'netlink/route'
|
||||
require 'linux/netlink/route'
|
||||
|
||||
# Example of use of low-level API for NETLINK_ROUTE socket.
|
||||
# Each of these method calls performs a netlink protocol exchange.
|
||||
|
||||
ip = Netlink::Route::Socket.new
|
||||
ip = Linux::Netlink::Route::Socket.new
|
||||
puts "*** links ***"
|
||||
pp ip.link.read_link
|
||||
puts "*** addrs ***"
|
||||
|
Reference in New Issue
Block a user