Class: PacketGen::Plugin::NetBIOS::Datagram
- Inherits:
-
Header::Base
- Object
- Header::Base
- PacketGen::Plugin::NetBIOS::Datagram
- Defined in:
- lib/packetgen/plugin/netbios/datagram.rb
Overview
NetBIOS Datagram Service messages.
Constant Summary collapse
- UDP_PORT =
Port number for NetBIOS Session Service over TCP
138
- TYPES =
Datagram packet types
{ 'direct_unique' => 0x10, 'direct_group' => 0x11, 'broadcast' => 0x12, 'error' => 0x13, 'query_request' => 0x14, 'positive_query_resp' => 0x15, 'negative_query_resp' => 0x16, }.freeze
Instance Attribute Summary collapse
-
#:rsv(: rsv) ⇒ Integer
4-bit rsv field.
-
#:snt(: snt) ⇒ Integer
2-bit SNT (Source end-Node Type) field from #flags.
-
#body ⇒ String
User data.
-
#dgm_id ⇒ Integer
16-bit next transaction ID for datagrams.
-
#dgm_length ⇒ Object
Length of data + second level of encoded names.
-
#dst_name ⇒ Object
NetBIOS destination name.
-
#error_code ⇒ Integer
Error code.
-
#f ⇒ Boolean
First packet flag.
-
#flags ⇒ Integer
8-bit flags.
-
#m ⇒ Boolean
More flag.
-
#packet_offset ⇒ Integer
Not present in error datagram.
-
#src_ip ⇒ Object
Source IP address.
-
#src_name ⇒ Object
NetBIOS source name.
-
#src_port ⇒ Object
Source port.
-
#type ⇒ Integer
8-bit session packet type.
Class Method Summary collapse
-
.protocol_name ⇒ String
Give protocol name.
Instance Method Summary collapse
-
#calc_length ⇒ Integer
Compute and set #dgm_length field.
Instance Attribute Details
#:rsv(: rsv) ⇒ Integer
4-bit rsv field. 4 upper bits of #flags
94 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 94 define_bit_fields_on :flags, :rsv, 4, :snt, 2, :f, :m |
#:snt(: snt) ⇒ Integer
2-bit SNT (Source end-Node Type) field from #flags.
94 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 94 define_bit_fields_on :flags, :rsv, 4, :snt, 2, :f, :m |
#body ⇒ String
User data. Ony present in direct_unique, direct_group and broadcast datagrams.
78 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 78 define_field :body, PacketGen::Types::String, optional: ->(h) { (h.type >= 0x10) && (h.type <= 0x12) } |
#dgm_id ⇒ Integer
16-bit next transaction ID for datagrams
46 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 46 define_field :dgm_id, PacketGen::Types::Int16 |
#dgm_length ⇒ Object
Length of data + second level of encoded names. Not present in error datagram.
58 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 58 define_field :dgm_length, PacketGen::Types::Int16, optional: ->(h) { h.type != 0x13 } |
#dst_name ⇒ Object
NetBIOS destination name. Present in all but error datagrams.
74 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 74 define_field :dst_name, Name, default: '', optional: ->(h) { h.type != 0x13 } |
#error_code ⇒ Integer
Error code. Only present in error datagrams.
66 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 66 define_field :error_code, PacketGen::Types::Int16, optional: ->(h) { h.type == 0x13 } |
#f ⇒ Boolean
First packet flag. If set then this is first (and possibly only) fragment of NetBIOS datagram.
94 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 94 define_bit_fields_on :flags, :rsv, 4, :snt, 2, :f, :m |
#flags ⇒ Integer
8-bit flags
42 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 42 define_field :flags, PacketGen::Types::Int8 |
#m ⇒ Boolean
More flag. If set then more NetBIOS datagram fragments follow.
94 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 94 define_bit_fields_on :flags, :rsv, 4, :snt, 2, :f, :m |
#packet_offset ⇒ Integer
Not present in error datagram.
62 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 62 define_field :packet_offset, PacketGen::Types::Int16, optional: ->(h) { h.type != 0x13 } |
#src_ip ⇒ Object
Source IP address
50 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 50 define_field :src_ip, PacketGen::Header::IP::Addr |
#src_name ⇒ Object
NetBIOS source name. Only present in direct_unique, direct_group and broadcast datagrams.
70 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 70 define_field :src_name, Name, default: '', optional: ->(h) { (h.type >= 0x10) && (h.type <= 0x12) } |
#src_port ⇒ Object
Source port
54 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 54 define_field :src_port, PacketGen::Types::Int16 |
Class Method Details
.protocol_name ⇒ String
Give protocol name
17 18 19 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 17 def self.protocol_name 'NetBIOS::Datagram' end |
Instance Method Details
#calc_length ⇒ Integer
Compute and set #dgm_length field
98 99 100 101 102 103 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 98 def calc_length length = self[:body].sz length += self[:src_name].sz if present?(:src_name) length += self[:dst_name].sz if present?(:dst_name) self.dgm_length = length end |