packetgen 2.1.1 → 2.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e814826688f3a780a9c222dcc6fd5a2a3ae7daf0
4
- data.tar.gz: ccb268a111976248f6dd932c3556874c0f639938
3
+ metadata.gz: 59b1fc19fea5c7400e6d70e01a83ca68351e646b
4
+ data.tar.gz: b9ef7b691f66d23d763e7cf03f98aab5314924b5
5
5
  SHA512:
6
- metadata.gz: 7d2b48c08caafa50c4ee4ce3812bc3e7122ca69ccc00a91dc2c75b448dd78fb85cd18c8e352773b81e27e6f7b69b05417a3b953e131a2bd5b775c924b3da1ef3
7
- data.tar.gz: e1c2317f4d950c8b78bec81dd4944af29f0faa5ee21a949dd32422827689e752c43acbde5c12784ddd82fa56bfdf99f60449ed90faba2c530f2daadf3658c9a3
6
+ metadata.gz: bddf2bf621ae0ddd6e30d4f1ee25f24b575d4b42b994203baa135cc58d0fac3ecce8c1549966faa381a8049c0585cd8517dc358c0e2399dc0afab1778121ef77
7
+ data.tar.gz: a02f287f900e5f7d21e845fd26c86b146375a87babc61252f4c73cf63c306ff403f0fef8220594d4b8e0d17a9f5f71bb6f2dbef7e61e49c1cc1472aed2180d63
data/.travis.yml CHANGED
@@ -2,8 +2,8 @@ language: ruby
2
2
  sudo: required
3
3
  rvm:
4
4
  - 2.2.7
5
- - 2.3.4
6
- - 2.4.1
5
+ - 2.3.5
6
+ - 2.4.2
7
7
 
8
8
  install:
9
9
  - sudo apt-get update -qq
data/README.md CHANGED
@@ -148,6 +148,10 @@ classes. A special `config` object gives local network configuration:
148
148
 
149
149
  If `pry` gem is installed, it is used as backend for `pgconsole`, else IRB is used.
150
150
 
151
+ ## API documentation
152
+
153
+ see http://www.rubydoc.info/gems/packetgen
154
+
151
155
  ## Pull requests?
152
156
 
153
157
  yes
data/lib/packetgen.rb CHANGED
@@ -87,3 +87,4 @@ require 'packetgen/inspect'
87
87
  require 'packetgen/pcapng'
88
88
  require 'packetgen/packet'
89
89
  require 'packetgen/capture'
90
+ require 'packetgen/proto'
@@ -1,3 +1,8 @@
1
+ # This file is part of PacketGen
2
+ # See https://github.com/sdaubert/packetgen for more informations
3
+ # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
+ # This program is published under MIT license.
5
+
1
6
  require 'network_interface'
2
7
  require 'socket'
3
8
 
@@ -5,24 +10,24 @@ module PacketGen
5
10
 
6
11
  # Config class to provide +config+ object to pgconsole
7
12
  # @author Sylvain Daubert
8
- # @author Kent 'picat' Gruber
13
+ # @author Kent 'picat' Gruber
9
14
  class Config
10
15
 
11
16
  # Default network interface
12
- # @return [String]
17
+ # @return [String]
13
18
  attr_reader :iface
14
19
  # MAC address of default interface
15
- # @return [String]
20
+ # @return [String]
16
21
  attr_reader :hwaddr
17
22
  # IP address of default interface
18
- # @return [String]
23
+ # @return [String]
19
24
  attr_reader :ipaddr
20
25
  # IPv6 address of default interface
21
- # @return [String]
26
+ # @return [String]
22
27
  attr_reader :ip6addr
23
28
 
24
29
  # Create a configuration object. If +iface+ is not set,
25
- # attempt to find it automatically or default to the
30
+ # attempt to find it automatically or default to the
26
31
  # first available loopback interface.
27
32
  # @param [String,nil] iface
28
33
  def initialize(iface=nil)
@@ -1,4 +1,9 @@
1
1
  # coding: utf-8
2
+ # This file is part of PacketGen
3
+ # See https://github.com/sdaubert/packetgen for more informations
4
+ # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
5
+ # This program is published under MIT license.
6
+
2
7
  module PacketGen
3
8
  module Header
4
9
  class IKE
@@ -194,4 +199,3 @@ module PacketGen
194
199
  end
195
200
  end
196
201
  end
197
-
@@ -1,4 +1,9 @@
1
1
  # coding: utf-8
2
+ # This file is part of PacketGen
3
+ # See https://github.com/sdaubert/packetgen for more informations
4
+ # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
5
+ # This program is published under MIT license.
6
+
2
7
  module PacketGen
3
8
  module Header
4
9
  class IKE
@@ -1,4 +1,9 @@
1
1
  # coding: utf-8
2
+ # This file is part of PacketGen
3
+ # See https://github.com/sdaubert/packetgen for more informations
4
+ # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
5
+ # This program is published under MIT license.
6
+
2
7
  module PacketGen
3
8
  module Header
4
9
  class IKE
@@ -1,4 +1,9 @@
1
1
  # coding: utf-8
2
+ # This file is part of PacketGen
3
+ # See https://github.com/sdaubert/packetgen for more informations
4
+ # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
5
+ # This program is published under MIT license.
6
+
2
7
  module PacketGen
3
8
  module Header
4
9
  class IKE
@@ -1,8 +1,13 @@
1
1
  # coding: utf-8
2
+ # This file is part of PacketGen
3
+ # See https://github.com/sdaubert/packetgen for more informations
4
+ # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
5
+ # This program is published under MIT license.
6
+
2
7
  module PacketGen
3
8
  module Header
4
9
  class IKE
5
-
10
+
6
11
  # This class handles Key Exchange payloads, as defined in RFC 7296 §3.4
7
12
  #
8
13
  # A KE payload contains a generic payload header (see {Payload}) and some
@@ -1,4 +1,9 @@
1
1
  # coding: utf-8
2
+ # This file is part of PacketGen
3
+ # See https://github.com/sdaubert/packetgen for more informations
4
+ # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
5
+ # This program is published under MIT license.
6
+
2
7
  module PacketGen
3
8
  module Header
4
9
  class IKE
@@ -1,5 +1,8 @@
1
1
  # coding: utf-8
2
- require 'net-proto'
2
+ # This file is part of PacketGen
3
+ # See https://github.com/sdaubert/packetgen for more informations
4
+ # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
5
+ # This program is published under MIT license.
3
6
 
4
7
  module PacketGen
5
8
  module Header
@@ -105,10 +108,10 @@ module PacketGen
105
108
  # @return [Integer]
106
109
  def protocol=(value)
107
110
  protocol = case value
108
- when Integer
111
+ when Integer
109
112
  value
110
113
  else
111
- Net::Proto.getprotobyname(value)
114
+ Proto.getprotobyname(value)
112
115
  end
113
116
  raise ArgumentError, "unknown protocol #{value.inspect}" unless protocol
114
117
  self[:protocol].value = protocol
@@ -132,7 +135,7 @@ module PacketGen
132
135
  if protocol == 0
133
136
  ''
134
137
  else
135
- Net::Proto.getprotobynumber(protocol) || "#{protocol}"
138
+ Proto.getprotobynumber(protocol) || "#{protocol}"
136
139
  end
137
140
  end
138
141
 
@@ -1,4 +1,9 @@
1
1
  # coding: utf-8
2
+ # This file is part of PacketGen
3
+ # See https://github.com/sdaubert/packetgen for more informations
4
+ # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
5
+ # This program is published under MIT license.
6
+
2
7
  module PacketGen
3
8
  module Header
4
9
  class IKE
@@ -1,3 +1,8 @@
1
+ # This file is part of PacketGen
2
+ # See https://github.com/sdaubert/packetgen for more informations
3
+ # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
+ # This program is published under MIT license.
5
+
1
6
  module PacketGen
2
7
 
3
8
  # {Inspect} module provides methods to help writing +inspect+
@@ -45,7 +45,7 @@ module PacketGen
45
45
  # Packet.write 'file.pcapng', packets
46
46
  #
47
47
  # @since 2.0.0
48
- #
48
+ #
49
49
  # Packet accessor has changed. When header class is in a namespace
50
50
  # (for example Dot11::* header classes), to avoid clashes in names, such
51
51
  # accessors are named +namespace_class+. For example {Header::Dot11::Data}
@@ -97,7 +97,7 @@ module PacketGen
97
97
  capture.packets
98
98
  end
99
99
 
100
- # Read packets from +filename+.
100
+ # Read packets from +filename+. Mays read Pcap and Pcap-NG formats.
101
101
  #
102
102
  # For more control, see {PcapNG::File} or {PCAPRUB::Pcap}.
103
103
  # @param [String] filename PcapNG or Pcap file.
@@ -111,7 +111,7 @@ module PacketGen
111
111
  raise ArgumentError, e unless File.extname(filename.downcase) == '.pcap'
112
112
  packets = []
113
113
  PCAPRUB::Pcap.open_offline(filename).each_packet do |packet|
114
- next unless packet = PacketGen.parse(packet.to_s)
114
+ next unless packet = PacketGen.parse(packet.to_s)
115
115
  packets << packet
116
116
  end
117
117
  packets
@@ -0,0 +1,42 @@
1
+ # coding: utf-8
2
+ # This file is part of PacketGen
3
+ # See https://github.com/sdaubert/packetgen for more informations
4
+ # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
5
+ # This program is published under MIT license.
6
+ require 'socket'
7
+
8
+ module PacketGen
9
+
10
+ # Module handling some helper methods for protocols
11
+ # @author Sylvain Daubert
12
+ # @since 2.1.2
13
+ module Proto
14
+
15
+ # @private cache information used by {.getprotobyname} and
16
+ # {.getprotobynumber}
17
+ def self.prepare_cache
18
+ proto_constants = Socket.constants.grep(/IPPROTO_/)
19
+ @cache = {}
20
+ proto_constants.each do |const_sym|
21
+ name = const_sym.to_s[8..-1].downcase
22
+ number = Socket.const_get(const_sym)
23
+ @cache[name] = number
24
+ end
25
+ end
26
+ prepare_cache
27
+
28
+ # Get protocol number from its name
29
+ # @param [String] name
30
+ # @return [Integer,nil] return nil for unknown protocol names
31
+ def self.getprotobyname(name)
32
+ @cache[name]
33
+ end
34
+
35
+ # Get protocol name from its number
36
+ # @param [Integer] number
37
+ # @return [String,nil] return nil for unknown protocol numbers
38
+ def self.getprotobynumber(num)
39
+ @cache.key(num)
40
+ end
41
+ end
42
+ end
@@ -1,5 +1,9 @@
1
+ # This file is part of PacketGen
2
+ # See https://github.com/sdaubert/packetgen for more informations
3
+ # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
4
+ # This program is published under MIT license.
5
+
1
6
  module PacketGen
2
-
3
7
  # Module to group all type definitions
4
8
  module Types
5
9
  end
@@ -8,5 +8,5 @@
8
8
  # @author Sylvain Daubert
9
9
  module PacketGen
10
10
  # PacketGen version
11
- VERSION = '2.1.1'
11
+ VERSION = '2.1.2'
12
12
  end
data/packetgen.gemspec CHANGED
@@ -21,11 +21,10 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.required_ruby_version = '>= 2.1.0'
24
+ spec.required_ruby_version = '>= 2.2.0'
25
25
 
26
26
  spec.add_dependency 'pcaprub', '~>0.12.4'
27
27
  spec.add_dependency 'network_interface'
28
- spec.add_dependency 'net-proto', '~>1.2'
29
28
  spec.add_dependency 'rasn1', '~>0.3', '>= 0.3.1'
30
29
 
31
30
  spec.add_development_dependency 'bundler', '~> 1.7'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packetgen
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sylvain Daubert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-31 00:00:00.000000000 Z
11
+ date: 2017-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pcaprub
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: net-proto
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.2'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.2'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rasn1
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -217,6 +203,7 @@ files:
217
203
  - lib/packetgen/pcapng/shb.rb
218
204
  - lib/packetgen/pcapng/spb.rb
219
205
  - lib/packetgen/pcapng/unknown_block.rb
206
+ - lib/packetgen/proto.rb
220
207
  - lib/packetgen/types.rb
221
208
  - lib/packetgen/types/array.rb
222
209
  - lib/packetgen/types/fields.rb
@@ -239,7 +226,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
239
226
  requirements:
240
227
  - - ">="
241
228
  - !ruby/object:Gem::Version
242
- version: 2.1.0
229
+ version: 2.2.0
243
230
  required_rubygems_version: !ruby/object:Gem::Requirement
244
231
  requirements:
245
232
  - - ">="