packetgen 3.3.2 → 4.0.0
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 +37 -21
- data/lib/packetgen/capture.rb +2 -2
- data/lib/packetgen/config.rb +0 -1
- data/lib/packetgen/deprecation.rb +7 -7
- data/lib/packetgen/header/arp.rb +13 -13
- data/lib/packetgen/header/asn1_base.rb +1 -1
- data/lib/packetgen/header/base.rb +17 -18
- data/lib/packetgen/header/bootp.rb +32 -34
- data/lib/packetgen/header/dhcp/option.rb +19 -19
- data/lib/packetgen/header/dhcp/options.rb +1 -1
- data/lib/packetgen/header/dhcp.rb +3 -3
- data/lib/packetgen/header/dhcpv6/duid.rb +16 -16
- data/lib/packetgen/header/dhcpv6/option.rb +53 -53
- data/lib/packetgen/header/dhcpv6/options.rb +1 -1
- data/lib/packetgen/header/dhcpv6/relay.rb +5 -5
- data/lib/packetgen/header/dhcpv6.rb +6 -6
- data/lib/packetgen/header/dns/name.rb +14 -10
- data/lib/packetgen/header/dns/opt.rb +2 -2
- data/lib/packetgen/header/dns/option.rb +11 -11
- data/lib/packetgen/header/dns/qdsection.rb +1 -1
- data/lib/packetgen/header/dns/question.rb +6 -8
- data/lib/packetgen/header/dns/rr.rb +56 -43
- data/lib/packetgen/header/dns/rrsection.rb +4 -4
- data/lib/packetgen/header/dns.rb +27 -30
- data/lib/packetgen/header/dot11/control.rb +11 -11
- data/lib/packetgen/header/dot11/data.rb +20 -20
- data/lib/packetgen/header/dot11/element.rb +4 -4
- data/lib/packetgen/header/dot11/management.rb +8 -8
- data/lib/packetgen/header/dot11/sub_mngt.rb +39 -53
- data/lib/packetgen/header/dot11.rb +88 -93
- data/lib/packetgen/header/dot1q.rb +10 -12
- data/lib/packetgen/header/dot1x.rb +9 -9
- data/lib/packetgen/header/eap/fast.rb +4 -4
- data/lib/packetgen/header/eap/md5.rb +6 -6
- data/lib/packetgen/header/eap/tls.rb +13 -15
- data/lib/packetgen/header/eap/ttls.rb +13 -15
- data/lib/packetgen/header/eap.rb +22 -22
- data/lib/packetgen/header/eth.rb +18 -18
- data/lib/packetgen/header/gre.rb +8 -10
- data/lib/packetgen/header/http/headers.rb +2 -2
- data/lib/packetgen/header/http/request.rb +17 -16
- data/lib/packetgen/header/http/response.rb +18 -17
- data/lib/packetgen/header/http/verbs.rb +1 -3
- data/lib/packetgen/header/icmp.rb +8 -8
- data/lib/packetgen/header/icmpv6.rb +3 -3
- data/lib/packetgen/header/igmp.rb +8 -8
- data/lib/packetgen/header/igmpv3/group_record.rb +12 -12
- data/lib/packetgen/header/igmpv3/mq.rb +16 -18
- data/lib/packetgen/header/igmpv3/mr.rb +4 -4
- data/lib/packetgen/header/igmpv3.rb +7 -7
- data/lib/packetgen/header/ip/addr.rb +13 -13
- data/lib/packetgen/header/ip/option.rb +31 -33
- data/lib/packetgen/header/ip/options.rb +1 -1
- data/lib/packetgen/header/ip.rb +37 -72
- data/lib/packetgen/header/ipv6/addr.rb +14 -14
- data/lib/packetgen/header/ipv6/extension.rb +8 -8
- data/lib/packetgen/header/ipv6/hop_by_hop.rb +9 -9
- data/lib/packetgen/header/ipv6.rb +20 -22
- data/lib/packetgen/header/llc.rb +17 -17
- data/lib/packetgen/header/mdns.rb +1 -1
- data/lib/packetgen/header/mld.rb +6 -6
- data/lib/packetgen/header/mldv2/mcast_address_record.rb +11 -11
- data/lib/packetgen/header/mldv2/mlq.rb +21 -23
- data/lib/packetgen/header/mldv2/mlr.rb +8 -8
- data/lib/packetgen/header/ospfv2/db_description.rb +11 -12
- data/lib/packetgen/header/ospfv2/hello.rb +11 -11
- data/lib/packetgen/header/ospfv2/ls_ack.rb +1 -1
- data/lib/packetgen/header/ospfv2/ls_request.rb +9 -9
- data/lib/packetgen/header/ospfv2/ls_update.rb +3 -3
- data/lib/packetgen/header/ospfv2/lsa.rb +54 -58
- data/lib/packetgen/header/ospfv2/lsa_header.rb +9 -9
- data/lib/packetgen/header/ospfv2.rb +27 -29
- data/lib/packetgen/header/ospfv3/db_description.rb +13 -14
- data/lib/packetgen/header/ospfv3/hello.rb +12 -12
- data/lib/packetgen/header/ospfv3/ipv6_prefix.rb +17 -19
- data/lib/packetgen/header/ospfv3/ls_ack.rb +2 -2
- data/lib/packetgen/header/ospfv3/ls_request.rb +9 -9
- data/lib/packetgen/header/ospfv3/ls_update.rb +4 -4
- data/lib/packetgen/header/ospfv3/lsa.rb +48 -51
- data/lib/packetgen/header/ospfv3/lsa_header.rb +9 -9
- data/lib/packetgen/header/ospfv3.rb +25 -27
- data/lib/packetgen/header/sctp/chunk.rb +44 -41
- data/lib/packetgen/header/sctp/error.rb +52 -52
- data/lib/packetgen/header/sctp/parameter.rb +38 -38
- data/lib/packetgen/header/sctp.rb +5 -5
- data/lib/packetgen/header/snmp.rb +2 -2
- data/lib/packetgen/header/tcp/option.rb +45 -39
- data/lib/packetgen/header/tcp/options.rb +2 -2
- data/lib/packetgen/header/tcp.rb +55 -44
- data/lib/packetgen/header/tftp.rb +16 -16
- data/lib/packetgen/header/udp.rb +8 -8
- data/lib/packetgen/header.rb +9 -10
- data/lib/packetgen/headerable.rb +13 -3
- data/lib/packetgen/inspect.rb +2 -2
- data/lib/packetgen/packet.rb +54 -37
- data/lib/packetgen/pcap.rb +15 -4
- data/lib/packetgen/pcapng/block.rb +18 -17
- data/lib/packetgen/pcapng/epb.rb +13 -15
- data/lib/packetgen/pcapng/file.rb +3 -97
- data/lib/packetgen/pcapng/idb.rb +9 -11
- data/lib/packetgen/pcapng/shb.rb +13 -15
- data/lib/packetgen/pcapng/spb.rb +8 -10
- data/lib/packetgen/pcapng/unknown_block.rb +6 -17
- data/lib/packetgen/pcapng.rb +4 -4
- data/lib/packetgen/pcaprub_wrapper.rb +17 -1
- data/lib/packetgen/proto.rb +1 -1
- data/lib/packetgen/unknown_packet.rb +2 -2
- data/lib/packetgen/utils/arp_spoofer.rb +18 -19
- data/lib/packetgen/utils.rb +2 -2
- data/lib/packetgen/version.rb +1 -1
- data/lib/packetgen.rb +4 -3
- metadata +34 -29
- data/lib/packetgen/types/abstract_tlv.rb +0 -278
- data/lib/packetgen/types/array.rb +0 -287
- data/lib/packetgen/types/cstring.rb +0 -109
- data/lib/packetgen/types/enum.rb +0 -171
- data/lib/packetgen/types/fieldable.rb +0 -66
- data/lib/packetgen/types/fields.rb +0 -622
- data/lib/packetgen/types/int.rb +0 -473
- data/lib/packetgen/types/int_string.rb +0 -102
- data/lib/packetgen/types/length_from.rb +0 -54
- data/lib/packetgen/types/oui.rb +0 -52
- data/lib/packetgen/types/string.rb +0 -97
- data/lib/packetgen/types/tlv.rb +0 -161
- data/lib/packetgen/types.rb +0 -26
@@ -37,16 +37,16 @@ module PacketGen
|
|
37
37
|
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
38
38
|
#
|
39
39
|
# A IPv6 header consists of:
|
40
|
-
# * a first 32-bit word ({#u32}, of {
|
40
|
+
# * a first 32-bit word ({#u32}, of {BinStruct::Int32} type) composed of:
|
41
41
|
# * a 4-bit {#version} field,
|
42
42
|
# * a 8-bit {#traffic_class} field,
|
43
43
|
# * a 20-bit {#flow_label} field,
|
44
|
-
# * a payload length field ({#length}, {
|
45
|
-
# * a next header field ({#next}, {
|
44
|
+
# * a payload length field ({#length}, {BinStruct::Int16} type}),
|
45
|
+
# * a next header field ({#next}, {BinStruct::Int8} type),
|
46
46
|
# * a hop-limit field ({#hop}, +Int8+ type),
|
47
47
|
# * a source address field ({#src}, {IPv6::Addr} type),
|
48
48
|
# * a destination address field ({#dst}, +IPv6::Addr+ type),
|
49
|
-
# * and a {#body} ({
|
49
|
+
# * and a {#body} ({BinStruct::String} type).
|
50
50
|
#
|
51
51
|
# == Create a IPv6 header
|
52
52
|
# # standalone
|
@@ -95,38 +95,36 @@ module PacketGen
|
|
95
95
|
# @!attribute u32
|
96
96
|
# First 32-bit word of IPv6 header
|
97
97
|
# @return [Integer]
|
98
|
-
|
98
|
+
# @!attribute version
|
99
|
+
# @return [Integer] 4-bit version attribute
|
100
|
+
# @!attribute traffic_class
|
101
|
+
# @return [Integer] 8-bit traffic_class attribute
|
102
|
+
# @!attribute flow_label
|
103
|
+
# @return [Integer] 20-bit flow_label attribute
|
104
|
+
define_bit_attr :u32, default: 0x60000000, version: 4, traffic_class: 8, flow_label: 20
|
99
105
|
# @!attribute length
|
100
106
|
# 16-bit word of IPv6 payload length
|
101
107
|
# @return [Integer]
|
102
|
-
|
108
|
+
define_attr :length, BinStruct::Int16
|
103
109
|
# @!attribute next
|
104
110
|
# 8-bit IPv6 next payload value
|
105
111
|
# @return [Integer]
|
106
|
-
|
112
|
+
define_attr :next, BinStruct::Int8
|
107
113
|
# @!attribute hop
|
108
114
|
# 8-bit IPv6 hop limit
|
109
115
|
# @return [Integer]
|
110
|
-
|
116
|
+
define_attr :hop, BinStruct::Int8, default: 64
|
111
117
|
# @!attribute src
|
112
118
|
# IPv6 source address
|
113
119
|
# @return [Addr]
|
114
|
-
|
120
|
+
define_attr :src, Addr, default: '::1'
|
115
121
|
# @!attribute dst
|
116
122
|
# IPv6 destination address
|
117
123
|
# @return [Addr]
|
118
|
-
|
124
|
+
define_attr :dst, Addr, default: '::1'
|
119
125
|
# @!attribute body
|
120
|
-
# @return [
|
121
|
-
|
122
|
-
|
123
|
-
# @!attribute version
|
124
|
-
# @return [Integer] 4-bit version attribute
|
125
|
-
# @!attribute traffic_class
|
126
|
-
# @return [Integer] 8-bit traffic_class attribute
|
127
|
-
# @!attribute flow_label
|
128
|
-
# @return [Integer] 20-bit flow_label attribute
|
129
|
-
define_bit_fields_on :u32, :version, 4, :traffic_class, 8, :flow_label, 20
|
126
|
+
# @return [BinStruct::String,Header::Base]
|
127
|
+
define_attr :body, BinStruct::String
|
130
128
|
|
131
129
|
# Compute length and set +len+ field
|
132
130
|
# @return [Integer]
|
@@ -143,14 +141,14 @@ module PacketGen
|
|
143
141
|
sum
|
144
142
|
end
|
145
143
|
|
146
|
-
# Send IPv6 packet on wire. All
|
144
|
+
# Send IPv6 packet on wire. All attributes.may be set (even {#version}).
|
147
145
|
# @param [String] _iface interface name (not used)
|
148
146
|
# @return [void]
|
149
147
|
# @since 3.0.0 no more limitations on +flow_label+, +length+ and +src+ fields.
|
150
148
|
def to_w(_iface=nil)
|
151
149
|
sock = Socket.new(Socket::AF_INET6, Socket::SOCK_RAW, Socket::IPPROTO_RAW)
|
152
150
|
sockaddrin = Socket.sockaddr_in(0, dst)
|
153
|
-
sock.send
|
151
|
+
sock.send(to_s, 0, sockaddrin)
|
154
152
|
sock.close
|
155
153
|
end
|
156
154
|
|
data/lib/packetgen/header/llc.rb
CHANGED
@@ -12,25 +12,25 @@ module PacketGen
|
|
12
12
|
# Logical-Link Control header
|
13
13
|
#
|
14
14
|
# A LLC header consists of:
|
15
|
-
# * a {#dsap} ({
|
16
|
-
# * a {#ssap} ({
|
17
|
-
# * a {#control} ({
|
18
|
-
# * and a {#body} (a {
|
15
|
+
# * a {#dsap} ({BinStruct::Int8}),
|
16
|
+
# * a {#ssap} ({BinStruct::Int8}),
|
17
|
+
# * a {#control} ({BinStruct::Int8}),
|
18
|
+
# * and a {#body} (a {BinStruct::String} or another {Base} class).
|
19
19
|
# @author Sylvain Daubert
|
20
20
|
# @since 1.4.0
|
21
21
|
class LLC < Base
|
22
22
|
# @!attribute dsap
|
23
23
|
# @return [Integer] 8-bit dsap value
|
24
|
-
|
24
|
+
define_attr :dsap, BinStruct::Int8
|
25
25
|
# @!attribute ssap
|
26
26
|
# @return [Integer] 8-bit ssap value
|
27
|
-
|
27
|
+
define_attr :ssap, BinStruct::Int8
|
28
28
|
# @!attribute control
|
29
29
|
# @return [Integer] 8-bit control value
|
30
|
-
|
30
|
+
define_attr :control, BinStruct::Int8
|
31
31
|
# @!attribute body
|
32
|
-
# @return [
|
33
|
-
|
32
|
+
# @return [BinStruct::String,Header::Base]
|
33
|
+
define_attr :body, BinStruct::String
|
34
34
|
end
|
35
35
|
self.add_class LLC
|
36
36
|
Dot11::Data.bind LLC, type: 2, wep?: false
|
@@ -38,21 +38,21 @@ module PacketGen
|
|
38
38
|
# Sub-Network Access Protocol
|
39
39
|
#
|
40
40
|
# A SNAP header consists of:
|
41
|
-
# * a {#oui} ({
|
42
|
-
# * a {#proto_id} ({
|
43
|
-
# * and a {#body} (a {
|
41
|
+
# * a {#oui} ({BinStruct::OUI}),
|
42
|
+
# * a {#proto_id} ({BinStruct::Int16}),
|
43
|
+
# * and a {#body} (a {BinStruct::String} or another {Base} class).
|
44
44
|
# @author Sylvain Daubert
|
45
45
|
# @since 1.4.0
|
46
46
|
class SNAP < Base
|
47
47
|
# @!attribute oui
|
48
|
-
# @return [
|
49
|
-
|
48
|
+
# @return [BinStruct::OUI]
|
49
|
+
define_attr :oui, BinStruct::OUI
|
50
50
|
# @!attribute proto_id
|
51
51
|
# @return [Integer] 16-bit protocol id
|
52
|
-
|
52
|
+
define_attr :proto_id, BinStruct::Int16
|
53
53
|
# @!attribute body
|
54
|
-
# @return [
|
55
|
-
|
54
|
+
# @return [BinStruct::String,Header::Base]
|
55
|
+
define_attr :body, BinStruct::String
|
56
56
|
end
|
57
57
|
self.add_class SNAP
|
58
58
|
LLC.bind SNAP, dsap: 170, ssap: 170, control: 3
|
@@ -47,7 +47,7 @@ module PacketGen
|
|
47
47
|
def added_to_packet(packet)
|
48
48
|
mdns_idx = packet.headers.size
|
49
49
|
packet.instance_eval "def mdnsize() @headers[#{mdns_idx}].mdnsize; end" # def mdnsize() @headers[4].mdnsize; end
|
50
|
-
return unless packet.is?
|
50
|
+
return unless packet.is?('UDP')
|
51
51
|
return unless packet.udp.sport.zero?
|
52
52
|
|
53
53
|
packet.udp.sport = UDP_PORT
|
data/lib/packetgen/header/mld.rb
CHANGED
@@ -26,8 +26,8 @@ module PacketGen
|
|
26
26
|
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
27
27
|
#
|
28
28
|
# A MLD header consists of:
|
29
|
-
# * a {#max_resp_delay} field ({
|
30
|
-
# * a {#reserved} field ({
|
29
|
+
# * a {#max_resp_delay} field ({BinStruct::Int16} type),
|
30
|
+
# * a {#reserved} field ({BinStruct::Int16} type),
|
31
31
|
# * a {#mcast_addr} field ({Header::IPv6::Addr} type),
|
32
32
|
# * and a {#body} (unused for MLDv1).
|
33
33
|
#
|
@@ -49,20 +49,20 @@ module PacketGen
|
|
49
49
|
# @!attribute max_resp_delay
|
50
50
|
# 16-bit MLD Max Response Delay
|
51
51
|
# @return [Integer]
|
52
|
-
|
52
|
+
define_attr :max_resp_delay, BinStruct::Int16
|
53
53
|
alias max_resp_code max_resp_delay
|
54
54
|
alias max_resp_code= max_resp_delay=
|
55
55
|
# @!attribute reserved
|
56
56
|
# 16-bit Reserved field
|
57
57
|
# @return [Integer]
|
58
|
-
|
58
|
+
define_attr :reserved, BinStruct::Int16
|
59
59
|
# @!attribute mcast_addr
|
60
60
|
# IPv6 Multicast address
|
61
61
|
# @return [IPv6::Addr]
|
62
|
-
|
62
|
+
define_attr :mcast_addr, IPv6::Addr, default: '::'
|
63
63
|
# @!attribute body
|
64
64
|
# @return [String,Base]
|
65
|
-
|
65
|
+
define_attr :body, BinStruct::String
|
66
66
|
|
67
67
|
# @api private
|
68
68
|
# @note This method is used internally by PacketGen and should not be
|
@@ -52,8 +52,8 @@ module PacketGen
|
|
52
52
|
# | |
|
53
53
|
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
54
54
|
# @author Sylvain Daubert
|
55
|
-
class McastAddressRecord <
|
56
|
-
include
|
55
|
+
class McastAddressRecord < BinStruct::Struct
|
56
|
+
include BinStruct::Structable
|
57
57
|
|
58
58
|
# Known record types
|
59
59
|
RECORD_TYPES = IGMPv3::GroupRecord::RECORD_TYPES
|
@@ -61,29 +61,29 @@ module PacketGen
|
|
61
61
|
# @!attribute type
|
62
62
|
# 8-bit record type
|
63
63
|
# @return [Integer]
|
64
|
-
|
64
|
+
define_attr :type, BinStruct::Int8Enum, enum: RECORD_TYPES
|
65
65
|
# @!attribute aux_data_len
|
66
66
|
# 8-bit length of of the Auxiliary Data field ({#aux_data}), in unit of
|
67
67
|
# 32-bit words
|
68
68
|
# @return [Integer]
|
69
|
-
|
69
|
+
define_attr :aux_data_len, BinStruct::Int8, default: 0
|
70
70
|
# @!attribute number_of_sources
|
71
71
|
# 16-bit Number of source addresses in {#source_addr}
|
72
72
|
# @return [Integer]
|
73
|
-
|
73
|
+
define_attr :number_of_sources, BinStruct::Int16, default: 0
|
74
74
|
# @!attribute multicast_addr
|
75
75
|
# IP multicast address to which this Multicast Address Record pertains
|
76
76
|
# @return [IPv6::Addr]
|
77
|
-
|
77
|
+
define_attr :multicast_addr, IPv6::Addr, default: '::'
|
78
78
|
# @!attribute source_addr
|
79
79
|
# Array of source addresses
|
80
80
|
# @return [IPv6::ArrayOfAddr]
|
81
|
-
|
82
|
-
|
81
|
+
define_attr :source_addr, IPv6::ArrayOfAddr,
|
82
|
+
builder: ->(h, t) { t.new(counter: h[:number_of_sources]) }
|
83
83
|
# @!attribute aux_data
|
84
84
|
# @return [String]
|
85
|
-
|
86
|
-
|
85
|
+
define_attr :aux_data, BinStruct::String,
|
86
|
+
builder: ->(h, t) { t.new(length_from: -> { h[:aux_data_len].to_i * 4 }) }
|
87
87
|
|
88
88
|
def human_type
|
89
89
|
self[:type].to_human
|
@@ -96,7 +96,7 @@ module PacketGen
|
|
96
96
|
|
97
97
|
# Class to handle series of {McastAddressRecord}.
|
98
98
|
# @author Sylvain Daubert
|
99
|
-
class McastAddressRecords <
|
99
|
+
class McastAddressRecords < BinStruct::Array
|
100
100
|
set_of McastAddressRecord
|
101
101
|
|
102
102
|
# Separator used in {#to_human}.
|
@@ -57,18 +57,18 @@ module PacketGen
|
|
57
57
|
# * *
|
58
58
|
# | |
|
59
59
|
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
60
|
-
# +type+, +code+ and +checksum+ are
|
60
|
+
# +type+, +code+ and +checksum+ are attributes.from {ICMPv6} header.
|
61
61
|
#
|
62
|
-
# MLQ
|
63
|
-
# * {#max_resp_code #max_resp_code} ({
|
64
|
-
# * {#reserved #reserved} ({
|
62
|
+
# MLQ attributes.are:
|
63
|
+
# * {#max_resp_code #max_resp_code} ({BinStruct::Int16}),
|
64
|
+
# * {#reserved #reserved} ({BinStruct::Int16}),
|
65
65
|
# * {#mcast_addr #mcast_addr} ({IPv6::Addr}),
|
66
|
-
# * {#flags} ({
|
66
|
+
# * {#flags} ({BinStruct::Int8}), with sub-fields:
|
67
67
|
# * a 4-bit {#flag_resv} field,
|
68
68
|
# * a 1-bit {#flag_s} boolean,
|
69
69
|
# * a 3-bit {#flag_qrv} field,
|
70
|
-
# * {#qqic} ({
|
71
|
-
# * {#number_of_sources} ({
|
70
|
+
# * {#qqic} ({BinStruct::Int8}),
|
71
|
+
# * {#number_of_sources} ({BinStruct::Int16}),
|
72
72
|
# * and {#source_addr}, a {IPv6::ArrayOfAddr}.
|
73
73
|
#
|
74
74
|
# == Max Resp Delay
|
@@ -80,31 +80,29 @@ module PacketGen
|
|
80
80
|
# @!attribute flags
|
81
81
|
# 8-bit flags
|
82
82
|
# @return [Integer]
|
83
|
-
|
83
|
+
# @!attribute flag_resv
|
84
|
+
# 4-bit reserved field in {#flags}
|
85
|
+
# @return [Integer]
|
86
|
+
# @!attribute flag_s
|
87
|
+
# S Flag (Suppress Router-Side Processing)
|
88
|
+
# @return [Integer]
|
89
|
+
# @!attribute flag_qrv
|
90
|
+
# 3-bit QRV (Querier's Robustness Variable)
|
91
|
+
# @return [Integer]
|
92
|
+
define_bit_attr_before :body, :flags, flag_resv: 4, flag_s: 1, flag_qrv: 3
|
84
93
|
# @!attribute qqic
|
85
94
|
# 8-bit QQIC
|
86
95
|
# @return [Integer]
|
87
|
-
|
96
|
+
define_attr_before :body, :qqic, BinStruct::Int8
|
88
97
|
# @!attribute number_of_sources
|
89
98
|
# 16-bit number of sources
|
90
99
|
# @return [Integer]
|
91
|
-
|
100
|
+
define_attr_before :body, :number_of_sources, BinStruct::Int16
|
92
101
|
# @!attribute source_addr
|
93
102
|
# Array of IPv6 source addresses
|
94
103
|
# @return [IPv6::ArrayOfAddr]
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
# @!attribute flag_resv
|
99
|
-
# 4-bit reserved field in {#flags}
|
100
|
-
# @return [Integer]
|
101
|
-
# @!attribute flag_s
|
102
|
-
# S Flag (Suppress Router-Side Processing)
|
103
|
-
# @return [Boolean]
|
104
|
-
# @!attribute flag_qrv
|
105
|
-
# 3-bit QRV (Querier's Robustness Variable)
|
106
|
-
# @return [Integer]
|
107
|
-
define_bit_fields_on :flags, :flag_resv, 4, :flag_s, :flag_qrv, 3
|
104
|
+
define_attr_before :body, :source_addr, IPv6::ArrayOfAddr,
|
105
|
+
builder: ->(h, t) { t.new(counter: h[:number_of_sources]) }
|
108
106
|
|
109
107
|
# Getter for +max_resp_code+ for MLDv2 packets. Use {MLDv2.decode}.
|
110
108
|
# @return [Integer]
|
@@ -38,28 +38,28 @@ module PacketGen
|
|
38
38
|
# . .
|
39
39
|
# | |
|
40
40
|
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
41
|
-
# +type+, +code+ and +checksum+ are
|
41
|
+
# +type+, +code+ and +checksum+ are attributes.from {ICMPv6} header.
|
42
42
|
#
|
43
|
-
# MLR
|
44
|
-
# * {#reserved} ({
|
45
|
-
# * {#number_of_mar} (number of mcast address records, {
|
43
|
+
# MLR attributes.are:
|
44
|
+
# * {#reserved} ({BinStruct::Int16}),
|
45
|
+
# * {#number_of_mar} (number of mcast address records, {BinStruct::Int16}),
|
46
46
|
# * {#records} ({McastAddressRecords}).
|
47
47
|
# @author Sylvain Daubert
|
48
48
|
class MLR < Base
|
49
49
|
# @!attribute reserved
|
50
50
|
# 16-bit reserved field
|
51
51
|
# @return [Integer]
|
52
|
-
|
52
|
+
define_attr :reserved, BinStruct::Int16, default: 0
|
53
53
|
# @!attribute number_of_mar
|
54
54
|
# 16-bit Number of group records in {#records}
|
55
55
|
# @return [Integer]
|
56
|
-
|
56
|
+
define_attr :number_of_mar, BinStruct::Int16, default: 0
|
57
57
|
|
58
58
|
# @!attribute records
|
59
59
|
# Array of Mcast Address Records
|
60
60
|
# @return [McastAddressRecords]
|
61
|
-
|
62
|
-
|
61
|
+
define_attr :records, McastAddressRecords,
|
62
|
+
builder: ->(h, t) { t.new(counter: h[:number_of_mar]) }
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -31,13 +31,13 @@ module PacketGen
|
|
31
31
|
# | ... |
|
32
32
|
#
|
33
33
|
# A DB description payload is composed of:
|
34
|
-
# * a 16-bit {#mtu} field ({
|
35
|
-
# * a 8-bit {#options} field ({
|
36
|
-
# * a 8-bit {#flags} field ({
|
34
|
+
# * a 16-bit {#mtu} field ({BinStruct::Int16}),
|
35
|
+
# * a 8-bit {#options} field ({BinStruct::Int8}),
|
36
|
+
# * a 8-bit {#flags} field ({BinStruct::Int8}). Supported flags are:
|
37
37
|
# * {i_flag},
|
38
38
|
# * {m_flag},
|
39
39
|
# * {ms_flag},
|
40
|
-
# * a 32-bit {#sequence_number} field ({
|
40
|
+
# * a 32-bit {#sequence_number} field ({BinStruct::Int32}),
|
41
41
|
# * and an array of {LSAHeader LSAHeaders} ({#lsas}, {ArrayOfLSA}).
|
42
42
|
#
|
43
43
|
# == Create a DbDescription payload
|
@@ -64,7 +64,7 @@ module PacketGen
|
|
64
64
|
# @!attribute mtu
|
65
65
|
# 16-bit interface MTU
|
66
66
|
# @return [Integer]
|
67
|
-
|
67
|
+
define_attr :mtu, BinStruct::Int16
|
68
68
|
|
69
69
|
# @!macro define_options
|
70
70
|
OSPFv2.define_options(self)
|
@@ -72,30 +72,29 @@ module PacketGen
|
|
72
72
|
# @!attribute flags
|
73
73
|
# 8-bit interface flags ({#i_flag}, {#m_flag} and {#ms_flag})
|
74
74
|
# @return [Integer]
|
75
|
-
define_field :flags, Types::Int8
|
76
75
|
# @!attribute i_flag
|
77
76
|
# Init bit
|
78
|
-
# @return [
|
77
|
+
# @return [Integer]
|
79
78
|
# @!attribute m_flag
|
80
79
|
# More bit
|
81
|
-
# @return [
|
80
|
+
# @return [Integer]
|
82
81
|
# @!attribute ms_flag
|
83
82
|
# Master/Slave bit
|
84
|
-
# @return [
|
85
|
-
|
83
|
+
# @return [Integer]
|
84
|
+
define_bit_attr :flags, zero: 5, i_flag: 1, m_flag: 1, ms_flag: 1
|
86
85
|
|
87
86
|
# @!attribute sequence_number
|
88
87
|
# 32-bit DD sequence number, used to sequence the collection of Database
|
89
88
|
# Description Packets.
|
90
89
|
# @return [Integer]
|
91
|
-
|
90
|
+
define_attr :sequence_number, BinStruct::Int32
|
92
91
|
alias seqnum sequence_number
|
93
92
|
alias seqnum= sequence_number=
|
94
93
|
|
95
94
|
# @!attribute lsas
|
96
95
|
# Array of LSA headers
|
97
96
|
# @return [ArrayOfLSAHeader]
|
98
|
-
|
97
|
+
define_attr :lsas, ArrayOfLSA, builder: ->(_h, t) { t.new(only_headers: true) }
|
99
98
|
end
|
100
99
|
end
|
101
100
|
|
@@ -29,10 +29,10 @@ module PacketGen
|
|
29
29
|
# | ... |
|
30
30
|
# A HELLO payload consists of:
|
31
31
|
# * a {#network_mask} field ({IP::Addr}),
|
32
|
-
# * a {#hello_interval} field ({
|
33
|
-
# * an {#options} field ({
|
34
|
-
# * a {#priority} field ({
|
35
|
-
# * a {#dead_interval} field ({
|
32
|
+
# * a {#hello_interval} field ({BinStruct::Int16}),
|
33
|
+
# * an {#options} field ({BinStruct::Int8}),
|
34
|
+
# * a {#priority} field ({BinStruct::Int8}),
|
35
|
+
# * a {#dead_interval} field ({BinStruct::Int32}),
|
36
36
|
# * a {#designated_router} field ({IP::Addr}),
|
37
37
|
# * a {#backup_designated_router} field ({IP::Addr}),
|
38
38
|
# * a {#neighbors} array containing neighbors as {IP::Addr}.
|
@@ -63,11 +63,11 @@ module PacketGen
|
|
63
63
|
# @!attribute network_mask
|
64
64
|
# The network mask associated with this interface.
|
65
65
|
# @return [String]
|
66
|
-
|
66
|
+
define_attr :network_mask, IP::Addr
|
67
67
|
# @!attribute hello_interval
|
68
68
|
# The number of seconds between this router's Hello packets.
|
69
69
|
# @return [Integer]
|
70
|
-
|
70
|
+
define_attr :hello_interval, BinStruct::Int16
|
71
71
|
|
72
72
|
# @!macro define_options
|
73
73
|
OSPFv2.define_options(self)
|
@@ -76,25 +76,25 @@ module PacketGen
|
|
76
76
|
# This router's Router Priority. Used in (Backup) Designated
|
77
77
|
# Router election.
|
78
78
|
# @return [Integer]
|
79
|
-
|
79
|
+
define_attr :priority, BinStruct::Int8
|
80
80
|
# @!attribute dead_interval
|
81
81
|
# The number of seconds before declaring a silent router down.
|
82
82
|
# @return [Integer]
|
83
|
-
|
83
|
+
define_attr :dead_interval, BinStruct::Int32
|
84
84
|
# @!attribute designated_router
|
85
85
|
# The identity of the Designated Router for this network, in the
|
86
86
|
# view of the sending router.
|
87
87
|
# @return [String]
|
88
|
-
|
88
|
+
define_attr :designated_router, IP::Addr
|
89
89
|
# @!attribute backup_designated_router
|
90
90
|
# The identity of the Backup Designated Router for this network,
|
91
91
|
# in the view of the sending router.
|
92
92
|
# @return [String]
|
93
|
-
|
93
|
+
define_attr :backup_designated_router, IP::Addr
|
94
94
|
# @!attribute neighbors
|
95
95
|
# Array of neighbors
|
96
96
|
# @return [IP::ArrayOfAddr]
|
97
|
-
|
97
|
+
define_attr :neighbors, IP::ArrayOfAddr
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
@@ -45,7 +45,7 @@ module PacketGen
|
|
45
45
|
# @!attribute lsas
|
46
46
|
# Array of LSA headers
|
47
47
|
# @return [ArrayOfLSA]
|
48
|
-
|
48
|
+
define_attr :lsas, ArrayOfLSA, builder: ->(_h, t) { t.new(only_headers: true) }
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -9,27 +9,27 @@
|
|
9
9
|
module PacketGen
|
10
10
|
module Header
|
11
11
|
class OSPFv2
|
12
|
-
# This class handle a LS request, which is composed 3 {
|
12
|
+
# This class handle a LS request, which is composed 3 {BinStruct::Int32} fields:
|
13
13
|
# * {#type},
|
14
14
|
# * {#link_state_id},
|
15
15
|
# * and {#advertising_router}.
|
16
16
|
# @author Sylvain Daubert
|
17
|
-
class LSR <
|
18
|
-
include
|
17
|
+
class LSR < BinStruct::Struct
|
18
|
+
include BinStruct::Structable
|
19
19
|
|
20
20
|
# @!attribute type
|
21
21
|
# The type of the LSA to request.
|
22
22
|
# @return [Integer]
|
23
|
-
|
23
|
+
define_attr :type, BinStruct::Int32Enum, enum: LSAHeader::TYPES
|
24
24
|
# @!attribute link_state_id
|
25
25
|
# This field identifies the portion of the internet environment
|
26
26
|
# that is being described by the LSA to request.
|
27
27
|
# @return [String]
|
28
|
-
|
28
|
+
define_attr :link_state_id, IP::Addr
|
29
29
|
# @!attribute advertising_router
|
30
30
|
# The Router ID of the requested LSA.
|
31
31
|
# @return [String]
|
32
|
-
|
32
|
+
define_attr :advertising_router, IP::Addr
|
33
33
|
|
34
34
|
# Get human-readable type
|
35
35
|
# @return [String]
|
@@ -43,10 +43,10 @@ module PacketGen
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
# This class defines a specialized {
|
46
|
+
# This class defines a specialized {BinStruct::Array array} to handle series
|
47
47
|
# of {LSR LSRs}.
|
48
48
|
# @author Sylvain Daubert
|
49
|
-
class ArrayOfLSR <
|
49
|
+
class ArrayOfLSR < BinStruct::Array
|
50
50
|
set_of LSR
|
51
51
|
end
|
52
52
|
|
@@ -82,7 +82,7 @@ module PacketGen
|
|
82
82
|
# @!attribute lsrs
|
83
83
|
# Array of {LSR}
|
84
84
|
# @return [ArrayOfLSR]
|
85
|
-
|
85
|
+
define_attr :lsrs, ArrayOfLSR
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -22,7 +22,7 @@ module PacketGen
|
|
22
22
|
# +- +-+
|
23
23
|
# | ... |
|
24
24
|
# This paylod is implemented with two fields:
|
25
|
-
# * {#lsas_count}, a {
|
25
|
+
# * {#lsas_count}, a {BinStruct::Int32} field,
|
26
26
|
# * and {#lsas}, an {ArrayOfLSA} object.
|
27
27
|
#
|
28
28
|
# == Create a LSUpdate payload
|
@@ -47,11 +47,11 @@ module PacketGen
|
|
47
47
|
# @!attribute lsas_count
|
48
48
|
# Count of LSAs included in this update
|
49
49
|
# @return [Integer]
|
50
|
-
|
50
|
+
define_attr :lsas_count, BinStruct::Int32
|
51
51
|
# @!attribute lsas
|
52
52
|
# Array of {LSA LSAs}
|
53
53
|
# @return [ArrayOfLSA]
|
54
|
-
|
54
|
+
define_attr :lsas, ArrayOfLSA, builder: ->(h, t) { t.new(counter: h[:lsas_count]) }
|
55
55
|
|
56
56
|
# Calculate checksums of all LSAs
|
57
57
|
# @return [void]
|