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
56 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 56 define_bit_attr :flags, rsv: 4, snt: 2, f: 1, m: 1 |
#:snt(: snt) ⇒ Integer
2-bit SNT (Source end-Node Type) field from #flags.
56 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 56 define_bit_attr :flags, rsv: 4, snt: 2, f: 1, m: 1 |
#body ⇒ String
User data. Ony present in direct_unique, direct_group and broadcast datagrams.
92 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 92 define_attr :body, BinStruct::String, optional: ->(h) { (h.type >= 0x10) && (h.type <= 0x12) } |
#dgm_id ⇒ Integer
16-bit next transaction ID for datagrams
60 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 60 define_attr :dgm_id, BinStruct::Int16 |
#dgm_length ⇒ Object
Length of data + second level of encoded names. Not present in error datagram.
72 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 72 define_attr :dgm_length, BinStruct::Int16, optional: ->(h) { h.type != 0x13 } |
#dst_name ⇒ Object
NetBIOS destination name. Present in all but error datagrams.
88 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 88 define_attr :dst_name, Name, default: '', optional: ->(h) { h.type != 0x13 } |
#error_code ⇒ Integer
Error code. Only present in error datagrams.
80 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 80 define_attr :error_code, BinStruct::Int16, optional: ->(h) { h.type == 0x13 } |
#f ⇒ Boolean
First packet flag. If set then this is first (and possibly only) fragment of NetBIOS datagram.
56 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 56 define_bit_attr :flags, rsv: 4, snt: 2, f: 1, m: 1 |
#flags ⇒ Integer
8-bit flags
56 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 56 define_bit_attr :flags, rsv: 4, snt: 2, f: 1, m: 1 |
#m ⇒ Boolean
More flag. If set then more NetBIOS datagram fragments follow.
56 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 56 define_bit_attr :flags, rsv: 4, snt: 2, f: 1, m: 1 |
#packet_offset ⇒ Integer
Not present in error datagram.
76 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 76 define_attr :packet_offset, BinStruct::Int16, optional: ->(h) { h.type != 0x13 } |
#src_ip ⇒ Object
Source IP address
64 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 64 define_attr :src_ip, PacketGen::Header::IP::Addr |
#src_name ⇒ Object
NetBIOS source name. Only present in direct_unique, direct_group and broadcast datagrams.
84 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 84 define_attr :src_name, Name, default: '', optional: ->(h) { (h.type >= 0x10) && (h.type <= 0x12) } |
#src_port ⇒ Object
Source port
68 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 68 define_attr :src_port, BinStruct::Int16 |
#type ⇒ Integer
8-bit session packet type
38 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 38 define_attr :type, BinStruct::Int8Enum, enum: TYPES |
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
96 97 98 99 100 101 |
# File 'lib/packetgen/plugin/netbios/datagram.rb', line 96 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 |