class RubySMB::Nbss::NetbiosName
Representation of the NetBIOS Name as defined in [4.1. NAME FORMAT](tools.ietf.org/html/rfc1002#section-4.1) and [14. REPRESENTATION OF NETBIOS NAMES](tools.ietf.org/html/rfc1001#section-14) and [Domain name representation and compression](tools.ietf.org/html/rfc883#page-31)
Public Instance Methods
get()
click to toggle source
# File lib/ruby_smb/nbss/netbios_name.rb, line 37 def get nb_name_decode(label) end
nb_name_decode(encoded_name)
click to toggle source
# File lib/ruby_smb/nbss/netbios_name.rb, line 27 def nb_name_decode(encoded_name) name = encoded_name.scan(/../).map do |char_pair| first_half = char_pair[0]; second_half = char_pair[1] char = ((first_half.ord - 'A'.ord) << 4) + (second_half.ord - 'A'.ord) char.chr end name.join end
nb_name_encode(name)
click to toggle source
# File lib/ruby_smb/nbss/netbios_name.rb, line 16 def nb_name_encode(name) encoded_name = '' name.each_byte do |char| first_half = (char >> 4) + 'A'.ord second_half = (char & 0xF) + 'A'.ord encoded_name << first_half.chr encoded_name << second_half.chr end encoded_name end
set(label)
click to toggle source
# File lib/ruby_smb/nbss/netbios_name.rb, line 41 def set(label) self.label = nb_name_encode(label) self.label_length = self.label.length end