packetgen 3.1.6 → 3.1.7
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 +4 -4
- data/README.md +0 -1
- data/lib/packetgen/types/cstring.rb +20 -7
- data/lib/packetgen/types/string.rb +16 -3
- data/lib/packetgen/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6297501a0b2bbf2242e1481e52183c961d694306611cc7b61db46aaac59cb399
|
4
|
+
data.tar.gz: b9af651662460d50c7ea93030f171469d5efbc85759df27e6fa25d6870f6f5b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1dea6fa78201583d40f94439943a217deeea8fd6b7485a6fd0a748c802fd6f0d3f25b82e7dcf24e525dd93634a111ae49c4437fde73b6e51ab4d37070346dcb
|
7
|
+
data.tar.gz: ca4b7bd3596d9e50ab6cc9d3bbcaeb9127544509badb2371eab71466cbe85efdfe4060ccb072c1724bf1240c427fc27ab4ace581250fdb79d1c0c5bf5d7f32ed
|
data/README.md
CHANGED
@@ -17,8 +17,9 @@ module PacketGen
|
|
17
17
|
extend Forwardable
|
18
18
|
include Fieldable
|
19
19
|
|
20
|
-
def_delegators :@string, :[], :length, :size, :inspect, :==,
|
21
|
-
:unpack, :force_encoding, :encoding, :index, :empty
|
20
|
+
def_delegators :@string, :[], :length, :size, :inspect, :==,
|
21
|
+
:unpack, :force_encoding, :encoding, :index, :empty?,
|
22
|
+
:encode, :slice, :slice!
|
22
23
|
|
23
24
|
# @return [::String]
|
24
25
|
attr_reader :string
|
@@ -28,7 +29,7 @@ module PacketGen
|
|
28
29
|
# @param [Hash] options
|
29
30
|
# @option options [Integer] :static_length set a static length for this string
|
30
31
|
def initialize(options={})
|
31
|
-
register_internal_string
|
32
|
+
register_internal_string(+'')
|
32
33
|
@static_length = options[:static_length]
|
33
34
|
end
|
34
35
|
|
@@ -37,9 +38,8 @@ module PacketGen
|
|
37
38
|
def read(str)
|
38
39
|
s = str.to_s
|
39
40
|
s = s[0, static_length] if static_length?
|
40
|
-
idx = s.index(0.chr)
|
41
|
-
s = s[0, idx] unless idx.nil?
|
42
41
|
register_internal_string s
|
42
|
+
remove_null_character
|
43
43
|
self
|
44
44
|
end
|
45
45
|
|
@@ -55,6 +55,15 @@ module PacketGen
|
|
55
55
|
PacketGen.force_binary(s)
|
56
56
|
end
|
57
57
|
|
58
|
+
# Append the given string to CString
|
59
|
+
# @param [#to_s] str
|
60
|
+
# @return [self]
|
61
|
+
def <<(str)
|
62
|
+
@string << str.to_s
|
63
|
+
remove_null_character
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
58
67
|
# @return [Integer]
|
59
68
|
def sz
|
60
69
|
if static_length?
|
@@ -80,8 +89,7 @@ module PacketGen
|
|
80
89
|
|
81
90
|
# @return [String]
|
82
91
|
def to_human
|
83
|
-
|
84
|
-
self[0, idx]
|
92
|
+
string
|
85
93
|
end
|
86
94
|
|
87
95
|
private
|
@@ -90,6 +98,11 @@ module PacketGen
|
|
90
98
|
@string = str
|
91
99
|
PacketGen.force_binary(@string)
|
92
100
|
end
|
101
|
+
|
102
|
+
def remove_null_character
|
103
|
+
idx = string.index(0.chr)
|
104
|
+
register_internal_string(string[0, idx]) unless idx.nil?
|
105
|
+
end
|
93
106
|
end
|
94
107
|
end
|
95
108
|
end
|
@@ -18,8 +18,9 @@ module PacketGen
|
|
18
18
|
include Fieldable
|
19
19
|
include LengthFrom
|
20
20
|
|
21
|
-
def_delegators :@string, :[], :to_s, :length, :size, :inspect, :==,
|
22
|
-
:unpack, :force_encoding, :encoding, :index, :empty
|
21
|
+
def_delegators :@string, :[], :to_s, :length, :size, :inspect, :==,
|
22
|
+
:unpack, :force_encoding, :encoding, :index, :empty?,
|
23
|
+
:encode, :slice, :slice!, :[]=
|
23
24
|
|
24
25
|
# @return [::String]
|
25
26
|
attr_reader :string
|
@@ -31,11 +32,15 @@ module PacketGen
|
|
31
32
|
# takes length when reading
|
32
33
|
# @option options [Integer] :static_length set a static length for this string
|
33
34
|
def initialize(options={})
|
34
|
-
register_internal_string
|
35
|
+
register_internal_string(+'')
|
35
36
|
initialize_length_from(options)
|
36
37
|
@static_length = options[:static_length]
|
37
38
|
end
|
38
39
|
|
40
|
+
def initialize_copy(_orig)
|
41
|
+
@string = @string.dup
|
42
|
+
end
|
43
|
+
|
39
44
|
# @param [::String] str
|
40
45
|
# @return [String] self
|
41
46
|
def read(str)
|
@@ -68,6 +73,14 @@ module PacketGen
|
|
68
73
|
inspect
|
69
74
|
end
|
70
75
|
|
76
|
+
# Append the given string to String
|
77
|
+
# @param [#to_s] str
|
78
|
+
# @return [self]
|
79
|
+
def <<(str)
|
80
|
+
@string << str.to_s
|
81
|
+
self
|
82
|
+
end
|
83
|
+
|
71
84
|
alias sz length
|
72
85
|
alias to_human to_s
|
73
86
|
alias from_human read
|
data/lib/packetgen/version.rb
CHANGED
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: 3.1.
|
4
|
+
version: 3.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvain Daubert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: interfacez
|