ip_frag 0.0.3 → 0.0.4

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.
@@ -12,21 +12,21 @@ module IPFrag
12
12
  offset = 0
13
13
  ret << make_ip_packet(packet_offset) do |p|
14
14
  p.offset = make_offset(offset)
15
- p.payload = udp_offset( contant(udp_size_from(@size), p), 1)
15
+ p.payload = udp_offset( contant(udp_size_from(@size), p), offset, packet_offset)
16
16
  end
17
17
  offset += packet_offset
18
18
 
19
19
  (packet_count - 2).times do |i|
20
20
  ret << make_ip_packet(packet_offset) do |p|
21
21
  p.offset = make_offset(offset)
22
- p.payload = udp_offset( contant(udp_size_from(@size), p), i+2)
22
+ p.payload = udp_offset( contant(udp_size_from(@size), p), offset, packet_offset)
23
23
  end
24
24
  offset += packet_offset
25
25
  end
26
26
 
27
27
  ret << make_ip_packet(packet_left) do |p|
28
28
  p.offset = make_offset(offset, true)
29
- p.payload = udp_offset( contant(udp_size_from(@size), p), packet_count)
29
+ p.payload = udp_offset( contant(udp_size_from(@size), p), offset, packet_left)
30
30
  end
31
31
 
32
32
  ret
@@ -134,9 +134,8 @@ module IPFrag
134
134
 
135
135
  attr_writer :src_ip, :dst_ip, :src_mac, :dst_mac, :src_port, :dst_port
136
136
 
137
- def udp_offset( udp, packet_num)
138
- size = @mtu
139
- udp[(packet_num-1)*size..packet_num*size -1 ]
137
+ def udp_offset( udp, start, endt)
138
+ udp[start..(start + endt-1)]
140
139
  end
141
140
 
142
141
  def udp_size_from(ip_size)
@@ -1,3 +1,3 @@
1
1
  module IPFrag
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -21,9 +21,18 @@ describe IPFrag do
21
21
 
22
22
  it "#write_dat" do
23
23
  g = IPFrag::Generator.new(2000, 1460)
24
+ FileUtils.rm_rf('tmp')
24
25
  FileUtils.mkdir('tmp') rescue nil
25
26
  g.write_dat('tmp')
26
27
  Dir["tmp/*"].size.should == 2
28
+
29
+ end
30
+
31
+ it "#write_dat2" do
32
+ g = IPFrag::Generator.new(60000, 700)
33
+ FileUtils.mkdir('tmp') rescue nil
34
+ g.write_dat('tmp')
35
+ Dir["tmp/*"].size.should == 87
27
36
  FileUtils.rm_rf('tmp')
28
37
  end
29
38
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ip_frag
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - yafei Lee