packetfu 1.1.10 → 1.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -0
- data/.gitignore +3 -0
- data/.travis.yml +8 -0
- data/CONTRIBUTING.md +47 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +1 -1
- data/README.rdoc +35 -30
- data/Rakefile +4 -4
- data/bench/octets.rb +9 -9
- data/examples/100kpackets.rb +12 -12
- data/examples/ackscan.rb +16 -16
- data/examples/arp.rb +35 -35
- data/examples/arphood.rb +36 -36
- data/examples/dissect_thinger.rb +6 -6
- data/examples/new-simple-stats.rb +23 -23
- data/examples/packetfu-shell.rb +25 -25
- data/examples/simple-sniffer.rb +9 -9
- data/examples/simple-stats.rb +23 -23
- data/examples/slammer.rb +3 -3
- data/gem-public_cert.pem +21 -0
- data/lib/packetfu.rb +149 -127
- data/lib/packetfu/capture.rb +169 -169
- data/lib/packetfu/config.rb +52 -52
- data/lib/packetfu/inject.rb +56 -56
- data/lib/packetfu/packet.rb +531 -528
- data/lib/packetfu/pcap.rb +579 -579
- data/lib/packetfu/protos/arp.rb +90 -90
- data/lib/packetfu/protos/arp/header.rb +158 -158
- data/lib/packetfu/protos/arp/mixin.rb +36 -36
- data/lib/packetfu/protos/eth.rb +44 -44
- data/lib/packetfu/protos/eth/header.rb +243 -243
- data/lib/packetfu/protos/eth/mixin.rb +3 -3
- data/lib/packetfu/protos/hsrp.rb +69 -69
- data/lib/packetfu/protos/hsrp/header.rb +107 -107
- data/lib/packetfu/protos/hsrp/mixin.rb +29 -29
- data/lib/packetfu/protos/icmp.rb +71 -71
- data/lib/packetfu/protos/icmp/header.rb +82 -82
- data/lib/packetfu/protos/icmp/mixin.rb +14 -14
- data/lib/packetfu/protos/invalid.rb +49 -49
- data/lib/packetfu/protos/ip.rb +69 -69
- data/lib/packetfu/protos/ip/header.rb +291 -291
- data/lib/packetfu/protos/ip/mixin.rb +40 -40
- data/lib/packetfu/protos/ipv6.rb +50 -50
- data/lib/packetfu/protos/ipv6/header.rb +188 -188
- data/lib/packetfu/protos/ipv6/mixin.rb +29 -29
- data/lib/packetfu/protos/tcp.rb +176 -176
- data/lib/packetfu/protos/tcp/ecn.rb +35 -35
- data/lib/packetfu/protos/tcp/flags.rb +74 -74
- data/lib/packetfu/protos/tcp/header.rb +268 -268
- data/lib/packetfu/protos/tcp/hlen.rb +32 -32
- data/lib/packetfu/protos/tcp/mixin.rb +46 -46
- data/lib/packetfu/protos/tcp/option.rb +321 -321
- data/lib/packetfu/protos/tcp/options.rb +95 -95
- data/lib/packetfu/protos/tcp/reserved.rb +35 -35
- data/lib/packetfu/protos/udp.rb +159 -123
- data/lib/packetfu/protos/udp/header.rb +91 -91
- data/lib/packetfu/protos/udp/mixin.rb +3 -3
- data/lib/packetfu/structfu.rb +280 -280
- data/lib/packetfu/utils.rb +292 -225
- data/lib/packetfu/version.rb +41 -41
- data/packetfu.gemspec +14 -3
- data/spec/arp_spec.rb +191 -0
- data/spec/eth_spec.rb +148 -0
- data/spec/icmp_spec.rb +97 -0
- data/spec/ip_spec.rb +78 -0
- data/spec/ipv6_spec.rb +81 -0
- data/spec/packet_spec.rb +61 -59
- data/spec/packet_subclasses_spec.rb +9 -10
- data/spec/packetfu_spec.rb +55 -62
- data/spec/sample3.pcap +0 -0
- data/spec/spec_helper.rb +44 -0
- data/spec/structfu_spec.rb +270 -271
- data/spec/tcp_spec.rb +76 -77
- data/spec/udp_spec.rb +32 -0
- data/spec/utils_spec.rb +95 -0
- data/test/all_tests.rb +14 -17
- data/test/func_lldp.rb +3 -3
- data/test/ptest.rb +2 -2
- data/test/test_capture.rb +45 -45
- data/test/test_eth.rb +70 -68
- data/test/test_hsrp.rb +9 -9
- data/test/test_inject.rb +18 -18
- data/test/test_invalid.rb +16 -16
- data/test/test_octets.rb +23 -21
- data/test/test_packet.rb +156 -154
- data/test/test_pcap.rb +172 -170
- data/test/test_structfu.rb +99 -97
- data/test/test_tcp.rb +322 -320
- data/test/test_udp.rb +78 -76
- metadata +108 -44
- metadata.gz.sig +2 -0
- data/spec/ethpacket_spec.rb +0 -74
- data/test/test_arp.rb +0 -135
- data/test/test_icmp.rb +0 -62
- data/test/test_ip.rb +0 -50
- data/test/test_ip6.rb +0 -68
@@ -1,44 +1,44 @@
|
|
1
1
|
# -*- coding: binary -*-
|
2
2
|
|
3
3
|
module PacketFu
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
4
|
+
# This Mixin simplifies access to the IPHeaders. Mix this in with your
|
5
|
+
# packet interface, and it will add methods that essentially delegate to
|
6
|
+
# the 'ip_header' method (assuming that it is a IPHeader object)
|
7
|
+
module IPHeaderMixin
|
8
|
+
def ip_calc_id; self.ip_header.ip_calc_id ; end
|
9
|
+
def ip_calc_len; self.ip_header.ip_calc_len ; end
|
10
|
+
def ip_calc_sum; self.ip_header.ip_calc_sum ; end
|
11
|
+
def ip_daddr; self.ip_header.ip_daddr ; end
|
12
|
+
def ip_daddr=(v); self.ip_header.ip_daddr= v; end
|
13
|
+
def ip_dst; self.ip_header.ip_dst ; end
|
14
|
+
def ip_dst=(v); self.ip_header.ip_dst= v; end
|
15
|
+
def ip_dst_readable; self.ip_header.ip_dst_readable ; end
|
16
|
+
def ip_frag; self.ip_header.ip_frag ; end
|
17
|
+
def ip_frag=(v); self.ip_header.ip_frag= v; end
|
18
|
+
def ip_hl; self.ip_header.ip_hl ; end
|
19
|
+
def ip_hl=(v); self.ip_header.ip_hl= v; end
|
20
|
+
def ip_hlen; self.ip_header.ip_hlen ; end
|
21
|
+
def ip_id; self.ip_header.ip_id ; end
|
22
|
+
def ip_id=(v); self.ip_header.ip_id= v; end
|
23
|
+
def ip_id_readable; self.ip_header.ip_id_readable ; end
|
24
|
+
def ip_len; self.ip_header.ip_len ; end
|
25
|
+
def ip_len=(v); self.ip_header.ip_len= v; end
|
26
|
+
def ip_proto; self.ip_header.ip_proto ; end
|
27
|
+
def ip_proto=(v); self.ip_header.ip_proto= v; end
|
28
|
+
def ip_recalc(*args); self.ip_header.ip_recalc(*args) ; end
|
29
|
+
def ip_saddr; self.ip_header.ip_saddr ; end
|
30
|
+
def ip_saddr=(v); self.ip_header.ip_saddr= v; end
|
31
|
+
def ip_src; self.ip_header.ip_src ; end
|
32
|
+
def ip_src=(v); self.ip_header.ip_src= v; end
|
33
|
+
def ip_src_readable; self.ip_header.ip_src_readable ; end
|
34
|
+
def ip_sum; self.ip_header.ip_sum ; end
|
35
|
+
def ip_sum=(v); self.ip_header.ip_sum= v; end
|
36
|
+
def ip_sum_readable; self.ip_header.ip_sum_readable ; end
|
37
|
+
def ip_tos; self.ip_header.ip_tos ; end
|
38
|
+
def ip_tos=(v); self.ip_header.ip_tos= v; end
|
39
|
+
def ip_ttl; self.ip_header.ip_ttl ; end
|
40
|
+
def ip_ttl=(v); self.ip_header.ip_ttl= v; end
|
41
|
+
def ip_v; self.ip_header.ip_v ; end
|
42
|
+
def ip_v=(v); self.ip_header.ip_v= v; end
|
43
|
+
end
|
44
44
|
end
|
data/lib/packetfu/protos/ipv6.rb
CHANGED
@@ -6,62 +6,62 @@ require 'packetfu/protos/ipv6/header'
|
|
6
6
|
require 'packetfu/protos/ipv6/mixin'
|
7
7
|
|
8
8
|
module PacketFu
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
9
|
+
# IPv6Packet is used to construct IPv6 Packets. They contain an EthHeader and an IPv6Header, and in
|
10
|
+
# the distant, unknowable future, will take interesting IPv6ish payloads.
|
11
|
+
#
|
12
|
+
# This mostly complete, but not very useful. It's intended primarily as an example protocol.
|
13
|
+
#
|
14
|
+
# == Parameters
|
15
|
+
#
|
16
|
+
# :eth
|
17
|
+
# A pre-generated EthHeader object.
|
18
|
+
# :ip
|
19
|
+
# A pre-generated IPHeader object.
|
20
|
+
# :flavor
|
21
|
+
# TODO: Sets the "flavor" of the IPv6 packet. No idea what this will look like, haven't done much IPv6 fingerprinting.
|
22
|
+
# :config
|
23
|
+
# A hash of return address details, often the output of Utils.whoami?
|
24
|
+
class IPv6Packet < Packet
|
25
25
|
include ::PacketFu::EthHeaderMixin
|
26
26
|
include ::PacketFu::IPv6HeaderMixin
|
27
27
|
|
28
|
-
|
28
|
+
attr_accessor :eth_header, :ipv6_header
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
30
|
+
def self.can_parse?(str)
|
31
|
+
return false unless EthPacket.can_parse? str
|
32
|
+
return false unless str.size >= 54
|
33
|
+
return false unless str[12,2] == "\x86\xdd"
|
34
|
+
true
|
35
|
+
end
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
def read(str=nil,args={})
|
38
|
+
raise "Cannot parse `#{str}'" unless self.class.can_parse?(str)
|
39
|
+
@eth_header.read(str)
|
40
|
+
super(args)
|
41
|
+
self
|
42
|
+
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
44
|
+
def initialize(args={})
|
45
|
+
@eth_header = (args[:eth] || EthHeader.new)
|
46
|
+
@ipv6_header = (args[:ipv6] || IPv6Header.new)
|
47
|
+
@eth_header.eth_proto = 0x86dd
|
48
|
+
@eth_header.body=@ipv6_header
|
49
|
+
@headers = [@eth_header, @ipv6_header]
|
50
|
+
super
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
53
|
+
# Peek provides summary data on packet contents.
|
54
|
+
def peek(args={})
|
55
|
+
peek_data = ["6 "]
|
56
|
+
peek_data << "%-5d" % self.to_s.size
|
57
|
+
peek_data << "%-31s" % self.ipv6_saddr
|
58
|
+
peek_data << "-> "
|
59
|
+
peek_data << "%-31s" % self.ipv6_daddr
|
60
|
+
peek_data << " N:"
|
61
|
+
peek_data << self.ipv6_next.to_s(16)
|
62
|
+
peek_data.join
|
63
|
+
end
|
64
64
|
|
65
|
-
|
66
|
-
|
65
|
+
end
|
66
|
+
|
67
67
|
end
|
@@ -1,191 +1,191 @@
|
|
1
1
|
# -*- coding: binary -*-
|
2
2
|
module PacketFu
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
3
|
+
# AddrIpv6 handles addressing for IPv6Header
|
4
|
+
#
|
5
|
+
# ==== Header Definition
|
6
|
+
#
|
7
|
+
# Int32 :a1
|
8
|
+
# Int32 :a2
|
9
|
+
# Int32 :a3
|
10
|
+
# Int32 :a4
|
11
|
+
class AddrIpv6 < Struct.new(:a1, :a2, :a3, :a4)
|
12
|
+
|
13
|
+
include StructFu
|
14
|
+
|
15
|
+
def initialize(args={})
|
16
|
+
super(
|
17
|
+
Int32.new(args[:a1]),
|
18
|
+
Int32.new(args[:a2]),
|
19
|
+
Int32.new(args[:a3]),
|
20
|
+
Int32.new(args[:a4]))
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns the address in string format.
|
24
|
+
def to_s
|
25
|
+
self.to_a.map {|x| x.to_s}.join
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns the address as a fairly ginormous integer.
|
29
|
+
def to_i
|
30
|
+
(a1.to_i << 96) + (a2.to_i << 64) + (a3.to_i << 32) + a4.to_i
|
31
|
+
end
|
32
|
+
|
33
|
+
# Returns the address as a colon-delimited hex string.
|
34
|
+
def to_x
|
35
|
+
IPAddr.new(self.to_i, Socket::AF_INET6).to_s
|
36
|
+
end
|
37
|
+
|
38
|
+
# Reads in a string and casts it as an IPv6 address
|
39
|
+
def read(str)
|
40
|
+
force_binary(str)
|
41
|
+
return self if str.nil?
|
42
|
+
self[:a1].read str[0,4]
|
43
|
+
self[:a2].read str[4,4]
|
44
|
+
self[:a3].read str[8,4]
|
45
|
+
self[:a4].read str[12,4]
|
46
|
+
self
|
47
|
+
end
|
48
|
+
|
49
|
+
# Reads in a colon-delimited hex string and casts it as an IPv6 address.
|
50
|
+
def read_x(str)
|
51
|
+
addr = IPAddr.new(str).to_i
|
52
|
+
self[:a1]=Int32.new(addr >> 96)
|
53
|
+
self[:a2]=Int32.new((addr & 0x00000000ffffffff0000000000000000) >> 64)
|
54
|
+
self[:a3]=Int32.new((addr & 0x0000000000000000ffffffff00000000) >> 32)
|
55
|
+
self[:a4]=Int32.new(addr & 0x000000000000000000000000ffffffff)
|
56
|
+
self
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
# IPv6Header is complete IPv6 struct, used in IPv6Packet.
|
62
|
+
#
|
63
|
+
# ==== Header Definition
|
64
|
+
#
|
65
|
+
# Fixnum (4 bits) :ipv6_v Default: 6 # Versiom
|
66
|
+
# Fixnum (8 bits) :ipv6_class Defualt: 0 # Class
|
67
|
+
# Fixnum (20 bits) :ipv6_label Defualt: 0 # Label
|
68
|
+
# Int16 :ipv6_len Default: calc # Payload length
|
69
|
+
# Int8 :ipv6_next # Next Header
|
70
|
+
# Int8 :ipv6_hop Default: 0xff # Hop limit
|
71
|
+
# AddrIpv6 :ipv6_src
|
72
|
+
# AddrIpv6 :ipv6_dst
|
73
|
+
# String :body
|
74
|
+
class IPv6Header < Struct.new(:ipv6_v, :ipv6_class, :ipv6_label,
|
75
|
+
:ipv6_len, :ipv6_next, :ipv6_hop,
|
76
|
+
:ipv6_src, :ipv6_dst, :body)
|
77
|
+
include StructFu
|
78
|
+
|
79
|
+
def initialize(args={})
|
80
|
+
super(
|
81
|
+
(args[:ipv6_v] || 6),
|
82
|
+
(args[:ipv6_class] || 0),
|
83
|
+
(args[:ipv6_label] || 0),
|
84
|
+
Int16.new(args[:ipv6_len]),
|
85
|
+
Int8.new(args[:ipv6_next]),
|
86
|
+
Int8.new(args[:ipv6_hop] || 0xff),
|
87
|
+
AddrIpv6.new.read(args[:ipv6_src] || ("\x00" * 16)),
|
88
|
+
AddrIpv6.new.read(args[:ipv6_dst] || ("\x00" * 16)),
|
89
|
+
StructFu::String.new.read(args[:body])
|
90
|
+
)
|
91
|
+
end
|
92
|
+
|
93
|
+
# Returns the object in string form.
|
94
|
+
def to_s
|
95
|
+
bytes_v_class_label = [(self.ipv6_v << 28) +
|
96
|
+
(self.ipv6_class << 20) +
|
97
|
+
self.ipv6_label].pack("N")
|
98
|
+
bytes_v_class_label + (self.to_a[3,6].map {|x| x.to_s}.join)
|
99
|
+
end
|
100
|
+
|
101
|
+
# Reads a string to populate the object.
|
102
|
+
def read(str)
|
103
|
+
force_binary(str)
|
104
|
+
return self if str.nil?
|
105
|
+
self[:ipv6_v] = str[0,1].unpack("C").first >> 4
|
106
|
+
self[:ipv6_class] = (str[0,2].unpack("n").first & 0x0ff0) >> 4
|
107
|
+
self[:ipv6_label] = str[0,4].unpack("N").first & 0x000fffff
|
108
|
+
self[:ipv6_len].read(str[4,2])
|
109
|
+
self[:ipv6_next].read(str[6,1])
|
110
|
+
self[:ipv6_hop].read(str[7,1])
|
111
|
+
self[:ipv6_src].read(str[8,16])
|
112
|
+
self[:ipv6_dst].read(str[24,16])
|
113
|
+
self[:body].read(str[40,str.size]) if str.size > 40
|
114
|
+
self
|
115
|
+
end
|
116
|
+
|
117
|
+
# Setter for the version (usually, 6).
|
118
|
+
def ipv6_v=(i); self[:ip_v] = i.to_i; end
|
119
|
+
# Getter for the version (usually, 6).
|
120
|
+
def ipv6_v; self[:ipv6_v].to_i; end
|
121
|
+
# Setter for the traffic class.
|
122
|
+
def ipv6_class=(i); self[:ip_class] = i.to_i; end
|
123
|
+
# Getter for the traffic class.
|
124
|
+
def ipv6_class; self[:ipv6_class].to_i; end
|
125
|
+
# Setter for the flow label.
|
126
|
+
def ipv6_label=(i); self[:ip_label] = i.to_i; end
|
127
|
+
# Getter for the flow label.
|
128
|
+
def ipv6_label; self[:ipv6_label].to_i; end
|
129
|
+
# Setter for the payload length.
|
130
|
+
def ipv6_len=(i); typecast i; end
|
131
|
+
# Getter for the payload length.
|
132
|
+
def ipv6_len; self[:ipv6_len].to_i; end
|
133
|
+
# Setter for the next protocol header.
|
134
|
+
def ipv6_next=(i); typecast i; end
|
135
|
+
# Getter for the next protocol header.
|
136
|
+
def ipv6_next; self[:ipv6_next].to_i; end
|
137
|
+
# Setter for the hop limit.
|
138
|
+
def ipv6_hop=(i); typecast i; end
|
139
|
+
# Getter for the hop limit.
|
140
|
+
def ipv6_hop; self[:ipv6_hop].to_i; end
|
141
|
+
# Setter for the source address.
|
142
|
+
def ipv6_src=(i); typecast i; end
|
143
|
+
# Getter for the source address.
|
144
|
+
def ipv6_src; self[:ipv6_src].to_i; end
|
145
|
+
# Setter for the destination address.
|
146
|
+
def ipv6_dst=(i); typecast i; end
|
147
|
+
# Getter for the destination address.
|
148
|
+
def ipv6_dst; self[:ipv6_dst].to_i; end
|
149
|
+
|
150
|
+
# Calculates the payload length.
|
151
|
+
def ipv6_calc_len
|
152
|
+
self.ipv6_len = body.to_s.length
|
153
|
+
end
|
154
|
+
|
155
|
+
# Recalculates the calculatable fields for this object.
|
156
|
+
def ipv6_recalc(arg=:all)
|
157
|
+
case arg
|
158
|
+
when :ipv6_len
|
159
|
+
ipv6_calc_len
|
160
|
+
when :all
|
161
|
+
ipv6_recalc(:ipv6_len)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
# Get the source address in a more readable form.
|
166
|
+
def ipv6_saddr
|
167
|
+
self[:ipv6_src].to_x
|
168
|
+
end
|
169
|
+
|
170
|
+
# Set the source address in a more readable form.
|
171
|
+
def ipv6_saddr=(str)
|
172
|
+
self[:ipv6_src].read_x(str)
|
173
|
+
end
|
174
|
+
|
175
|
+
# Get the destination address in a more readable form.
|
176
|
+
def ipv6_daddr
|
177
|
+
self[:ipv6_dst].to_x
|
178
|
+
end
|
179
|
+
|
180
|
+
# Set the destination address in a more readable form.
|
181
|
+
def ipv6_daddr=(str)
|
182
|
+
self[:ipv6_dst].read_x(str)
|
183
|
+
end
|
184
|
+
|
185
|
+
# Readability aliases
|
186
|
+
|
187
|
+
alias :ipv6_src_readable :ipv6_saddr
|
188
|
+
alias :ipv6_dst_readable :ipv6_daddr
|
189
|
+
|
190
|
+
end # class IPv6Header
|
191
191
|
end
|