pcaprub 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -19,3 +19,5 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
+ Makefile
23
+ mkmf.log
data/Rakefile CHANGED
@@ -16,6 +16,7 @@ end
16
16
 
17
17
  CLEAN.include 'ext/**/Makefile'
18
18
  CLEAN.include 'ext/**/*.o'
19
+ CLEAN.include 'ext/**/mkmf.log'
19
20
  CLEAN.include 'ext/**/*.so'
20
21
  CLEAN.include 'lib/**/*.so'
21
22
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.0
1
+ 0.8.1
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{pcaprub}
8
- s.version = "0.8.0"
8
+ s.version = "0.8.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["shadowbq"]
@@ -21,18 +21,16 @@ Gem::Specification.new do |s|
21
21
  ".document",
22
22
  ".gitignore",
23
23
  "LICENSE",
24
- "Makefile",
25
24
  "README.rdoc",
26
25
  "Rakefile",
27
26
  "VERSION",
28
27
  "ext/pcaprub/extconf.rb",
29
- "ext/pcaprub/mkmf.log",
30
28
  "ext/pcaprub/pcaprub.c",
31
29
  "lib/pcaprub.rb",
32
- "mkmf.log",
33
30
  "pcaprub.gemspec",
34
31
  "test/helper.rb",
35
- "test/test_pcaprub.rb"
32
+ "test/test_pcaprub.rb",
33
+ "test/test_pcaprub_unit.rb"
36
34
  ]
37
35
  s.homepage = %q{http://github.com/shadowbq/pcaprub}
38
36
  s.rdoc_options = ["--charset=UTF-8"]
@@ -42,7 +40,8 @@ Gem::Specification.new do |s|
42
40
  s.summary = %q{libpcap bindings for ruby}
43
41
  s.test_files = [
44
42
  "test/helper.rb",
45
- "test/test_pcaprub.rb"
43
+ "test/test_pcaprub.rb",
44
+ "test/test_pcaprub_unit.rb"
46
45
  ]
47
46
 
48
47
  if s.respond_to? :specification_version then
@@ -0,0 +1,95 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ base = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
4
+ $:.unshift(File.join(File.dirname(base)))
5
+
6
+ require 'test/unit'
7
+ require 'pcaprub'
8
+
9
+ #
10
+ # Simple unit test, requires r00t.
11
+ #
12
+
13
+ class Pcap::UnitTest < Test::Unit::TestCase
14
+
15
+ def test_version
16
+ assert_equal(String, Pcap.version.class)
17
+ puts "Pcaprub version: #{Pcap.version}"
18
+ end
19
+
20
+ def test_lookupdev
21
+ assert_equal(String, Pcap.lookupdev.class)
22
+ puts "Pcaprub default device: #{Pcap.lookupdev}"
23
+ end
24
+
25
+ def test_lookupnet
26
+ dev = Pcap.lookupdev
27
+ assert_equal(Array, Pcap.lookupnet(dev).class)
28
+ net = Pcap.lookupnet(dev)
29
+ puts "Pcaprub net (#{dev}): #{net[0]} #{[net[1]].pack("N").unpack("H*")[0]}"
30
+ end
31
+
32
+ def test_pcap_new
33
+ o = Pcap.new
34
+ assert_equal(Pcap, o.class)
35
+ end
36
+
37
+ def test_pcap_setfilter_bad
38
+ e = nil
39
+ o = Pcap.new
40
+ begin
41
+ o.setfilter("not ip")
42
+ rescue ::Exception => e
43
+ end
44
+
45
+ assert_equal(e.class, ArgumentError)
46
+ end
47
+
48
+ def test_pcap_setfilter
49
+ d = Pcap.lookupdev
50
+ o = Pcap.open_live(d, 65535, true, 1)
51
+ r = o.setfilter("not ip")
52
+ assert_equal(Pcap, r.class)
53
+ end
54
+
55
+ def test_pcap_inject
56
+ d = Pcap.lookupdev
57
+ o = Pcap.open_live(d, 65535, true, 1)
58
+ r = o.inject("X" * 512)
59
+ assert_equal(512, r)
60
+ end
61
+
62
+ def test_pcap_datalink
63
+ d = Pcap.lookupdev
64
+ o = Pcap.open_live(d, 65535, true, 1)
65
+ r = o.datalink
66
+ assert_equal(Fixnum, r.class)
67
+ end
68
+
69
+ def test_pcap_snapshot
70
+ d = Pcap.lookupdev
71
+ o = Pcap.open_live(d, 1344, true, 1)
72
+ r = o.snapshot
73
+ assert_equal(1344, r)
74
+ end
75
+
76
+ def test_pcap_stats
77
+ d = Pcap.lookupdev
78
+ o = Pcap.open_live(d, 1344, true, 1)
79
+ r = o.stats
80
+ assert_equal(Hash, r.class)
81
+ end
82
+
83
+ def test_pcap_next
84
+ =begin
85
+ d = Pcap.lookupdev
86
+ o = Pcap.open_live(d, 1344, true, 1)
87
+ @c = 0
88
+ t = Thread.new { while(true); @c += 1; end; }
89
+ x = o.next
90
+ t.kill
91
+ =end
92
+ true
93
+ end
94
+
95
+ enD
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pcaprub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - shadowbq
@@ -26,18 +26,16 @@ files:
26
26
  - .document
27
27
  - .gitignore
28
28
  - LICENSE
29
- - Makefile
30
29
  - README.rdoc
31
30
  - Rakefile
32
31
  - VERSION
33
32
  - ext/pcaprub/extconf.rb
34
- - ext/pcaprub/mkmf.log
35
33
  - ext/pcaprub/pcaprub.c
36
34
  - lib/pcaprub.rb
37
- - mkmf.log
38
35
  - pcaprub.gemspec
39
36
  - test/helper.rb
40
37
  - test/test_pcaprub.rb
38
+ - test/test_pcaprub_unit.rb
41
39
  has_rdoc: true
42
40
  homepage: http://github.com/shadowbq/pcaprub
43
41
  licenses: []
@@ -69,3 +67,4 @@ summary: libpcap bindings for ruby
69
67
  test_files:
70
68
  - test/helper.rb
71
69
  - test/test_pcaprub.rb
70
+ - test/test_pcaprub_unit.rb
data/Makefile DELETED
@@ -1,128 +0,0 @@
1
-
2
- SHELL = /bin/sh
3
-
4
- #### Start of system configuration section. ####
5
-
6
- srcdir = /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake
7
- topdir = /usr/local/lib/ruby/1.8/i386-freebsd8
8
- hdrdir = $(topdir)
9
- VPATH = $(srcdir):$(topdir):$(hdrdir)
10
- exec_prefix = $(prefix)
11
- prefix = $(DESTDIR)/usr/local
12
- sharedstatedir = $(prefix)/com
13
- mandir = $(DESTDIR)/usr/local/man
14
- psdir = $(docdir)
15
- oldincludedir = $(DESTDIR)/usr/include
16
- localedir = $(datarootdir)/locale
17
- bindir = $(exec_prefix)/bin
18
- libexecdir = $(exec_prefix)/libexec
19
- sitedir = $(libdir)/ruby/site_ruby
20
- htmldir = $(docdir)
21
- vendorarchdir = $(vendorlibdir)/$(sitearch)
22
- includedir = $(prefix)/include
23
- infodir = $(DESTDIR)/usr/local/info
24
- vendorlibdir = $(vendordir)/$(ruby_version)
25
- sysconfdir = $(prefix)/etc
26
- libdir = $(exec_prefix)/lib
27
- sbindir = $(exec_prefix)/sbin
28
- rubylibdir = $(libdir)/ruby/$(ruby_version)
29
- docdir = $(datarootdir)/doc/$(PACKAGE)
30
- dvidir = $(docdir)
31
- vendordir = $(libdir)/ruby/vendor_ruby
32
- datarootdir = $(prefix)/share
33
- pdfdir = $(docdir)
34
- archdir = $(rubylibdir)/$(arch)
35
- sitearchdir = $(sitelibdir)/$(sitearch)
36
- datadir = $(datarootdir)
37
- localstatedir = $(prefix)/var
38
- sitelibdir = $(sitedir)/$(ruby_version)
39
-
40
- CC = cc
41
- LIBRUBY = $(LIBRUBY_SO)
42
- LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
43
- LIBRUBYARG_SHARED = -Wl,-R -Wl,$(libdir) -L$(libdir) -l$(RUBY_SO_NAME)
44
- LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static
45
-
46
- RUBY_EXTCONF_H =
47
- CFLAGS = -fPIC -O2 -pipe -fno-strict-aliasing -fPIC $(cflags)
48
- INCFLAGS = -I. -I. -I/usr/local/lib/ruby/1.8/i386-freebsd8 -I/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake
49
- DEFS =
50
- CPPFLAGS =
51
- CXXFLAGS = $(CFLAGS)
52
- ldflags = -L. -rdynamic
53
- dldflags = -Wl,-soname,$(.TARGET)
54
- archflag =
55
- DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
56
- LDSHARED = cc -shared
57
- AR = ar
58
- EXEEXT =
59
-
60
- RUBY_INSTALL_NAME = ruby18
61
- RUBY_SO_NAME = ruby18
62
- arch = i386-freebsd8
63
- sitearch = i386-freebsd8
64
- ruby_version = 1.8
65
- ruby = /usr/local/bin/ruby18
66
- RUBY = $(ruby)
67
- RM = rm -f
68
- MAKEDIRS = mkdir -p
69
- INSTALL = /usr/bin/install -c -o root -g wheel
70
- INSTALL_PROG = $(INSTALL) -m 0755
71
- INSTALL_DATA = install -o root -g wheel -m 444
72
- COPY = cp
73
-
74
- #### End of system configuration section. ####
75
-
76
- preload =
77
-
78
- libpath = . $(libdir)
79
- LIBPATH = -L. -L$(libdir) -Wl,-R$(libdir)
80
- DEFFILE =
81
-
82
- CLEANFILES = mkmf.log
83
- DISTCLEANFILES =
84
-
85
- extout =
86
- extout_prefix =
87
- target_prefix =
88
- LOCAL_LIBS =
89
- LIBS = $(LIBRUBYARG_SHARED) -lpcap -lrt -lcrypt -lm -rpath=/usr/lib:/usr/local/lib -pthread
90
- SRCS =
91
- OBJS =
92
- TARGET =
93
- DLLIB =
94
- EXTSTATIC =
95
- STATIC_LIB =
96
-
97
- BINDIR = $(bindir)
98
- RUBYCOMMONDIR = $(sitedir)$(target_prefix)
99
- RUBYLIBDIR = $(sitelibdir)$(target_prefix)
100
- RUBYARCHDIR = $(sitearchdir)$(target_prefix)
101
-
102
- TARGET_SO = $(DLLIB)
103
- CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
104
- CLEANOBJS = *.o *.a *.s[ol] *.pdb *.exp *.bak
105
-
106
- all: Makefile
107
- static: $(STATIC_LIB)
108
-
109
- clean:
110
- @-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
111
-
112
- distclean: clean
113
- @-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
114
- @-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
115
-
116
- realclean: distclean
117
- install: install-so install-rb
118
-
119
- install-so: Makefile
120
- install-rb: pre-install-rb install-rb-default
121
- install-rb-default: pre-install-rb-default
122
- pre-install-rb: Makefile
123
- pre-install-rb-default: Makefile
124
-
125
- site-install: site-install-so site-install-rb install
126
- site-install-so: install-so
127
- site-install-rb: install-rb
128
-
@@ -1,48 +0,0 @@
1
- have_library: checking for pcap_open_live() in -lpcap... -------------------- yes
2
-
3
- "cc -o conftest -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -O2 -fno-strict-aliasing -pipe -fPIC conftest.c -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -lruby18-static -lpcap -lcrypt -lm -rpath=/usr/lib:/usr/local/lib -pthread -lc"
4
- conftest.c: In function 't':
5
- conftest.c:3: error: 'pcap_open_live' undeclared (first use in this function)
6
- conftest.c:3: error: (Each undeclared identifier is reported only once
7
- conftest.c:3: error: for each function it appears in.)
8
- checked program was:
9
- /* begin */
10
- 1: /*top*/
11
- 2: int main() { return 0; }
12
- 3: int t() { void ((*volatile p)()); p = (void ((*)()))pcap_open_live; return 0; }
13
- /* end */
14
-
15
- "cc -o conftest -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -O2 -fno-strict-aliasing -pipe -fPIC conftest.c -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -lruby18-static -lpcap -lcrypt -lm -rpath=/usr/lib:/usr/local/lib -pthread -lc"
16
- checked program was:
17
- /* begin */
18
- 1: /*top*/
19
- 2: int main() { return 0; }
20
- 3: int t() { pcap_open_live(); return 0; }
21
- /* end */
22
-
23
- --------------------
24
-
25
- have_library: checking for pcap_setnonblock() in -lpcap... -------------------- yes
26
-
27
- "cc -o conftest -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -O2 -fno-strict-aliasing -pipe -fPIC conftest.c -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -lpcap -lruby18-static -lpcap -lpcap -lcrypt -lm -rpath=/usr/lib:/usr/local/lib -pthread -lc"
28
- conftest.c: In function 't':
29
- conftest.c:3: error: 'pcap_setnonblock' undeclared (first use in this function)
30
- conftest.c:3: error: (Each undeclared identifier is reported only once
31
- conftest.c:3: error: for each function it appears in.)
32
- checked program was:
33
- /* begin */
34
- 1: /*top*/
35
- 2: int main() { return 0; }
36
- 3: int t() { void ((*volatile p)()); p = (void ((*)()))pcap_setnonblock; return 0; }
37
- /* end */
38
-
39
- "cc -o conftest -I. -I/usr/local/lib/ruby/1.8/i386-freebsd7 -I. -O2 -fno-strict-aliasing -pipe -fPIC conftest.c -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -lpcap -lruby18-static -lpcap -lpcap -lcrypt -lm -rpath=/usr/lib:/usr/local/lib -pthread -lc"
40
- checked program was:
41
- /* begin */
42
- 1: /*top*/
43
- 2: int main() { return 0; }
44
- 3: int t() { pcap_setnonblock(); return 0; }
45
- /* end */
46
-
47
- --------------------
48
-
data/mkmf.log DELETED
@@ -1,24 +0,0 @@
1
- have_library: checking for pcap_open_live() in -lpcap... -------------------- yes
2
-
3
- "cc -o conftest -I. -I/usr/local/lib/ruby/1.8/i386-freebsd8 -I/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake -O2 -pipe -fno-strict-aliasing -fPIC conftest.c -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -lruby18-static -lpcap -lrt -lcrypt -lm -rpath=/usr/lib:/usr/local/lib -pthread "
4
- conftest.c: In function 't':
5
- conftest.c:3: error: 'pcap_open_live' undeclared (first use in this function)
6
- conftest.c:3: error: (Each undeclared identifier is reported only once
7
- conftest.c:3: error: for each function it appears in.)
8
- checked program was:
9
- /* begin */
10
- 1: /*top*/
11
- 2: int main() { return 0; }
12
- 3: int t() { void ((*volatile p)()); p = (void ((*)()))pcap_open_live; return 0; }
13
- /* end */
14
-
15
- "cc -o conftest -I. -I/usr/local/lib/ruby/1.8/i386-freebsd8 -I/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake -O2 -pipe -fno-strict-aliasing -fPIC conftest.c -L. -L/usr/local/lib -Wl,-R/usr/local/lib -L. -rdynamic -lruby18-static -lpcap -lrt -lcrypt -lm -rpath=/usr/lib:/usr/local/lib -pthread "
16
- checked program was:
17
- /* begin */
18
- 1: /*top*/
19
- 2: int main() { return 0; }
20
- 3: int t() { pcap_open_live(); return 0; }
21
- /* end */
22
-
23
- --------------------
24
-