Skip to content

Commit

Permalink
add SMBHeader struct
Browse files Browse the repository at this point in the history
adds the basic Header for all SMB1 packets

MSP-12907
  • Loading branch information
David Maloney authored and David Maloney committed Jul 29, 2015
1 parent 7800be4 commit bf6301d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/ruby_smb/smb1/packet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Smb1
# This module holds the namespace for all SMB1 packets and related structures.
module Packet
autoload :SmbParameterBlock, 'ruby_smb/smb1/packet/smb_parameter_block'
autoload :SmbHeader, 'ruby_smb/smb1/packet/smb_header'
end
end
end
24 changes: 24 additions & 0 deletions lib/ruby_smb/smb1/packet/smb_header.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module RubySMB
module Smb1
module Packet

# This class represents the Header of an SMB1 Packet.
# [2.2.3.1 SMB Header Extensions](https://msdn.microsoft.com/en-us/library/cc246254.aspx)
class SmbHeader < BitStruct
unsigned :protocol, 32
unsigned :command, 8
unsigned :nt_status, 32
unsigned :flags, 8
unsigned :flags2, 16
unsigned :pid_high, 16
unsigned :security_features, 64
unsigned :reserved, 16
unsigned :tid, 16
unsigned :pid_low, 16
unsigned :uid, 16
unsigned :mid, 16

end
end
end
end
19 changes: 19 additions & 0 deletions spec/lib/ruby_smb/smb1/packet/smb_header_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'spec_helper'

RSpec.describe RubySMB::Smb1::Packet::SmbHeader do

subject(:header) { described_class.new }

it { is_expected.to respond_to :protocol }
it { is_expected.to respond_to :command }
it { is_expected.to respond_to :nt_status }
it { is_expected.to respond_to :flags }
it { is_expected.to respond_to :flags2 }
it { is_expected.to respond_to :pid_high }
it { is_expected.to respond_to :security_features }
it { is_expected.to respond_to :reserved }
it { is_expected.to respond_to :tid }
it { is_expected.to respond_to :pid_low }
it { is_expected.to respond_to :uid }
it { is_expected.to respond_to :mid }
end

0 comments on commit bf6301d

Please sign in to comment.