ruby-pcap 0.7.8 → 0.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,18 +8,18 @@
8
8
  <DT><H1>UDPPacket</H1></DT>
9
9
  <DD>
10
10
 
11
- UDP�إå���ޤ�ѥ��åȡ�
11
+ UDPヘッダを含むパケット。
12
12
  </DD>
13
- <DT><H2>�����ѡ����饹:</H2></DT>
13
+ <DT><H2>スーパークラス:</H2></DT>
14
14
  <DD><DL><DT><A HREF="IPPacket.html"><CODE>IPPacket</CODE></A></DT></DL></DD>
15
- <DT><H2>�᥽�å�:</H2></DT>
15
+ <DT><H2>メソッド:</H2></DT>
16
16
  <DL COMPACT>
17
17
  <DT>
18
18
  <A NAME="udp_data"><CODE>udp_data</CODE></A>
19
19
  <DD>
20
20
  <p>
21
21
 
22
- �ǡ�����ʬ�� <A HREF="http://www.ruby-lang.org/ja/man-1.4/String.html"><CODE>String</CODE></A> �Ȥ����֤��ޤ���
22
+ データ部分を <A HREF="http://www.ruby-lang.org/ja/man-1.4/String.html"><CODE>String</CODE></A> として返します。
23
23
  </p>
24
24
  <DT>
25
25
  <A NAME="udp_dport"><CODE>udp_dport</CODE></A>
@@ -29,22 +29,22 @@
29
29
  <DD>
30
30
  <p>
31
31
 
32
- �ǥ��ƥ��͡������ݡ����ֹ���֤��ޤ���
32
+ デスティネーションポート番号を返します.
33
33
  </p>
34
34
  <DT>
35
35
  <A NAME="udp_len"><CODE>udp_len</CODE></A>
36
36
  <DD>
37
37
  <p>
38
38
 
39
- Length�ե�����ɤ��ͤ��֤��ޤ��������ͤ�UDP�ǡ��������
40
- ���Τ�Ĺ��(ñ��: �����ƥå�)��ɽ���ޤ���
39
+ Lengthフィールドの値を返します。この値はUDPデータグラム
40
+ 全体の長さ(単位: オクテット)を表します。
41
41
  </p>
42
42
  <DT>
43
43
  <A NAME="udp_sum"><CODE>udp_sum</CODE></A>
44
44
  <DD>
45
45
  <p>
46
46
 
47
- Checksum �ե�����ɤ��ͤ��֤��ޤ���
47
+ Checksum フィールドの値を返します。
48
48
  </p>
49
49
  <DT>
50
50
  <A NAME="udp_sport"><CODE>udp_sport</CODE></A>
@@ -54,14 +54,14 @@
54
54
  <DD>
55
55
  <p>
56
56
 
57
- �������ݡ����ֹ���֤��ޤ���
57
+ ソースポート番号を返します.
58
58
  </p>
59
59
  <DT>
60
60
  <A NAME="to_s"><CODE>to_s</CODE></A>
61
61
  <DD>
62
62
  <p>
63
63
 
64
- ʸ������Ѵ����ޤ���
64
+ 文字列に変換します。
65
65
  </p>
66
66
  </DL>
67
67
  </DL>
@@ -4,21 +4,21 @@
4
4
  </head>
5
5
 
6
6
  <body bgcolor="ffffff">
7
- <h1>Ruby/Pcap��ĥ�饤�֥��</h1>
7
+ <h1>Ruby/Pcap拡張ライブラリ</h1>
8
8
 
9
- LBL �� libpcap (Packet Capture library) �ؤ� ruby ���󥿥ե������Ǥ���
9
+ LBL libpcap (Packet Capture library) への ruby インタフェースです。
10
10
 
11
- <h2>�⥸�塼��</h2>
11
+ <h2>モジュール</h2>
12
12
  <ul>
13
13
  <li><a href="Pcap.html"><code>Pcap</code></a>
14
14
  </ul>
15
15
 
16
- <h2>���饹</h2>
16
+ <h2>クラス</h2>
17
17
 
18
- �ʲ��Υ��饹������ <code>Pcap</code> �⥸�塼��β����������Ƥ��ޤ���
19
- �������äƻ��Ѥ���Ȥ��� <code>Pcap</code> �⥸�塼���
20
- <code>include</code> ���뤫���⤷���� <code>Pcap::Capture</code> �Τ�
21
- ���˻��Ȥ��Ƥ���������
18
+ 以下のクラスは全て <code>Pcap</code> モジュールの下で定義されています。
19
+ したがって使用するときは <code>Pcap</code> モジュールを
20
+ <code>include</code> するか、もしくは <code>Pcap::Capture</code> のよ
21
+ うに参照してください。
22
22
 
23
23
  <ul>
24
24
  <li><a href="Capture.html"><code>Capture</code></a>
@@ -37,7 +37,7 @@ LBL
37
37
  <li><a href="Filter.html"><code>Filter</code></a>
38
38
  </ul>
39
39
 
40
- <h2>�㳰</h2>
40
+ <h2>例外</h2>
41
41
 
42
42
  <ul>
43
43
  <li><a href="PcapError.html"><code>PcapError</code></a>
@@ -176,7 +176,7 @@ capture_open_live(argc, argv, class)
176
176
  &v_promisc, &v_to_ms);
177
177
 
178
178
  /* device */
179
- Check_SafeStr(v_device);
179
+ SafeStringValue(v_device);
180
180
  device = RSTRING_PTR(v_device);
181
181
  /* snaplen */
182
182
  if (rs >= 2) {
@@ -232,7 +232,7 @@ capture_open_offline(class, fname)
232
232
  DEBUG_PRINT("capture_open_offline");
233
233
 
234
234
  /* open offline */
235
- Check_SafeStr(fname);
235
+ SafeStringValue(fname);
236
236
  pcap = pcap_open_offline(RSTRING_PTR(fname), pcap_errbuf);
237
237
  if (pcap == NULL) {
238
238
  rb_raise(ePcapError, "%s", pcap_errbuf);
@@ -590,7 +590,7 @@ dumper_open(class, v_cap, v_fname)
590
590
 
591
591
  CheckClass(v_cap, cCapture);
592
592
  GetCapture(v_cap, cap);
593
- Check_SafeStr(v_fname);
593
+ SafeStringValue(v_fname);
594
594
 
595
595
  pcap_dumper = pcap_dump_open(cap->pcap, RSTRING_PTR(v_fname));
596
596
  if (pcap_dumper == NULL) {
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,69 @@
1
+ module Pcap
2
+ class Packet
3
+ def to_s
4
+ 'Some packet'
5
+ end
6
+
7
+ def inspect
8
+ "#<#{self.class}: #{self}>"
9
+ end
10
+ end
11
+
12
+ class IPPacket
13
+ def to_s
14
+ "#{ip_src} > #{ip_dst}"
15
+ end
16
+ end
17
+
18
+ class TCPPacket
19
+ def tcp_data_len
20
+ ip_len - 4 * (ip_hlen + tcp_hlen)
21
+ end
22
+
23
+ def tcp_flags_s
24
+ return \
25
+ (tcp_urg? ? 'U' : '.') +
26
+ (tcp_ack? ? 'A' : '.') +
27
+ (tcp_psh? ? 'P' : '.') +
28
+ (tcp_rst? ? 'R' : '.') +
29
+ (tcp_syn? ? 'S' : '.') +
30
+ (tcp_fin? ? 'F' : '.')
31
+ end
32
+
33
+ def to_s
34
+ "#{src}:#{sport} > #{dst}:#{dport} #{tcp_flags_s}"
35
+ end
36
+
37
+ def src_mac_address
38
+ return unpack_hex_string(raw_data[6, 12])
39
+ end
40
+
41
+ def dst_mac_address
42
+ return unpack_hex_string(raw_data[0, 6])
43
+ end
44
+
45
+ def unpack_hex_string(hex)
46
+ return hex.unpack('H2H2H2H2H2H2').join('')
47
+ end
48
+ end
49
+
50
+ class UDPPacket
51
+ def to_s
52
+ "#{src}:#{sport} > #{dst}:#{dport} len #{udp_len} sum #{udp_sum}"
53
+ end
54
+ end
55
+
56
+ class ICMPPacket
57
+ def to_s
58
+ "#{src} > #{dst}: icmp: #{icmp_typestr}"
59
+ end
60
+ end
61
+
62
+ #
63
+ # Backword compatibility
64
+ #
65
+ IpPacket = IPPacket
66
+ IpAddress = IPAddress
67
+ TcpPacket = TCPPacket
68
+ UdpPacket = UDPPacket
69
+ end
@@ -1,17 +1,6 @@
1
1
  require 'pcap'
2
2
  require 'optparse'
3
3
 
4
- def pcaplet_usage()
5
- $stderr.print <<END
6
- Usage: #{File.basename $0} [ -dnv ] [ -i interface | -r file ]
7
- #{' ' * File.basename($0).length} [ -c count ] [ -s snaplen ] [ filter ]
8
- Options:
9
- -n do not convert address to name
10
- -d debug mode
11
- -v verbose mode
12
- END
13
- end
14
-
15
4
  module Pcap
16
5
  class Pcaplet
17
6
  def usage(status, msg = nil)
@@ -121,6 +110,20 @@ module Pcap
121
110
  def close
122
111
  @capture.close
123
112
  end
113
+
114
+
115
+ private
116
+
117
+ def pcaplet_usage()
118
+ $stderr.print <<END
119
+ Usage: #{File.basename $0} [ -dnv ] [ -i interface | -r file ]
120
+ #{' ' * File.basename($0).length} [ -c count ] [ -s snaplen ] [ filter ]
121
+ Options:
122
+ -n do not convert address to name
123
+ -d debug mode
124
+ -v verbose mode
125
+ END
126
+ end
124
127
  end
125
128
  end
126
129
 
@@ -0,0 +1,10 @@
1
+ module Pcap
2
+ module TcpdumpTimeFormat
3
+ # tcpdump style format
4
+ def tcpdump
5
+ sprintf "%0.2d:%0.2d:%0.2d.%0.6d", hour, min, sec, tv_usec
6
+ end
7
+ end
8
+ end
9
+
10
+ Time.include Pcap::TcpdumpTimeFormat
@@ -1,80 +1,4 @@
1
-
2
- module Pcap
3
- class Packet
4
- def to_s
5
- 'Some packet'
6
- end
7
-
8
- def inspect
9
- "#<#{self.class}: #{self}>"
10
- end
11
- end
12
-
13
- class IPPacket
14
- def to_s
15
- "#{ip_src} > #{ip_dst}"
16
- end
17
- end
18
-
19
- class TCPPacket
20
- def tcp_data_len
21
- ip_len - 4 * (ip_hlen + tcp_hlen)
22
- end
23
-
24
- def tcp_flags_s
25
- return \
26
- (tcp_urg? ? 'U' : '.') +
27
- (tcp_ack? ? 'A' : '.') +
28
- (tcp_psh? ? 'P' : '.') +
29
- (tcp_rst? ? 'R' : '.') +
30
- (tcp_syn? ? 'S' : '.') +
31
- (tcp_fin? ? 'F' : '.')
32
- end
33
-
34
- def to_s
35
- "#{src}:#{sport} > #{dst}:#{dport} #{tcp_flags_s}"
36
- end
37
-
38
- def src_mac_address
39
- return unpack_hex_string(raw_data[6, 12])
40
- end
41
-
42
- def dst_mac_address
43
- return unpack_hex_string(raw_data[0, 6])
44
- end
45
-
46
- def unpack_hex_string(hex)
47
- return hex.unpack('H2H2H2H2H2H2').join('')
48
- end
49
- end
50
-
51
- class UDPPacket
52
- def to_s
53
- "#{src}:#{sport} > #{dst}:#{dport} len #{udp_len} sum #{udp_sum}"
54
- end
55
- end
56
-
57
- class ICMPPacket
58
- def to_s
59
- "#{src} > #{dst}: icmp: #{icmp_typestr}"
60
- end
61
- end
62
-
63
- #
64
- # Backword compatibility
65
- #
66
- IpPacket = IPPacket
67
- IpAddress = IPAddress
68
- TcpPacket = TCPPacket
69
- UdpPacket = UDPPacket
70
-
71
- end
72
-
73
- class Time
74
- # tcpdump style format
75
- def tcpdump
76
- sprintf "%0.2d:%0.2d:%0.2d.%0.6d", hour, min, sec, tv_usec
77
- end
78
- end
1
+ require 'pcap/packet'
2
+ require 'pcap/tcpdump_time_format'
79
3
 
80
4
  autoload :Pcaplet, 'pcaplet'
@@ -4,17 +4,20 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "ruby-pcap"
7
- gem.version = "0.7.8"
7
+ gem.version = "0.7.9"
8
8
  gem.authors = [%q{Masaki Fukushima}, %q{Andrew Hobson}]
9
9
  gem.email = ["mbarczak@gmail.com"]
10
10
  gem.description = %q{Ruby interface to LBL Packet Capture library. This library also includes classes to access packet header fields.}
11
- gem.summary = %q{Ruby interface to LBL Packet Capture library. This library also includes classes to access packet header fields.}
11
+ gem.summary = %q{Ruby interface to LBL Packet Capture library.}
12
12
  gem.homepage = "https://github.com/ickymettle/ruby-pcap"
13
+ gem.license = "GPL-2.0"
13
14
 
14
15
  gem.files = `git ls-files`.split($/)
15
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
18
  gem.require_paths = ["lib"]
18
19
 
19
- gem.extensions << "ext/extconf.rb"
20
+ gem.extensions << "ext/pcap/extconf.rb"
21
+
22
+ gem.add_development_dependency "rake-compiler"
20
23
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-pcap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.8
5
- prerelease:
4
+ version: 0.7.9
6
5
  platform: ruby
7
6
  authors:
8
7
  - Masaki Fukushima
@@ -10,26 +9,39 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2012-12-07 00:00:00.000000000 Z
14
- dependencies: []
12
+ date: 2015-07-20 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake-compiler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
15
28
  description: Ruby interface to LBL Packet Capture library. This library also includes
16
29
  classes to access packet header fields.
17
30
  email:
18
31
  - mbarczak@gmail.com
19
32
  executables: []
20
33
  extensions:
21
- - ext/extconf.rb
34
+ - ext/pcap/extconf.rb
22
35
  extra_rdoc_files: []
23
36
  files:
24
- - .gitignore
37
+ - ".gitignore"
38
+ - ".travis.yml"
25
39
  - COPYING
26
40
  - ChangeLog
27
41
  - Gemfile
28
- - MANIFEST
29
- - README
30
- - README.ja
42
+ - README.ja.md
43
+ - README.md
31
44
  - Rakefile
32
- - VERSION
33
45
  - doc-ja/Capture.html
34
46
  - doc-ja/Dumper.html
35
47
  - doc-ja/Filter.html
@@ -62,40 +74,41 @@ files:
62
74
  - examples/rewrite_time.rb
63
75
  - examples/tcpdump.rb
64
76
  - examples/test.rb
65
- - ext/Pcap.c
66
- - ext/extconf.rb
67
- - ext/icmp_packet.c
68
- - ext/ip_packet.c
69
- - ext/packet.c
70
- - ext/ruby_pcap.h
71
- - ext/tcp_packet.c
72
- - ext/udp_packet.c
77
+ - ext/pcap/Pcap.c
78
+ - ext/pcap/extconf.rb
79
+ - ext/pcap/icmp_packet.c
80
+ - ext/pcap/ip_packet.c
81
+ - ext/pcap/packet.c
82
+ - ext/pcap/ruby_pcap.h
83
+ - ext/pcap/tcp_packet.c
84
+ - ext/pcap/udp_packet.c
85
+ - lib/pcap/packet.rb
86
+ - lib/pcap/pcaplet.rb
87
+ - lib/pcap/tcpdump_time_format.rb
73
88
  - lib/pcap_misc.rb
74
- - lib/pcaplet.rb
75
89
  - ruby-pcap.gemspec
76
90
  homepage: https://github.com/ickymettle/ruby-pcap
77
- licenses: []
91
+ licenses:
92
+ - GPL-2.0
93
+ metadata: {}
78
94
  post_install_message:
79
95
  rdoc_options: []
80
96
  require_paths:
81
97
  - lib
82
98
  required_ruby_version: !ruby/object:Gem::Requirement
83
- none: false
84
99
  requirements:
85
- - - ! '>='
100
+ - - ">="
86
101
  - !ruby/object:Gem::Version
87
102
  version: '0'
88
103
  required_rubygems_version: !ruby/object:Gem::Requirement
89
- none: false
90
104
  requirements:
91
- - - ! '>='
105
+ - - ">="
92
106
  - !ruby/object:Gem::Version
93
107
  version: '0'
94
108
  requirements: []
95
109
  rubyforge_project:
96
- rubygems_version: 1.8.23
110
+ rubygems_version: 2.2.3
97
111
  signing_key:
98
- specification_version: 3
99
- summary: Ruby interface to LBL Packet Capture library. This library also includes
100
- classes to access packet header fields.
112
+ specification_version: 4
113
+ summary: Ruby interface to LBL Packet Capture library.
101
114
  test_files: []