Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "structs"

This module implements parsing / formatting routines for Netlink and Generic Netlink structures.

Important: These structures use the host endianness. This module will serialize messages differently depending on that.

Index

Type aliases

GetArrayOptions

GetArrayOptions: { zero?: undefined | false | true }

Type declaration

  • Optional zero?: undefined | false | true

StreamData

StreamData: Uint8Array | Uint8Array[] | ((out: AttrStream) => any)

Object allowing efficient construction of an attribute stream.

Variables

Const GENL_HEADER_LENGTH

GENL_HEADER_LENGTH: 4 = 4

Length of generic netlink headers

Const HEADER_LENGTH

HEADER_LENGTH: 16 = 16

Length of netlink headers

Const readF32

readF32: readFloatLE = isLE ? __BP.readFloatLE : __BP.readFloatBE

Const readF64

readF64: readDoubleLE = isLE ? __BP.readDoubleLE : __BP.readDoubleBE

Const readS16

readS16: readInt16LE = isLE ? __BP.readInt16LE : __BP.readInt16BE

Const readS32

readS32: readInt32LE = isLE ? __BP.readInt32LE : __BP.readInt32BE

Const readS64

readS64: readBigInt64LE = isLE ? __BP.readBigInt64LE : __BP.readBigInt64BE

Const readS8

readS8: readInt8 = __BP.readInt8

Const readU16

readU16: readUInt16LE = isLE ? __BP.readUInt16LE : __BP.readUInt16BE

Const readU16be

readU16be: readUInt16BE = __BP.readUInt16BE

Const readU32

readU32: readUInt32LE = isLE ? __BP.readUInt32LE : __BP.readUInt32BE

Const readU32be

readU32be: readUInt32BE = __BP.readUInt32BE

Const readU64

readU64: readBigUInt64LE = isLE ? __BP.readBigUInt64LE : __BP.readBigUInt64BE

Const readU8

readU8: readUInt8 = __BP.readUInt8

Const writeF32

writeF32: writeFloatLE = isLE ? __BP.writeFloatLE : __BP.writeFloatBE

Const writeF64

writeF64: writeDoubleLE = isLE ? __BP.writeDoubleLE : __BP.writeDoubleBE

Const writeS16

writeS16: writeInt16LE = isLE ? __BP.writeInt16LE : __BP.writeInt16BE

Const writeS32

writeS32: writeInt32LE = isLE ? __BP.writeInt32LE : __BP.writeInt32BE

Const writeS64

writeS64: writeBigInt64LE = isLE ? __BP.writeBigInt64LE : __BP.writeBigInt64BE

Const writeS8

writeS8: writeInt8 = __BP.writeInt8

Const writeU16

writeU16: writeUInt16LE = isLE ? __BP.writeUInt16LE : __BP.writeUInt16BE

Const writeU16be

writeU16be: writeUInt16BE = __BP.writeUInt16BE

Const writeU32

writeU32: writeUInt32LE = isLE ? __BP.writeUInt32LE : __BP.writeUInt32BE

Const writeU32be

writeU32be: writeUInt32BE = __BP.writeUInt32BE

Const writeU64

writeU64: writeBigUInt64LE = isLE ? __BP.writeBigUInt64LE : __BP.writeBigUInt64BE

Const writeU8

writeU8: writeUInt8 = __BP.writeUInt8

Functions

Const align

  • align(x: number): number
  • Round the passed length up to align it

    Parameters

    • x: number

    Returns number

countLength

  • countLength(x: Uint8Array | Uint8Array[]): number
  • Parameters

    • x: Uint8Array | Uint8Array[]

    Returns number

Const ensureArray

  • ensureArray(x: Uint8Array | Uint8Array[]): Uint8Array[]
  • Parameters

    • x: Uint8Array | Uint8Array[]

    Returns Uint8Array[]

formatAttribute

formatGenlHeader

formatHeader

formatMessage

getArray

  • getArray<T>(x: Buffer, fn: (item: Buffer) => T, options?: GetArrayOptions): T[]
  • Type parameters

    • T

    Parameters

    • x: Buffer
    • fn: (item: Buffer) => T
        • (item: Buffer): T
        • Parameters

          • item: Buffer

          Returns T

    • Optional options: GetArrayOptions

    Returns T[]

getBool

  • getBool(x: Buffer): boolean

getEnum

  • getEnum<R>(mapping: {}, x: number): number | keyof R
  • Type parameters

    • R

    Parameters

    • mapping: {}
      • [key: number]: string
    • x: number

    Returns number | keyof R

Const getF32

  • getF32(x: Buffer): number

Const getF64

  • getF64(x: Buffer): number

Const getFlag

  • getFlag(x: Buffer): true

getMap

  • getMap<T>(x: Buffer, fn: (item: Buffer) => T): Map<number, T>
  • Type parameters

    • T

    Parameters

    • x: Buffer
    • fn: (item: Buffer) => T
        • (item: Buffer): T
        • Parameters

          • item: Buffer

          Returns T

    Returns Map<number, T>

getObject

  • getObject<T>(x: Buffer, fns: {}): T
  • Type parameters

    Parameters

    • x: Buffer
    • fns: {}
      • [key: number]: (data: Buffer, obj: T) => any
          • (data: Buffer, obj: T): any
          • Parameters

            • data: Buffer
            • obj: T

            Returns any

    Returns T

Const getPadding

  • getPadding(x: number): Buffer
  • Like padding but returns a zero-filled buffer of that length

    Parameters

    • x: number

    Returns Buffer

Const getS16

  • getS16(x: Buffer): number

Const getS32

  • getS32(x: Buffer): number

Const getS64

  • getS64(x: Buffer): bigint

Const getS8

  • getS8(x: Buffer): number

getString

  • getString(x: Buffer, options?: undefined | { encoding?: BufferEncoding; maxLength: number }): string
  • Parameters

    • x: Buffer
    • Optional options: undefined | { encoding?: BufferEncoding; maxLength: number }

    Returns string

Const getU16

  • getU16(x: Buffer): number

Const getU16be

  • getU16be(x: Buffer): number

Const getU32

  • getU32(x: Buffer): number

Const getU32be

  • getU32be(x: Buffer): number

Const getU64

  • getU64(x: Buffer): bigint

Const getU8

  • getU8(x: Buffer): number

pad

  • pad(x: Uint8Array[]): Uint8Array[]
  • Append necessary padding to data. THIS MODIFIES THE ORIGINAL ARRAY

    Parameters

    • x: Uint8Array[]

    Returns Uint8Array[]

Const padding

  • padding(x: number): number
  • Get the amount of padding (in bytes) to add after length

    Parameters

    • x: number

    Returns number

parseAttribute

parseAttributes

parseError

  • parseError(r: Buffer, flags: number): NetlinkErrorMessage
  • Parameters

    • r: Buffer
    • flags: number

    Returns NetlinkErrorMessage

parseGenlHeader

  • Parses a Generic Netlink header

    throws

    If x contains less than GENL_HEADER_LENGTH

    Parameters

    • r: Buffer

    Returns ParseResult<GenericNetlinkHeader>

    Parsed header

parseHeader

  • Parses a Netlink header

    throws

    If x contains less than HEADER_LENGTH

    Parameters

    • r: Buffer

    Returns ParseResult<NetlinkHeader>

    Parsed header

parseMessage

parseMessages

  • Calls parseMessage repeatedly, ignoring padding between messages, until there's no data left (other than padding).

    retrns

    Array of parsed messages

    Parameters

    • r: Buffer

    Returns NetlinkMessage[]

putArray

Const putBool

  • putBool(x: boolean): Buffer

putEnum

  • putEnum<R>(mapping: {}, x: number | keyof R): number
  • Type parameters

    • R

    Parameters

    • mapping: {}
    • x: number | keyof R

    Returns number

Const putF32

  • putF32(x: number): Buffer

Const putF64

  • putF64(x: number): Buffer

Const putFlag

  • putFlag(x: true): Buffer

putMap

putObject

Const putS16

  • putS16(x: number): Buffer

Const putS32

  • putS32(x: number): Buffer

Const putS64

  • putS64(x: bigint): Buffer

Const putS8

  • putS8(x: number): Buffer

putString

  • putString(x: string, options?: undefined | { encoding?: BufferEncoding; maxLength: number }): Buffer
  • Parameters

    • x: string
    • Optional options: undefined | { encoding?: BufferEncoding; maxLength: number }

    Returns Buffer

Const putU16

  • putU16(x: number): Buffer

Const putU16be

  • putU16be(x: number): Buffer

Const putU32

  • putU32(x: number): Buffer

Const putU32be

  • putU32be(x: number): Buffer

Const putU64

  • putU64(x: bigint): Buffer

Const putU8

  • putU8(x: number): Buffer

Generated using TypeDoc