header
import "github.com/TheManticoreProject/Manticore/network/llmnr/message/header"
Index
Constants
Size of LLMNR message header in bytes
const HeaderSize = 12
type Flags
type Flags uint16
LLMNR Header Flags
const (
FlagQR Flags = 1 << 15 // Query/Response flag
FlagOP Flags = 1 << 14 // Operation code
FlagC Flags = 1 << 13 // Conflict flag
FlagTC Flags = 1 << 12 // Truncation flag
FlagT Flags = 1 << 11 // Tentative flag
)
func (Flags) IsConflict
func (f Flags) IsConflict() bool
IsConflict returns true if the conflict flag is set.
func (Flags) IsQuery
func (f Flags) IsQuery() bool
IsQuery returns true if the flags are set for a query.
func (Flags) IsResponse
func (f Flags) IsResponse() bool
IsResponse returns true if the flags are set for a response.
func (Flags) IsTentative
func (f Flags) IsTentative() bool
IsTentative returns true if the tentative flag is set.
func (Flags) IsTruncation
func (f Flags) IsTruncation() bool
IsTruncation returns true if the truncation flag is set.
func (*Flags) Marshal
func (f *Flags) Marshal() ([]byte, error)
Marshal encodes the Flags into a 2-byte big-endian representation.
func (Flags) String
func (f Flags) String() string
String returns a string representation of the flags.
The QR label is emitted only when the QR bit is set (response), matching the convention used in DNS trace output. Query messages (QR=0) produce no QR label. OPCODE is a separate 4-bit field and is not derived from the QR bit.
func (*Flags) Unmarshal
func (f *Flags) Unmarshal(data []byte) (int, error)
Unmarshal decodes a 2-byte big-endian representation into the Flags receiver. It returns an error if the input slice is not exactly 2 bytes.
type Header
Header represents the LLMNR message header.
The header contains essential information about the LLMNR message, including the message ID, flags, and counts of various sections such as questions, answers, authority records, and additional records.
Fields:
- Identifier: A 16-bit identifier assigned by the program that generates any kind of query. This identifier is copied to the corresponding reply and can be used by the requester to match up replies to outstanding queries.
- Flags: A 16-bit field containing various flags that control the message flow and interpretation. These flags include the Query/Response flag (QR), Operation code (OP), Conflict flag (C), Truncation flag (TC), and Tentative flag (T).
- QDCount: An unsigned 16-bit integer specifying the number of entries in the question section of the message.
- ANCount: An unsigned 16-bit integer specifying the number of resource records in the answer section of the message.
- NSCount: An unsigned 16-bit integer specifying the number of name server resource records in the authority records section of the message.
- ARCount: An unsigned 16-bit integer specifying the number of resource records in the additional records section of the message.
Usage example:
header := Header{
Identifier: 12345,
Flags: FlagQR,
QDCount: 1,
ANCount: 0,
NSCount: 0,
ARCount: 0,
}
type Header struct {
Identifier uint16 `json:"identifier"`
Flags Flags `json:"flags"`
QDCount uint16 `json:"qd_count"` // Question count
ANCount uint16 `json:"an_count"` // Answer count
NSCount uint16 `json:"ns_count"` // Authority count
ARCount uint16 `json:"ar_count"` // Additional count
}
func (*Header) Describe
func (h *Header) Describe(indent int)
Describe prints a detailed description of the Header struct. Parameters: - indent: An integer value specifying the indentation level for the output.
func (*Header) Marshal
func (h *Header) Marshal() ([]byte, error)
Marshal encodes the Header into a 12-byte big-endian representation.
func (*Header) Unmarshal
func (h *Header) Unmarshal(data []byte) (int, error)
Unmarshal decodes a 12-byte big-endian representation into the Header receiver. It returns an error if the input slice is not exactly 12 bytes.