Read list of tables/targets/matches

This commit is contained in:
Brian Candler
2011-05-06 15:23:01 +01:00
parent 15d26f5595
commit 7d3671e9d1
2 changed files with 21 additions and 0 deletions

View File

@@ -36,6 +36,22 @@ module Linux
def self.table(tablename = "filter")
@tables[tablename] ||= new(tablename, socket)
end
def self.tables
proc_read(self::PROC_TABLES)
end
def self.targets
proc_read(self::PROC_TARGETS)
end
def self.matches
proc_read(self::PROC_MATCHES)
end
def self.proc_read(filename)
File.readlines(filename).each { |x| x.chomp! }
end
def initialize(name, socket)
raise "Invalid table name" if name.bytesize > self.class::TABLE_MAXNAMELEN