lib/packetgen/plugin/smb/trans.rb in packetgen-plugin-smb-0.1.0 vs lib/packetgen/plugin/smb/trans.rb in packetgen-plugin-smb-0.2.0

- old
+ new

@@ -1,7 +1,7 @@ # This file is part of PacketGen -# See https://github.com/sdaubert/packetgen for more informations +# See https://github.com/sdaubert/packetgen-plugin-smb for more informations # Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net> # This program is published under MIT license. # frozen_string_literal: true @@ -10,11 +10,10 @@ # Transaction Request. # # See also {Blocks}, as {TransRequest} is a specialization of {Blocks#words} # and {Blocks#bytes}. # @author Sylvain Daubert - # @since 0.1.0 class TransRequest < PacketGen::Header::Base # @!attribute word_count # The size, in 2-byte words, of the SMB command parameters. It should # be +14 + setup_count+. # @return [Integer] @@ -91,17 +90,18 @@ define_field :setup, PacketGen::Types::ArrayOfInt16le, builder: ->(h, t) { t.new(counter: h[:setup_count]) } # @!attribute byte_count # @return [Integer] define_field :byte_count, PacketGen::Types::Int16le # @!attribute padname - # 8-bit optional padding to align {#name} on a 2-byte boundary. + # 8-bit optional padding to align {#name} on a 2-byte boundary. Only present + # if {SMB#flags2_unicode?} is +true+. # @return [Integer] - define_field :padname, PacketGen::Types::Int8 + define_field :padname, PacketGen::Types::Int8, optional: ->(h) { h.packet && h.packet.smb.flags2_unicode? } # @!attribute name # Pathname of the mailslot or named pipe. # @return [String] - define_field :name, SMB::String + define_field :name, SMB::String, builder: ->(h, t) { t.new(unicode: !h.packet || h.packet.smb.flags2_unicode?) } # @!attribute pad1 # Padding to align {#body} on 4-byte boundary. # @return [String] define_field :pad1, PacketGen::Types::String, default: "\0" * 4, builder: ->(h, t) { t.new(length_from: -> { h.data_offset - SMB.new.sz - (h.offset_of(:name) + h[:name].sz) }) } @@ -117,10 +117,9 @@ # Transaction Response. # # See also {Blocks}, as {TransResponse} is a specialization of {Blocks#words} # and {Blocks#bytes}. # @author Sylvain Daubert - # @since 0.1.0 class TransResponse < PacketGen::Header::Base # @!attribute word_count # The size, in 2-byte words, of the SMB command parameters. It should # be +14 + setup_count+. # @return [Integer]