packetnom 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8bb38e3e4f057d5d3849a7fc365f256db8f034e2
4
- data.tar.gz: 4f05fe382874734826ed6091306c10e9535f5acf
3
+ metadata.gz: c3ce9ae5feaae80c9ab5fe6ee5304910c3999a57
4
+ data.tar.gz: c15e5afb9cd789f7df847ddfcdc75cf6f606a1c3
5
5
  SHA512:
6
- metadata.gz: e81cffbe48d529ab2581a3094f9c77ca6b9e48f36f1a0980b2e5d1918e2b6cd8fca6ab77ccd581df628b815d9caf571da254f5fa65454a6844e99153d915b723
7
- data.tar.gz: 233802b24f8f00187221779fa2395429bcd1977c6893ee641c0ff4c79cb625e8fc6408f1bdca93ea93bbf936dc936da16b250f6d0aa7d7aab24cad94771af31e
6
+ metadata.gz: 29b2f7bc0be31b0b2493cd5b0fb39c959560da6e6c64c23ad5ae08fa5e07720fc5af0f1fd4cec4c9dae293843b5254b7120780b6a6feb2fccd48906fccc98e80
7
+ data.tar.gz: 065c452fba28b6465cfc37dbadd49c2cafb2df6bfa6d897896652eb60f76adee69eea8dedfee57cd14c9682b57ac93b2b3a02e3488091bbf2be79ce7646da512
data/lib/packet/eth.rb CHANGED
@@ -10,14 +10,11 @@ module Packetnom
10
10
  attr_accessor :type
11
11
 
12
12
  # Initialize the packet
13
- def initialize( bytes )
14
- @packet = bytes
15
-
13
+ def initialize( bytes )
16
14
  # Layer 2
17
15
  @dst = bytes[0..5].join(':')
18
16
  @src = bytes[6..11].join(':')
19
17
  @type = bytes[12..13].join() # http://en.wikipedia.org/wiki/EtherType
20
-
21
18
  end
22
19
 
23
20
  def type
data/lib/packet/ip.rb CHANGED
@@ -19,9 +19,7 @@ module Packetnom
19
19
  attr_accessor :dst
20
20
 
21
21
  # Initialize the packet
22
- def initialize( bytes )
23
- @packet = bytes
24
-
22
+ def initialize( bytes )
25
23
  @version = bytes[14].split(//)[0]
26
24
  @ihl = bytes[14].split(//)[1]
27
25
  @ds = bytes[15]
data/lib/packet/tcp.rb CHANGED
@@ -18,9 +18,7 @@ module Packetnom
18
18
  attr_accessor :uptr
19
19
 
20
20
  # Initialize the packet
21
- def initialize( bytes )
22
- @packet = bytes
23
-
21
+ def initialize( bytes )
24
22
  @src_port = bytes[34..35].join().to_i(16).to_s(10).to_i
25
23
  @dst_port = bytes[36..37].join().to_i(16).to_s(10).to_i
26
24
 
data/lib/packet/udp.rb ADDED
@@ -0,0 +1,33 @@
1
+ module Packetnom
2
+
3
+ class Packet
4
+
5
+ class Udp
6
+
7
+ # Attributes
8
+ attr_accessor :src_port
9
+ attr_accessor :dst_port
10
+ attr_accessor :length
11
+ attr_accessor :sum
12
+
13
+ # Initialize the packet
14
+ def initialize( bytes )
15
+ @src_port = bytes[34..35].join().to_i(16).to_s(10).to_i
16
+ @dst_port = bytes[36..37].join().to_i(16).to_s(10).to_i
17
+
18
+ @length = bytes[38..39].join().to_i(16).to_s(10).to_i
19
+ @sum = bytes[40..41].join().to_i(16).to_s(10).to_i
20
+ end
21
+
22
+ alias_method :source_port, :src_port
23
+ alias_method :sport, :src_port
24
+ alias_method :dest_port, :dst_port
25
+ alias_method :dport, :dst_port
26
+ alias_method :len, :length
27
+ alias_method :checksum, :sum
28
+
29
+ end
30
+
31
+ end
32
+
33
+ end
data/lib/packetnom.rb CHANGED
@@ -2,4 +2,4 @@ require 'packet/eth'
2
2
  require 'packet/ip'
3
3
 
4
4
  require 'packet/tcp'
5
- #require 'packet/udp'
5
+ require 'packet/udp'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: packetnom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Mackintosh
@@ -62,6 +62,7 @@ files:
62
62
  - lib/packet/eth.rb
63
63
  - lib/packet/ip.rb
64
64
  - lib/packet/tcp.rb
65
+ - lib/packet/udp.rb
65
66
  homepage: http://github.com/mikemackintosh/packetnom
66
67
  licenses:
67
68
  - not-yet-decided