diff --git a/.travis.yml b/.travis.yml index 993556fef7..1aea01aa1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -58,7 +58,7 @@ matrix: deploy: provider: releases api_key: - secure: "EbM5FzcjE5waVpl0fl3J/rorE3UbhbX+gyhbjIv35GqHU5Ifwo5oMo2xno8G8y83PTzVFvpF9n/AWxRtKUEB2j5gtK1uljBheeBHmXIs6G7LdBZPq2bexPRpO2N7GgS1huWd8Z8YSwsoxC5/OR/hwIU1KgEY/ol2q15XiZLsl4c=" + secure: "kElMZA2rpuSswHZuQuFZYdOllg5b+cOcid+Ac8RZJlqM+EPi+5cDuNWGmqxNka9lvLwwB+Mq37+t9J1PSHuTf/WNcDeI82h//Prll6jP5aHuxrIZA6UTeqTAzhmVGHbcjorvROp5O2MeyJMHtyi3gi9XOf8OlfSLpO4pM37Ad1w=" file: haskell/sbp_linux_tools.tar.gz skip_cleanup: true on: diff --git a/c/include/libsbp/linux.h b/c/include/libsbp/linux.h new file mode 100644 index 0000000000..fb018f9ab7 --- /dev/null +++ b/c/include/libsbp/linux.h @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2015-2018 Swift Navigation Inc. + * Contact: Swift Navigation + * + * This source is subject to the license found in the file 'LICENSE' which must + * be be distributed together with this source. All other rights reserved. + * + * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, + * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + */ + +/***************************************************************************** + * Automatically generated from yaml/swiftnav/sbp/linux.yaml + * with generate.py. Please do not hand edit! + *****************************************************************************/ + +/** \defgroup linux Linux + * + * * Linux state monitoring. + * \{ */ + +#ifndef LIBSBP_LINUX_MESSAGES_H +#define LIBSBP_LINUX_MESSAGES_H + +#include "common.h" + +SBP_PACK_START + + +/** List CPU state on the system + * + * This message indicates the process state of the top 10 heaviest + * consumers of CPU on the system. + */ +#define SBP_MSG_LINUX_CPU_STATE 0x7F00 +typedef struct SBP_ATTR_PACKED { + u8 index; /**< sequence of this status message, values from 0-9 */ + u16 pid; /**< the PID of the process */ + u8 pcpu; /**< percent of cpu used, expressed as a fraction of 256 */ + char tname[15]; /**< fixed length string representing the thread name */ + char cmdline[0]; /**< the command line (as much as it fits in the remaining packet) */ +} msg_linux_cpu_state_t; + + +/** List CPU state on the system + * + * This message indicates the process state of the top 10 heaviest + * consumers of memory on the system. + */ +#define SBP_MSG_LINUX_MEM_STATE 0x7F01 +typedef struct SBP_ATTR_PACKED { + u8 index; /**< sequence of this status message, values from 0-9 */ + u16 pid; /**< the PID of the process */ + u8 pmem; /**< percent of memory used, expressed as a fraction of 256 */ + char tname[15]; /**< fixed length string representing the thread name */ + char cmdline[0]; /**< the command line (as much as it fits in the remaining packet) */ +} msg_linux_mem_state_t; + + +/** CPU, Memory and Process Starts/Stops + * + * This presents a summary of CPU and memory utilization. + */ +#define SBP_MSG_LINUX_SYS_STATE 0x7F02 +typedef struct SBP_ATTR_PACKED { + u16 mem_total; /**< total system memory */ + u8 pcpu; /**< percent of total cpu currently utilized */ + u8 pmem; /**< percent of total memory currently utilized */ + u16 procs_starting; /**< number of processes that started during collection phase */ + u16 procs_stopping; /**< number of processes that stopped during collection phase */ + u16 pid_count; /**< the count of processes on the system */ +} msg_linux_sys_state_t; + + +/** A list of processes with high socket counts + * + * Top 10 list of processes with high socket counts. + */ +#define SBP_MSG_LINUX_PROCESS_SOCKET_COUNTS 0x7F03 +typedef struct SBP_ATTR_PACKED { + u8 index; /**< sequence of this status message, values from 0-9 */ + u16 pid; /**< the PID of the process in question */ + u16 socket_count; /**< the number of sockets the process is using */ + u16 socket_types; /**< A bitfield indicating the socket types used: + 0x1 (tcp), 0x2 (udp), 0x4 (unix stream), 0x8 (unix dgram), 0x10 (netlink), + and 0x8000 (unknown) + */ + u16 socket_states; /**< A bitfield indicating the socket states: + 0x1 (established), 0x2 (syn-sent), 0x4 (syn-recv), 0x8 (fin-wait-1), + 0x10 (fin-wait-2), 0x20 (time-wait), 0x40 (closed), 0x80 (close-wait), + 0x100 (last-ack), 0x200 (listen), 0x400 (closing), 0x800 (unconnected), + and 0x8000 (unknown) + */ + char cmdline[0]; /**< the command line of the process in question */ +} msg_linux_process_socket_counts_t; + + +/** A list of processes with deep socket queues + * + * Top 10 list of sockets with deep queues. + */ +#define SBP_MSG_LINUX_PROCESS_SOCKET_QUEUES 0x7F04 +typedef struct SBP_ATTR_PACKED { + u8 index; /**< sequence of this status message, values from 0-9 */ + u16 pid; /**< the PID of the process in question */ + u16 recv_queued; /**< the total amount of receive data queued for this process */ + u16 send_queued; /**< the total amount of send data queued for this process */ + u16 socket_types; /**< A bitfield indicating the socket types used: + 0x1 (tcp), 0x2 (udp), 0x4 (unix stream), 0x8 (unix dgram), 0x10 (netlink), + and 0x8000 (unknown) + */ + u16 socket_states; /**< A bitfield indicating the socket states: + 0x1 (established), 0x2 (syn-sent), 0x4 (syn-recv), 0x8 (fin-wait-1), + 0x10 (fin-wait-2), 0x20 (time-wait), 0x40 (closed), 0x80 (close-wait), + 0x100 (last-ack), 0x200 (listen), 0x400 (closing), 0x800 (unconnected), + and 0x8000 (unknown) + */ + char address_of_largest[64]; /**< Address of the largest queue, remote or local depending on the directionality +of the connection. + */ + char cmdline[0]; /**< the command line of the process in question */ +} msg_linux_process_socket_queues_t; + + +/** Summary of socket usage across the system + * + * Summaries the socket usage across the system. + */ +#define SBP_MSG_LINUX_SOCKET_USAGE 0x7F05 +typedef struct SBP_ATTR_PACKED { + u32 avg_queue_depth; /**< average socket queue depths across all sockets on the system */ + u32 max_queue_depth; /**< the max queue depth seen within the reporting period */ + u16 socket_state_counts[16]; /**< A count for each socket type reported in the `socket_types_reported` field, +the first entry corresponds to the first enabled bit in `types_reported`. + */ + u16 socket_type_counts[16]; /**< A count for each socket type reported in the `socket_types_reported` field, +the first entry corresponds to the first enabled bit in `types_reported`. + */ +} msg_linux_socket_usage_t; + + +/** \} */ + +SBP_PACK_END + +#endif /* LIBSBP_LINUX_MESSAGES_H */ \ No newline at end of file diff --git a/c/src/CMakeLists.txt b/c/src/CMakeLists.txt index bf922eae04..9ff1c2f35f 100644 --- a/c/src/CMakeLists.txt +++ b/c/src/CMakeLists.txt @@ -8,6 +8,7 @@ set(libsbp_HEADERS "${PROJECT_SOURCE_DIR}/include/libsbp/flash.h" "${PROJECT_SOURCE_DIR}/include/libsbp/gnss.h" "${PROJECT_SOURCE_DIR}/include/libsbp/imu.h" + "${PROJECT_SOURCE_DIR}/include/libsbp/linux.h" "${PROJECT_SOURCE_DIR}/include/libsbp/logging.h" "${PROJECT_SOURCE_DIR}/include/libsbp/mag.h" "${PROJECT_SOURCE_DIR}/include/libsbp/navigation.h" diff --git a/docs/sbp.pdf b/docs/sbp.pdf index c8b64954d7..7cb279663b 100644 Binary files a/docs/sbp.pdf and b/docs/sbp.pdf differ diff --git a/generator/sbpg/targets/javascript.py b/generator/sbpg/targets/javascript.py index 0b6fd0f2eb..1990dfb708 100644 --- a/generator/sbpg/targets/javascript.py +++ b/generator/sbpg/targets/javascript.py @@ -140,7 +140,10 @@ def construct_format(f, type_map=CONSTRUCT_CODE): else: field_type = "'%s'" % field_type if size is not None: - return "array('%s', { length: %d, type: %s })" % (f.identifier, size.value, field_type) + d = { "'uint16'" : "'uint16le'", "'uint32'" : "'uint32le'", "'uint64'" : "'uint16le'", + "'int16'" : "'int16le'", "'int32'" : "'int32le'", "'int64'" : "'int16le'" } + field_type_arr = d.get(field_type, field_type) + return "array('%s', { length: %d, type: %s })" % (f.identifier, size.value, field_type_arr) elif f.options.get('size_fn') is not None: return "array('%s', { type: %s, length: '%s' })" % (f_.identifier, field_type, size_fn.value) else: diff --git a/haskell/sbp.cabal b/haskell/sbp.cabal index c5c61ce19a..d2e5cca1dd 100644 --- a/haskell/sbp.cabal +++ b/haskell/sbp.cabal @@ -32,6 +32,7 @@ library , SwiftNav.SBP.Flash , SwiftNav.SBP.Gnss , SwiftNav.SBP.Imu + , SwiftNav.SBP.Linux , SwiftNav.SBP.Logging , SwiftNav.SBP.Mag , SwiftNav.SBP.Navigation @@ -136,4 +137,4 @@ test-suite test , tasty , tasty-hunit ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall - default-language: Haskell2010 \ No newline at end of file + default-language: Haskell2010 diff --git a/haskell/sbp.cabal.m4 b/haskell/sbp.cabal.m4 index c3b1f7e533..b1eb401e3a 100644 --- a/haskell/sbp.cabal.m4 +++ b/haskell/sbp.cabal.m4 @@ -1,5 +1,5 @@ name: sbp -version: 2.4.1 +version: 2.4.2 synopsis: SwiftNav's SBP Library homepage: https://github.com/swift-nav/libsbp license: LGPL-3 @@ -32,6 +32,7 @@ library , SwiftNav.SBP.Flash , SwiftNav.SBP.Gnss , SwiftNav.SBP.Imu + , SwiftNav.SBP.Linux , SwiftNav.SBP.Logging , SwiftNav.SBP.Mag , SwiftNav.SBP.Navigation @@ -136,4 +137,4 @@ test-suite test , tasty , tasty-hunit ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall - default-language: Haskell2010 \ No newline at end of file + default-language: Haskell2010 diff --git a/haskell/shell.nix b/haskell/shell.nix new file mode 100644 index 0000000000..4787be935b --- /dev/null +++ b/haskell/shell.nix @@ -0,0 +1,12 @@ +with import {}; + +stdenv.mkDerivation rec { + name = "libsbp"; + env = buildEnv { name = name; paths = buildInputs; }; + buildInputs = [ + jq + libiconv + stack + zlib.dev + ]; +} diff --git a/haskell/src/SwiftNav/SBP.hs b/haskell/src/SwiftNav/SBP.hs index 04d79a4cd7..f4d4e77092 100644 --- a/haskell/src/SwiftNav/SBP.hs +++ b/haskell/src/SwiftNav/SBP.hs @@ -21,6 +21,7 @@ import SwiftNav.SBP.FileIo as Exports import SwiftNav.SBP.Flash as Exports import SwiftNav.SBP.Gnss as Exports import SwiftNav.SBP.Imu as Exports +import SwiftNav.SBP.Linux as Exports import SwiftNav.SBP.Logging as Exports import SwiftNav.SBP.Mag as Exports import SwiftNav.SBP.Navigation as Exports diff --git a/haskell/src/SwiftNav/SBP/Linux.hs b/haskell/src/SwiftNav/SBP/Linux.hs new file mode 100644 index 0000000000..7b69c43d21 --- /dev/null +++ b/haskell/src/SwiftNav/SBP/Linux.hs @@ -0,0 +1,301 @@ +{-# OPTIONS_GHC -fno-warn-unused-imports #-} +{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE RecordWildCards #-} + +-- | +-- Module: SwiftNav.SBP.Linux +-- Copyright: Copyright (C) 2015-2018 Swift Navigation, Inc. +-- License: LGPL-3 +-- Maintainer: Swift Navigation +-- Stability: experimental +-- Portability: portable +-- +-- Linux state monitoring. + +module SwiftNav.SBP.Linux + ( module SwiftNav.SBP.Linux + ) where + +import BasicPrelude +import Control.Lens +import Control.Monad.Loops +import Data.Binary +import Data.Binary.Get +import Data.Binary.IEEE754 +import Data.Binary.Put +import Data.ByteString.Lazy hiding (ByteString) +import Data.Int +import Data.Word +import SwiftNav.SBP.TH +import SwiftNav.SBP.Types + +{-# ANN module ("HLint: ignore Use camelCase"::String) #-} +{-# ANN module ("HLint: ignore Redundant do"::String) #-} +{-# ANN module ("HLint: ignore Use newtype instead of data"::String) #-} + + +msgLinuxCpuState :: Word16 +msgLinuxCpuState = 0x7F00 + +-- | SBP class for message MSG_LINUX_CPU_STATE (0x7F00). +-- +-- This message indicates the process state of the top 10 heaviest consumers of +-- CPU on the system. +data MsgLinuxCpuState = MsgLinuxCpuState + { _msgLinuxCpuState_index :: !Word8 + -- ^ sequence of this status message, values from 0-9 + , _msgLinuxCpuState_pid :: !Word16 + -- ^ the PID of the process + , _msgLinuxCpuState_pcpu :: !Word8 + -- ^ percent of cpu used, expressed as a fraction of 256 + , _msgLinuxCpuState_tname :: !Text + -- ^ fixed length string representing the thread name + , _msgLinuxCpuState_cmdline :: !Text + -- ^ the command line (as much as it fits in the remaining packet) + } deriving ( Show, Read, Eq ) + +instance Binary MsgLinuxCpuState where + get = do + _msgLinuxCpuState_index <- getWord8 + _msgLinuxCpuState_pid <- getWord16le + _msgLinuxCpuState_pcpu <- getWord8 + _msgLinuxCpuState_tname <- decodeUtf8 <$> getByteString 15 + _msgLinuxCpuState_cmdline <- decodeUtf8 . toStrict <$> getRemainingLazyByteString + pure MsgLinuxCpuState {..} + + put MsgLinuxCpuState {..} = do + putWord8 _msgLinuxCpuState_index + putWord16le _msgLinuxCpuState_pid + putWord8 _msgLinuxCpuState_pcpu + putByteString $ encodeUtf8 _msgLinuxCpuState_tname + putByteString $ encodeUtf8 _msgLinuxCpuState_cmdline + +$(makeSBP 'msgLinuxCpuState ''MsgLinuxCpuState) +$(makeJSON "_msgLinuxCpuState_" ''MsgLinuxCpuState) +$(makeLenses ''MsgLinuxCpuState) + +msgLinuxMemState :: Word16 +msgLinuxMemState = 0x7F01 + +-- | SBP class for message MSG_LINUX_MEM_STATE (0x7F01). +-- +-- This message indicates the process state of the top 10 heaviest consumers of +-- memory on the system. +data MsgLinuxMemState = MsgLinuxMemState + { _msgLinuxMemState_index :: !Word8 + -- ^ sequence of this status message, values from 0-9 + , _msgLinuxMemState_pid :: !Word16 + -- ^ the PID of the process + , _msgLinuxMemState_pmem :: !Word8 + -- ^ percent of memory used, expressed as a fraction of 256 + , _msgLinuxMemState_tname :: !Text + -- ^ fixed length string representing the thread name + , _msgLinuxMemState_cmdline :: !Text + -- ^ the command line (as much as it fits in the remaining packet) + } deriving ( Show, Read, Eq ) + +instance Binary MsgLinuxMemState where + get = do + _msgLinuxMemState_index <- getWord8 + _msgLinuxMemState_pid <- getWord16le + _msgLinuxMemState_pmem <- getWord8 + _msgLinuxMemState_tname <- decodeUtf8 <$> getByteString 15 + _msgLinuxMemState_cmdline <- decodeUtf8 . toStrict <$> getRemainingLazyByteString + pure MsgLinuxMemState {..} + + put MsgLinuxMemState {..} = do + putWord8 _msgLinuxMemState_index + putWord16le _msgLinuxMemState_pid + putWord8 _msgLinuxMemState_pmem + putByteString $ encodeUtf8 _msgLinuxMemState_tname + putByteString $ encodeUtf8 _msgLinuxMemState_cmdline + +$(makeSBP 'msgLinuxMemState ''MsgLinuxMemState) +$(makeJSON "_msgLinuxMemState_" ''MsgLinuxMemState) +$(makeLenses ''MsgLinuxMemState) + +msgLinuxSysState :: Word16 +msgLinuxSysState = 0x7F02 + +-- | SBP class for message MSG_LINUX_SYS_STATE (0x7F02). +-- +-- This presents a summary of CPU and memory utilization. +data MsgLinuxSysState = MsgLinuxSysState + { _msgLinuxSysState_mem_total :: !Word16 + -- ^ total system memory + , _msgLinuxSysState_pcpu :: !Word8 + -- ^ percent of total cpu currently utilized + , _msgLinuxSysState_pmem :: !Word8 + -- ^ percent of total memory currently utilized + , _msgLinuxSysState_procs_starting :: !Word16 + -- ^ number of processes that started during collection phase + , _msgLinuxSysState_procs_stopping :: !Word16 + -- ^ number of processes that stopped during collection phase + , _msgLinuxSysState_pid_count :: !Word16 + -- ^ the count of processes on the system + } deriving ( Show, Read, Eq ) + +instance Binary MsgLinuxSysState where + get = do + _msgLinuxSysState_mem_total <- getWord16le + _msgLinuxSysState_pcpu <- getWord8 + _msgLinuxSysState_pmem <- getWord8 + _msgLinuxSysState_procs_starting <- getWord16le + _msgLinuxSysState_procs_stopping <- getWord16le + _msgLinuxSysState_pid_count <- getWord16le + pure MsgLinuxSysState {..} + + put MsgLinuxSysState {..} = do + putWord16le _msgLinuxSysState_mem_total + putWord8 _msgLinuxSysState_pcpu + putWord8 _msgLinuxSysState_pmem + putWord16le _msgLinuxSysState_procs_starting + putWord16le _msgLinuxSysState_procs_stopping + putWord16le _msgLinuxSysState_pid_count + +$(makeSBP 'msgLinuxSysState ''MsgLinuxSysState) +$(makeJSON "_msgLinuxSysState_" ''MsgLinuxSysState) +$(makeLenses ''MsgLinuxSysState) + +msgLinuxProcessSocketCounts :: Word16 +msgLinuxProcessSocketCounts = 0x7F03 + +-- | SBP class for message MSG_LINUX_PROCESS_SOCKET_COUNTS (0x7F03). +-- +-- Top 10 list of processes with high socket counts. +data MsgLinuxProcessSocketCounts = MsgLinuxProcessSocketCounts + { _msgLinuxProcessSocketCounts_index :: !Word8 + -- ^ sequence of this status message, values from 0-9 + , _msgLinuxProcessSocketCounts_pid :: !Word16 + -- ^ the PID of the process in question + , _msgLinuxProcessSocketCounts_socket_count :: !Word16 + -- ^ the number of sockets the process is using + , _msgLinuxProcessSocketCounts_socket_types :: !Word16 + -- ^ A bitfield indicating the socket types used: 0x1 (tcp), 0x2 (udp), 0x4 + -- (unix stream), 0x8 (unix dgram), 0x10 (netlink), and 0x8000 (unknown) + , _msgLinuxProcessSocketCounts_socket_states :: !Word16 + -- ^ A bitfield indicating the socket states: 0x1 (established), 0x2 (syn- + -- sent), 0x4 (syn-recv), 0x8 (fin-wait-1), 0x10 (fin-wait-2), 0x20 + -- (time-wait), 0x40 (closed), 0x80 (close-wait), 0x100 (last-ack), 0x200 + -- (listen), 0x400 (closing), 0x800 (unconnected), and 0x8000 (unknown) + , _msgLinuxProcessSocketCounts_cmdline :: !Text + -- ^ the command line of the process in question + } deriving ( Show, Read, Eq ) + +instance Binary MsgLinuxProcessSocketCounts where + get = do + _msgLinuxProcessSocketCounts_index <- getWord8 + _msgLinuxProcessSocketCounts_pid <- getWord16le + _msgLinuxProcessSocketCounts_socket_count <- getWord16le + _msgLinuxProcessSocketCounts_socket_types <- getWord16le + _msgLinuxProcessSocketCounts_socket_states <- getWord16le + _msgLinuxProcessSocketCounts_cmdline <- decodeUtf8 . toStrict <$> getRemainingLazyByteString + pure MsgLinuxProcessSocketCounts {..} + + put MsgLinuxProcessSocketCounts {..} = do + putWord8 _msgLinuxProcessSocketCounts_index + putWord16le _msgLinuxProcessSocketCounts_pid + putWord16le _msgLinuxProcessSocketCounts_socket_count + putWord16le _msgLinuxProcessSocketCounts_socket_types + putWord16le _msgLinuxProcessSocketCounts_socket_states + putByteString $ encodeUtf8 _msgLinuxProcessSocketCounts_cmdline + +$(makeSBP 'msgLinuxProcessSocketCounts ''MsgLinuxProcessSocketCounts) +$(makeJSON "_msgLinuxProcessSocketCounts_" ''MsgLinuxProcessSocketCounts) +$(makeLenses ''MsgLinuxProcessSocketCounts) + +msgLinuxProcessSocketQueues :: Word16 +msgLinuxProcessSocketQueues = 0x7F04 + +-- | SBP class for message MSG_LINUX_PROCESS_SOCKET_QUEUES (0x7F04). +-- +-- Top 10 list of sockets with deep queues. +data MsgLinuxProcessSocketQueues = MsgLinuxProcessSocketQueues + { _msgLinuxProcessSocketQueues_index :: !Word8 + -- ^ sequence of this status message, values from 0-9 + , _msgLinuxProcessSocketQueues_pid :: !Word16 + -- ^ the PID of the process in question + , _msgLinuxProcessSocketQueues_recv_queued :: !Word16 + -- ^ the total amount of receive data queued for this process + , _msgLinuxProcessSocketQueues_send_queued :: !Word16 + -- ^ the total amount of send data queued for this process + , _msgLinuxProcessSocketQueues_socket_types :: !Word16 + -- ^ A bitfield indicating the socket types used: 0x1 (tcp), 0x2 (udp), 0x4 + -- (unix stream), 0x8 (unix dgram), 0x10 (netlink), and 0x8000 (unknown) + , _msgLinuxProcessSocketQueues_socket_states :: !Word16 + -- ^ A bitfield indicating the socket states: 0x1 (established), 0x2 (syn- + -- sent), 0x4 (syn-recv), 0x8 (fin-wait-1), 0x10 (fin-wait-2), 0x20 + -- (time-wait), 0x40 (closed), 0x80 (close-wait), 0x100 (last-ack), 0x200 + -- (listen), 0x400 (closing), 0x800 (unconnected), and 0x8000 (unknown) + , _msgLinuxProcessSocketQueues_address_of_largest :: !Text + -- ^ Address of the largest queue, remote or local depending on the + -- directionality of the connection. + , _msgLinuxProcessSocketQueues_cmdline :: !Text + -- ^ the command line of the process in question + } deriving ( Show, Read, Eq ) + +instance Binary MsgLinuxProcessSocketQueues where + get = do + _msgLinuxProcessSocketQueues_index <- getWord8 + _msgLinuxProcessSocketQueues_pid <- getWord16le + _msgLinuxProcessSocketQueues_recv_queued <- getWord16le + _msgLinuxProcessSocketQueues_send_queued <- getWord16le + _msgLinuxProcessSocketQueues_socket_types <- getWord16le + _msgLinuxProcessSocketQueues_socket_states <- getWord16le + _msgLinuxProcessSocketQueues_address_of_largest <- decodeUtf8 <$> getByteString 64 + _msgLinuxProcessSocketQueues_cmdline <- decodeUtf8 . toStrict <$> getRemainingLazyByteString + pure MsgLinuxProcessSocketQueues {..} + + put MsgLinuxProcessSocketQueues {..} = do + putWord8 _msgLinuxProcessSocketQueues_index + putWord16le _msgLinuxProcessSocketQueues_pid + putWord16le _msgLinuxProcessSocketQueues_recv_queued + putWord16le _msgLinuxProcessSocketQueues_send_queued + putWord16le _msgLinuxProcessSocketQueues_socket_types + putWord16le _msgLinuxProcessSocketQueues_socket_states + putByteString $ encodeUtf8 _msgLinuxProcessSocketQueues_address_of_largest + putByteString $ encodeUtf8 _msgLinuxProcessSocketQueues_cmdline + +$(makeSBP 'msgLinuxProcessSocketQueues ''MsgLinuxProcessSocketQueues) +$(makeJSON "_msgLinuxProcessSocketQueues_" ''MsgLinuxProcessSocketQueues) +$(makeLenses ''MsgLinuxProcessSocketQueues) + +msgLinuxSocketUsage :: Word16 +msgLinuxSocketUsage = 0x7F05 + +-- | SBP class for message MSG_LINUX_SOCKET_USAGE (0x7F05). +-- +-- Summaries the socket usage across the system. +data MsgLinuxSocketUsage = MsgLinuxSocketUsage + { _msgLinuxSocketUsage_avg_queue_depth :: !Word32 + -- ^ average socket queue depths across all sockets on the system + , _msgLinuxSocketUsage_max_queue_depth :: !Word32 + -- ^ the max queue depth seen within the reporting period + , _msgLinuxSocketUsage_socket_state_counts :: ![Word16] + -- ^ A count for each socket type reported in the `socket_types_reported` + -- field, the first entry corresponds to the first enabled bit in + -- `types_reported`. + , _msgLinuxSocketUsage_socket_type_counts :: ![Word16] + -- ^ A count for each socket type reported in the `socket_types_reported` + -- field, the first entry corresponds to the first enabled bit in + -- `types_reported`. + } deriving ( Show, Read, Eq ) + +instance Binary MsgLinuxSocketUsage where + get = do + _msgLinuxSocketUsage_avg_queue_depth <- getWord32le + _msgLinuxSocketUsage_max_queue_depth <- getWord32le + _msgLinuxSocketUsage_socket_state_counts <- replicateM 16 getWord16le + _msgLinuxSocketUsage_socket_type_counts <- replicateM 16 getWord16le + pure MsgLinuxSocketUsage {..} + + put MsgLinuxSocketUsage {..} = do + putWord32le _msgLinuxSocketUsage_avg_queue_depth + putWord32le _msgLinuxSocketUsage_max_queue_depth + mapM_ putWord16le _msgLinuxSocketUsage_socket_state_counts + mapM_ putWord16le _msgLinuxSocketUsage_socket_type_counts + +$(makeSBP 'msgLinuxSocketUsage ''MsgLinuxSocketUsage) +$(makeJSON "_msgLinuxSocketUsage_" ''MsgLinuxSocketUsage) +$(makeLenses ''MsgLinuxSocketUsage) diff --git a/haskell/src/SwiftNav/SBP/Msg.hs b/haskell/src/SwiftNav/SBP/Msg.hs index 6ade2c3695..b7f4652aad 100644 --- a/haskell/src/SwiftNav/SBP/Msg.hs +++ b/haskell/src/SwiftNav/SBP/Msg.hs @@ -31,6 +31,7 @@ import SwiftNav.SBP.FileIo import SwiftNav.SBP.Flash import SwiftNav.SBP.Gnss import SwiftNav.SBP.Imu +import SwiftNav.SBP.Linux import SwiftNav.SBP.Logging import SwiftNav.SBP.Mag import SwiftNav.SBP.Navigation @@ -133,6 +134,12 @@ data SBPMsg = | SBPMsgInitBase MsgInitBase Msg | SBPMsgInsStatus MsgInsStatus Msg | SBPMsgIono MsgIono Msg + | SBPMsgLinuxCpuState MsgLinuxCpuState Msg + | SBPMsgLinuxMemState MsgLinuxMemState Msg + | SBPMsgLinuxProcessSocketCounts MsgLinuxProcessSocketCounts Msg + | SBPMsgLinuxProcessSocketQueues MsgLinuxProcessSocketQueues Msg + | SBPMsgLinuxSocketUsage MsgLinuxSocketUsage Msg + | SBPMsgLinuxSysState MsgLinuxSysState Msg | SBPMsgLog MsgLog Msg | SBPMsgM25FlashWriteStatus MsgM25FlashWriteStatus Msg | SBPMsgMagRaw MsgMagRaw Msg @@ -298,6 +305,12 @@ instance Binary SBPMsg where | _msgSBPType == msgInitBase = SBPMsgInitBase (decode (fromStrict (unBytes _msgSBPPayload))) m | _msgSBPType == msgInsStatus = SBPMsgInsStatus (decode (fromStrict (unBytes _msgSBPPayload))) m | _msgSBPType == msgIono = SBPMsgIono (decode (fromStrict (unBytes _msgSBPPayload))) m + | _msgSBPType == msgLinuxCpuState = SBPMsgLinuxCpuState (decode (fromStrict (unBytes _msgSBPPayload))) m + | _msgSBPType == msgLinuxMemState = SBPMsgLinuxMemState (decode (fromStrict (unBytes _msgSBPPayload))) m + | _msgSBPType == msgLinuxProcessSocketCounts = SBPMsgLinuxProcessSocketCounts (decode (fromStrict (unBytes _msgSBPPayload))) m + | _msgSBPType == msgLinuxProcessSocketQueues = SBPMsgLinuxProcessSocketQueues (decode (fromStrict (unBytes _msgSBPPayload))) m + | _msgSBPType == msgLinuxSocketUsage = SBPMsgLinuxSocketUsage (decode (fromStrict (unBytes _msgSBPPayload))) m + | _msgSBPType == msgLinuxSysState = SBPMsgLinuxSysState (decode (fromStrict (unBytes _msgSBPPayload))) m | _msgSBPType == msgLog = SBPMsgLog (decode (fromStrict (unBytes _msgSBPPayload))) m | _msgSBPType == msgM25FlashWriteStatus = SBPMsgM25FlashWriteStatus (decode (fromStrict (unBytes _msgSBPPayload))) m | _msgSBPType == msgMagRaw = SBPMsgMagRaw (decode (fromStrict (unBytes _msgSBPPayload))) m @@ -455,6 +468,12 @@ instance Binary SBPMsg where encoder (SBPMsgInitBase _ m) = put m encoder (SBPMsgInsStatus _ m) = put m encoder (SBPMsgIono _ m) = put m + encoder (SBPMsgLinuxCpuState _ m) = put m + encoder (SBPMsgLinuxMemState _ m) = put m + encoder (SBPMsgLinuxProcessSocketCounts _ m) = put m + encoder (SBPMsgLinuxProcessSocketQueues _ m) = put m + encoder (SBPMsgLinuxSocketUsage _ m) = put m + encoder (SBPMsgLinuxSysState _ m) = put m encoder (SBPMsgLog _ m) = put m encoder (SBPMsgM25FlashWriteStatus _ m) = put m encoder (SBPMsgMagRaw _ m) = put m @@ -616,6 +635,12 @@ instance FromJSON SBPMsg where | msgType == msgInitBase = SBPMsgInitBase <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj | msgType == msgInsStatus = SBPMsgInsStatus <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj | msgType == msgIono = SBPMsgIono <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj + | msgType == msgLinuxCpuState = SBPMsgLinuxCpuState <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj + | msgType == msgLinuxMemState = SBPMsgLinuxMemState <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj + | msgType == msgLinuxProcessSocketCounts = SBPMsgLinuxProcessSocketCounts <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj + | msgType == msgLinuxProcessSocketQueues = SBPMsgLinuxProcessSocketQueues <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj + | msgType == msgLinuxSocketUsage = SBPMsgLinuxSocketUsage <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj + | msgType == msgLinuxSysState = SBPMsgLinuxSysState <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj | msgType == msgLog = SBPMsgLog <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj | msgType == msgM25FlashWriteStatus = SBPMsgM25FlashWriteStatus <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj | msgType == msgMagRaw = SBPMsgMagRaw <$> pure (decode (fromStrict (unBytes payload))) <*> parseJSON obj @@ -778,6 +803,12 @@ instance ToJSON SBPMsg where toJSON (SBPMsgInitBase n m) = toJSON n <<>> toJSON m toJSON (SBPMsgInsStatus n m) = toJSON n <<>> toJSON m toJSON (SBPMsgIono n m) = toJSON n <<>> toJSON m + toJSON (SBPMsgLinuxCpuState n m) = toJSON n <<>> toJSON m + toJSON (SBPMsgLinuxMemState n m) = toJSON n <<>> toJSON m + toJSON (SBPMsgLinuxProcessSocketCounts n m) = toJSON n <<>> toJSON m + toJSON (SBPMsgLinuxProcessSocketQueues n m) = toJSON n <<>> toJSON m + toJSON (SBPMsgLinuxSocketUsage n m) = toJSON n <<>> toJSON m + toJSON (SBPMsgLinuxSysState n m) = toJSON n <<>> toJSON m toJSON (SBPMsgLog n m) = toJSON n <<>> toJSON m toJSON (SBPMsgM25FlashWriteStatus n m) = toJSON n <<>> toJSON m toJSON (SBPMsgMagRaw n m) = toJSON n <<>> toJSON m @@ -934,6 +965,12 @@ instance HasMsg SBPMsg where msg f (SBPMsgInitBase n m) = SBPMsgInitBase n <$> f m msg f (SBPMsgInsStatus n m) = SBPMsgInsStatus n <$> f m msg f (SBPMsgIono n m) = SBPMsgIono n <$> f m + msg f (SBPMsgLinuxCpuState n m) = SBPMsgLinuxCpuState n <$> f m + msg f (SBPMsgLinuxMemState n m) = SBPMsgLinuxMemState n <$> f m + msg f (SBPMsgLinuxProcessSocketCounts n m) = SBPMsgLinuxProcessSocketCounts n <$> f m + msg f (SBPMsgLinuxProcessSocketQueues n m) = SBPMsgLinuxProcessSocketQueues n <$> f m + msg f (SBPMsgLinuxSocketUsage n m) = SBPMsgLinuxSocketUsage n <$> f m + msg f (SBPMsgLinuxSysState n m) = SBPMsgLinuxSysState n <$> f m msg f (SBPMsgLog n m) = SBPMsgLog n <$> f m msg f (SBPMsgM25FlashWriteStatus n m) = SBPMsgM25FlashWriteStatus n <$> f m msg f (SBPMsgMagRaw n m) = SBPMsgMagRaw n <$> f m diff --git a/java/src/com/swiftnav/sbp/SBPMessage.java b/java/src/com/swiftnav/sbp/SBPMessage.java index 0e4a6c623d..24e1211a10 100644 --- a/java/src/com/swiftnav/sbp/SBPMessage.java +++ b/java/src/com/swiftnav/sbp/SBPMessage.java @@ -156,6 +156,16 @@ public int[] getArrayofU8(int n) { return ret; } + public int[] getArrayofU16() { + return getArrayofU16(buf.remaining()); + } + public int[] getArrayofU16(int n) { + int[] ret = new int[n]; + for (int i = 0; i < n; i++) + ret[i] = getU16(); + return ret; + } + public float[] getArrayofFloat() { return getArrayofFloat(buf.remaining()); } @@ -269,6 +279,15 @@ public void putArrayofU8(int[] data, int n) { putArrayofU8(data); } + public void putArrayofU16(int[] data) { + for (int x : data) + buf.putShort((short)x); + } + public void putArrayofU16(int[] data, int n) { + assert(n == data.length); + putArrayofU16(data); + } + public void putArrayofDouble(double[] data) { for (double x: data) putDouble(x); diff --git a/java/src/com/swiftnav/sbp/client/MessageTable.java b/java/src/com/swiftnav/sbp/client/MessageTable.java index ed4262ef12..c69f0ee3ef 100644 --- a/java/src/com/swiftnav/sbp/client/MessageTable.java +++ b/java/src/com/swiftnav/sbp/client/MessageTable.java @@ -47,6 +47,12 @@ import com.swiftnav.sbp.flash.MsgM25FlashWriteStatus; import com.swiftnav.sbp.imu.MsgImuRaw; import com.swiftnav.sbp.imu.MsgImuAux; +import com.swiftnav.sbp.linux.MsgLinuxCpuState; +import com.swiftnav.sbp.linux.MsgLinuxMemState; +import com.swiftnav.sbp.linux.MsgLinuxSysState; +import com.swiftnav.sbp.linux.MsgLinuxProcessSocketCounts; +import com.swiftnav.sbp.linux.MsgLinuxProcessSocketQueues; +import com.swiftnav.sbp.linux.MsgLinuxSocketUsage; import com.swiftnav.sbp.logging.MsgLog; import com.swiftnav.sbp.logging.MsgFwd; import com.swiftnav.sbp.logging.MsgTweet; @@ -235,6 +241,18 @@ static SBPMessage dispatch(SBPMessage msg) throws SBPBinaryException { return new MsgImuRaw(msg); case MsgImuAux.TYPE: return new MsgImuAux(msg); + case MsgLinuxCpuState.TYPE: + return new MsgLinuxCpuState(msg); + case MsgLinuxMemState.TYPE: + return new MsgLinuxMemState(msg); + case MsgLinuxSysState.TYPE: + return new MsgLinuxSysState(msg); + case MsgLinuxProcessSocketCounts.TYPE: + return new MsgLinuxProcessSocketCounts(msg); + case MsgLinuxProcessSocketQueues.TYPE: + return new MsgLinuxProcessSocketQueues(msg); + case MsgLinuxSocketUsage.TYPE: + return new MsgLinuxSocketUsage(msg); case MsgLog.TYPE: return new MsgLog(msg); case MsgFwd.TYPE: diff --git a/java/src/com/swiftnav/sbp/linux/MsgLinuxCpuState.java b/java/src/com/swiftnav/sbp/linux/MsgLinuxCpuState.java new file mode 100644 index 0000000000..b7b26f1ae1 --- /dev/null +++ b/java/src/com/swiftnav/sbp/linux/MsgLinuxCpuState.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2015-2018 Swift Navigation Inc. + * Contact: Swift Navigation + * + * This source is subject to the license found in the file 'LICENSE' which must + * be be distributed together with this source. All other rights reserved. + * + * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, + * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + */ + +package com.swiftnav.sbp.linux; + +import java.math.BigInteger; + +import com.swiftnav.sbp.SBPMessage; +import com.swiftnav.sbp.SBPBinaryException; +import com.swiftnav.sbp.SBPStruct; + +import org.json.JSONObject; +import org.json.JSONArray; + + +/** SBP class for message MSG_LINUX_CPU_STATE (0x7F00). + * + * You can have MSG_LINUX_CPU_STATE inherent its fields directly from + * an inherited SBP object, or construct it inline using a dict of its + * fields. + * + * This message indicates the process state of the top 10 heaviest + * consumers of CPU on the system. */ + +public class MsgLinuxCpuState extends SBPMessage { + public static final int TYPE = 0x7F00; + + + /** sequence of this status message, values from 0-9 */ + public int index; + + /** the PID of the process */ + public int pid; + + /** percent of cpu used, expressed as a fraction of 256 */ + public int pcpu; + + /** fixed length string representing the thread name */ + public String tname; + + /** the command line (as much as it fits in the remaining packet) */ + public String cmdline; + + + public MsgLinuxCpuState (int sender) { super(sender, TYPE); } + public MsgLinuxCpuState () { super(TYPE); } + public MsgLinuxCpuState (SBPMessage msg) throws SBPBinaryException { + super(msg); + assert msg.type != TYPE; + } + + @Override + protected void parse(Parser parser) throws SBPBinaryException { + /* Parse fields from binary */ + index = parser.getU8(); + pid = parser.getU16(); + pcpu = parser.getU8(); + tname = parser.getString(15); + cmdline = parser.getString(); + } + + @Override + protected void build(Builder builder) { + builder.putU8(index); + builder.putU16(pid); + builder.putU8(pcpu); + builder.putString(tname, 15); + builder.putString(cmdline); + } + + @Override + public JSONObject toJSON() { + JSONObject obj = super.toJSON(); + obj.put("index", index); + obj.put("pid", pid); + obj.put("pcpu", pcpu); + obj.put("tname", tname); + obj.put("cmdline", cmdline); + return obj; + } +} \ No newline at end of file diff --git a/java/src/com/swiftnav/sbp/linux/MsgLinuxMemState.java b/java/src/com/swiftnav/sbp/linux/MsgLinuxMemState.java new file mode 100644 index 0000000000..670ec4616f --- /dev/null +++ b/java/src/com/swiftnav/sbp/linux/MsgLinuxMemState.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2015-2018 Swift Navigation Inc. + * Contact: Swift Navigation + * + * This source is subject to the license found in the file 'LICENSE' which must + * be be distributed together with this source. All other rights reserved. + * + * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, + * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + */ + +package com.swiftnav.sbp.linux; + +import java.math.BigInteger; + +import com.swiftnav.sbp.SBPMessage; +import com.swiftnav.sbp.SBPBinaryException; +import com.swiftnav.sbp.SBPStruct; + +import org.json.JSONObject; +import org.json.JSONArray; + + +/** SBP class for message MSG_LINUX_MEM_STATE (0x7F01). + * + * You can have MSG_LINUX_MEM_STATE inherent its fields directly from + * an inherited SBP object, or construct it inline using a dict of its + * fields. + * + * This message indicates the process state of the top 10 heaviest + * consumers of memory on the system. */ + +public class MsgLinuxMemState extends SBPMessage { + public static final int TYPE = 0x7F01; + + + /** sequence of this status message, values from 0-9 */ + public int index; + + /** the PID of the process */ + public int pid; + + /** percent of memory used, expressed as a fraction of 256 */ + public int pmem; + + /** fixed length string representing the thread name */ + public String tname; + + /** the command line (as much as it fits in the remaining packet) */ + public String cmdline; + + + public MsgLinuxMemState (int sender) { super(sender, TYPE); } + public MsgLinuxMemState () { super(TYPE); } + public MsgLinuxMemState (SBPMessage msg) throws SBPBinaryException { + super(msg); + assert msg.type != TYPE; + } + + @Override + protected void parse(Parser parser) throws SBPBinaryException { + /* Parse fields from binary */ + index = parser.getU8(); + pid = parser.getU16(); + pmem = parser.getU8(); + tname = parser.getString(15); + cmdline = parser.getString(); + } + + @Override + protected void build(Builder builder) { + builder.putU8(index); + builder.putU16(pid); + builder.putU8(pmem); + builder.putString(tname, 15); + builder.putString(cmdline); + } + + @Override + public JSONObject toJSON() { + JSONObject obj = super.toJSON(); + obj.put("index", index); + obj.put("pid", pid); + obj.put("pmem", pmem); + obj.put("tname", tname); + obj.put("cmdline", cmdline); + return obj; + } +} \ No newline at end of file diff --git a/java/src/com/swiftnav/sbp/linux/MsgLinuxProcessSocketCounts.java b/java/src/com/swiftnav/sbp/linux/MsgLinuxProcessSocketCounts.java new file mode 100644 index 0000000000..f25f05c015 --- /dev/null +++ b/java/src/com/swiftnav/sbp/linux/MsgLinuxProcessSocketCounts.java @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2015-2018 Swift Navigation Inc. + * Contact: Swift Navigation + * + * This source is subject to the license found in the file 'LICENSE' which must + * be be distributed together with this source. All other rights reserved. + * + * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, + * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + */ + +package com.swiftnav.sbp.linux; + +import java.math.BigInteger; + +import com.swiftnav.sbp.SBPMessage; +import com.swiftnav.sbp.SBPBinaryException; +import com.swiftnav.sbp.SBPStruct; + +import org.json.JSONObject; +import org.json.JSONArray; + + +/** SBP class for message MSG_LINUX_PROCESS_SOCKET_COUNTS (0x7F03). + * + * You can have MSG_LINUX_PROCESS_SOCKET_COUNTS inherent its fields directly from + * an inherited SBP object, or construct it inline using a dict of its + * fields. + * + * Top 10 list of processes with high socket counts. */ + +public class MsgLinuxProcessSocketCounts extends SBPMessage { + public static final int TYPE = 0x7F03; + + + /** sequence of this status message, values from 0-9 */ + public int index; + + /** the PID of the process in question */ + public int pid; + + /** the number of sockets the process is using */ + public int socket_count; + + /** A bitfield indicating the socket types used: + 0x1 (tcp), 0x2 (udp), 0x4 (unix stream), 0x8 (unix dgram), 0x10 (netlink), + and 0x8000 (unknown) + */ + public int socket_types; + + /** A bitfield indicating the socket states: + 0x1 (established), 0x2 (syn-sent), 0x4 (syn-recv), 0x8 (fin-wait-1), + 0x10 (fin-wait-2), 0x20 (time-wait), 0x40 (closed), 0x80 (close-wait), + 0x100 (last-ack), 0x200 (listen), 0x400 (closing), 0x800 (unconnected), + and 0x8000 (unknown) + */ + public int socket_states; + + /** the command line of the process in question */ + public String cmdline; + + + public MsgLinuxProcessSocketCounts (int sender) { super(sender, TYPE); } + public MsgLinuxProcessSocketCounts () { super(TYPE); } + public MsgLinuxProcessSocketCounts (SBPMessage msg) throws SBPBinaryException { + super(msg); + assert msg.type != TYPE; + } + + @Override + protected void parse(Parser parser) throws SBPBinaryException { + /* Parse fields from binary */ + index = parser.getU8(); + pid = parser.getU16(); + socket_count = parser.getU16(); + socket_types = parser.getU16(); + socket_states = parser.getU16(); + cmdline = parser.getString(); + } + + @Override + protected void build(Builder builder) { + builder.putU8(index); + builder.putU16(pid); + builder.putU16(socket_count); + builder.putU16(socket_types); + builder.putU16(socket_states); + builder.putString(cmdline); + } + + @Override + public JSONObject toJSON() { + JSONObject obj = super.toJSON(); + obj.put("index", index); + obj.put("pid", pid); + obj.put("socket_count", socket_count); + obj.put("socket_types", socket_types); + obj.put("socket_states", socket_states); + obj.put("cmdline", cmdline); + return obj; + } +} \ No newline at end of file diff --git a/java/src/com/swiftnav/sbp/linux/MsgLinuxProcessSocketQueues.java b/java/src/com/swiftnav/sbp/linux/MsgLinuxProcessSocketQueues.java new file mode 100644 index 0000000000..8cae37ea4e --- /dev/null +++ b/java/src/com/swiftnav/sbp/linux/MsgLinuxProcessSocketQueues.java @@ -0,0 +1,117 @@ +/* + * Copyright (C) 2015-2018 Swift Navigation Inc. + * Contact: Swift Navigation + * + * This source is subject to the license found in the file 'LICENSE' which must + * be be distributed together with this source. All other rights reserved. + * + * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, + * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + */ + +package com.swiftnav.sbp.linux; + +import java.math.BigInteger; + +import com.swiftnav.sbp.SBPMessage; +import com.swiftnav.sbp.SBPBinaryException; +import com.swiftnav.sbp.SBPStruct; + +import org.json.JSONObject; +import org.json.JSONArray; + + +/** SBP class for message MSG_LINUX_PROCESS_SOCKET_QUEUES (0x7F04). + * + * You can have MSG_LINUX_PROCESS_SOCKET_QUEUES inherent its fields directly from + * an inherited SBP object, or construct it inline using a dict of its + * fields. + * + * Top 10 list of sockets with deep queues. */ + +public class MsgLinuxProcessSocketQueues extends SBPMessage { + public static final int TYPE = 0x7F04; + + + /** sequence of this status message, values from 0-9 */ + public int index; + + /** the PID of the process in question */ + public int pid; + + /** the total amount of receive data queued for this process */ + public int recv_queued; + + /** the total amount of send data queued for this process */ + public int send_queued; + + /** A bitfield indicating the socket types used: + 0x1 (tcp), 0x2 (udp), 0x4 (unix stream), 0x8 (unix dgram), 0x10 (netlink), + and 0x8000 (unknown) + */ + public int socket_types; + + /** A bitfield indicating the socket states: + 0x1 (established), 0x2 (syn-sent), 0x4 (syn-recv), 0x8 (fin-wait-1), + 0x10 (fin-wait-2), 0x20 (time-wait), 0x40 (closed), 0x80 (close-wait), + 0x100 (last-ack), 0x200 (listen), 0x400 (closing), 0x800 (unconnected), + and 0x8000 (unknown) + */ + public int socket_states; + + /** Address of the largest queue, remote or local depending on the directionality +of the connection. + */ + public String address_of_largest; + + /** the command line of the process in question */ + public String cmdline; + + + public MsgLinuxProcessSocketQueues (int sender) { super(sender, TYPE); } + public MsgLinuxProcessSocketQueues () { super(TYPE); } + public MsgLinuxProcessSocketQueues (SBPMessage msg) throws SBPBinaryException { + super(msg); + assert msg.type != TYPE; + } + + @Override + protected void parse(Parser parser) throws SBPBinaryException { + /* Parse fields from binary */ + index = parser.getU8(); + pid = parser.getU16(); + recv_queued = parser.getU16(); + send_queued = parser.getU16(); + socket_types = parser.getU16(); + socket_states = parser.getU16(); + address_of_largest = parser.getString(64); + cmdline = parser.getString(); + } + + @Override + protected void build(Builder builder) { + builder.putU8(index); + builder.putU16(pid); + builder.putU16(recv_queued); + builder.putU16(send_queued); + builder.putU16(socket_types); + builder.putU16(socket_states); + builder.putString(address_of_largest, 64); + builder.putString(cmdline); + } + + @Override + public JSONObject toJSON() { + JSONObject obj = super.toJSON(); + obj.put("index", index); + obj.put("pid", pid); + obj.put("recv_queued", recv_queued); + obj.put("send_queued", send_queued); + obj.put("socket_types", socket_types); + obj.put("socket_states", socket_states); + obj.put("address_of_largest", address_of_largest); + obj.put("cmdline", cmdline); + return obj; + } +} \ No newline at end of file diff --git a/java/src/com/swiftnav/sbp/linux/MsgLinuxSocketUsage.java b/java/src/com/swiftnav/sbp/linux/MsgLinuxSocketUsage.java new file mode 100644 index 0000000000..60ec4ff2a0 --- /dev/null +++ b/java/src/com/swiftnav/sbp/linux/MsgLinuxSocketUsage.java @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2015-2018 Swift Navigation Inc. + * Contact: Swift Navigation + * + * This source is subject to the license found in the file 'LICENSE' which must + * be be distributed together with this source. All other rights reserved. + * + * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, + * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + */ + +package com.swiftnav.sbp.linux; + +import java.math.BigInteger; + +import com.swiftnav.sbp.SBPMessage; +import com.swiftnav.sbp.SBPBinaryException; +import com.swiftnav.sbp.SBPStruct; + +import org.json.JSONObject; +import org.json.JSONArray; + + +/** SBP class for message MSG_LINUX_SOCKET_USAGE (0x7F05). + * + * You can have MSG_LINUX_SOCKET_USAGE inherent its fields directly from + * an inherited SBP object, or construct it inline using a dict of its + * fields. + * + * Summaries the socket usage across the system. */ + +public class MsgLinuxSocketUsage extends SBPMessage { + public static final int TYPE = 0x7F05; + + + /** average socket queue depths across all sockets on the system */ + public long avg_queue_depth; + + /** the max queue depth seen within the reporting period */ + public long max_queue_depth; + + /** A count for each socket type reported in the `socket_types_reported` field, +the first entry corresponds to the first enabled bit in `types_reported`. + */ + public int[] socket_state_counts; + + /** A count for each socket type reported in the `socket_types_reported` field, +the first entry corresponds to the first enabled bit in `types_reported`. + */ + public int[] socket_type_counts; + + + public MsgLinuxSocketUsage (int sender) { super(sender, TYPE); } + public MsgLinuxSocketUsage () { super(TYPE); } + public MsgLinuxSocketUsage (SBPMessage msg) throws SBPBinaryException { + super(msg); + assert msg.type != TYPE; + } + + @Override + protected void parse(Parser parser) throws SBPBinaryException { + /* Parse fields from binary */ + avg_queue_depth = parser.getU32(); + max_queue_depth = parser.getU32(); + socket_state_counts = parser.getArrayofU16(16); + socket_type_counts = parser.getArrayofU16(16); + } + + @Override + protected void build(Builder builder) { + builder.putU32(avg_queue_depth); + builder.putU32(max_queue_depth); + builder.putArrayofU16(socket_state_counts, 16); + builder.putArrayofU16(socket_type_counts, 16); + } + + @Override + public JSONObject toJSON() { + JSONObject obj = super.toJSON(); + obj.put("avg_queue_depth", avg_queue_depth); + obj.put("max_queue_depth", max_queue_depth); + obj.put("socket_state_counts", new JSONArray(socket_state_counts)); + obj.put("socket_type_counts", new JSONArray(socket_type_counts)); + return obj; + } +} \ No newline at end of file diff --git a/java/src/com/swiftnav/sbp/linux/MsgLinuxSysState.java b/java/src/com/swiftnav/sbp/linux/MsgLinuxSysState.java new file mode 100644 index 0000000000..fffc61309a --- /dev/null +++ b/java/src/com/swiftnav/sbp/linux/MsgLinuxSysState.java @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2015-2018 Swift Navigation Inc. + * Contact: Swift Navigation + * + * This source is subject to the license found in the file 'LICENSE' which must + * be be distributed together with this source. All other rights reserved. + * + * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, + * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + */ + +package com.swiftnav.sbp.linux; + +import java.math.BigInteger; + +import com.swiftnav.sbp.SBPMessage; +import com.swiftnav.sbp.SBPBinaryException; +import com.swiftnav.sbp.SBPStruct; + +import org.json.JSONObject; +import org.json.JSONArray; + + +/** SBP class for message MSG_LINUX_SYS_STATE (0x7F02). + * + * You can have MSG_LINUX_SYS_STATE inherent its fields directly from + * an inherited SBP object, or construct it inline using a dict of its + * fields. + * + * This presents a summary of CPU and memory utilization. */ + +public class MsgLinuxSysState extends SBPMessage { + public static final int TYPE = 0x7F02; + + + /** total system memory */ + public int mem_total; + + /** percent of total cpu currently utilized */ + public int pcpu; + + /** percent of total memory currently utilized */ + public int pmem; + + /** number of processes that started during collection phase */ + public int procs_starting; + + /** number of processes that stopped during collection phase */ + public int procs_stopping; + + /** the count of processes on the system */ + public int pid_count; + + + public MsgLinuxSysState (int sender) { super(sender, TYPE); } + public MsgLinuxSysState () { super(TYPE); } + public MsgLinuxSysState (SBPMessage msg) throws SBPBinaryException { + super(msg); + assert msg.type != TYPE; + } + + @Override + protected void parse(Parser parser) throws SBPBinaryException { + /* Parse fields from binary */ + mem_total = parser.getU16(); + pcpu = parser.getU8(); + pmem = parser.getU8(); + procs_starting = parser.getU16(); + procs_stopping = parser.getU16(); + pid_count = parser.getU16(); + } + + @Override + protected void build(Builder builder) { + builder.putU16(mem_total); + builder.putU8(pcpu); + builder.putU8(pmem); + builder.putU16(procs_starting); + builder.putU16(procs_stopping); + builder.putU16(pid_count); + } + + @Override + public JSONObject toJSON() { + JSONObject obj = super.toJSON(); + obj.put("mem_total", mem_total); + obj.put("pcpu", pcpu); + obj.put("pmem", pmem); + obj.put("procs_starting", procs_starting); + obj.put("procs_stopping", procs_stopping); + obj.put("pid_count", pid_count); + return obj; + } +} \ No newline at end of file diff --git a/javascript/sbp.bundle.js b/javascript/sbp.bundle.js index f6e355e6b8..df56929e8d 100644 --- a/javascript/sbp.bundle.js +++ b/javascript/sbp.bundle.js @@ -1,15 +1,15 @@ -!function(e){var t={};function r(o){if(t[o])return t[o].exports;var p=t[o]={i:o,l:!1,exports:{}};return e[o].call(p.exports,p,p.exports,r),p.l=!0,p.exports}r.m=e,r.c=t,r.d=function(e,t,o){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},r.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=66)}([function(e,t,r){var o=r(2),p=r(4),i=(r(3),r(1).UINT64,function(e,t){return o.call(this,e),this.messageType="GnssSignal",this.fields=t||this.parser.parse(e.payload),this});(i.prototype=Object.create(o.prototype)).messageType="GnssSignal",i.prototype.constructor=i,i.prototype.parser=(new p).endianess("little").uint8("sat").uint8("code"),i.prototype.fieldSpec=[],i.prototype.fieldSpec.push(["sat","writeUInt8",1]),i.prototype.fieldSpec.push(["code","writeUInt8",1]);var s=function(e,t){return o.call(this,e),this.messageType="GnssSignalDep",this.fields=t||this.parser.parse(e.payload),this};(s.prototype=Object.create(o.prototype)).messageType="GnssSignalDep",s.prototype.constructor=s,s.prototype.parser=(new p).endianess("little").uint16("sat").uint8("code").uint8("reserved"),s.prototype.fieldSpec=[],s.prototype.fieldSpec.push(["sat","writeUInt16LE",2]),s.prototype.fieldSpec.push(["code","writeUInt8",1]),s.prototype.fieldSpec.push(["reserved","writeUInt8",1]);var n=function(e,t){return o.call(this,e),this.messageType="GPSTimeDep",this.fields=t||this.parser.parse(e.payload),this};(n.prototype=Object.create(o.prototype)).messageType="GPSTimeDep",n.prototype.constructor=n,n.prototype.parser=(new p).endianess("little").uint32("tow").uint16("wn"),n.prototype.fieldSpec=[],n.prototype.fieldSpec.push(["tow","writeUInt32LE",4]),n.prototype.fieldSpec.push(["wn","writeUInt16LE",2]);var a=function(e,t){return o.call(this,e),this.messageType="GPSTimeSec",this.fields=t||this.parser.parse(e.payload),this};(a.prototype=Object.create(o.prototype)).messageType="GPSTimeSec",a.prototype.constructor=a,a.prototype.parser=(new p).endianess("little").uint32("tow").uint16("wn"),a.prototype.fieldSpec=[],a.prototype.fieldSpec.push(["tow","writeUInt32LE",4]),a.prototype.fieldSpec.push(["wn","writeUInt16LE",2]);var l=function(e,t){return o.call(this,e),this.messageType="GPSTime",this.fields=t||this.parser.parse(e.payload),this};(l.prototype=Object.create(o.prototype)).messageType="GPSTime",l.prototype.constructor=l,l.prototype.parser=(new p).endianess("little").uint32("tow").int32("ns_residual").uint16("wn"),l.prototype.fieldSpec=[],l.prototype.fieldSpec.push(["tow","writeUInt32LE",4]),l.prototype.fieldSpec.push(["ns_residual","writeInt32LE",4]),l.prototype.fieldSpec.push(["wn","writeUInt16LE",2]);var c=function(e,t){return o.call(this,e),this.messageType="CarrierPhase",this.fields=t||this.parser.parse(e.payload),this};(c.prototype=Object.create(o.prototype)).messageType="CarrierPhase",c.prototype.constructor=c,c.prototype.parser=(new p).endianess("little").int32("i").uint8("f"),c.prototype.fieldSpec=[],c.prototype.fieldSpec.push(["i","writeInt32LE",4]),c.prototype.fieldSpec.push(["f","writeUInt8",1]),e.exports={GnssSignal:i,GnssSignalDep:s,GPSTimeDep:n,GPSTimeSec:a,GPSTime:l,CarrierPhase:c}},function(e,t,r){t.UINT32=r(44),t.UINT64=r(43)},function(e,t,r){(function(t){var o=r(48),p=(r(3),r(1).UINT64),i=function(e,r,o,p){var i=new t(e);return i[r](o,p||0),i};function s(e){return this.messageType="raw",this.sbp=e||{},this.fields={},this}p.prototype.toJSON=function(){return this.toString()},s.prototype.fieldSpec=[],s.prototype.payloadToBuffer=function(e,r){var i=[];for(var s in e=e||this.fieldSpec,r=r||this.fields,e){var n=e[s],a=n[0],l=n[1],c=function(e){return"function"==typeof e?e.apply(this):e}.bind(this);if("string"==typeof l&&0===l.indexOf("write")){var u=c(n[2]);if("writeUInt64LE"===l){o(r[a]instanceof p,"uint64 type must be represented by cuint.UINT64");var h=r[a].clone().shiftRight(32).and(new p(4294967295,0)).toNumber(),f=r[a].clone().and(new p(4294967295,0)).toNumber();(_=new t(8)).writeUInt32LE(f),_.writeUInt32LE(h,4),i.push(_)}else{(_=new t(u))[l](r[a],0),i.push(_)}}else if("string"===l){(_=new t(r[a].length)).write(r[a],0,"utf8"),i.push(_)}else if("array"===l){var y=n[2];for(var d in r[a]){var _,S=r[a][d];if(Array.isArray(y))i=i.concat(this.payloadToBuffer(y,S));else(_=new t(c(n[3])))[y](S,0),i.push(_)}}else i=i.concat(this.payloadToBuffer(l,r[a]))}return t.concat(i)},s.prototype.getLengthBuffer=function(){return i(1,"writeUInt8",this.length||this.sbp.length,0)},s.prototype.getSenderBuffer=function(){return i(2,"writeUInt16LE",this.sender||this.sbp.sender,0)},s.prototype.getPreambleBuffer=function(){return i(1,"writeUInt8",this.preamble||this.sbp.preamble,0)},s.prototype.getMsgTypeBuffer=function(){return i(2,"writeUInt16LE",this.msg_type||this.sbp.msg_type,0)},s.prototype.toBuffer=function(){var e=this.payloadToBuffer(),r=i(2,"writeUInt16LE",this.crc||this.sbp.crc,0),o=[this.getPreambleBuffer(),this.getMsgTypeBuffer(),this.getSenderBuffer(),this.getLengthBuffer()];return t.concat(o.concat(e).concat(r))},s.prototype.toJSON=function(){var e={};return Object.keys(this.sbp).map(function(r){this.sbp[r]instanceof t?e[r]=this.sbp[r].toString("base64"):e[r]=this.sbp[r]}.bind(this)),Object.keys(this.fields).map(function(t){e[t]=this.fields[t]}.bind(this)),e},s.prototype.toBase64=function(){return this.toBuffer().toString("base64")},e.exports=s}).call(this,r(9).Buffer)},function(e,t,r){(function(t){for(var r=[],o=0;o<256;o++)r[o]=(o>15?"":"0")+o.toString(16);var p=e.exports=function(e,r){e instanceof t?(this.buffer=e,this.offset=r||0):"[object Uint8Array]"==Object.prototype.toString.call(e)?(this.buffer=new t(e),this.offset=r||0):(this.buffer=this.buffer||new t(8),this.offset=0,this.setValue.apply(this,arguments))};p.MAX_INT=Math.pow(2,53),p.MIN_INT=-Math.pow(2,53),p.prototype={constructor:p,_2scomp:function(){for(var e=this.buffer,t=this.offset,r=1,o=t+7;o>=t;o--){var p=(255^e[o])+r;e[o]=255&p,r=p>>8}},setValue:function(e,t){var r=!1;if(1==arguments.length)if("number"==typeof e){if(r=e<0,t=(e=Math.abs(e))%4294967296,(e/=4294967296)>4294967296)throw new RangeError(e+" is outside Int64 range");e|=0}else{if("string"!=typeof e)throw new Error(e+" must be a Number or String");t=(e=(e+"").replace(/^0x/,"")).substr(-8),e=e.length>8?e.substr(0,e.length-8):"",e=parseInt(e,16),t=parseInt(t,16)}for(var o=this.buffer,p=this.offset,i=7;i>=0;i--)o[p+i]=255&t,t=4==i?e:t>>>8;r&&this._2scomp()},toNumber:function(e){for(var t=this.buffer,r=this.offset,o=128&t[r],i=0,s=1,n=7,a=1;n>=0;n--,a*=256){var l=t[r+n];o&&(s=(l=(255^l)+s)>>8,l&=255),i+=l*a}return!e&&i>=p.MAX_INT?o?-1/0:1/0:o?-i:i},valueOf:function(){return this.toNumber(!1)},toString:function(e){return this.valueOf().toString(e||10)},toOctetString:function(e){for(var t=new Array(8),o=this.buffer,p=this.offset,i=0;i<8;i++)t[i]=r[o[p+i]];return t.join(e||"")},toBuffer:function(e){if(e&&0===this.offset)return this.buffer;var r=new t(8);return this.buffer.copy(r,0,this.offset,this.offset+8),r},copy:function(e,t){this.buffer.copy(e,t||0,this.offset,this.offset+8)},compare:function(e){if((128&this.buffer[this.offset])!=(128&e.buffer[e.offset]))return e.buffer[e.offset]-this.buffer[this.offset];for(var t=0;t<8;t++)if(this.buffer[this.offset+t]!==e.buffer[e.offset+t])return this.buffer[this.offset+t]-e.buffer[e.offset+t];return 0},equals:function(e){return 0===this.compare(e)},inspect:function(){return"[Int64 value:"+this+" octets:"+this.toOctetString(" ")+"]"}}}).call(this,r(9).Buffer)},function(e,t,r){(function(t){var o=r(16).Parser;o.prototype.uint64=function(e,t){return this.setNextParser("uint64",e,Object.assign({},t,{formatter:function(e){var t=r(1).UINT64,o=buffer.readUInt32LE(offset);offset+=4;var p=buffer.readUInt32LE(offset);return offset+=4,new t(o,p)}}))},o.prototype.compile=function(){var e=this.getCode();this.compiled=function(o,p,i){return"undefined"!=typeof window&&void 0===window.Buffer&&(window.Buffer=t),new Function("buffer","callback","constructorFn","require",e).call(this,o,p,i,function(e){if("cuint"===e)return r(1);throw new Error("Unknown module required: "+e)})}},e.exports=o}).call(this,r(9).Buffer)},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";var o=r(12),p=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=u;var i=r(10);i.inherits=r(7);var s=r(21),n=r(13);i.inherits(u,s);for(var a=p(n.prototype),l=0;l1)for(var r=1;r15?"":"0")+o.toString(16);var p=e.exports=function(e,r){e instanceof t?(this.buffer=e,this.offset=r||0):"[object Uint8Array]"==Object.prototype.toString.call(e)?(this.buffer=new t(e),this.offset=r||0):(this.buffer=this.buffer||new t(8),this.offset=0,this.setValue.apply(this,arguments))};p.MAX_INT=Math.pow(2,53),p.MIN_INT=-Math.pow(2,53),p.prototype={constructor:p,_2scomp:function(){for(var e=this.buffer,t=this.offset,r=1,o=t+7;o>=t;o--){var p=(255^e[o])+r;e[o]=255&p,r=p>>8}},setValue:function(e,t){var r=!1;if(1==arguments.length)if("number"==typeof e){if(r=e<0,t=(e=Math.abs(e))%4294967296,(e/=4294967296)>4294967296)throw new RangeError(e+" is outside Int64 range");e|=0}else{if("string"!=typeof e)throw new Error(e+" must be a Number or String");t=(e=(e+"").replace(/^0x/,"")).substr(-8),e=e.length>8?e.substr(0,e.length-8):"",e=parseInt(e,16),t=parseInt(t,16)}for(var o=this.buffer,p=this.offset,i=7;i>=0;i--)o[p+i]=255&t,t=4==i?e:t>>>8;r&&this._2scomp()},toNumber:function(e){for(var t=this.buffer,r=this.offset,o=128&t[r],i=0,s=1,n=7,a=1;n>=0;n--,a*=256){var l=t[r+n];o&&(s=(l=(255^l)+s)>>8,l&=255),i+=l*a}return!e&&i>=p.MAX_INT?o?-1/0:1/0:o?-i:i},valueOf:function(){return this.toNumber(!1)},toString:function(e){return this.valueOf().toString(e||10)},toOctetString:function(e){for(var t=new Array(8),o=this.buffer,p=this.offset,i=0;i<8;i++)t[i]=r[o[p+i]];return t.join(e||"")},toBuffer:function(e){if(e&&0===this.offset)return this.buffer;var r=new t(8);return this.buffer.copy(r,0,this.offset,this.offset+8),r},copy:function(e,t){this.buffer.copy(e,t||0,this.offset,this.offset+8)},compare:function(e){if((128&this.buffer[this.offset])!=(128&e.buffer[e.offset]))return e.buffer[e.offset]-this.buffer[this.offset];for(var t=0;t<8;t++)if(this.buffer[this.offset+t]!==e.buffer[e.offset+t])return this.buffer[this.offset+t]-e.buffer[e.offset+t];return 0},equals:function(e){return 0===this.compare(e)},inspect:function(){return"[Int64 value:"+this+" octets:"+this.toOctetString(" ")+"]"}}}).call(this,r(9).Buffer)},function(e,t,r){(function(t){var o=r(16).Parser;o.prototype.uint64=function(e,t){return this.setNextParser("uint64",e,Object.assign({},t,{formatter:function(e){var t=r(1).UINT64,o=buffer.readUInt32LE(offset);offset+=4;var p=buffer.readUInt32LE(offset);return offset+=4,new t(o,p)}}))},o.prototype.compile=function(){var e=this.getCode();this.compiled=function(o,p,i){return"undefined"!=typeof window&&void 0===window.Buffer&&(window.Buffer=t),new Function("buffer","callback","constructorFn","require",e).call(this,o,p,i,function(e){if("cuint"===e)return r(1);throw new Error("Unknown module required: "+e)})}},e.exports=o}).call(this,r(9).Buffer)},function(e,t){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";var o=r(12),p=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=u;var i=r(10);i.inherits=r(7);var s=r(21),n=r(13);i.inherits(u,s);for(var a=p(n.prototype),l=0;l1)for(var r=1;r * @license MIT */ -var o=r(65),p=r(64),i=r(22);function s(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function n(e,t){if(s()=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function y(e,t){if(a.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return k(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(e).length;default:if(o)return k(e).length;t=(""+t).toLowerCase(),o=!0}}function d(e,t,r){var o=e[t];e[t]=e[r],e[r]=o}function _(e,t,r,o,p){if(0===e.length)return-1;if("string"==typeof r?(o=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=p?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(p)return-1;r=e.length-1}else if(r<0){if(!p)return-1;r=0}if("string"==typeof t&&(t=a.from(t,o)),a.isBuffer(t))return 0===t.length?-1:S(e,t,r,o,p);if("number"==typeof t)return t&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?p?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):S(e,[t],r,o,p);throw new TypeError("val must be string, number or Buffer")}function S(e,t,r,o,p){var i,s=1,n=e.length,a=t.length;if(void 0!==o&&("ucs2"===(o=String(o).toLowerCase())||"ucs-2"===o||"utf16le"===o||"utf-16le"===o)){if(e.length<2||t.length<2)return-1;s=2,n/=2,a/=2,r/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(p){var c=-1;for(i=r;in&&(r=n-a),i=r;i>=0;i--){for(var u=!0,h=0;hp&&(o=p):o=p;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");o>i/2&&(o=i/2);for(var s=0;s>8,p=r%256,i.push(p),i.push(o);return i}(t,e.length-r),e,r,o)}function L(e,t,r){return 0===t&&r===e.length?o.fromByteArray(e):o.fromByteArray(e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);for(var o=[],p=t;p239?4:l>223?3:l>191?2:1;if(p+u<=r)switch(u){case 1:l<128&&(c=l);break;case 2:128==(192&(i=e[p+1]))&&(a=(31&l)<<6|63&i)>127&&(c=a);break;case 3:i=e[p+1],s=e[p+2],128==(192&i)&&128==(192&s)&&(a=(15&l)<<12|(63&i)<<6|63&s)>2047&&(a<55296||a>57343)&&(c=a);break;case 4:i=e[p+1],s=e[p+2],n=e[p+3],128==(192&i)&&128==(192&s)&&128==(192&n)&&(a=(15&l)<<18|(63&i)<<12|(63&s)<<6|63&n)>65535&&a<1114112&&(c=a)}null===c?(c=65533,u=1):c>65535&&(c-=65536,o.push(c>>>10&1023|55296),c=56320|1023&c),o.push(c),p+=u}return function(e){var t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);var r="",o=0;for(;othis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return U(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return M(this,t,r);case"latin1":case"binary":return D(this,t,r);case"base64":return L(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,r);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}.apply(this,arguments)},a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},a.prototype.compare=function(e,t,r,o,p){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===o&&(o=0),void 0===p&&(p=this.length),t<0||r>e.length||o<0||p>this.length)throw new RangeError("out of range index");if(o>=p&&t>=r)return 0;if(o>=p)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,o>>>=0,p>>>=0,this===e)return 0;for(var i=p-o,s=r-t,n=Math.min(i,s),l=this.slice(o,p),c=e.slice(t,r),u=0;up)&&(r=p),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var i=!1;;)switch(o){case"hex":return g(this,e,t,r);case"utf8":case"utf-8":return w(this,e,t,r);case"ascii":return E(this,e,t,r);case"latin1":case"binary":return m(this,e,t,r);case"base64":return b(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function M(e,t,r){var o="";r=Math.min(e.length,r);for(var p=t;po)&&(r=o);for(var p="",i=t;ir)throw new RangeError("Trying to access beyond buffer length")}function G(e,t,r,o,p,i){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>p||te.length)throw new RangeError("Index out of range")}function P(e,t,r,o){t<0&&(t=65535+t+1);for(var p=0,i=Math.min(e.length-r,2);p>>8*(o?p:1-p)}function R(e,t,r,o){t<0&&(t=4294967295+t+1);for(var p=0,i=Math.min(e.length-r,4);p>>8*(o?p:3-p)&255}function C(e,t,r,o,p,i){if(r+o>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function x(e,t,r,o,i){return i||C(e,0,r,4),p.write(e,t,r,o,23,4),r+4}function j(e,t,r,o,i){return i||C(e,0,r,8),p.write(e,t,r,o,52,8),r+8}a.prototype.slice=function(e,t){var r,o=this.length;if(e=~~e,t=void 0===t?o:~~t,e<0?(e+=o)<0&&(e=0):e>o&&(e=o),t<0?(t+=o)<0&&(t=0):t>o&&(t=o),t0&&(p*=256);)o+=this[e+--t]*p;return o},a.prototype.readUInt8=function(e,t){return t||O(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return t||O(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return t||O(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||O(e,t,this.length);for(var o=this[e],p=1,i=0;++i=(p*=128)&&(o-=Math.pow(2,8*t)),o},a.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||O(e,t,this.length);for(var o=t,p=1,i=this[e+--o];o>0&&(p*=256);)i+=this[e+--o]*p;return i>=(p*=128)&&(i-=Math.pow(2,8*t)),i},a.prototype.readInt8=function(e,t){return t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){t||O(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){t||O(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return t||O(e,4,this.length),p.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return t||O(e,4,this.length),p.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return t||O(e,8,this.length),p.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return t||O(e,8,this.length),p.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,r,o){(e=+e,t|=0,r|=0,o)||G(this,e,t,r,Math.pow(2,8*r)-1,0);var p=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+p]=e/i&255;return t+r},a.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,1,255,0),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):R(this,e,t,!0),t+4},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):R(this,e,t,!1),t+4},a.prototype.writeIntLE=function(e,t,r,o){if(e=+e,t|=0,!o){var p=Math.pow(2,8*r-1);G(this,e,t,r,p-1,-p)}var i=0,s=1,n=0;for(this[t]=255&e;++i>0)-n&255;return t+r},a.prototype.writeIntBE=function(e,t,r,o){if(e=+e,t|=0,!o){var p=Math.pow(2,8*r-1);G(this,e,t,r,p-1,-p)}var i=r-1,s=1,n=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===n&&0!==this[t+i+1]&&(n=1),this[t+i]=(e/s>>0)-n&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,1,127,-128),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):R(this,e,t,!0),t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):R(this,e,t,!1),t+4},a.prototype.writeFloatLE=function(e,t,r){return x(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return x(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return j(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return j(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,o){if(r||(r=0),o||0===o||(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t=0;--p)e[p+t]=this[p+r];else if(i<1e3||!a.TYPED_ARRAY_SUPPORT)for(p=0;p>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&r<57344){if(!p){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===o){(t-=3)>-1&&i.push(239,191,189);continue}p=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),p=r;continue}r=65536+(p-55296<<10|r-56320)}else p&&(t-=3)>-1&&i.push(239,191,189);if(p=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(e){return o.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function q(e,t,r,o){for(var p=0;p=t.length||p>=e.length);++p)t[p+r]=e[p];return p}}).call(this,r(5))},function(e,t,r){(function(e){function r(e){return Object.prototype.toString.call(e)}t.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===r(e)},t.isBoolean=function(e){return"boolean"==typeof e},t.isNull=function(e){return null===e},t.isNullOrUndefined=function(e){return null==e},t.isNumber=function(e){return"number"==typeof e},t.isString=function(e){return"string"==typeof e},t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=function(e){return void 0===e},t.isRegExp=function(e){return"[object RegExp]"===r(e)},t.isObject=function(e){return"object"==typeof e&&null!==e},t.isDate=function(e){return"[object Date]"===r(e)},t.isError=function(e){return"[object Error]"===r(e)||e instanceof Error},t.isFunction=function(e){return"function"==typeof e},t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=e.isBuffer}).call(this,r(9).Buffer)},function(e,t,r){var o=r(9),p=o.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return p(e,t,r)}p.from&&p.alloc&&p.allocUnsafe&&p.allocUnsafeSlow?e.exports=o:(i(o,t),t.Buffer=s),i(p,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return p(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var o=p(e);return void 0!==t?"string"==typeof r?o.fill(t,r):o.fill(t):o.fill(0),o},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return p(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o.SlowBuffer(e)}},function(e,t,r){"use strict";(function(t){!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,o,p){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,s,n=arguments.length;switch(n){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,o)});case 4:return t.nextTick(function(){e.call(null,r,o,p)});default:for(i=new Array(n-1),s=0;s-1?o:i.nextTick;g.WritableState=S;var l=r(10);l.inherits=r(7);var c={deprecate:r(54)},u=r(20),h=r(11).Buffer,f=p.Uint8Array||function(){};var y,d=r(19);function _(){}function S(e,t){n=n||r(6),e=e||{};var o=t instanceof n;this.objectMode=!!e.objectMode,o&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var p=e.highWaterMark,l=e.writableHighWaterMark,c=this.objectMode?16:16384;this.highWaterMark=p||0===p?p:o&&(l||0===l)?l:c,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var u=!1===e.decodeStrings;this.decodeStrings=!u,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,o=r.sync,p=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,o,p){--t.pendingcb,r?(i.nextTick(p,o),i.nextTick(L,e,t),e._writableState.errorEmitted=!0,e.emit("error",o)):(p(o),e._writableState.errorEmitted=!0,e.emit("error",o),L(e,t))}(e,r,o,t,p);else{var s=b(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||m(e,r),o?a(E,e,r,s,p):E(e,r,s,p)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function g(e){if(n=n||r(6),!(y.call(g,this)||this instanceof n))return new g(e);this._writableState=new S(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),u.call(this)}function w(e,t,r,o,p,i,s){t.writelen=o,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(p,t.onwrite):e._write(p,i,t.onwrite),t.sync=!1}function E(e,t,r,o){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,o(),L(e,t)}function m(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var o=t.bufferedRequestCount,p=new Array(o),i=t.corkedRequestsFree;i.entry=r;for(var n=0,a=!0;r;)p[n]=r,r.isBuf||(a=!1),r=r.next,n+=1;p.allBuffers=a,w(e,t,!0,t.length,p,"",i.finish),t.pendingcb++,t.lastBufferedRequest=null,i.next?(t.corkedRequestsFree=i.next,i.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;r;){var l=r.chunk,c=r.encoding,u=r.callback;if(w(e,t,!1,t.objectMode?1:l.length,l,c,u),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function b(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function v(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),L(e,t)})}function L(e,t){var r=b(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,i.nextTick(v,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}l.inherits(g,u),S.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(S.prototype,"buffer",{get:c.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(y=Function.prototype[Symbol.hasInstance],Object.defineProperty(g,Symbol.hasInstance,{value:function(e){return!!y.call(this,e)||this===g&&(e&&e._writableState instanceof S)}})):y=function(e){return e instanceof this},g.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},g.prototype.write=function(e,t,r){var o,p=this._writableState,s=!1,n=!p.objectMode&&(o=e,h.isBuffer(o)||o instanceof f);return n&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(r=t,t=null),n?t="buffer":t||(t=p.defaultEncoding),"function"!=typeof r&&(r=_),p.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),i.nextTick(t,r)}(this,r):(n||function(e,t,r,o){var p=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),i.nextTick(o,s),p=!1),p}(this,p,e,r))&&(p.pendingcb++,s=function(e,t,r,o,p,i){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,r));return t}(t,o,p);o!==s&&(r=!0,p="buffer",o=s)}var n=t.objectMode?1:o.length;t.length+=n;var a=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(g.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),g.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},g.prototype._writev=null,g.prototype.end=function(e,t,r){var o=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),o.corked&&(o.corked=1,this.uncork()),o.ending||o.finished||function(e,t,r){t.ending=!0,L(e,t),r&&(t.finished?i.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,o,r)},Object.defineProperty(g.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),g.prototype.destroy=d.destroy,g.prototype._undestroy=d.undestroy,g.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,r(8),r(56).setImmediate,r(5))},function(e,t,r){(t=e.exports=r(21)).Stream=t,t.Readable=t,t.Writable=r(13),t.Duplex=r(6),t.Transform=r(17),t.PassThrough=r(53)},function(e,t){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function o(e){return"function"==typeof e}function p(e){return"object"==typeof e&&null!==e}function i(e){return void 0===e}e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,r,s,n,a,l;if(this._events||(this._events={}),"error"===e&&(!this._events.error||p(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}if(i(r=this._events[e]))return!1;if(o(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:n=Array.prototype.slice.call(arguments,1),r.apply(this,n)}else if(p(r))for(n=Array.prototype.slice.call(arguments,1),s=(l=r.slice()).length,a=0;a0&&this._events[e].length>s&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){if(!o(t))throw TypeError("listener must be a function");var r=!1;function p(){this.removeListener(e,p),r||(r=!0,t.apply(this,arguments))}return p.listener=t,this.on(e,p),this},r.prototype.removeListener=function(e,t){var r,i,s,n;if(!o(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(r=this._events[e]).length,i=-1,r===t||o(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(p(r)){for(n=s;n-- >0;)if(r[n]===t||r[n].listener&&r[n].listener===t){i=n;break}if(i<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(o(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?o(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(o(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,r){var o=r(62).Context,p={UInt8:1,UInt16LE:2,UInt16BE:2,UInt32LE:4,UInt32BE:4,Int8:1,Int16LE:2,Int16BE:2,Int32LE:4,Int32BE:4,FloatLE:4,FloatBE:4,DoubleLE:8,DoubleBE:8},i=[];!function(){var e;for(e=1;e<=32;e++)i.push(e)}();var s={};Object.keys(p).concat(Object.keys({String:null,Buffer:null,Array:null,Skip:null,Choice:null,Nest:null,Bit:null})).forEach(function(e){s[e.toLowerCase()]=e});var n=function(){this.varName="",this.type="",this.options={},this.next=null,this.head=null,this.compiled=null,this.endian="be",this.constructorFn=null};n.start=function(){return new n},Object.keys(p).forEach(function(e){n.prototype[e.toLowerCase()]=function(t,r){return this.setNextParser(e.toLowerCase(),t,r)};var t=e.replace(/BE|LE/,"").toLowerCase();t in n.prototype||(n.prototype[t]=function(e,r){return this[t+this.endian](e,r)})}),i.forEach(function(e){n.prototype["bit"+e.toString()]=function(t,r){return r||(r={}),r.length=e,this.setNextParser("bit",t,r)}}),n.prototype.skip=function(e,t){if(t&&t.assert)throw new Error("assert option on skip is not allowed.");return this.setNextParser("skip","",{length:e})},n.prototype.string=function(e,t){if(!t.zeroTerminated&&!t.length&&!t.greedy)throw new Error("Neither length, zeroTerminated, nor greedy is defined for string.");if((t.zeroTerminated||t.length)&&t.greedy)throw new Error("greedy is mutually exclusive with length and zeroTerminated for string.");if(t.stripNull&&!t.length&&!t.greedy)throw new Error("Length or greedy must be defined if stripNull is defined.");return t.encoding=t.encoding||"utf8",this.setNextParser("string",e,t)},n.prototype.buffer=function(e,t){if(!t.length&&!t.readUntil)throw new Error("Length nor readUntil is defined in buffer parser");return this.setNextParser("buffer",e,t)},n.prototype.array=function(e,t){if(!t.readUntil&&!t.length)throw new Error("Length option of array is not defined.");if(!t.type)throw new Error("Type option of array is not defined.");if("string"==typeof t.type&&Object.keys(p).indexOf(s[t.type])<0)throw new Error('Specified primitive type "'+t.type+'" is not supported.');return this.setNextParser("array",e,t)},n.prototype.choice=function(e,t){if(!t.tag)throw new Error("Tag option of array is not defined.");if(!t.choices)throw new Error("Choices option of array is not defined.");return Object.keys(t.choices).forEach(function(r){if(isNaN(parseInt(r,10)))throw new Error("Key of choices must be a number.");if(!t.choices[r])throw new Error("Choice Case "+r+" of "+e+" is not valid.");if("string"==typeof t.choices[r]&&Object.keys(p).indexOf(s[t.choices[r]])<0)throw new Error('Specified primitive type "'+t.choices[r]+'" is not supported.')}),this.setNextParser("choice",e,t)},n.prototype.nest=function(e,t){if(!t.type)throw new Error("Type option of nest is not defined.");if(!(t.type instanceof n))throw new Error("Type option of nest must be a Parser object.");return this.setNextParser("nest",e,t)},n.prototype.endianess=function(e){switch(e.toLowerCase()){case"little":this.endian="le";break;case"big":this.endian="be";break;default:throw new Error("Invalid endianess: "+e)}return this},n.prototype.create=function(e){if(!(e instanceof Function))throw new Error("Constructor must be a Function object.");return this.constructorFn=e,this},n.prototype.getCode=function(){var e=new o;return this.constructorFn?e.pushCode("var vars = new constructorFn();"):e.pushCode("var vars = {};"),e.pushCode("var offset = 0;"),e.pushCode("if (!Buffer.isBuffer(buffer)) {"),e.generateError('"argument buffer is not a Buffer object"'),e.pushCode("}"),this.generate(e),e.pushCode("return vars;"),e.code},n.prototype.compile=function(){this.compiled=new Function("buffer","callback","constructorFn",this.getCode())},n.prototype.sizeOf=function(){var e=NaN;if(Object.keys(p).indexOf(this.type)>=0)e=p[this.type];else if("String"===this.type&&"number"==typeof this.options.length)e=this.options.length;else if("Array"===this.type&&"number"==typeof this.options.length){var t=NaN;"string"==typeof this.options.type?t=p[s[this.options.type]]:this.options.type instanceof n&&(t=this.options.type.sizeOf()),e=this.options.length*t}else"Skip"===this.type?e=this.options.length:this.type||(e=0);return this.next&&(e+=this.next.sizeOf()),e},n.prototype.parse=function(e,t){return this.compiled||this.compile(),this.compiled(e,t,this.constructorFn)},n.prototype.setNextParser=function(e,t,r){var o=new n;return o.type=s[e],o.varName=t,o.options=r||o.options,o.endian=this.endian,this.head?this.head.next=o:this.next=o,this.head=o,this},n.prototype.generate=function(e){this.type&&(this["generate"+this.type](e),this.generateAssert(e));var t=e.generateVariable(this.varName);return this.options.formatter&&this.generateFormatter(e,t,this.options.formatter),this.generateNext(e)},n.prototype.generateAssert=function(e){if(this.options.assert){var t=e.generateVariable(this.varName);switch(typeof this.options.assert){case"function":e.pushCode("if (!({0}).call(vars, {1})) {",this.options.assert,t);break;case"number":e.pushCode("if ({0} !== {1}) {",this.options.assert,t);break;case"string":e.pushCode('if ("{0}" !== {1}) {',this.options.assert,t);break;default:throw new Error("Assert option supports only strings, numbers and assert functions.")}e.generateError('"Assert error: {0} is " + {0}',t),e.pushCode("}")}},n.prototype.generateNext=function(e){return this.next&&(e=this.next.generate(e)),e},Object.keys(p).forEach(function(e){n.prototype["generate"+e]=function(t){t.pushCode("{0} = buffer.read{1}(offset);",t.generateVariable(this.varName),e),t.pushCode("offset += {0};",p[e])}}),n.prototype.generateBit=function(e){var t=JSON.parse(JSON.stringify(this));if(t.varName=e.generateVariable(t.varName),e.bitFields.push(t),!this.next||this.next&&["Bit","Nest"].indexOf(this.next.type)<0){var r=0;e.bitFields.forEach(function(e){r+=e.options.length});var o=e.generateTmpVariable();if(r<=8)e.pushCode("var {0} = buffer.readUInt8(offset);",o),r=8;else if(r<=16)e.pushCode("var {0} = buffer.readUInt16BE(offset);",o),r=16;else if(r<=24){var p=e.generateTmpVariable(),i=e.generateTmpVariable();e.pushCode("var {0} = buffer.readUInt16BE(offset);",p),e.pushCode("var {0} = buffer.readUInt8(offset + 2);",i),e.pushCode("var {2} = ({0} << 8) | {1};",p,i,o),r=24}else{if(!(r<=32))throw new Error("Currently, bit field sequence longer than 4-bytes is not supported.");e.pushCode("var {0} = buffer.readUInt32BE(offset);",o),r=32}e.pushCode("offset += {0};",r/8);var s=0,n="be"===this.endian;e.bitFields.forEach(function(t){e.pushCode("{0} = {1} >> {2} & {3};",t.varName,o,n?r-s-t.options.length:s,(1< offset++);"),e.pushCode("{0} = buffer.toString('{1}', {2}, offset);",t,this.options.encoding,r)),this.options.stripNull&&e.pushCode("{0} = {0}.replace(/\\x00+$/g, '')",t)},n.prototype.generateBuffer=function(e){if("eof"===this.options.readUntil?e.pushCode("{0} = buffer.slice(offset, buffer.length - 1);",e.generateVariable(this.varName)):(e.pushCode("{0} = buffer.slice(offset, offset + {1});",e.generateVariable(this.varName),e.generateOption(this.options.length)),e.pushCode("offset += {0};",e.generateOption(this.options.length))),this.options.clone){var t=e.generateTmpVariable();e.pushCode("var {0} = new Buffer({1}.length);",t,e.generateVariable(this.varName)),e.pushCode("{0}.copy({1});",e.generateVariable(this.varName),t),e.pushCode("{0} = {1}",e.generateVariable(this.varName),t)}},n.prototype.generateArray=function(e){var t=e.generateOption(this.options.length),r=this.options.type,o=e.generateTmpVariable(),i=e.generateVariable(this.varName),a=e.generateTmpVariable(),l=this.options.key,c="string"==typeof l;c?e.pushCode("{0} = {};",i):e.pushCode("{0} = [];",i),"function"==typeof this.options.readUntil?e.pushCode("do {"):"eof"===this.options.readUntil?e.pushCode("for (var {0} = 0; offset < buffer.length; {0}++) {",o):e.pushCode("for (var {0} = 0; {0} < {1}; {0}++) {",o,t),"string"==typeof r?(e.pushCode("var {0} = buffer.read{1}(offset);",a,s[r]),e.pushCode("offset += {0};",p[s[r]])):r instanceof n&&(e.pushCode("var {0} = {};",a),e.pushScope(a),r.generate(e),e.popScope()),c?e.pushCode("{0}[{2}.{1}] = {2};",i,l,a):e.pushCode("{0}.push({1});",i,a),e.pushCode("}"),"function"==typeof this.options.readUntil&&e.pushCode(" while (!({0}).call(this, {1}, buffer.slice(offset)));",this.options.readUntil,a)},n.prototype.generateChoiceCase=function(e,t,r){"string"==typeof r?(e.pushCode("{0} = buffer.read{1}(offset);",e.generateVariable(this.varName),s[r]),e.pushCode("offset += {0};",p[s[r]])):r instanceof n&&(e.pushPath(t),r.generate(e),e.popPath())},n.prototype.generateChoice=function(e){var t=e.generateOption(this.options.tag);e.pushCode("{0} = {};",e.generateVariable(this.varName)),e.pushCode("switch({0}) {",t),Object.keys(this.options.choices).forEach(function(t){var r=this.options.choices[t];e.pushCode("case {0}:",t),this.generateChoiceCase(e,this.varName,r),e.pushCode("break;")},this),e.pushCode("default:"),this.options.defaultChoice?this.generateChoiceCase(e,this.varName,this.options.defaultChoice):e.generateError('"Met undefined tag value " + {0} + " at choice"',t),e.pushCode("}")},n.prototype.generateNest=function(e){var t=e.generateVariable(this.varName);e.pushCode("{0} = {};",t),e.pushPath(this.varName),this.options.type.generate(e),e.popPath()},n.prototype.generateFormatter=function(e,t,r){"function"==typeof r&&e.pushCode("{0} = ({1}).call(this, {0});",t,r)},n.prototype.isInteger=function(){return!!this.type.match(/U?Int[8|16|32][BE|LE]?|Bit\d+/)},t.Parser=n},function(e,t,r){"use strict";e.exports=i;var o=r(6),p=r(10);function i(e){if(!(this instanceof i))return new i(e);o.call(this,e),this._transformState={afterTransform:function(e,t){var r=this._transformState;r.transforming=!1;var o=r.writecb;if(!o)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),o(e);var p=this._readableState;p.reading=!1,(p.needReadable||p.length>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function n(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function a(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var o=r.charCodeAt(r.length-1);if(o>=55296&&o<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function l(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function c(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function u(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function f(e){return e&&e.length?this.write(e):""}t.StringDecoder=i,i.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return p>0&&(e.lastNeed=p-1),p;if(--o=0)return p>0&&(e.lastNeed=p-2),p;if(--o=0)return p>0&&(2===p?p=0:e.lastNeed=p-3),p;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var o=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,o),e.toString("utf8",t,o)},i.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,r){"use strict";var o=r(12);function p(e,t){e.emit("error",t)}e.exports={destroy:function(e,t){var r=this,i=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return i||s?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||o.nextTick(p,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(o.nextTick(p,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(e,t,r){e.exports=r(15).EventEmitter},function(e,t,r){"use strict";(function(t,o){var p=r(12);e.exports=w;var i,s=r(22);w.ReadableState=g;r(15).EventEmitter;var n=function(e,t){return e.listeners(t).length},a=r(20),l=r(11).Buffer,c=t.Uint8Array||function(){};var u=r(10);u.inherits=r(7);var h=r(59),f=void 0;f=h&&h.debuglog?h.debuglog("stream"):function(){};var y,d=r(58),_=r(19);u.inherits(w,a);var S=["error","close","destroy","pause","resume"];function g(e,t){i=i||r(6),e=e||{};var o=t instanceof i;this.objectMode=!!e.objectMode,o&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var p=e.highWaterMark,s=e.readableHighWaterMark,n=this.objectMode?16:16384;this.highWaterMark=p||0===p?p:o&&(s||0===s)?s:n,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(y||(y=r(18).StringDecoder),this.decoder=new y(e.encoding),this.encoding=e.encoding)}function w(e){if(i=i||r(6),!(this instanceof w))return new w(e);this._readableState=new g(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),a.call(this)}function E(e,t,r,o,p){var i,s=e._readableState;null===t?(s.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,L(e)}(e,s)):(p||(i=function(e,t){var r;o=t,l.isBuffer(o)||o instanceof c||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var o;return r}(s,t)),i?e.emit("error",i):s.objectMode||t&&t.length>0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===l.prototype||(t=function(e){return l.from(e)}(t)),o?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):m(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?m(e,s,t,!1):I(e,s)):m(e,s,t,!1))):o||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=b?e=b:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function L(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(f("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?p.nextTick(T,e):T(e))}function T(e){f("emit readable"),e.emit("readable"),A(e)}function I(e,t){t.readingMore||(t.readingMore=!0,p.nextTick(M,e,t))}function M(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var o;ei.length?i.length:e;if(s===i.length?p+=i:p+=i.slice(0,e),0===(e-=s)){s===i.length?(++o,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=i.slice(s));break}++o}return t.length-=o,p}(e,t):function(e,t){var r=l.allocUnsafe(e),o=t.head,p=1;o.data.copy(r),e-=o.data.length;for(;o=o.next;){var i=o.data,s=e>i.length?i.length:e;if(i.copy(r,r.length-e,0,s),0===(e-=s)){s===i.length?(++p,o.next?t.head=o.next:t.head=t.tail=null):(t.head=o,o.data=i.slice(s));break}++p}return t.length-=p,r}(e,t);return o}(e,t.buffer,t.decoder),r);var r}function G(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,p.nextTick(P,t,e))}function P(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function R(e,t){for(var r=0,o=e.length;r=t.highWaterMark||t.ended))return f("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?G(this):L(this),null;if(0===(e=v(e,t))&&t.ended)return 0===t.length&&G(this),null;var o,p=t.needReadable;return f("need readable",p),(0===t.length||t.length-e0?O(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&G(this)),null!==o&&this.emit("data",o),o},w.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},w.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,f("pipe count=%d opts=%j",i.pipesCount,t);var a=(!t||!1!==t.end)&&e!==o.stdout&&e!==o.stderr?c:w;function l(t,o){f("onunpipe"),t===r&&o&&!1===o.hasUnpiped&&(o.hasUnpiped=!0,f("cleanup"),e.removeListener("close",S),e.removeListener("finish",g),e.removeListener("drain",u),e.removeListener("error",_),e.removeListener("unpipe",l),r.removeListener("end",c),r.removeListener("end",w),r.removeListener("data",d),h=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||u())}function c(){f("onend"),e.end()}i.endEmitted?p.nextTick(a):r.once("end",a),e.on("unpipe",l);var u=function(e){return function(){var t=e._readableState;f("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&n(e,"data")&&(t.flowing=!0,A(e))}}(r);e.on("drain",u);var h=!1;var y=!1;function d(t){f("ondata"),y=!1,!1!==e.write(t)||y||((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==R(i.pipes,e))&&!h&&(f("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,y=!0),r.pause())}function _(t){f("onerror",t),w(),e.removeListener("error",_),0===n(e,"error")&&e.emit("error",t)}function S(){e.removeListener("finish",g),w()}function g(){f("onfinish"),e.removeListener("close",S),w()}function w(){f("unpipe"),r.unpipe(e)}return r.on("data",d),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",_),e.once("close",S),e.once("finish",g),e.emit("pipe",r),i.flowing||(f("pipe resume"),r.resume()),e},w.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var o=t.pipes,p=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i>>16,this._a32=65535&t,this._a48=t>>>16,this):(this._a00=0|e,this._a16=0|t,this._a32=0|r,this._a48=0|o,this)}function a(e){return this._a00=65535&e,this._a16=e>>>16,this._a32=0,this._a48=0,this}function l(e,t){t=t||10,this._a00=0,this._a16=0,this._a32=0,this._a48=0;for(var r=p[t]||new s(Math.pow(t,5)),o=0,i=e.length;o=0&&(r.div(t),o[p]=r.remainder.toNumber().toString(e),r.gt(t));p--);return o[p-1]=r.toNumber().toString(e),o.join("")},s.prototype.add=function(e){var t=this._a00+e._a00,r=t>>>16,o=(r+=this._a16+e._a16)>>>16,p=(o+=this._a32+e._a32)>>>16;return p+=this._a48+e._a48,this._a00=65535&t,this._a16=65535&r,this._a32=65535&o,this._a48=65535&p,this},s.prototype.subtract=function(e){return this.add(e.clone().negate())},s.prototype.multiply=function(e){var t=this._a00,r=this._a16,o=this._a32,p=this._a48,i=e._a00,s=e._a16,n=e._a32,a=e._a48,l=t*i,c=l>>>16,u=(c+=t*s)>>>16;c&=65535,u+=(c+=r*i)>>>16;var h=(u+=t*n)>>>16;return u&=65535,h+=(u+=r*s)>>>16,u&=65535,h+=(u+=o*i)>>>16,h+=t*a,h&=65535,h+=r*n,h&=65535,h+=o*s,h&=65535,h+=p*i,this._a00=65535&l,this._a16=65535&c,this._a32=65535&u,this._a48=65535&h,this},s.prototype.div=function(e){if(0==e._a16&&0==e._a32&&0==e._a48){if(0==e._a00)throw Error("division by zero");if(1==e._a00)return this.remainder=new s(0),this}if(e.gt(this))return this.remainder=this.clone(),this._a00=0,this._a16=0,this._a32=0,this._a48=0,this;if(this.eq(e))return this.remainder=new s(0),this._a00=1,this._a16=0,this._a32=0,this._a48=0,this;for(var t=e.clone(),r=-1;!this.lt(t);)t.shiftLeft(1,!0),r++;for(this.remainder=this.clone(),this._a00=0,this._a16=0,this._a32=0,this._a48=0;r>=0;r--)t.shiftRight(1),this.remainder.lt(t)||(this.remainder.subtract(t),r>=48?this._a48|=1<=32?this._a32|=1<=16?this._a16|=1<>>16),this._a16=65535&e,e=(65535&~this._a32)+(e>>>16),this._a32=65535&e,this._a48=~this._a48+(e>>>16)&65535,this},s.prototype.equals=s.prototype.eq=function(e){return this._a48==e._a48&&this._a00==e._a00&&this._a32==e._a32&&this._a16==e._a16},s.prototype.greaterThan=s.prototype.gt=function(e){return this._a48>e._a48||!(this._a48e._a32||!(this._a32e._a16||!(this._a16e._a00))},s.prototype.lessThan=s.prototype.lt=function(e){return this._a48e._a48)&&(this._a32e._a32)&&(this._a16e._a16)&&this._a00=48?(this._a00=this._a48>>e-48,this._a16=0,this._a32=0,this._a48=0):e>=32?(e-=32,this._a00=65535&(this._a32>>e|this._a48<<16-e),this._a16=this._a48>>e&65535,this._a32=0,this._a48=0):e>=16?(e-=16,this._a00=65535&(this._a16>>e|this._a32<<16-e),this._a16=65535&(this._a32>>e|this._a48<<16-e),this._a32=this._a48>>e&65535,this._a48=0):(this._a00=65535&(this._a00>>e|this._a16<<16-e),this._a16=65535&(this._a16>>e|this._a32<<16-e),this._a32=65535&(this._a32>>e|this._a48<<16-e),this._a48=this._a48>>e&65535),this},s.prototype.shiftLeft=s.prototype.shiftl=function(e,t){return(e%=64)>=48?(this._a48=this._a00<=32?(e-=32,this._a48=this._a16<>16-e,this._a32=this._a00<=16?(e-=16,this._a48=this._a32<>16-e,this._a32=65535&(this._a16<>16-e),this._a16=this._a00<>16-e,this._a32=65535&(this._a32<>16-e),this._a16=65535&(this._a16<>16-e),this._a00=this._a00<=32){var t=this._a00;if(this._a00=this._a32,this._a32=t,t=this._a48,this._a48=this._a16,this._a16=t,32==e)return this;e-=32}var r=this._a48<<16|this._a32,o=this._a16<<16|this._a00,p=r<>>32-e,i=o<>>32-e;return this._a00=65535&i,this._a16=i>>>16,this._a32=65535&p,this._a48=p>>>16,this},s.prototype.rotateRight=s.prototype.rotr=function(e){if(0==(e%=64))return this;if(e>=32){var t=this._a00;if(this._a00=this._a32,this._a32=t,t=this._a48,this._a48=this._a16,this._a16=t,32==e)return this;e-=32}var r=this._a48<<16|this._a32,o=this._a16<<16|this._a00,p=r>>>e|o<<32-e,i=o>>>e|r<<32-e;return this._a00=65535&i,this._a16=i>>>16,this._a32=65535&p,this._a48=p>>>16,this},s.prototype.clone=function(){return new s(this._a00,this._a16,this._a32,this._a48)},void 0===(o=function(){return s}.apply(t,[]))||(e.exports=o)}()},function(e,t,r){var o;!function(r){p(Math.pow(36,5)),p(Math.pow(16,7)),p(Math.pow(10,9)),p(Math.pow(2,30)),p(36),p(16),p(10),p(2);function p(e,t){return this instanceof p?(this._low=0,this._high=0,this.remainder=null,void 0===t?s.call(this,e):"string"==typeof e?n.call(this,e,t):void i.call(this,e,t)):new p(e,t)}function i(e,t){return this._low=0|e,this._high=0|t,this}function s(e){return this._low=65535&e,this._high=e>>>16,this}function n(e,t){var r=parseInt(e,t||10);return this._low=65535&r,this._high=r>>>16,this}p.prototype.fromBits=i,p.prototype.fromNumber=s,p.prototype.fromString=n,p.prototype.toNumber=function(){return 65536*this._high+this._low},p.prototype.toString=function(e){return this.toNumber().toString(e||10)},p.prototype.add=function(e){var t=this._low+e._low,r=t>>>16;return r+=this._high+e._high,this._low=65535&t,this._high=65535&r,this},p.prototype.subtract=function(e){return this.add(e.clone().negate())},p.prototype.multiply=function(e){var t,r,o=this._high,p=this._low,i=e._high,s=e._low;return t=(r=p*s)>>>16,t+=o*s,t&=65535,t+=p*i,this._low=65535&r,this._high=65535&t,this},p.prototype.div=function(e){if(0==e._low&&0==e._high)throw Error("division by zero");if(0==e._high&&1==e._low)return this.remainder=new p(0),this;if(e.gt(this))return this.remainder=this.clone(),this._low=0,this._high=0,this;if(this.eq(e))return this.remainder=new p(0),this._low=1,this._high=0,this;for(var t=e.clone(),r=-1;!this.lt(t);)t.shiftLeft(1,!0),r++;for(this.remainder=this.clone(),this._low=0,this._high=0;r>=0;r--)t.shiftRight(1),this.remainder.lt(t)||(this.remainder.subtract(t),r>=16?this._high|=1<>>16)&65535,this},p.prototype.equals=p.prototype.eq=function(e){return this._low==e._low&&this._high==e._high},p.prototype.greaterThan=p.prototype.gt=function(e){return this._high>e._high||!(this._highe._low},p.prototype.lessThan=p.prototype.lt=function(e){return this._highe._high)&&this._low16?(this._low=this._high>>e-16,this._high=0):16==e?(this._low=this._high,this._high=0):(this._low=this._low>>e|this._high<<16-e&65535,this._high>>=e),this},p.prototype.shiftLeft=p.prototype.shiftl=function(e,t){return e>16?(this._high=this._low<>16-e,this._low=this._low<>>32-e,this._low=65535&t,this._high=t>>>16,this},p.prototype.rotateRight=p.prototype.rotr=function(e){var t=this._high<<16|this._low;return t=t>>>e|t<<32-e,this._low=65535&t,this._high=t>>>16,this},p.prototype.clone=function(){return new p(this._low,this._high)},void 0===(o=function(){return p}.apply(t,[]))||(e.exports=o)}()},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},function(e,t){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(e,t,r){(function(e,o){var p=/%[sdj%]/g;t.format=function(e){if(!S(e)){for(var t=[],r=0;r=i)return e;switch(e){case"%s":return String(o[r++]);case"%d":return Number(o[r++]);case"%j":try{return JSON.stringify(o[r++])}catch(e){return"[Circular]"}default:return e}}),a=o[r];r=3&&(o.depth=arguments[2]),arguments.length>=4&&(o.colors=arguments[3]),y(r)?o.showHidden=r:r&&t._extend(o,r),g(o.showHidden)&&(o.showHidden=!1),g(o.depth)&&(o.depth=2),g(o.colors)&&(o.colors=!1),g(o.customInspect)&&(o.customInspect=!0),o.colors&&(o.stylize=a),c(o,e,o.depth)}function a(e,t){var r=n.styles[t];return r?"["+n.colors[r][0]+"m"+e+"["+n.colors[r][1]+"m":e}function l(e,t){return e}function c(e,r,o){if(e.customInspect&&r&&v(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var p=r.inspect(o,e);return S(p)||(p=c(e,p,o)),p}var i=function(e,t){if(g(t))return e.stylize("undefined","undefined");if(S(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(_(t))return e.stylize(""+t,"number");if(y(t))return e.stylize(""+t,"boolean");if(d(t))return e.stylize("null","null")}(e,r);if(i)return i;var s=Object.keys(r),n=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(r)),b(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return u(r);if(0===s.length){if(v(r)){var a=r.name?": "+r.name:"";return e.stylize("[Function"+a+"]","special")}if(w(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(m(r))return e.stylize(Date.prototype.toString.call(r),"date");if(b(r))return u(r)}var l,E="",L=!1,T=["{","}"];(f(r)&&(L=!0,T=["[","]"]),v(r))&&(E=" [Function"+(r.name?": "+r.name:"")+"]");return w(r)&&(E=" "+RegExp.prototype.toString.call(r)),m(r)&&(E=" "+Date.prototype.toUTCString.call(r)),b(r)&&(E=" "+u(r)),0!==s.length||L&&0!=r.length?o<0?w(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),l=L?function(e,t,r,o,p){for(var i=[],s=0,n=t.length;s=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(l,E,T)):T[0]+E+T[1]}function u(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,r,o,p,i){var s,n,a;if((a=Object.getOwnPropertyDescriptor(t,p)||{value:t[p]}).get?n=a.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):a.set&&(n=e.stylize("[Setter]","special")),M(o,p)||(s="["+p+"]"),n||(e.seen.indexOf(a.value)<0?(n=d(r)?c(e,a.value,null):c(e,a.value,r-1)).indexOf("\n")>-1&&(n=i?n.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+n.split("\n").map(function(e){return" "+e}).join("\n")):n=e.stylize("[Circular]","special")),g(s)){if(i&&p.match(/^\d+$/))return n;(s=JSON.stringify(""+p)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+n}function f(e){return Array.isArray(e)}function y(e){return"boolean"==typeof e}function d(e){return null===e}function _(e){return"number"==typeof e}function S(e){return"string"==typeof e}function g(e){return void 0===e}function w(e){return E(e)&&"[object RegExp]"===L(e)}function E(e){return"object"==typeof e&&null!==e}function m(e){return E(e)&&"[object Date]"===L(e)}function b(e){return E(e)&&("[object Error]"===L(e)||e instanceof Error)}function v(e){return"function"==typeof e}function L(e){return Object.prototype.toString.call(e)}function T(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(g(i)&&(i=o.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(i)){var r=o.pid;s[e]=function(){var o=t.format.apply(t,arguments);console.error("%s %d: %s",e,r,o)}}else s[e]=function(){};return s[e]},t.inspect=n,n.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},n.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=f,t.isBoolean=y,t.isNull=d,t.isNullOrUndefined=function(e){return null==e},t.isNumber=_,t.isString=S,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=g,t.isRegExp=w,t.isObject=E,t.isDate=m,t.isError=b,t.isFunction=v,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=r(46);var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){var e,r;console.log("%s - %s",(e=new Date,r=[T(e.getHours()),T(e.getMinutes()),T(e.getSeconds())].join(":"),[e.getDate(),I[e.getMonth()],r].join(" ")),t.format.apply(t,arguments))},t.inherits=r(45),t._extend=function(e,t){if(!t||!E(t))return e;for(var r=Object.keys(t),o=r.length;o--;)e[r[o]]=t[r[o]];return e}}).call(this,r(5),r(8))},function(e,t,r){"use strict";(function(t){ +var o=r(66),p=r(65),i=r(22);function s(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function n(e,t){if(s()=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function y(e,t){if(a.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var o=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(e).length;default:if(o)return B(e).length;t=(""+t).toLowerCase(),o=!0}}function d(e,t,r){var o=e[t];e[t]=e[r],e[r]=o}function _(e,t,r,o,p){if(0===e.length)return-1;if("string"==typeof r?(o=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=p?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(p)return-1;r=e.length-1}else if(r<0){if(!p)return-1;r=0}if("string"==typeof t&&(t=a.from(t,o)),a.isBuffer(t))return 0===t.length?-1:S(e,t,r,o,p);if("number"==typeof t)return t&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?p?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):S(e,[t],r,o,p);throw new TypeError("val must be string, number or Buffer")}function S(e,t,r,o,p){var i,s=1,n=e.length,a=t.length;if(void 0!==o&&("ucs2"===(o=String(o).toLowerCase())||"ucs-2"===o||"utf16le"===o||"utf-16le"===o)){if(e.length<2||t.length<2)return-1;s=2,n/=2,a/=2,r/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(p){var c=-1;for(i=r;in&&(r=n-a),i=r;i>=0;i--){for(var u=!0,h=0;hp&&(o=p):o=p;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");o>i/2&&(o=i/2);for(var s=0;s>8,p=r%256,i.push(p),i.push(o);return i}(t,e.length-r),e,r,o)}function L(e,t,r){return 0===t&&r===e.length?o.fromByteArray(e):o.fromByteArray(e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);for(var o=[],p=t;p239?4:l>223?3:l>191?2:1;if(p+u<=r)switch(u){case 1:l<128&&(c=l);break;case 2:128==(192&(i=e[p+1]))&&(a=(31&l)<<6|63&i)>127&&(c=a);break;case 3:i=e[p+1],s=e[p+2],128==(192&i)&&128==(192&s)&&(a=(15&l)<<12|(63&i)<<6|63&s)>2047&&(a<55296||a>57343)&&(c=a);break;case 4:i=e[p+1],s=e[p+2],n=e[p+3],128==(192&i)&&128==(192&s)&&128==(192&n)&&(a=(15&l)<<18|(63&i)<<12|(63&s)<<6|63&n)>65535&&a<1114112&&(c=a)}null===c?(c=65533,u=1):c>65535&&(c-=65536,o.push(c>>>10&1023|55296),c=56320|1023&c),o.push(c),p+=u}return function(e){var t=e.length;if(t<=I)return String.fromCharCode.apply(String,e);var r="",o=0;for(;othis.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return D(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return M(this,t,r);case"latin1":case"binary":return U(this,t,r);case"base64":return L(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return A(this,t,r);default:if(o)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}.apply(this,arguments)},a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===a.compare(this,e)},a.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},a.prototype.compare=function(e,t,r,o,p){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===o&&(o=0),void 0===p&&(p=this.length),t<0||r>e.length||o<0||p>this.length)throw new RangeError("out of range index");if(o>=p&&t>=r)return 0;if(o>=p)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,o>>>=0,p>>>=0,this===e)return 0;for(var i=p-o,s=r-t,n=Math.min(i,s),l=this.slice(o,p),c=e.slice(t,r),u=0;up)&&(r=p),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");for(var i=!1;;)switch(o){case"hex":return g(this,e,t,r);case"utf8":case"utf-8":return w(this,e,t,r);case"ascii":return E(this,e,t,r);case"latin1":case"binary":return m(this,e,t,r);case"base64":return b(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return v(this,e,t,r);default:if(i)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),i=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var I=4096;function M(e,t,r){var o="";r=Math.min(e.length,r);for(var p=t;po)&&(r=o);for(var p="",i=t;ir)throw new RangeError("Trying to access beyond buffer length")}function G(e,t,r,o,p,i){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>p||te.length)throw new RangeError("Index out of range")}function P(e,t,r,o){t<0&&(t=65535+t+1);for(var p=0,i=Math.min(e.length-r,2);p>>8*(o?p:1-p)}function R(e,t,r,o){t<0&&(t=4294967295+t+1);for(var p=0,i=Math.min(e.length-r,4);p>>8*(o?p:3-p)&255}function C(e,t,r,o,p,i){if(r+o>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function x(e,t,r,o,i){return i||C(e,0,r,4),p.write(e,t,r,o,23,4),r+4}function j(e,t,r,o,i){return i||C(e,0,r,8),p.write(e,t,r,o,52,8),r+8}a.prototype.slice=function(e,t){var r,o=this.length;if(e=~~e,t=void 0===t?o:~~t,e<0?(e+=o)<0&&(e=0):e>o&&(e=o),t<0?(t+=o)<0&&(t=0):t>o&&(t=o),t0&&(p*=256);)o+=this[e+--t]*p;return o},a.prototype.readUInt8=function(e,t){return t||O(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return t||O(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return t||O(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return t||O(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return t||O(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||O(e,t,this.length);for(var o=this[e],p=1,i=0;++i=(p*=128)&&(o-=Math.pow(2,8*t)),o},a.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||O(e,t,this.length);for(var o=t,p=1,i=this[e+--o];o>0&&(p*=256);)i+=this[e+--o]*p;return i>=(p*=128)&&(i-=Math.pow(2,8*t)),i},a.prototype.readInt8=function(e,t){return t||O(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){t||O(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){t||O(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return t||O(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return t||O(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return t||O(e,4,this.length),p.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return t||O(e,4,this.length),p.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return t||O(e,8,this.length),p.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return t||O(e,8,this.length),p.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,r,o){(e=+e,t|=0,r|=0,o)||G(this,e,t,r,Math.pow(2,8*r)-1,0);var p=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+p]=e/i&255;return t+r},a.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,1,255,0),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):R(this,e,t,!0),t+4},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):R(this,e,t,!1),t+4},a.prototype.writeIntLE=function(e,t,r,o){if(e=+e,t|=0,!o){var p=Math.pow(2,8*r-1);G(this,e,t,r,p-1,-p)}var i=0,s=1,n=0;for(this[t]=255&e;++i>0)-n&255;return t+r},a.prototype.writeIntBE=function(e,t,r,o){if(e=+e,t|=0,!o){var p=Math.pow(2,8*r-1);G(this,e,t,r,p-1,-p)}var i=r-1,s=1,n=0;for(this[t+i]=255&e;--i>=0&&(s*=256);)e<0&&0===n&&0!==this[t+i+1]&&(n=1),this[t+i]=(e/s>>0)-n&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,1,127,-128),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):P(this,e,t,!0),t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):P(this,e,t,!1),t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):R(this,e,t,!0),t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||G(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):R(this,e,t,!1),t+4},a.prototype.writeFloatLE=function(e,t,r){return x(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return x(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return j(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return j(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,o){if(r||(r=0),o||0===o||(o=this.length),t>=e.length&&(t=e.length),t||(t=0),o>0&&o=this.length)throw new RangeError("sourceStart out of bounds");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),e.length-t=0;--p)e[p+t]=this[p+r];else if(i<1e3||!a.TYPED_ARRAY_SUPPORT)for(p=0;p>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i55295&&r<57344){if(!p){if(r>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(s+1===o){(t-=3)>-1&&i.push(239,191,189);continue}p=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),p=r;continue}r=65536+(p-55296<<10|r-56320)}else p&&(t-=3)>-1&&i.push(239,191,189);if(p=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return i}function F(e){return o.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(N,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function q(e,t,r,o){for(var p=0;p=t.length||p>=e.length);++p)t[p+r]=e[p];return p}}).call(this,r(5))},function(e,t,r){(function(e){function r(e){return Object.prototype.toString.call(e)}t.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===r(e)},t.isBoolean=function(e){return"boolean"==typeof e},t.isNull=function(e){return null===e},t.isNullOrUndefined=function(e){return null==e},t.isNumber=function(e){return"number"==typeof e},t.isString=function(e){return"string"==typeof e},t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=function(e){return void 0===e},t.isRegExp=function(e){return"[object RegExp]"===r(e)},t.isObject=function(e){return"object"==typeof e&&null!==e},t.isDate=function(e){return"[object Date]"===r(e)},t.isError=function(e){return"[object Error]"===r(e)||e instanceof Error},t.isFunction=function(e){return"function"==typeof e},t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=e.isBuffer}).call(this,r(9).Buffer)},function(e,t,r){var o=r(9),p=o.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return p(e,t,r)}p.from&&p.alloc&&p.allocUnsafe&&p.allocUnsafeSlow?e.exports=o:(i(o,t),t.Buffer=s),i(p,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return p(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var o=p(e);return void 0!==t?"string"==typeof r?o.fill(t,r):o.fill(t):o.fill(0),o},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return p(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o.SlowBuffer(e)}},function(e,t,r){"use strict";(function(t){!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,o,p){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var i,s,n=arguments.length;switch(n){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,o)});case 4:return t.nextTick(function(){e.call(null,r,o,p)});default:for(i=new Array(n-1),s=0;s-1?o:i.nextTick;g.WritableState=S;var l=r(10);l.inherits=r(7);var c={deprecate:r(55)},u=r(20),h=r(11).Buffer,f=p.Uint8Array||function(){};var y,d=r(19);function _(){}function S(e,t){n=n||r(6),e=e||{};var o=t instanceof n;this.objectMode=!!e.objectMode,o&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var p=e.highWaterMark,l=e.writableHighWaterMark,c=this.objectMode?16:16384;this.highWaterMark=p||0===p?p:o&&(l||0===l)?l:c,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var u=!1===e.decodeStrings;this.decodeStrings=!u,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,o=r.sync,p=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,o,p){--t.pendingcb,r?(i.nextTick(p,o),i.nextTick(L,e,t),e._writableState.errorEmitted=!0,e.emit("error",o)):(p(o),e._writableState.errorEmitted=!0,e.emit("error",o),L(e,t))}(e,r,o,t,p);else{var s=b(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||m(e,r),o?a(E,e,r,s,p):E(e,r,s,p)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function g(e){if(n=n||r(6),!(y.call(g,this)||this instanceof n))return new g(e);this._writableState=new S(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),u.call(this)}function w(e,t,r,o,p,i,s){t.writelen=o,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(p,t.onwrite):e._write(p,i,t.onwrite),t.sync=!1}function E(e,t,r,o){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,o(),L(e,t)}function m(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var o=t.bufferedRequestCount,p=new Array(o),i=t.corkedRequestsFree;i.entry=r;for(var n=0,a=!0;r;)p[n]=r,r.isBuf||(a=!1),r=r.next,n+=1;p.allBuffers=a,w(e,t,!0,t.length,p,"",i.finish),t.pendingcb++,t.lastBufferedRequest=null,i.next?(t.corkedRequestsFree=i.next,i.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;r;){var l=r.chunk,c=r.encoding,u=r.callback;if(w(e,t,!1,t.objectMode?1:l.length,l,c,u),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function b(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function v(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),L(e,t)})}function L(e,t){var r=b(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,i.nextTick(v,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}l.inherits(g,u),S.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(S.prototype,"buffer",{get:c.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(y=Function.prototype[Symbol.hasInstance],Object.defineProperty(g,Symbol.hasInstance,{value:function(e){return!!y.call(this,e)||this===g&&(e&&e._writableState instanceof S)}})):y=function(e){return e instanceof this},g.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},g.prototype.write=function(e,t,r){var o,p=this._writableState,s=!1,n=!p.objectMode&&(o=e,h.isBuffer(o)||o instanceof f);return n&&!h.isBuffer(e)&&(e=function(e){return h.from(e)}(e)),"function"==typeof t&&(r=t,t=null),n?t="buffer":t||(t=p.defaultEncoding),"function"!=typeof r&&(r=_),p.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),i.nextTick(t,r)}(this,r):(n||function(e,t,r,o){var p=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),i.nextTick(o,s),p=!1),p}(this,p,e,r))&&(p.pendingcb++,s=function(e,t,r,o,p,i){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=h.from(t,r));return t}(t,o,p);o!==s&&(r=!0,p="buffer",o=s)}var n=t.objectMode?1:o.length;t.length+=n;var a=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(g.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),g.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},g.prototype._writev=null,g.prototype.end=function(e,t,r){var o=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!==e&&void 0!==e&&this.write(e,t),o.corked&&(o.corked=1,this.uncork()),o.ending||o.finished||function(e,t,r){t.ending=!0,L(e,t),r&&(t.finished?i.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,o,r)},Object.defineProperty(g.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),g.prototype.destroy=d.destroy,g.prototype._undestroy=d.undestroy,g.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,r(8),r(57).setImmediate,r(5))},function(e,t,r){(t=e.exports=r(21)).Stream=t,t.Readable=t,t.Writable=r(13),t.Duplex=r(6),t.Transform=r(17),t.PassThrough=r(54)},function(e,t){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function o(e){return"function"==typeof e}function p(e){return"object"==typeof e&&null!==e}function i(e){return void 0===e}e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,r,s,n,a,l;if(this._events||(this._events={}),"error"===e&&(!this._events.error||p(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}if(i(r=this._events[e]))return!1;if(o(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:n=Array.prototype.slice.call(arguments,1),r.apply(this,n)}else if(p(r))for(n=Array.prototype.slice.call(arguments,1),s=(l=r.slice()).length,a=0;a0&&this._events[e].length>s&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){if(!o(t))throw TypeError("listener must be a function");var r=!1;function p(){this.removeListener(e,p),r||(r=!0,t.apply(this,arguments))}return p.listener=t,this.on(e,p),this},r.prototype.removeListener=function(e,t){var r,i,s,n;if(!o(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(s=(r=this._events[e]).length,i=-1,r===t||o(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(p(r)){for(n=s;n-- >0;)if(r[n]===t||r[n].listener&&r[n].listener===t){i=n;break}if(i<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(o(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?o(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(o(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t,r){var o=r(63).Context,p={UInt8:1,UInt16LE:2,UInt16BE:2,UInt32LE:4,UInt32BE:4,Int8:1,Int16LE:2,Int16BE:2,Int32LE:4,Int32BE:4,FloatLE:4,FloatBE:4,DoubleLE:8,DoubleBE:8},i=[];!function(){var e;for(e=1;e<=32;e++)i.push(e)}();var s={};Object.keys(p).concat(Object.keys({String:null,Buffer:null,Array:null,Skip:null,Choice:null,Nest:null,Bit:null})).forEach(function(e){s[e.toLowerCase()]=e});var n=function(){this.varName="",this.type="",this.options={},this.next=null,this.head=null,this.compiled=null,this.endian="be",this.constructorFn=null};n.start=function(){return new n},Object.keys(p).forEach(function(e){n.prototype[e.toLowerCase()]=function(t,r){return this.setNextParser(e.toLowerCase(),t,r)};var t=e.replace(/BE|LE/,"").toLowerCase();t in n.prototype||(n.prototype[t]=function(e,r){return this[t+this.endian](e,r)})}),i.forEach(function(e){n.prototype["bit"+e.toString()]=function(t,r){return r||(r={}),r.length=e,this.setNextParser("bit",t,r)}}),n.prototype.skip=function(e,t){if(t&&t.assert)throw new Error("assert option on skip is not allowed.");return this.setNextParser("skip","",{length:e})},n.prototype.string=function(e,t){if(!t.zeroTerminated&&!t.length&&!t.greedy)throw new Error("Neither length, zeroTerminated, nor greedy is defined for string.");if((t.zeroTerminated||t.length)&&t.greedy)throw new Error("greedy is mutually exclusive with length and zeroTerminated for string.");if(t.stripNull&&!t.length&&!t.greedy)throw new Error("Length or greedy must be defined if stripNull is defined.");return t.encoding=t.encoding||"utf8",this.setNextParser("string",e,t)},n.prototype.buffer=function(e,t){if(!t.length&&!t.readUntil)throw new Error("Length nor readUntil is defined in buffer parser");return this.setNextParser("buffer",e,t)},n.prototype.array=function(e,t){if(!t.readUntil&&!t.length)throw new Error("Length option of array is not defined.");if(!t.type)throw new Error("Type option of array is not defined.");if("string"==typeof t.type&&Object.keys(p).indexOf(s[t.type])<0)throw new Error('Specified primitive type "'+t.type+'" is not supported.');return this.setNextParser("array",e,t)},n.prototype.choice=function(e,t){if(!t.tag)throw new Error("Tag option of array is not defined.");if(!t.choices)throw new Error("Choices option of array is not defined.");return Object.keys(t.choices).forEach(function(r){if(isNaN(parseInt(r,10)))throw new Error("Key of choices must be a number.");if(!t.choices[r])throw new Error("Choice Case "+r+" of "+e+" is not valid.");if("string"==typeof t.choices[r]&&Object.keys(p).indexOf(s[t.choices[r]])<0)throw new Error('Specified primitive type "'+t.choices[r]+'" is not supported.')}),this.setNextParser("choice",e,t)},n.prototype.nest=function(e,t){if(!t.type)throw new Error("Type option of nest is not defined.");if(!(t.type instanceof n))throw new Error("Type option of nest must be a Parser object.");return this.setNextParser("nest",e,t)},n.prototype.endianess=function(e){switch(e.toLowerCase()){case"little":this.endian="le";break;case"big":this.endian="be";break;default:throw new Error("Invalid endianess: "+e)}return this},n.prototype.create=function(e){if(!(e instanceof Function))throw new Error("Constructor must be a Function object.");return this.constructorFn=e,this},n.prototype.getCode=function(){var e=new o;return this.constructorFn?e.pushCode("var vars = new constructorFn();"):e.pushCode("var vars = {};"),e.pushCode("var offset = 0;"),e.pushCode("if (!Buffer.isBuffer(buffer)) {"),e.generateError('"argument buffer is not a Buffer object"'),e.pushCode("}"),this.generate(e),e.pushCode("return vars;"),e.code},n.prototype.compile=function(){this.compiled=new Function("buffer","callback","constructorFn",this.getCode())},n.prototype.sizeOf=function(){var e=NaN;if(Object.keys(p).indexOf(this.type)>=0)e=p[this.type];else if("String"===this.type&&"number"==typeof this.options.length)e=this.options.length;else if("Array"===this.type&&"number"==typeof this.options.length){var t=NaN;"string"==typeof this.options.type?t=p[s[this.options.type]]:this.options.type instanceof n&&(t=this.options.type.sizeOf()),e=this.options.length*t}else"Skip"===this.type?e=this.options.length:this.type||(e=0);return this.next&&(e+=this.next.sizeOf()),e},n.prototype.parse=function(e,t){return this.compiled||this.compile(),this.compiled(e,t,this.constructorFn)},n.prototype.setNextParser=function(e,t,r){var o=new n;return o.type=s[e],o.varName=t,o.options=r||o.options,o.endian=this.endian,this.head?this.head.next=o:this.next=o,this.head=o,this},n.prototype.generate=function(e){this.type&&(this["generate"+this.type](e),this.generateAssert(e));var t=e.generateVariable(this.varName);return this.options.formatter&&this.generateFormatter(e,t,this.options.formatter),this.generateNext(e)},n.prototype.generateAssert=function(e){if(this.options.assert){var t=e.generateVariable(this.varName);switch(typeof this.options.assert){case"function":e.pushCode("if (!({0}).call(vars, {1})) {",this.options.assert,t);break;case"number":e.pushCode("if ({0} !== {1}) {",this.options.assert,t);break;case"string":e.pushCode('if ("{0}" !== {1}) {',this.options.assert,t);break;default:throw new Error("Assert option supports only strings, numbers and assert functions.")}e.generateError('"Assert error: {0} is " + {0}',t),e.pushCode("}")}},n.prototype.generateNext=function(e){return this.next&&(e=this.next.generate(e)),e},Object.keys(p).forEach(function(e){n.prototype["generate"+e]=function(t){t.pushCode("{0} = buffer.read{1}(offset);",t.generateVariable(this.varName),e),t.pushCode("offset += {0};",p[e])}}),n.prototype.generateBit=function(e){var t=JSON.parse(JSON.stringify(this));if(t.varName=e.generateVariable(t.varName),e.bitFields.push(t),!this.next||this.next&&["Bit","Nest"].indexOf(this.next.type)<0){var r=0;e.bitFields.forEach(function(e){r+=e.options.length});var o=e.generateTmpVariable();if(r<=8)e.pushCode("var {0} = buffer.readUInt8(offset);",o),r=8;else if(r<=16)e.pushCode("var {0} = buffer.readUInt16BE(offset);",o),r=16;else if(r<=24){var p=e.generateTmpVariable(),i=e.generateTmpVariable();e.pushCode("var {0} = buffer.readUInt16BE(offset);",p),e.pushCode("var {0} = buffer.readUInt8(offset + 2);",i),e.pushCode("var {2} = ({0} << 8) | {1};",p,i,o),r=24}else{if(!(r<=32))throw new Error("Currently, bit field sequence longer than 4-bytes is not supported.");e.pushCode("var {0} = buffer.readUInt32BE(offset);",o),r=32}e.pushCode("offset += {0};",r/8);var s=0,n="be"===this.endian;e.bitFields.forEach(function(t){e.pushCode("{0} = {1} >> {2} & {3};",t.varName,o,n?r-s-t.options.length:s,(1< offset++);"),e.pushCode("{0} = buffer.toString('{1}', {2}, offset);",t,this.options.encoding,r)),this.options.stripNull&&e.pushCode("{0} = {0}.replace(/\\x00+$/g, '')",t)},n.prototype.generateBuffer=function(e){if("eof"===this.options.readUntil?e.pushCode("{0} = buffer.slice(offset, buffer.length - 1);",e.generateVariable(this.varName)):(e.pushCode("{0} = buffer.slice(offset, offset + {1});",e.generateVariable(this.varName),e.generateOption(this.options.length)),e.pushCode("offset += {0};",e.generateOption(this.options.length))),this.options.clone){var t=e.generateTmpVariable();e.pushCode("var {0} = new Buffer({1}.length);",t,e.generateVariable(this.varName)),e.pushCode("{0}.copy({1});",e.generateVariable(this.varName),t),e.pushCode("{0} = {1}",e.generateVariable(this.varName),t)}},n.prototype.generateArray=function(e){var t=e.generateOption(this.options.length),r=this.options.type,o=e.generateTmpVariable(),i=e.generateVariable(this.varName),a=e.generateTmpVariable(),l=this.options.key,c="string"==typeof l;c?e.pushCode("{0} = {};",i):e.pushCode("{0} = [];",i),"function"==typeof this.options.readUntil?e.pushCode("do {"):"eof"===this.options.readUntil?e.pushCode("for (var {0} = 0; offset < buffer.length; {0}++) {",o):e.pushCode("for (var {0} = 0; {0} < {1}; {0}++) {",o,t),"string"==typeof r?(e.pushCode("var {0} = buffer.read{1}(offset);",a,s[r]),e.pushCode("offset += {0};",p[s[r]])):r instanceof n&&(e.pushCode("var {0} = {};",a),e.pushScope(a),r.generate(e),e.popScope()),c?e.pushCode("{0}[{2}.{1}] = {2};",i,l,a):e.pushCode("{0}.push({1});",i,a),e.pushCode("}"),"function"==typeof this.options.readUntil&&e.pushCode(" while (!({0}).call(this, {1}, buffer.slice(offset)));",this.options.readUntil,a)},n.prototype.generateChoiceCase=function(e,t,r){"string"==typeof r?(e.pushCode("{0} = buffer.read{1}(offset);",e.generateVariable(this.varName),s[r]),e.pushCode("offset += {0};",p[s[r]])):r instanceof n&&(e.pushPath(t),r.generate(e),e.popPath())},n.prototype.generateChoice=function(e){var t=e.generateOption(this.options.tag);e.pushCode("{0} = {};",e.generateVariable(this.varName)),e.pushCode("switch({0}) {",t),Object.keys(this.options.choices).forEach(function(t){var r=this.options.choices[t];e.pushCode("case {0}:",t),this.generateChoiceCase(e,this.varName,r),e.pushCode("break;")},this),e.pushCode("default:"),this.options.defaultChoice?this.generateChoiceCase(e,this.varName,this.options.defaultChoice):e.generateError('"Met undefined tag value " + {0} + " at choice"',t),e.pushCode("}")},n.prototype.generateNest=function(e){var t=e.generateVariable(this.varName);e.pushCode("{0} = {};",t),e.pushPath(this.varName),this.options.type.generate(e),e.popPath()},n.prototype.generateFormatter=function(e,t,r){"function"==typeof r&&e.pushCode("{0} = ({1}).call(this, {0});",t,r)},n.prototype.isInteger=function(){return!!this.type.match(/U?Int[8|16|32][BE|LE]?|Bit\d+/)},t.Parser=n},function(e,t,r){"use strict";e.exports=i;var o=r(6),p=r(10);function i(e){if(!(this instanceof i))return new i(e);o.call(this,e),this._transformState={afterTransform:function(e,t){var r=this._transformState;r.transforming=!1;var o=r.writecb;if(!o)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),o(e);var p=this._readableState;p.reading=!1,(p.needReadable||p.length>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function n(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function a(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var o=r.charCodeAt(r.length-1);if(o>=55296&&o<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function l(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function c(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function u(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function h(e){return e.toString(this.encoding)}function f(e){return e&&e.length?this.write(e):""}t.StringDecoder=i,i.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return p>0&&(e.lastNeed=p-1),p;if(--o=0)return p>0&&(e.lastNeed=p-2),p;if(--o=0)return p>0&&(2===p?p=0:e.lastNeed=p-3),p;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var o=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,o),e.toString("utf8",t,o)},i.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,r){"use strict";var o=r(12);function p(e,t){e.emit("error",t)}e.exports={destroy:function(e,t){var r=this,i=this._readableState&&this._readableState.destroyed,s=this._writableState&&this._writableState.destroyed;return i||s?(t?t(e):!e||this._writableState&&this._writableState.errorEmitted||o.nextTick(p,this,e),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(e){!t&&e?(o.nextTick(p,r,e),r._writableState&&(r._writableState.errorEmitted=!0)):t&&t(e)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}}},function(e,t,r){e.exports=r(15).EventEmitter},function(e,t,r){"use strict";(function(t,o){var p=r(12);e.exports=w;var i,s=r(22);w.ReadableState=g;r(15).EventEmitter;var n=function(e,t){return e.listeners(t).length},a=r(20),l=r(11).Buffer,c=t.Uint8Array||function(){};var u=r(10);u.inherits=r(7);var h=r(60),f=void 0;f=h&&h.debuglog?h.debuglog("stream"):function(){};var y,d=r(59),_=r(19);u.inherits(w,a);var S=["error","close","destroy","pause","resume"];function g(e,t){i=i||r(6),e=e||{};var o=t instanceof i;this.objectMode=!!e.objectMode,o&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var p=e.highWaterMark,s=e.readableHighWaterMark,n=this.objectMode?16:16384;this.highWaterMark=p||0===p?p:o&&(s||0===s)?s:n,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(y||(y=r(18).StringDecoder),this.decoder=new y(e.encoding),this.encoding=e.encoding)}function w(e){if(i=i||r(6),!(this instanceof w))return new w(e);this._readableState=new g(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),a.call(this)}function E(e,t,r,o,p){var i,s=e._readableState;null===t?(s.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,L(e)}(e,s)):(p||(i=function(e,t){var r;o=t,l.isBuffer(o)||o instanceof c||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var o;return r}(s,t)),i?e.emit("error",i):s.objectMode||t&&t.length>0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===l.prototype||(t=function(e){return l.from(e)}(t)),o?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):m(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?m(e,s,t,!1):I(e,s)):m(e,s,t,!1))):o||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=b?e=b:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function L(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(f("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?p.nextTick(T,e):T(e))}function T(e){f("emit readable"),e.emit("readable"),A(e)}function I(e,t){t.readingMore||(t.readingMore=!0,p.nextTick(M,e,t))}function M(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var o;ei.length?i.length:e;if(s===i.length?p+=i:p+=i.slice(0,e),0===(e-=s)){s===i.length?(++o,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=i.slice(s));break}++o}return t.length-=o,p}(e,t):function(e,t){var r=l.allocUnsafe(e),o=t.head,p=1;o.data.copy(r),e-=o.data.length;for(;o=o.next;){var i=o.data,s=e>i.length?i.length:e;if(i.copy(r,r.length-e,0,s),0===(e-=s)){s===i.length?(++p,o.next?t.head=o.next:t.head=t.tail=null):(t.head=o,o.data=i.slice(s));break}++p}return t.length-=p,r}(e,t);return o}(e,t.buffer,t.decoder),r);var r}function G(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,p.nextTick(P,t,e))}function P(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function R(e,t){for(var r=0,o=e.length;r=t.highWaterMark||t.ended))return f("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?G(this):L(this),null;if(0===(e=v(e,t))&&t.ended)return 0===t.length&&G(this),null;var o,p=t.needReadable;return f("need readable",p),(0===t.length||t.length-e0?O(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&G(this)),null!==o&&this.emit("data",o),o},w.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},w.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,f("pipe count=%d opts=%j",i.pipesCount,t);var a=(!t||!1!==t.end)&&e!==o.stdout&&e!==o.stderr?c:w;function l(t,o){f("onunpipe"),t===r&&o&&!1===o.hasUnpiped&&(o.hasUnpiped=!0,f("cleanup"),e.removeListener("close",S),e.removeListener("finish",g),e.removeListener("drain",u),e.removeListener("error",_),e.removeListener("unpipe",l),r.removeListener("end",c),r.removeListener("end",w),r.removeListener("data",d),h=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||u())}function c(){f("onend"),e.end()}i.endEmitted?p.nextTick(a):r.once("end",a),e.on("unpipe",l);var u=function(e){return function(){var t=e._readableState;f("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&n(e,"data")&&(t.flowing=!0,A(e))}}(r);e.on("drain",u);var h=!1;var y=!1;function d(t){f("ondata"),y=!1,!1!==e.write(t)||y||((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==R(i.pipes,e))&&!h&&(f("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,y=!0),r.pause())}function _(t){f("onerror",t),w(),e.removeListener("error",_),0===n(e,"error")&&e.emit("error",t)}function S(){e.removeListener("finish",g),w()}function g(){f("onfinish"),e.removeListener("close",S),w()}function w(){f("unpipe"),r.unpipe(e)}return r.on("data",d),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",_),e.once("close",S),e.once("finish",g),e.emit("pipe",r),i.flowing||(f("pipe resume"),r.resume()),e},w.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var o=t.pipes,p=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i>>16,this._a32=65535&t,this._a48=t>>>16,this):(this._a00=0|e,this._a16=0|t,this._a32=0|r,this._a48=0|o,this)}function a(e){return this._a00=65535&e,this._a16=e>>>16,this._a32=0,this._a48=0,this}function l(e,t){t=t||10,this._a00=0,this._a16=0,this._a32=0,this._a48=0;for(var r=p[t]||new s(Math.pow(t,5)),o=0,i=e.length;o=0&&(r.div(t),o[p]=r.remainder.toNumber().toString(e),r.gt(t));p--);return o[p-1]=r.toNumber().toString(e),o.join("")},s.prototype.add=function(e){var t=this._a00+e._a00,r=t>>>16,o=(r+=this._a16+e._a16)>>>16,p=(o+=this._a32+e._a32)>>>16;return p+=this._a48+e._a48,this._a00=65535&t,this._a16=65535&r,this._a32=65535&o,this._a48=65535&p,this},s.prototype.subtract=function(e){return this.add(e.clone().negate())},s.prototype.multiply=function(e){var t=this._a00,r=this._a16,o=this._a32,p=this._a48,i=e._a00,s=e._a16,n=e._a32,a=e._a48,l=t*i,c=l>>>16,u=(c+=t*s)>>>16;c&=65535,u+=(c+=r*i)>>>16;var h=(u+=t*n)>>>16;return u&=65535,h+=(u+=r*s)>>>16,u&=65535,h+=(u+=o*i)>>>16,h+=t*a,h&=65535,h+=r*n,h&=65535,h+=o*s,h&=65535,h+=p*i,this._a00=65535&l,this._a16=65535&c,this._a32=65535&u,this._a48=65535&h,this},s.prototype.div=function(e){if(0==e._a16&&0==e._a32&&0==e._a48){if(0==e._a00)throw Error("division by zero");if(1==e._a00)return this.remainder=new s(0),this}if(e.gt(this))return this.remainder=this.clone(),this._a00=0,this._a16=0,this._a32=0,this._a48=0,this;if(this.eq(e))return this.remainder=new s(0),this._a00=1,this._a16=0,this._a32=0,this._a48=0,this;for(var t=e.clone(),r=-1;!this.lt(t);)t.shiftLeft(1,!0),r++;for(this.remainder=this.clone(),this._a00=0,this._a16=0,this._a32=0,this._a48=0;r>=0;r--)t.shiftRight(1),this.remainder.lt(t)||(this.remainder.subtract(t),r>=48?this._a48|=1<=32?this._a32|=1<=16?this._a16|=1<>>16),this._a16=65535&e,e=(65535&~this._a32)+(e>>>16),this._a32=65535&e,this._a48=~this._a48+(e>>>16)&65535,this},s.prototype.equals=s.prototype.eq=function(e){return this._a48==e._a48&&this._a00==e._a00&&this._a32==e._a32&&this._a16==e._a16},s.prototype.greaterThan=s.prototype.gt=function(e){return this._a48>e._a48||!(this._a48e._a32||!(this._a32e._a16||!(this._a16e._a00))},s.prototype.lessThan=s.prototype.lt=function(e){return this._a48e._a48)&&(this._a32e._a32)&&(this._a16e._a16)&&this._a00=48?(this._a00=this._a48>>e-48,this._a16=0,this._a32=0,this._a48=0):e>=32?(e-=32,this._a00=65535&(this._a32>>e|this._a48<<16-e),this._a16=this._a48>>e&65535,this._a32=0,this._a48=0):e>=16?(e-=16,this._a00=65535&(this._a16>>e|this._a32<<16-e),this._a16=65535&(this._a32>>e|this._a48<<16-e),this._a32=this._a48>>e&65535,this._a48=0):(this._a00=65535&(this._a00>>e|this._a16<<16-e),this._a16=65535&(this._a16>>e|this._a32<<16-e),this._a32=65535&(this._a32>>e|this._a48<<16-e),this._a48=this._a48>>e&65535),this},s.prototype.shiftLeft=s.prototype.shiftl=function(e,t){return(e%=64)>=48?(this._a48=this._a00<=32?(e-=32,this._a48=this._a16<>16-e,this._a32=this._a00<=16?(e-=16,this._a48=this._a32<>16-e,this._a32=65535&(this._a16<>16-e),this._a16=this._a00<>16-e,this._a32=65535&(this._a32<>16-e),this._a16=65535&(this._a16<>16-e),this._a00=this._a00<=32){var t=this._a00;if(this._a00=this._a32,this._a32=t,t=this._a48,this._a48=this._a16,this._a16=t,32==e)return this;e-=32}var r=this._a48<<16|this._a32,o=this._a16<<16|this._a00,p=r<>>32-e,i=o<>>32-e;return this._a00=65535&i,this._a16=i>>>16,this._a32=65535&p,this._a48=p>>>16,this},s.prototype.rotateRight=s.prototype.rotr=function(e){if(0==(e%=64))return this;if(e>=32){var t=this._a00;if(this._a00=this._a32,this._a32=t,t=this._a48,this._a48=this._a16,this._a16=t,32==e)return this;e-=32}var r=this._a48<<16|this._a32,o=this._a16<<16|this._a00,p=r>>>e|o<<32-e,i=o>>>e|r<<32-e;return this._a00=65535&i,this._a16=i>>>16,this._a32=65535&p,this._a48=p>>>16,this},s.prototype.clone=function(){return new s(this._a00,this._a16,this._a32,this._a48)},void 0===(o=function(){return s}.apply(t,[]))||(e.exports=o)}()},function(e,t,r){var o;!function(r){p(Math.pow(36,5)),p(Math.pow(16,7)),p(Math.pow(10,9)),p(Math.pow(2,30)),p(36),p(16),p(10),p(2);function p(e,t){return this instanceof p?(this._low=0,this._high=0,this.remainder=null,void 0===t?s.call(this,e):"string"==typeof e?n.call(this,e,t):void i.call(this,e,t)):new p(e,t)}function i(e,t){return this._low=0|e,this._high=0|t,this}function s(e){return this._low=65535&e,this._high=e>>>16,this}function n(e,t){var r=parseInt(e,t||10);return this._low=65535&r,this._high=r>>>16,this}p.prototype.fromBits=i,p.prototype.fromNumber=s,p.prototype.fromString=n,p.prototype.toNumber=function(){return 65536*this._high+this._low},p.prototype.toString=function(e){return this.toNumber().toString(e||10)},p.prototype.add=function(e){var t=this._low+e._low,r=t>>>16;return r+=this._high+e._high,this._low=65535&t,this._high=65535&r,this},p.prototype.subtract=function(e){return this.add(e.clone().negate())},p.prototype.multiply=function(e){var t,r,o=this._high,p=this._low,i=e._high,s=e._low;return t=(r=p*s)>>>16,t+=o*s,t&=65535,t+=p*i,this._low=65535&r,this._high=65535&t,this},p.prototype.div=function(e){if(0==e._low&&0==e._high)throw Error("division by zero");if(0==e._high&&1==e._low)return this.remainder=new p(0),this;if(e.gt(this))return this.remainder=this.clone(),this._low=0,this._high=0,this;if(this.eq(e))return this.remainder=new p(0),this._low=1,this._high=0,this;for(var t=e.clone(),r=-1;!this.lt(t);)t.shiftLeft(1,!0),r++;for(this.remainder=this.clone(),this._low=0,this._high=0;r>=0;r--)t.shiftRight(1),this.remainder.lt(t)||(this.remainder.subtract(t),r>=16?this._high|=1<>>16)&65535,this},p.prototype.equals=p.prototype.eq=function(e){return this._low==e._low&&this._high==e._high},p.prototype.greaterThan=p.prototype.gt=function(e){return this._high>e._high||!(this._highe._low},p.prototype.lessThan=p.prototype.lt=function(e){return this._highe._high)&&this._low16?(this._low=this._high>>e-16,this._high=0):16==e?(this._low=this._high,this._high=0):(this._low=this._low>>e|this._high<<16-e&65535,this._high>>=e),this},p.prototype.shiftLeft=p.prototype.shiftl=function(e,t){return e>16?(this._high=this._low<>16-e,this._low=this._low<>>32-e,this._low=65535&t,this._high=t>>>16,this},p.prototype.rotateRight=p.prototype.rotr=function(e){var t=this._high<<16|this._low;return t=t>>>e|t<<32-e,this._low=65535&t,this._high=t>>>16,this},p.prototype.clone=function(){return new p(this._low,this._high)},void 0===(o=function(){return p}.apply(t,[]))||(e.exports=o)}()},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}},function(e,t){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(e,t,r){(function(e,o){var p=/%[sdj%]/g;t.format=function(e){if(!S(e)){for(var t=[],r=0;r=i)return e;switch(e){case"%s":return String(o[r++]);case"%d":return Number(o[r++]);case"%j":try{return JSON.stringify(o[r++])}catch(e){return"[Circular]"}default:return e}}),a=o[r];r=3&&(o.depth=arguments[2]),arguments.length>=4&&(o.colors=arguments[3]),y(r)?o.showHidden=r:r&&t._extend(o,r),g(o.showHidden)&&(o.showHidden=!1),g(o.depth)&&(o.depth=2),g(o.colors)&&(o.colors=!1),g(o.customInspect)&&(o.customInspect=!0),o.colors&&(o.stylize=a),c(o,e,o.depth)}function a(e,t){var r=n.styles[t];return r?"["+n.colors[r][0]+"m"+e+"["+n.colors[r][1]+"m":e}function l(e,t){return e}function c(e,r,o){if(e.customInspect&&r&&v(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var p=r.inspect(o,e);return S(p)||(p=c(e,p,o)),p}var i=function(e,t){if(g(t))return e.stylize("undefined","undefined");if(S(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(_(t))return e.stylize(""+t,"number");if(y(t))return e.stylize(""+t,"boolean");if(d(t))return e.stylize("null","null")}(e,r);if(i)return i;var s=Object.keys(r),n=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(r)),b(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return u(r);if(0===s.length){if(v(r)){var a=r.name?": "+r.name:"";return e.stylize("[Function"+a+"]","special")}if(w(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(m(r))return e.stylize(Date.prototype.toString.call(r),"date");if(b(r))return u(r)}var l,E="",L=!1,T=["{","}"];(f(r)&&(L=!0,T=["[","]"]),v(r))&&(E=" [Function"+(r.name?": "+r.name:"")+"]");return w(r)&&(E=" "+RegExp.prototype.toString.call(r)),m(r)&&(E=" "+Date.prototype.toUTCString.call(r)),b(r)&&(E=" "+u(r)),0!==s.length||L&&0!=r.length?o<0?w(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),l=L?function(e,t,r,o,p){for(var i=[],s=0,n=t.length;s=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(l,E,T)):T[0]+E+T[1]}function u(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,r,o,p,i){var s,n,a;if((a=Object.getOwnPropertyDescriptor(t,p)||{value:t[p]}).get?n=a.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):a.set&&(n=e.stylize("[Setter]","special")),M(o,p)||(s="["+p+"]"),n||(e.seen.indexOf(a.value)<0?(n=d(r)?c(e,a.value,null):c(e,a.value,r-1)).indexOf("\n")>-1&&(n=i?n.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+n.split("\n").map(function(e){return" "+e}).join("\n")):n=e.stylize("[Circular]","special")),g(s)){if(i&&p.match(/^\d+$/))return n;(s=JSON.stringify(""+p)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+n}function f(e){return Array.isArray(e)}function y(e){return"boolean"==typeof e}function d(e){return null===e}function _(e){return"number"==typeof e}function S(e){return"string"==typeof e}function g(e){return void 0===e}function w(e){return E(e)&&"[object RegExp]"===L(e)}function E(e){return"object"==typeof e&&null!==e}function m(e){return E(e)&&"[object Date]"===L(e)}function b(e){return E(e)&&("[object Error]"===L(e)||e instanceof Error)}function v(e){return"function"==typeof e}function L(e){return Object.prototype.toString.call(e)}function T(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(g(i)&&(i=o.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(i)){var r=o.pid;s[e]=function(){var o=t.format.apply(t,arguments);console.error("%s %d: %s",e,r,o)}}else s[e]=function(){};return s[e]},t.inspect=n,n.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},n.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=f,t.isBoolean=y,t.isNull=d,t.isNullOrUndefined=function(e){return null==e},t.isNumber=_,t.isString=S,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=g,t.isRegExp=w,t.isObject=E,t.isDate=m,t.isError=b,t.isFunction=v,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=r(47);var I=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){var e,r;console.log("%s - %s",(e=new Date,r=[T(e.getHours()),T(e.getMinutes()),T(e.getSeconds())].join(":"),[e.getDate(),I[e.getMonth()],r].join(" ")),t.format.apply(t,arguments))},t.inherits=r(46),t._extend=function(e,t){if(!t||!E(t))return e;for(var r=Object.keys(t),o=r.length;o--;)e[r[o]]=t[r[o]];return e}}).call(this,r(5),r(8))},function(e,t,r){"use strict";(function(t){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ -function o(e,t){if(e===t)return 0;for(var r=e.length,o=t.length,p=0,i=Math.min(r,o);p=0;l--)if(c[l]!==u[l])return!1;for(l=c.length-1;l>=0;l--)if(a=c[l],!g(e[a],t[a],r,o))return!1;return!0}(e,t,r,s))}return r?e===t:e==t}function w(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function E(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function m(e,t,r,o){var p;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(o=r,r=null),p=function(e){var t;try{e()}catch(e){t=e}return t}(t),o=(r&&r.name?" ("+r.name+").":".")+(o?" "+o:"."),e&&!p&&_(p,r,"Missing expected exception"+o);var s="string"==typeof o,n=!e&&i.isError(p),a=!e&&p&&!r;if((n&&s&&E(p,r)||a)&&_(p,r,"Got unwanted exception"+o),e&&p&&r&&!E(p,r)||!e&&p)throw p}u.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=y(d((t=this).actual),128)+" "+t.operator+" "+y(d(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||_;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var o=new Error;if(o.stack){var p=o.stack,i=f(r),s=p.indexOf("\n"+i);if(s>=0){var n=p.indexOf("\n",s+1);p=p.substring(n+1)}this.stack=p}}},i.inherits(u.AssertionError,Error),u.fail=_,u.ok=S,u.equal=function(e,t,r){e!=t&&_(e,t,r,"==",u.equal)},u.notEqual=function(e,t,r){e==t&&_(e,t,r,"!=",u.notEqual)},u.deepEqual=function(e,t,r){g(e,t,!1)||_(e,t,r,"deepEqual",u.deepEqual)},u.deepStrictEqual=function(e,t,r){g(e,t,!0)||_(e,t,r,"deepStrictEqual",u.deepStrictEqual)},u.notDeepEqual=function(e,t,r){g(e,t,!1)&&_(e,t,r,"notDeepEqual",u.notDeepEqual)},u.notDeepStrictEqual=function e(t,r,o){g(t,r,!0)&&_(t,r,o,"notDeepStrictEqual",e)},u.strictEqual=function(e,t,r){e!==t&&_(e,t,r,"===",u.strictEqual)},u.notStrictEqual=function(e,t,r){e===t&&_(e,t,r,"!==",u.notStrictEqual)},u.throws=function(e,t,r){m(!0,e,t,r)},u.doesNotThrow=function(e,t,r){m(!1,e,t,r)},u.ifError=function(e){if(e)throw e};var b=Object.keys||function(e){var t=[];for(var r in e)s.call(e,r)&&t.push(r);return t}}).call(this,r(5))},function(e,t,r){e.exports=r(14).PassThrough},function(e,t,r){e.exports=r(14).Transform},function(e,t,r){e.exports=r(6)},function(e,t,r){e.exports=r(13)},function(e,t,r){"use strict";e.exports=i;var o=r(17),p=r(10);function i(e){if(!(this instanceof i))return new i(e);o.call(this,e)}p.inherits=r(7),p.inherits(i,o),i.prototype._transform=function(e,t,r){r(null,e)}},function(e,t,r){(function(t){function r(e){try{if(!t.localStorage)return!1}catch(e){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(e,t){if(r("noDeprecation"))return e;var o=!1;return function(){if(!o){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),o=!0}return e.apply(this,arguments)}}}).call(this,r(5))},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var o,p,i,s,n,a=1,l={},c=!1,u=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?o=function(e){t.nextTick(function(){y(e)})}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){y(e.data)},o=function(e){i.port2.postMessage(e)}):u&&"onreadystatechange"in u.createElement("script")?(p=u.documentElement,o=function(e){var t=u.createElement("script");t.onreadystatechange=function(){y(e),t.onreadystatechange=null,p.removeChild(t),t=null},p.appendChild(t)}):o=function(e){setTimeout(y,0,e)}:(s="setImmediate$"+Math.random()+"$",n=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&y(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",n,!1):e.attachEvent("onmessage",n),o=function(t){e.postMessage(s+t,"*")}),h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r(55),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(5))},function(e,t){},function(e,t,r){"use strict";var o=r(11).Buffer,p=r(57);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return o.alloc(0);if(1===this.length)return this.head.data;for(var t,r,p,i=o.allocUnsafe(e>>>0),s=this.head,n=0;s;)t=s.data,r=i,p=n,t.copy(r,p),n+=s.data.length,s=s.next;return i},e}(),p&&p.inspect&&p.inspect.custom&&(e.exports.prototype[p.inspect.custom]=function(){var e=p.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,r){e.exports=p;var o=r(15).EventEmitter;function p(){o.call(this)}r(7)(p,o),p.Readable=r(14),p.Writable=r(52),p.Duplex=r(51),p.Transform=r(50),p.PassThrough=r(49),p.Stream=p,p.prototype.pipe=function(e,t){var r=this;function p(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function i(){r.readable&&r.resume&&r.resume()}r.on("data",p),e.on("drain",i),e._isStdio||t&&!1===t.end||(r.on("end",n),r.on("close",a));var s=!1;function n(){s||(s=!0,e.end())}function a(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function l(e){if(c(),0===o.listenerCount(this,"error"))throw e}function c(){r.removeListener("data",p),e.removeListener("drain",i),r.removeListener("end",n),r.removeListener("close",a),r.removeListener("error",l),e.removeListener("error",l),r.removeListener("end",c),r.removeListener("close",c),e.removeListener("close",c)}return r.on("error",l),e.on("error",l),r.on("end",c),r.on("close",c),e.on("close",c),e.emit("pipe",r),e}},function(e,t,r){(function(e){function r(e,t){for(var r=0,o=e.length-1;o>=0;o--){var p=e[o];"."===p?e.splice(o,1):".."===p?(e.splice(o,1),r++):r&&(e.splice(o,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}var o=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,p=function(e){return o.exec(e).slice(1)};function i(e,t){if(e.filter)return e.filter(t);for(var r=[],o=0;o=-1&&!o;p--){var s=p>=0?arguments[p]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(t=s+"/"+t,o="/"===s.charAt(0))}return t=r(i(t.split("/"),function(e){return!!e}),!o).join("/"),(o?"/":"")+t||"."},t.normalize=function(e){var o=t.isAbsolute(e),p="/"===s(e,-1);return(e=r(i(e.split("/"),function(e){return!!e}),!o).join("/"))||o||(e="."),e&&p&&(e+="/"),(o?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(i(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},t.relative=function(e,r){function o(e){for(var t=0;t=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=t.resolve(e).substr(1),r=t.resolve(r).substr(1);for(var p=o(e.split("/")),i=o(r.split("/")),s=Math.min(p.length,i.length),n=s,a=0;a>1,c=-7,u=r?p-1:0,h=r?-1:1,f=e[t+u];for(u+=h,i=f&(1<<-c)-1,f>>=-c,c+=n;c>0;i=256*i+e[t+u],u+=h,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=o;c>0;s=256*s+e[t+u],u+=h,c-=8);if(0===i)i=1-l;else{if(i===a)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,o),i-=l}return(f?-1:1)*s*Math.pow(2,i-o)},t.write=function(e,t,r,o,p,i){var s,n,a,l=8*i-p-1,c=(1<>1,h=23===p?Math.pow(2,-24)-Math.pow(2,-77):0,f=o?0:i-1,y=o?1:-1,d=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(n=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-s))<1&&(s--,a*=2),(t+=s+u>=1?h/a:h*Math.pow(2,1-u))*a>=2&&(s++,a/=2),s+u>=c?(n=0,s=c):s+u>=1?(n=(t*a-1)*Math.pow(2,p),s+=u):(n=t*Math.pow(2,u-1)*Math.pow(2,p),s=0));p>=8;e[r+f]=255&n,f+=y,n/=256,p-=8);for(s=s<0;e[r+f]=255&s,f+=y,s/=256,l-=8);e[r+f-y]|=128*d}},function(e,t,r){"use strict";t.byteLength=function(e){var t=l(e),r=t[0],o=t[1];return 3*(r+o)/4-o},t.toByteArray=function(e){for(var t,r=l(e),o=r[0],s=r[1],n=new i(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),a=0,c=s>0?o-4:o,u=0;u>16&255,n[a++]=t>>8&255,n[a++]=255&t;2===s&&(t=p[e.charCodeAt(u)]<<2|p[e.charCodeAt(u+1)]>>4,n[a++]=255&t);1===s&&(t=p[e.charCodeAt(u)]<<10|p[e.charCodeAt(u+1)]<<4|p[e.charCodeAt(u+2)]>>2,n[a++]=t>>8&255,n[a++]=255&t);return n},t.fromByteArray=function(e){for(var t,r=e.length,p=r%3,i=[],s=0,n=r-p;sn?n:s+16383));1===p?(t=e[r-1],i.push(o[t>>2]+o[t<<4&63]+"==")):2===p&&(t=(e[r-2]<<8)+e[r-1],i.push(o[t>>10]+o[t>>4&63]+o[t<<2&63]+"="));return i.join("")};for(var o=[],p=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,a=s.length;n0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function c(e,t,r){for(var p,i,s=[],n=t;n>18&63]+o[i>>12&63]+o[i>>6&63]+o[63&i]);return s.join("")}p["-".charCodeAt(0)]=62,p["_".charCodeAt(0)]=63},function(e,t,r){(function(e,o,p){var i=r(16).Parser,s=(r(61),r(60),r(2)),n=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920],a=function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e};function l(e){this.name="ParameterValidationError",this.message=e,this.stack=(new Error).stack}function c(e){this.name="BufferTooShortError",this.message=e,this.stack=(new Error).stack}function u(e){this.name="BufferCorruptError",this.message=e,this.stack=(new Error).stack}l.prototype=Object.create(Error.prototype),l.prototype.constructor=l,c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,u.prototype=Object.create(Error.prototype),u.prototype.constructor=u;var h={acquisition:r(42),bootload:r(41),ext_events:r(40),file_io:r(39),flash:r(38),gnss:r(0),imu:r(37),logging:r(36),mag:r(35),navigation:r(34),ndb:r(33),observation:r(32),piksi:r(31),settings:r(30),signal:r(29),ssr:r(28),system:r(27),tracking:r(26),user:r(25),vehicle:r(24),orientation:r(23)},f=Object.keys(h).reduce(function(e,t){var r=h[t],o={};return Object.keys(r).map(function(e){parseInt(e)==e&&(o[e]=r[e])}),a(e,o)},{}),y=Object.keys(h).reduce(function(e,t){var r=h[t],o={};return Object.keys(r).map(function(e){if(parseInt(e)!=e){var t=r[e].prototype.messageType||e;o[t]=r[e]}}),a(e,o)},{}),d=(new i).endianess("little").uint8("preamble").uint16("msg_type").uint16("sender").uint8("length").buffer("payload",{length:"length"}).uint16("crc");function _(e,t){t=t||0;for(var r=0;r>8&255^255&o],t&=65535}return t}o.exports={preambleByte:85,crc16:_,sbpIdTable:f,sbpMessageTypesTable:y,decode:function(e){var t=d.parse(e),r=f[t.msg_type];return void 0===r?(console.log("Unknown message type: ",t.msg_type),new s(t)):new r(t)},dispatch:function(t,r,p){var i,s,n=new e(0);if(void 0===p&&"function"==typeof r?i=r:(i=p,s=r),s&&!Array.isArray(s)&&-1===["function","number"].indexOf(typeof s))throw l("dispatch: messageWhitelist must be function, number, or array");var a=function(r){t.pause();try{if((n=e.concat([n,r])).length<2)return;var p=function(){var e,t,r,p,i,a,l;for(l=0;ln.length)throw new c;e=n.slice(l+1,l+6),r=n.readUInt16LE(l+1),n.readUInt16LE(l+3),p=n.readUInt8(l+5);var h=s&&Array.isArray(s)&&-1!==s.indexOf(r),f=s&&"number"==typeof s&&s&r,y=s&&"function"==typeof s&&s(r);if(s&&!(h||f||y))return n=n.slice(l+6+p+2),null;if(l+8+p>n.length)throw new c;a=_(n.slice(l+6,l+6+p),_(e)),i=n.readUInt16LE(l+6+p);var d=n.slice(l,l+6+p+2);if(i===a)return n=n.slice(l+6+p+2),[o.exports.decode(d),d];throw n=n.slice(l+1),new u}();if(null===p)return;var l=p[0],h=p[1];i(null,l,h)}catch(e){if(!(e instanceof c||e instanceof u))throw e}finally{0,t.resume(),n.length>0&&setTimeout(function(){a(new e(0))},0)}};t.on("data",a)}},function(e){var r={function:!0,object:!0},i=r[typeof window]&&window||this,s=r[typeof t]&&t&&!t.nodeType&&t,n=r[typeof o]&&o&&!o.nodeType&&o,a=s&&n&&"object"==typeof p&&p;!a||a.global!==a&&a.window!==a&&a.self!==a||(i=a),i.SBP=e}(o.exports)}).call(this,r(9).Buffer,r(63)(e),r(5))}]); \ No newline at end of file +function o(e,t){if(e===t)return 0;for(var r=e.length,o=t.length,p=0,i=Math.min(r,o);p=0;l--)if(c[l]!==u[l])return!1;for(l=c.length-1;l>=0;l--)if(a=c[l],!g(e[a],t[a],r,o))return!1;return!0}(e,t,r,s))}return r?e===t:e==t}function w(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function E(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function m(e,t,r,o){var p;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(o=r,r=null),p=function(e){var t;try{e()}catch(e){t=e}return t}(t),o=(r&&r.name?" ("+r.name+").":".")+(o?" "+o:"."),e&&!p&&_(p,r,"Missing expected exception"+o);var s="string"==typeof o,n=!e&&i.isError(p),a=!e&&p&&!r;if((n&&s&&E(p,r)||a)&&_(p,r,"Got unwanted exception"+o),e&&p&&r&&!E(p,r)||!e&&p)throw p}u.AssertionError=function(e){var t;this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=y(d((t=this).actual),128)+" "+t.operator+" "+y(d(t.expected),128),this.generatedMessage=!0);var r=e.stackStartFunction||_;if(Error.captureStackTrace)Error.captureStackTrace(this,r);else{var o=new Error;if(o.stack){var p=o.stack,i=f(r),s=p.indexOf("\n"+i);if(s>=0){var n=p.indexOf("\n",s+1);p=p.substring(n+1)}this.stack=p}}},i.inherits(u.AssertionError,Error),u.fail=_,u.ok=S,u.equal=function(e,t,r){e!=t&&_(e,t,r,"==",u.equal)},u.notEqual=function(e,t,r){e==t&&_(e,t,r,"!=",u.notEqual)},u.deepEqual=function(e,t,r){g(e,t,!1)||_(e,t,r,"deepEqual",u.deepEqual)},u.deepStrictEqual=function(e,t,r){g(e,t,!0)||_(e,t,r,"deepStrictEqual",u.deepStrictEqual)},u.notDeepEqual=function(e,t,r){g(e,t,!1)&&_(e,t,r,"notDeepEqual",u.notDeepEqual)},u.notDeepStrictEqual=function e(t,r,o){g(t,r,!0)&&_(t,r,o,"notDeepStrictEqual",e)},u.strictEqual=function(e,t,r){e!==t&&_(e,t,r,"===",u.strictEqual)},u.notStrictEqual=function(e,t,r){e===t&&_(e,t,r,"!==",u.notStrictEqual)},u.throws=function(e,t,r){m(!0,e,t,r)},u.doesNotThrow=function(e,t,r){m(!1,e,t,r)},u.ifError=function(e){if(e)throw e};var b=Object.keys||function(e){var t=[];for(var r in e)s.call(e,r)&&t.push(r);return t}}).call(this,r(5))},function(e,t,r){e.exports=r(14).PassThrough},function(e,t,r){e.exports=r(14).Transform},function(e,t,r){e.exports=r(6)},function(e,t,r){e.exports=r(13)},function(e,t,r){"use strict";e.exports=i;var o=r(17),p=r(10);function i(e){if(!(this instanceof i))return new i(e);o.call(this,e)}p.inherits=r(7),p.inherits(i,o),i.prototype._transform=function(e,t,r){r(null,e)}},function(e,t,r){(function(t){function r(e){try{if(!t.localStorage)return!1}catch(e){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(e,t){if(r("noDeprecation"))return e;var o=!1;return function(){if(!o){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),o=!0}return e.apply(this,arguments)}}}).call(this,r(5))},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var o,p,i,s,n,a=1,l={},c=!1,u=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?o=function(e){t.nextTick(function(){y(e)})}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((i=new MessageChannel).port1.onmessage=function(e){y(e.data)},o=function(e){i.port2.postMessage(e)}):u&&"onreadystatechange"in u.createElement("script")?(p=u.documentElement,o=function(e){var t=u.createElement("script");t.onreadystatechange=function(){y(e),t.onreadystatechange=null,p.removeChild(t),t=null},p.appendChild(t)}):o=function(e){setTimeout(y,0,e)}:(s="setImmediate$"+Math.random()+"$",n=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&y(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",n,!1):e.attachEvent("onmessage",n),o=function(t){e.postMessage(s+t,"*")}),h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r(56),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(5))},function(e,t){},function(e,t,r){"use strict";var o=r(11).Buffer,p=r(58);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return o.alloc(0);if(1===this.length)return this.head.data;for(var t,r,p,i=o.allocUnsafe(e>>>0),s=this.head,n=0;s;)t=s.data,r=i,p=n,t.copy(r,p),n+=s.data.length,s=s.next;return i},e}(),p&&p.inspect&&p.inspect.custom&&(e.exports.prototype[p.inspect.custom]=function(){var e=p.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,r){e.exports=p;var o=r(15).EventEmitter;function p(){o.call(this)}r(7)(p,o),p.Readable=r(14),p.Writable=r(53),p.Duplex=r(52),p.Transform=r(51),p.PassThrough=r(50),p.Stream=p,p.prototype.pipe=function(e,t){var r=this;function p(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function i(){r.readable&&r.resume&&r.resume()}r.on("data",p),e.on("drain",i),e._isStdio||t&&!1===t.end||(r.on("end",n),r.on("close",a));var s=!1;function n(){s||(s=!0,e.end())}function a(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function l(e){if(c(),0===o.listenerCount(this,"error"))throw e}function c(){r.removeListener("data",p),e.removeListener("drain",i),r.removeListener("end",n),r.removeListener("close",a),r.removeListener("error",l),e.removeListener("error",l),r.removeListener("end",c),r.removeListener("close",c),e.removeListener("close",c)}return r.on("error",l),e.on("error",l),r.on("end",c),r.on("close",c),e.on("close",c),e.emit("pipe",r),e}},function(e,t,r){(function(e){function r(e,t){for(var r=0,o=e.length-1;o>=0;o--){var p=e[o];"."===p?e.splice(o,1):".."===p?(e.splice(o,1),r++):r&&(e.splice(o,1),r--)}if(t)for(;r--;r)e.unshift("..");return e}var o=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,p=function(e){return o.exec(e).slice(1)};function i(e,t){if(e.filter)return e.filter(t);for(var r=[],o=0;o=-1&&!o;p--){var s=p>=0?arguments[p]:e.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(t=s+"/"+t,o="/"===s.charAt(0))}return t=r(i(t.split("/"),function(e){return!!e}),!o).join("/"),(o?"/":"")+t||"."},t.normalize=function(e){var o=t.isAbsolute(e),p="/"===s(e,-1);return(e=r(i(e.split("/"),function(e){return!!e}),!o).join("/"))||o||(e="."),e&&p&&(e+="/"),(o?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(i(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},t.relative=function(e,r){function o(e){for(var t=0;t=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=t.resolve(e).substr(1),r=t.resolve(r).substr(1);for(var p=o(e.split("/")),i=o(r.split("/")),s=Math.min(p.length,i.length),n=s,a=0;a>1,c=-7,u=r?p-1:0,h=r?-1:1,f=e[t+u];for(u+=h,i=f&(1<<-c)-1,f>>=-c,c+=n;c>0;i=256*i+e[t+u],u+=h,c-=8);for(s=i&(1<<-c)-1,i>>=-c,c+=o;c>0;s=256*s+e[t+u],u+=h,c-=8);if(0===i)i=1-l;else{if(i===a)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,o),i-=l}return(f?-1:1)*s*Math.pow(2,i-o)},t.write=function(e,t,r,o,p,i){var s,n,a,l=8*i-p-1,c=(1<>1,h=23===p?Math.pow(2,-24)-Math.pow(2,-77):0,f=o?0:i-1,y=o?1:-1,d=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(n=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-s))<1&&(s--,a*=2),(t+=s+u>=1?h/a:h*Math.pow(2,1-u))*a>=2&&(s++,a/=2),s+u>=c?(n=0,s=c):s+u>=1?(n=(t*a-1)*Math.pow(2,p),s+=u):(n=t*Math.pow(2,u-1)*Math.pow(2,p),s=0));p>=8;e[r+f]=255&n,f+=y,n/=256,p-=8);for(s=s<0;e[r+f]=255&s,f+=y,s/=256,l-=8);e[r+f-y]|=128*d}},function(e,t,r){"use strict";t.byteLength=function(e){var t=l(e),r=t[0],o=t[1];return 3*(r+o)/4-o},t.toByteArray=function(e){for(var t,r=l(e),o=r[0],s=r[1],n=new i(function(e,t,r){return 3*(t+r)/4-r}(0,o,s)),a=0,c=s>0?o-4:o,u=0;u>16&255,n[a++]=t>>8&255,n[a++]=255&t;2===s&&(t=p[e.charCodeAt(u)]<<2|p[e.charCodeAt(u+1)]>>4,n[a++]=255&t);1===s&&(t=p[e.charCodeAt(u)]<<10|p[e.charCodeAt(u+1)]<<4|p[e.charCodeAt(u+2)]>>2,n[a++]=t>>8&255,n[a++]=255&t);return n},t.fromByteArray=function(e){for(var t,r=e.length,p=r%3,i=[],s=0,n=r-p;sn?n:s+16383));1===p?(t=e[r-1],i.push(o[t>>2]+o[t<<4&63]+"==")):2===p&&(t=(e[r-2]<<8)+e[r-1],i.push(o[t>>10]+o[t>>4&63]+o[t<<2&63]+"="));return i.join("")};for(var o=[],p=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=0,a=s.length;n0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function c(e,t,r){for(var p,i,s=[],n=t;n>18&63]+o[i>>12&63]+o[i>>6&63]+o[63&i]);return s.join("")}p["-".charCodeAt(0)]=62,p["_".charCodeAt(0)]=63},function(e,t,r){(function(e,o,p){var i=r(16).Parser,s=(r(62),r(61),r(2)),n=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920],a=function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return e};function l(e){this.name="ParameterValidationError",this.message=e,this.stack=(new Error).stack}function c(e){this.name="BufferTooShortError",this.message=e,this.stack=(new Error).stack}function u(e){this.name="BufferCorruptError",this.message=e,this.stack=(new Error).stack}l.prototype=Object.create(Error.prototype),l.prototype.constructor=l,c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,u.prototype=Object.create(Error.prototype),u.prototype.constructor=u;var h={acquisition:r(43),bootload:r(42),ext_events:r(41),file_io:r(40),flash:r(39),gnss:r(0),imu:r(38),linux:r(37),logging:r(36),mag:r(35),navigation:r(34),ndb:r(33),observation:r(32),piksi:r(31),settings:r(30),signal:r(29),ssr:r(28),system:r(27),tracking:r(26),user:r(25),vehicle:r(24),orientation:r(23)},f=Object.keys(h).reduce(function(e,t){var r=h[t],o={};return Object.keys(r).map(function(e){parseInt(e)==e&&(o[e]=r[e])}),a(e,o)},{}),y=Object.keys(h).reduce(function(e,t){var r=h[t],o={};return Object.keys(r).map(function(e){if(parseInt(e)!=e){var t=r[e].prototype.messageType||e;o[t]=r[e]}}),a(e,o)},{}),d=(new i).endianess("little").uint8("preamble").uint16("msg_type").uint16("sender").uint8("length").buffer("payload",{length:"length"}).uint16("crc");function _(e,t){t=t||0;for(var r=0;r>8&255^255&o],t&=65535}return t}o.exports={preambleByte:85,crc16:_,sbpIdTable:f,sbpMessageTypesTable:y,decode:function(e){var t=d.parse(e),r=f[t.msg_type];return void 0===r?(console.log("Unknown message type: ",t.msg_type),new s(t)):new r(t)},dispatch:function(t,r,p){var i,s,n=new e(0);if(void 0===p&&"function"==typeof r?i=r:(i=p,s=r),s&&!Array.isArray(s)&&-1===["function","number"].indexOf(typeof s))throw l("dispatch: messageWhitelist must be function, number, or array");var a=function(r){t.pause();try{if((n=e.concat([n,r])).length<2)return;var p=function(){var e,t,r,p,i,a,l;for(l=0;ln.length)throw new c;e=n.slice(l+1,l+6),r=n.readUInt16LE(l+1),n.readUInt16LE(l+3),p=n.readUInt8(l+5);var h=s&&Array.isArray(s)&&-1!==s.indexOf(r),f=s&&"number"==typeof s&&s&r,y=s&&"function"==typeof s&&s(r);if(s&&!(h||f||y))return n=n.slice(l+6+p+2),null;if(l+8+p>n.length)throw new c;a=_(n.slice(l+6,l+6+p),_(e)),i=n.readUInt16LE(l+6+p);var d=n.slice(l,l+6+p+2);if(i===a)return n=n.slice(l+6+p+2),[o.exports.decode(d),d];throw n=n.slice(l+1),new u}();if(null===p)return;var l=p[0],h=p[1];i(null,l,h)}catch(e){if(!(e instanceof c||e instanceof u))throw e}finally{0,t.resume(),n.length>0&&setTimeout(function(){a(new e(0))},0)}};t.on("data",a)}},function(e){var r={function:!0,object:!0},i=r[typeof window]&&window||this,s=r[typeof t]&&t&&!t.nodeType&&t,n=r[typeof o]&&o&&!o.nodeType&&o,a=s&&n&&"object"==typeof p&&p;!a||a.global!==a&&a.window!==a&&a.self!==a||(i=a),i.SBP=e}(o.exports)}).call(this,r(9).Buffer,r(64)(e),r(5))}]); diff --git a/javascript/sbp/linux.js b/javascript/sbp/linux.js new file mode 100644 index 0000000000..8ebcda9bfa --- /dev/null +++ b/javascript/sbp/linux.js @@ -0,0 +1,298 @@ +/** + * Copyright (C) 2015-2018 Swift Navigation Inc. + * Contact: Swift Navigation + * This source is subject to the license found in the file 'LICENSE' which must + * be distributed together with this source. All other rights reserved. + * + * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, + * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + */ + +/********************** + * Automatically generated from piksi/yaml/swiftnav/sbp/linux.yaml with generate.py. + * Don't edit this by hand! + ********************** + * Package description: + * + * Linux state monitoring. +***********************/ + +var SBP = require('./sbp'); +var Parser = require('./parser'); +var Int64 = require('node-int64'); +var UInt64 = require('cuint').UINT64; + +/** + * SBP class for message MSG_LINUX_CPU_STATE (0x7F00). + * + * This message indicates the process state of the top 10 heaviest consumers of CPU + * on the system. + * + * Fields in the SBP payload (`sbp.payload`): + * @field index number (unsigned 8-bit int, 1 byte) sequence of this status message, values from 0-9 + * @field pid number (unsigned 16-bit int, 2 bytes) the PID of the process + * @field pcpu number (unsigned 8-bit int, 1 byte) percent of cpu used, expressed as a fraction of 256 + * @field tname string fixed length string representing the thread name + * @field cmdline string the command line (as much as it fits in the remaining packet) + * + * @param sbp An SBP object with a payload to be decoded. + */ +var MsgLinuxCpuState = function (sbp, fields) { + SBP.call(this, sbp); + this.messageType = "MSG_LINUX_CPU_STATE"; + this.fields = (fields || this.parser.parse(sbp.payload)); + + return this; +}; +MsgLinuxCpuState.prototype = Object.create(SBP.prototype); +MsgLinuxCpuState.prototype.messageType = "MSG_LINUX_CPU_STATE"; +MsgLinuxCpuState.prototype.msg_type = 0x7F00; +MsgLinuxCpuState.prototype.constructor = MsgLinuxCpuState; +MsgLinuxCpuState.prototype.parser = new Parser() + .endianess('little') + .uint8('index') + .uint16('pid') + .uint8('pcpu') + .string('tname', { length: 15 }) + .string('cmdline', { greedy: true }); +MsgLinuxCpuState.prototype.fieldSpec = []; +MsgLinuxCpuState.prototype.fieldSpec.push(['index', 'writeUInt8', 1]); +MsgLinuxCpuState.prototype.fieldSpec.push(['pid', 'writeUInt16LE', 2]); +MsgLinuxCpuState.prototype.fieldSpec.push(['pcpu', 'writeUInt8', 1]); +MsgLinuxCpuState.prototype.fieldSpec.push(['tname', 'string', 15]); +MsgLinuxCpuState.prototype.fieldSpec.push(['cmdline', 'string', null]); + +/** + * SBP class for message MSG_LINUX_MEM_STATE (0x7F01). + * + * This message indicates the process state of the top 10 heaviest consumers of + * memory on the system. + * + * Fields in the SBP payload (`sbp.payload`): + * @field index number (unsigned 8-bit int, 1 byte) sequence of this status message, values from 0-9 + * @field pid number (unsigned 16-bit int, 2 bytes) the PID of the process + * @field pmem number (unsigned 8-bit int, 1 byte) percent of memory used, expressed as a fraction of 256 + * @field tname string fixed length string representing the thread name + * @field cmdline string the command line (as much as it fits in the remaining packet) + * + * @param sbp An SBP object with a payload to be decoded. + */ +var MsgLinuxMemState = function (sbp, fields) { + SBP.call(this, sbp); + this.messageType = "MSG_LINUX_MEM_STATE"; + this.fields = (fields || this.parser.parse(sbp.payload)); + + return this; +}; +MsgLinuxMemState.prototype = Object.create(SBP.prototype); +MsgLinuxMemState.prototype.messageType = "MSG_LINUX_MEM_STATE"; +MsgLinuxMemState.prototype.msg_type = 0x7F01; +MsgLinuxMemState.prototype.constructor = MsgLinuxMemState; +MsgLinuxMemState.prototype.parser = new Parser() + .endianess('little') + .uint8('index') + .uint16('pid') + .uint8('pmem') + .string('tname', { length: 15 }) + .string('cmdline', { greedy: true }); +MsgLinuxMemState.prototype.fieldSpec = []; +MsgLinuxMemState.prototype.fieldSpec.push(['index', 'writeUInt8', 1]); +MsgLinuxMemState.prototype.fieldSpec.push(['pid', 'writeUInt16LE', 2]); +MsgLinuxMemState.prototype.fieldSpec.push(['pmem', 'writeUInt8', 1]); +MsgLinuxMemState.prototype.fieldSpec.push(['tname', 'string', 15]); +MsgLinuxMemState.prototype.fieldSpec.push(['cmdline', 'string', null]); + +/** + * SBP class for message MSG_LINUX_SYS_STATE (0x7F02). + * + * This presents a summary of CPU and memory utilization. + * + * Fields in the SBP payload (`sbp.payload`): + * @field mem_total number (unsigned 16-bit int, 2 bytes) total system memory + * @field pcpu number (unsigned 8-bit int, 1 byte) percent of total cpu currently utilized + * @field pmem number (unsigned 8-bit int, 1 byte) percent of total memory currently utilized + * @field procs_starting number (unsigned 16-bit int, 2 bytes) number of processes that started during collection phase + * @field procs_stopping number (unsigned 16-bit int, 2 bytes) number of processes that stopped during collection phase + * @field pid_count number (unsigned 16-bit int, 2 bytes) the count of processes on the system + * + * @param sbp An SBP object with a payload to be decoded. + */ +var MsgLinuxSysState = function (sbp, fields) { + SBP.call(this, sbp); + this.messageType = "MSG_LINUX_SYS_STATE"; + this.fields = (fields || this.parser.parse(sbp.payload)); + + return this; +}; +MsgLinuxSysState.prototype = Object.create(SBP.prototype); +MsgLinuxSysState.prototype.messageType = "MSG_LINUX_SYS_STATE"; +MsgLinuxSysState.prototype.msg_type = 0x7F02; +MsgLinuxSysState.prototype.constructor = MsgLinuxSysState; +MsgLinuxSysState.prototype.parser = new Parser() + .endianess('little') + .uint16('mem_total') + .uint8('pcpu') + .uint8('pmem') + .uint16('procs_starting') + .uint16('procs_stopping') + .uint16('pid_count'); +MsgLinuxSysState.prototype.fieldSpec = []; +MsgLinuxSysState.prototype.fieldSpec.push(['mem_total', 'writeUInt16LE', 2]); +MsgLinuxSysState.prototype.fieldSpec.push(['pcpu', 'writeUInt8', 1]); +MsgLinuxSysState.prototype.fieldSpec.push(['pmem', 'writeUInt8', 1]); +MsgLinuxSysState.prototype.fieldSpec.push(['procs_starting', 'writeUInt16LE', 2]); +MsgLinuxSysState.prototype.fieldSpec.push(['procs_stopping', 'writeUInt16LE', 2]); +MsgLinuxSysState.prototype.fieldSpec.push(['pid_count', 'writeUInt16LE', 2]); + +/** + * SBP class for message MSG_LINUX_PROCESS_SOCKET_COUNTS (0x7F03). + * + * Top 10 list of processes with high socket counts. + * + * Fields in the SBP payload (`sbp.payload`): + * @field index number (unsigned 8-bit int, 1 byte) sequence of this status message, values from 0-9 + * @field pid number (unsigned 16-bit int, 2 bytes) the PID of the process in question + * @field socket_count number (unsigned 16-bit int, 2 bytes) the number of sockets the process is using + * @field socket_types number (unsigned 16-bit int, 2 bytes) A bitfield indicating the socket types used: 0x1 (tcp), 0x2 (udp), 0x4 (unix + * stream), 0x8 (unix dgram), 0x10 (netlink), and 0x8000 (unknown) + * @field socket_states number (unsigned 16-bit int, 2 bytes) A bitfield indicating the socket states: 0x1 (established), 0x2 (syn-sent), + * 0x4 (syn-recv), 0x8 (fin-wait-1), 0x10 (fin-wait-2), 0x20 (time-wait), 0x40 + * (closed), 0x80 (close-wait), 0x100 (last-ack), 0x200 (listen), 0x400 + * (closing), 0x800 (unconnected), and 0x8000 (unknown) + * @field cmdline string the command line of the process in question + * + * @param sbp An SBP object with a payload to be decoded. + */ +var MsgLinuxProcessSocketCounts = function (sbp, fields) { + SBP.call(this, sbp); + this.messageType = "MSG_LINUX_PROCESS_SOCKET_COUNTS"; + this.fields = (fields || this.parser.parse(sbp.payload)); + + return this; +}; +MsgLinuxProcessSocketCounts.prototype = Object.create(SBP.prototype); +MsgLinuxProcessSocketCounts.prototype.messageType = "MSG_LINUX_PROCESS_SOCKET_COUNTS"; +MsgLinuxProcessSocketCounts.prototype.msg_type = 0x7F03; +MsgLinuxProcessSocketCounts.prototype.constructor = MsgLinuxProcessSocketCounts; +MsgLinuxProcessSocketCounts.prototype.parser = new Parser() + .endianess('little') + .uint8('index') + .uint16('pid') + .uint16('socket_count') + .uint16('socket_types') + .uint16('socket_states') + .string('cmdline', { greedy: true }); +MsgLinuxProcessSocketCounts.prototype.fieldSpec = []; +MsgLinuxProcessSocketCounts.prototype.fieldSpec.push(['index', 'writeUInt8', 1]); +MsgLinuxProcessSocketCounts.prototype.fieldSpec.push(['pid', 'writeUInt16LE', 2]); +MsgLinuxProcessSocketCounts.prototype.fieldSpec.push(['socket_count', 'writeUInt16LE', 2]); +MsgLinuxProcessSocketCounts.prototype.fieldSpec.push(['socket_types', 'writeUInt16LE', 2]); +MsgLinuxProcessSocketCounts.prototype.fieldSpec.push(['socket_states', 'writeUInt16LE', 2]); +MsgLinuxProcessSocketCounts.prototype.fieldSpec.push(['cmdline', 'string', null]); + +/** + * SBP class for message MSG_LINUX_PROCESS_SOCKET_QUEUES (0x7F04). + * + * Top 10 list of sockets with deep queues. + * + * Fields in the SBP payload (`sbp.payload`): + * @field index number (unsigned 8-bit int, 1 byte) sequence of this status message, values from 0-9 + * @field pid number (unsigned 16-bit int, 2 bytes) the PID of the process in question + * @field recv_queued number (unsigned 16-bit int, 2 bytes) the total amount of receive data queued for this process + * @field send_queued number (unsigned 16-bit int, 2 bytes) the total amount of send data queued for this process + * @field socket_types number (unsigned 16-bit int, 2 bytes) A bitfield indicating the socket types used: 0x1 (tcp), 0x2 (udp), 0x4 (unix + * stream), 0x8 (unix dgram), 0x10 (netlink), and 0x8000 (unknown) + * @field socket_states number (unsigned 16-bit int, 2 bytes) A bitfield indicating the socket states: 0x1 (established), 0x2 (syn-sent), + * 0x4 (syn-recv), 0x8 (fin-wait-1), 0x10 (fin-wait-2), 0x20 (time-wait), 0x40 + * (closed), 0x80 (close-wait), 0x100 (last-ack), 0x200 (listen), 0x400 + * (closing), 0x800 (unconnected), and 0x8000 (unknown) + * @field address_of_largest string Address of the largest queue, remote or local depending on the directionality of + * the connection. + * @field cmdline string the command line of the process in question + * + * @param sbp An SBP object with a payload to be decoded. + */ +var MsgLinuxProcessSocketQueues = function (sbp, fields) { + SBP.call(this, sbp); + this.messageType = "MSG_LINUX_PROCESS_SOCKET_QUEUES"; + this.fields = (fields || this.parser.parse(sbp.payload)); + + return this; +}; +MsgLinuxProcessSocketQueues.prototype = Object.create(SBP.prototype); +MsgLinuxProcessSocketQueues.prototype.messageType = "MSG_LINUX_PROCESS_SOCKET_QUEUES"; +MsgLinuxProcessSocketQueues.prototype.msg_type = 0x7F04; +MsgLinuxProcessSocketQueues.prototype.constructor = MsgLinuxProcessSocketQueues; +MsgLinuxProcessSocketQueues.prototype.parser = new Parser() + .endianess('little') + .uint8('index') + .uint16('pid') + .uint16('recv_queued') + .uint16('send_queued') + .uint16('socket_types') + .uint16('socket_states') + .string('address_of_largest', { length: 64 }) + .string('cmdline', { greedy: true }); +MsgLinuxProcessSocketQueues.prototype.fieldSpec = []; +MsgLinuxProcessSocketQueues.prototype.fieldSpec.push(['index', 'writeUInt8', 1]); +MsgLinuxProcessSocketQueues.prototype.fieldSpec.push(['pid', 'writeUInt16LE', 2]); +MsgLinuxProcessSocketQueues.prototype.fieldSpec.push(['recv_queued', 'writeUInt16LE', 2]); +MsgLinuxProcessSocketQueues.prototype.fieldSpec.push(['send_queued', 'writeUInt16LE', 2]); +MsgLinuxProcessSocketQueues.prototype.fieldSpec.push(['socket_types', 'writeUInt16LE', 2]); +MsgLinuxProcessSocketQueues.prototype.fieldSpec.push(['socket_states', 'writeUInt16LE', 2]); +MsgLinuxProcessSocketQueues.prototype.fieldSpec.push(['address_of_largest', 'string', 64]); +MsgLinuxProcessSocketQueues.prototype.fieldSpec.push(['cmdline', 'string', null]); + +/** + * SBP class for message MSG_LINUX_SOCKET_USAGE (0x7F05). + * + * Summaries the socket usage across the system. + * + * Fields in the SBP payload (`sbp.payload`): + * @field avg_queue_depth number (unsigned 32-bit int, 4 bytes) average socket queue depths across all sockets on the system + * @field max_queue_depth number (unsigned 32-bit int, 4 bytes) the max queue depth seen within the reporting period + * @field socket_state_counts array A count for each socket type reported in the `socket_types_reported` field, the + * first entry corresponds to the first enabled bit in `types_reported`. + * @field socket_type_counts array A count for each socket type reported in the `socket_types_reported` field, the + * first entry corresponds to the first enabled bit in `types_reported`. + * + * @param sbp An SBP object with a payload to be decoded. + */ +var MsgLinuxSocketUsage = function (sbp, fields) { + SBP.call(this, sbp); + this.messageType = "MSG_LINUX_SOCKET_USAGE"; + this.fields = (fields || this.parser.parse(sbp.payload)); + + return this; +}; +MsgLinuxSocketUsage.prototype = Object.create(SBP.prototype); +MsgLinuxSocketUsage.prototype.messageType = "MSG_LINUX_SOCKET_USAGE"; +MsgLinuxSocketUsage.prototype.msg_type = 0x7F05; +MsgLinuxSocketUsage.prototype.constructor = MsgLinuxSocketUsage; +MsgLinuxSocketUsage.prototype.parser = new Parser() + .endianess('little') + .uint32('avg_queue_depth') + .uint32('max_queue_depth') + .array('socket_state_counts', { length: 16, type: 'uint16le' }) + .array('socket_type_counts', { length: 16, type: 'uint16le' }); +MsgLinuxSocketUsage.prototype.fieldSpec = []; +MsgLinuxSocketUsage.prototype.fieldSpec.push(['avg_queue_depth', 'writeUInt32LE', 4]); +MsgLinuxSocketUsage.prototype.fieldSpec.push(['max_queue_depth', 'writeUInt32LE', 4]); +MsgLinuxSocketUsage.prototype.fieldSpec.push(['socket_state_counts', 'array', 'writeUInt16LE', function () { return 2; }, 16]); +MsgLinuxSocketUsage.prototype.fieldSpec.push(['socket_type_counts', 'array', 'writeUInt16LE', function () { return 2; }, 16]); + +module.exports = { + 0x7F00: MsgLinuxCpuState, + MsgLinuxCpuState: MsgLinuxCpuState, + 0x7F01: MsgLinuxMemState, + MsgLinuxMemState: MsgLinuxMemState, + 0x7F02: MsgLinuxSysState, + MsgLinuxSysState: MsgLinuxSysState, + 0x7F03: MsgLinuxProcessSocketCounts, + MsgLinuxProcessSocketCounts: MsgLinuxProcessSocketCounts, + 0x7F04: MsgLinuxProcessSocketQueues, + MsgLinuxProcessSocketQueues: MsgLinuxProcessSocketQueues, + 0x7F05: MsgLinuxSocketUsage, + MsgLinuxSocketUsage: MsgLinuxSocketUsage, +} \ No newline at end of file diff --git a/javascript/sbp/msg.js b/javascript/sbp/msg.js index a74096112b..33326a898d 100644 --- a/javascript/sbp/msg.js +++ b/javascript/sbp/msg.js @@ -95,6 +95,7 @@ var sbpImports = { flash: require('./flash.js'), gnss: require('./gnss.js'), imu: require('./imu.js'), + linux: require('./linux.js'), logging: require('./logging.js'), mag: require('./mag.js'), navigation: require('./navigation.js'), diff --git a/package-lock.json b/package-lock.json index 434b28747b..0efd243b4a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "sbp", - "version": "2.4.1", + "version": "2.4.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index c8979b9977..be3133029c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sbp", - "version": "2.4.1", + "version": "2.4.2", "description": "libsbp bindings for JavaScript. More information here: http://swift-nav.github.io/libsbp/", "files": [ "javascript/*", diff --git a/proto/linux.proto b/proto/linux.proto new file mode 100644 index 0000000000..2cdbbd6bdd --- /dev/null +++ b/proto/linux.proto @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2018 Swift Navigation Inc. + * Contact: Swift Navigation + * + * This source is subject to the license found in the file 'LICENSE' which must + * be be distributed together with this source. All other rights reserved. + * + * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, + * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + */ + +syntax = "proto3"; + +/** Linux + * + * Linux state monitoring. + */ + +package swiftnav.sbp.linux; + + +/** List CPU state on the system + * + * This message indicates the process state of the top 10 heaviest + * consumers of CPU on the system. + */ +message MsgLinuxCpuState { + uint32 index = 1; + uint32 pid = 2; + uint32 pcpu = 3; + string tname = 4; + string cmdline = 5; +} + +/** List CPU state on the system + * + * This message indicates the process state of the top 10 heaviest + * consumers of memory on the system. + */ +message MsgLinuxMemState { + uint32 index = 1; + uint32 pid = 2; + uint32 pmem = 3; + string tname = 4; + string cmdline = 5; +} + +/** CPU, Memory and Process Starts/Stops + * + * This presents a summary of CPU and memory utilization. + */ +message MsgLinuxSysState { + uint32 mem_total = 1; + uint32 pcpu = 2; + uint32 pmem = 3; + uint32 procs_starting = 4; + uint32 procs_stopping = 5; + uint32 pid_count = 6; +} + +/** A list of processes with high socket counts + * + * Top 10 list of processes with high socket counts. + */ +message MsgLinuxProcessSocketCounts { + uint32 index = 1; + uint32 pid = 2; + uint32 socket_count = 3; + uint32 socket_types = 4; + uint32 socket_states = 5; + string cmdline = 6; +} + +/** A list of processes with deep socket queues + * + * Top 10 list of sockets with deep queues. + */ +message MsgLinuxProcessSocketQueues { + uint32 index = 1; + uint32 pid = 2; + uint32 recv_queued = 3; + uint32 send_queued = 4; + uint32 socket_types = 5; + uint32 socket_states = 6; + string address_of_largest = 7; + string cmdline = 8; +} + +/** Summary of socket usage across the system + * + * Summaries the socket usage across the system. + */ +message MsgLinuxSocketUsage { + uint32 avg_queue_depth = 1; + uint32 max_queue_depth = 2; + repeated uint32 socket_state_counts = 3; + repeated uint32 socket_type_counts = 4; +} \ No newline at end of file diff --git a/python/sbp/linux.py b/python/sbp/linux.py new file mode 100644 index 0000000000..932d0767de --- /dev/null +++ b/python/sbp/linux.py @@ -0,0 +1,687 @@ +#!/usr/bin/env python +# Copyright (C) 2015-2018 Swift Navigation Inc. +# Contact: Swift Navigation +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + + +""" +Linux state monitoring. + +""" + +import json + +import construct + +from sbp.msg import SBP, SENDER_ID +from sbp.utils import fmt_repr, exclude_fields, walk_json_dict, containerize + +# Automatically generated from piksi/yaml/swiftnav/sbp/linux.yaml with generate.py. +# Please do not hand edit! + + +SBP_MSG_LINUX_CPU_STATE = 0x7F00 +class MsgLinuxCpuState(SBP): + """SBP class for message MSG_LINUX_CPU_STATE (0x7F00). + + You can have MSG_LINUX_CPU_STATE inherit its fields directly + from an inherited SBP object, or construct it inline using a dict + of its fields. + + + This message indicates the process state of the top 10 heaviest +consumers of CPU on the system. + + + Parameters + ---------- + sbp : SBP + SBP parent object to inherit from. + index : int + sequence of this status message, values from 0-9 + pid : int + the PID of the process + pcpu : int + percent of cpu used, expressed as a fraction of 256 + tname : string + fixed length string representing the thread name + cmdline : string + the command line (as much as it fits in the remaining packet) + sender : int + Optional sender ID, defaults to SENDER_ID (see sbp/msg.py). + + """ + _parser = construct.Struct( + 'index' / construct.Int8ul, + 'pid' / construct.Int16ul, + 'pcpu' / construct.Int8ul, + 'tname'/ construct.Bytes(15), + 'cmdline' / construct.GreedyBytes,) + __slots__ = [ + 'index', + 'pid', + 'pcpu', + 'tname', + 'cmdline', + ] + + def __init__(self, sbp=None, **kwargs): + if sbp: + super( MsgLinuxCpuState, + self).__init__(sbp.msg_type, sbp.sender, sbp.length, + sbp.payload, sbp.crc) + self.from_binary(sbp.payload) + else: + super( MsgLinuxCpuState, self).__init__() + self.msg_type = SBP_MSG_LINUX_CPU_STATE + self.sender = kwargs.pop('sender', SENDER_ID) + self.index = kwargs.pop('index') + self.pid = kwargs.pop('pid') + self.pcpu = kwargs.pop('pcpu') + self.tname = kwargs.pop('tname') + self.cmdline = kwargs.pop('cmdline') + + def __repr__(self): + return fmt_repr(self) + + @staticmethod + def from_json(s): + """Given a JSON-encoded string s, build a message object. + + """ + d = json.loads(s) + return MsgLinuxCpuState.from_json_dict(d) + + @staticmethod + def from_json_dict(d): + sbp = SBP.from_json_dict(d) + return MsgLinuxCpuState(sbp, **d) + + + def from_binary(self, d): + """Given a binary payload d, update the appropriate payload fields of + the message. + + """ + p = MsgLinuxCpuState._parser.parse(d) + for n in self.__class__.__slots__: + setattr(self, n, getattr(p, n)) + + def to_binary(self): + """Produce a framed/packed SBP message. + + """ + c = containerize(exclude_fields(self)) + self.payload = MsgLinuxCpuState._parser.build(c) + return self.pack() + + def to_json_dict(self): + self.to_binary() + d = super( MsgLinuxCpuState, self).to_json_dict() + j = walk_json_dict(exclude_fields(self)) + d.update(j) + return d + +SBP_MSG_LINUX_MEM_STATE = 0x7F01 +class MsgLinuxMemState(SBP): + """SBP class for message MSG_LINUX_MEM_STATE (0x7F01). + + You can have MSG_LINUX_MEM_STATE inherit its fields directly + from an inherited SBP object, or construct it inline using a dict + of its fields. + + + This message indicates the process state of the top 10 heaviest +consumers of memory on the system. + + + Parameters + ---------- + sbp : SBP + SBP parent object to inherit from. + index : int + sequence of this status message, values from 0-9 + pid : int + the PID of the process + pmem : int + percent of memory used, expressed as a fraction of 256 + tname : string + fixed length string representing the thread name + cmdline : string + the command line (as much as it fits in the remaining packet) + sender : int + Optional sender ID, defaults to SENDER_ID (see sbp/msg.py). + + """ + _parser = construct.Struct( + 'index' / construct.Int8ul, + 'pid' / construct.Int16ul, + 'pmem' / construct.Int8ul, + 'tname'/ construct.Bytes(15), + 'cmdline' / construct.GreedyBytes,) + __slots__ = [ + 'index', + 'pid', + 'pmem', + 'tname', + 'cmdline', + ] + + def __init__(self, sbp=None, **kwargs): + if sbp: + super( MsgLinuxMemState, + self).__init__(sbp.msg_type, sbp.sender, sbp.length, + sbp.payload, sbp.crc) + self.from_binary(sbp.payload) + else: + super( MsgLinuxMemState, self).__init__() + self.msg_type = SBP_MSG_LINUX_MEM_STATE + self.sender = kwargs.pop('sender', SENDER_ID) + self.index = kwargs.pop('index') + self.pid = kwargs.pop('pid') + self.pmem = kwargs.pop('pmem') + self.tname = kwargs.pop('tname') + self.cmdline = kwargs.pop('cmdline') + + def __repr__(self): + return fmt_repr(self) + + @staticmethod + def from_json(s): + """Given a JSON-encoded string s, build a message object. + + """ + d = json.loads(s) + return MsgLinuxMemState.from_json_dict(d) + + @staticmethod + def from_json_dict(d): + sbp = SBP.from_json_dict(d) + return MsgLinuxMemState(sbp, **d) + + + def from_binary(self, d): + """Given a binary payload d, update the appropriate payload fields of + the message. + + """ + p = MsgLinuxMemState._parser.parse(d) + for n in self.__class__.__slots__: + setattr(self, n, getattr(p, n)) + + def to_binary(self): + """Produce a framed/packed SBP message. + + """ + c = containerize(exclude_fields(self)) + self.payload = MsgLinuxMemState._parser.build(c) + return self.pack() + + def to_json_dict(self): + self.to_binary() + d = super( MsgLinuxMemState, self).to_json_dict() + j = walk_json_dict(exclude_fields(self)) + d.update(j) + return d + +SBP_MSG_LINUX_SYS_STATE = 0x7F02 +class MsgLinuxSysState(SBP): + """SBP class for message MSG_LINUX_SYS_STATE (0x7F02). + + You can have MSG_LINUX_SYS_STATE inherit its fields directly + from an inherited SBP object, or construct it inline using a dict + of its fields. + + + This presents a summary of CPU and memory utilization. + + + Parameters + ---------- + sbp : SBP + SBP parent object to inherit from. + mem_total : int + total system memory + pcpu : int + percent of total cpu currently utilized + pmem : int + percent of total memory currently utilized + procs_starting : int + number of processes that started during collection phase + procs_stopping : int + number of processes that stopped during collection phase + pid_count : int + the count of processes on the system + sender : int + Optional sender ID, defaults to SENDER_ID (see sbp/msg.py). + + """ + _parser = construct.Struct( + 'mem_total' / construct.Int16ul, + 'pcpu' / construct.Int8ul, + 'pmem' / construct.Int8ul, + 'procs_starting' / construct.Int16ul, + 'procs_stopping' / construct.Int16ul, + 'pid_count' / construct.Int16ul,) + __slots__ = [ + 'mem_total', + 'pcpu', + 'pmem', + 'procs_starting', + 'procs_stopping', + 'pid_count', + ] + + def __init__(self, sbp=None, **kwargs): + if sbp: + super( MsgLinuxSysState, + self).__init__(sbp.msg_type, sbp.sender, sbp.length, + sbp.payload, sbp.crc) + self.from_binary(sbp.payload) + else: + super( MsgLinuxSysState, self).__init__() + self.msg_type = SBP_MSG_LINUX_SYS_STATE + self.sender = kwargs.pop('sender', SENDER_ID) + self.mem_total = kwargs.pop('mem_total') + self.pcpu = kwargs.pop('pcpu') + self.pmem = kwargs.pop('pmem') + self.procs_starting = kwargs.pop('procs_starting') + self.procs_stopping = kwargs.pop('procs_stopping') + self.pid_count = kwargs.pop('pid_count') + + def __repr__(self): + return fmt_repr(self) + + @staticmethod + def from_json(s): + """Given a JSON-encoded string s, build a message object. + + """ + d = json.loads(s) + return MsgLinuxSysState.from_json_dict(d) + + @staticmethod + def from_json_dict(d): + sbp = SBP.from_json_dict(d) + return MsgLinuxSysState(sbp, **d) + + + def from_binary(self, d): + """Given a binary payload d, update the appropriate payload fields of + the message. + + """ + p = MsgLinuxSysState._parser.parse(d) + for n in self.__class__.__slots__: + setattr(self, n, getattr(p, n)) + + def to_binary(self): + """Produce a framed/packed SBP message. + + """ + c = containerize(exclude_fields(self)) + self.payload = MsgLinuxSysState._parser.build(c) + return self.pack() + + def to_json_dict(self): + self.to_binary() + d = super( MsgLinuxSysState, self).to_json_dict() + j = walk_json_dict(exclude_fields(self)) + d.update(j) + return d + +SBP_MSG_LINUX_PROCESS_SOCKET_COUNTS = 0x7F03 +class MsgLinuxProcessSocketCounts(SBP): + """SBP class for message MSG_LINUX_PROCESS_SOCKET_COUNTS (0x7F03). + + You can have MSG_LINUX_PROCESS_SOCKET_COUNTS inherit its fields directly + from an inherited SBP object, or construct it inline using a dict + of its fields. + + + Top 10 list of processes with high socket counts. + + + Parameters + ---------- + sbp : SBP + SBP parent object to inherit from. + index : int + sequence of this status message, values from 0-9 + pid : int + the PID of the process in question + socket_count : int + the number of sockets the process is using + socket_types : int + A bitfield indicating the socket types used: + 0x1 (tcp), 0x2 (udp), 0x4 (unix stream), 0x8 (unix dgram), 0x10 (netlink), + and 0x8000 (unknown) + + socket_states : int + A bitfield indicating the socket states: + 0x1 (established), 0x2 (syn-sent), 0x4 (syn-recv), 0x8 (fin-wait-1), + 0x10 (fin-wait-2), 0x20 (time-wait), 0x40 (closed), 0x80 (close-wait), + 0x100 (last-ack), 0x200 (listen), 0x400 (closing), 0x800 (unconnected), + and 0x8000 (unknown) + + cmdline : string + the command line of the process in question + sender : int + Optional sender ID, defaults to SENDER_ID (see sbp/msg.py). + + """ + _parser = construct.Struct( + 'index' / construct.Int8ul, + 'pid' / construct.Int16ul, + 'socket_count' / construct.Int16ul, + 'socket_types' / construct.Int16ul, + 'socket_states' / construct.Int16ul, + 'cmdline' / construct.GreedyBytes,) + __slots__ = [ + 'index', + 'pid', + 'socket_count', + 'socket_types', + 'socket_states', + 'cmdline', + ] + + def __init__(self, sbp=None, **kwargs): + if sbp: + super( MsgLinuxProcessSocketCounts, + self).__init__(sbp.msg_type, sbp.sender, sbp.length, + sbp.payload, sbp.crc) + self.from_binary(sbp.payload) + else: + super( MsgLinuxProcessSocketCounts, self).__init__() + self.msg_type = SBP_MSG_LINUX_PROCESS_SOCKET_COUNTS + self.sender = kwargs.pop('sender', SENDER_ID) + self.index = kwargs.pop('index') + self.pid = kwargs.pop('pid') + self.socket_count = kwargs.pop('socket_count') + self.socket_types = kwargs.pop('socket_types') + self.socket_states = kwargs.pop('socket_states') + self.cmdline = kwargs.pop('cmdline') + + def __repr__(self): + return fmt_repr(self) + + @staticmethod + def from_json(s): + """Given a JSON-encoded string s, build a message object. + + """ + d = json.loads(s) + return MsgLinuxProcessSocketCounts.from_json_dict(d) + + @staticmethod + def from_json_dict(d): + sbp = SBP.from_json_dict(d) + return MsgLinuxProcessSocketCounts(sbp, **d) + + + def from_binary(self, d): + """Given a binary payload d, update the appropriate payload fields of + the message. + + """ + p = MsgLinuxProcessSocketCounts._parser.parse(d) + for n in self.__class__.__slots__: + setattr(self, n, getattr(p, n)) + + def to_binary(self): + """Produce a framed/packed SBP message. + + """ + c = containerize(exclude_fields(self)) + self.payload = MsgLinuxProcessSocketCounts._parser.build(c) + return self.pack() + + def to_json_dict(self): + self.to_binary() + d = super( MsgLinuxProcessSocketCounts, self).to_json_dict() + j = walk_json_dict(exclude_fields(self)) + d.update(j) + return d + +SBP_MSG_LINUX_PROCESS_SOCKET_QUEUES = 0x7F04 +class MsgLinuxProcessSocketQueues(SBP): + """SBP class for message MSG_LINUX_PROCESS_SOCKET_QUEUES (0x7F04). + + You can have MSG_LINUX_PROCESS_SOCKET_QUEUES inherit its fields directly + from an inherited SBP object, or construct it inline using a dict + of its fields. + + + Top 10 list of sockets with deep queues. + + + Parameters + ---------- + sbp : SBP + SBP parent object to inherit from. + index : int + sequence of this status message, values from 0-9 + pid : int + the PID of the process in question + recv_queued : int + the total amount of receive data queued for this process + send_queued : int + the total amount of send data queued for this process + socket_types : int + A bitfield indicating the socket types used: + 0x1 (tcp), 0x2 (udp), 0x4 (unix stream), 0x8 (unix dgram), 0x10 (netlink), + and 0x8000 (unknown) + + socket_states : int + A bitfield indicating the socket states: + 0x1 (established), 0x2 (syn-sent), 0x4 (syn-recv), 0x8 (fin-wait-1), + 0x10 (fin-wait-2), 0x20 (time-wait), 0x40 (closed), 0x80 (close-wait), + 0x100 (last-ack), 0x200 (listen), 0x400 (closing), 0x800 (unconnected), + and 0x8000 (unknown) + + address_of_largest : string + Address of the largest queue, remote or local depending on the directionality +of the connection. + + cmdline : string + the command line of the process in question + sender : int + Optional sender ID, defaults to SENDER_ID (see sbp/msg.py). + + """ + _parser = construct.Struct( + 'index' / construct.Int8ul, + 'pid' / construct.Int16ul, + 'recv_queued' / construct.Int16ul, + 'send_queued' / construct.Int16ul, + 'socket_types' / construct.Int16ul, + 'socket_states' / construct.Int16ul, + 'address_of_largest'/ construct.Bytes(64), + 'cmdline' / construct.GreedyBytes,) + __slots__ = [ + 'index', + 'pid', + 'recv_queued', + 'send_queued', + 'socket_types', + 'socket_states', + 'address_of_largest', + 'cmdline', + ] + + def __init__(self, sbp=None, **kwargs): + if sbp: + super( MsgLinuxProcessSocketQueues, + self).__init__(sbp.msg_type, sbp.sender, sbp.length, + sbp.payload, sbp.crc) + self.from_binary(sbp.payload) + else: + super( MsgLinuxProcessSocketQueues, self).__init__() + self.msg_type = SBP_MSG_LINUX_PROCESS_SOCKET_QUEUES + self.sender = kwargs.pop('sender', SENDER_ID) + self.index = kwargs.pop('index') + self.pid = kwargs.pop('pid') + self.recv_queued = kwargs.pop('recv_queued') + self.send_queued = kwargs.pop('send_queued') + self.socket_types = kwargs.pop('socket_types') + self.socket_states = kwargs.pop('socket_states') + self.address_of_largest = kwargs.pop('address_of_largest') + self.cmdline = kwargs.pop('cmdline') + + def __repr__(self): + return fmt_repr(self) + + @staticmethod + def from_json(s): + """Given a JSON-encoded string s, build a message object. + + """ + d = json.loads(s) + return MsgLinuxProcessSocketQueues.from_json_dict(d) + + @staticmethod + def from_json_dict(d): + sbp = SBP.from_json_dict(d) + return MsgLinuxProcessSocketQueues(sbp, **d) + + + def from_binary(self, d): + """Given a binary payload d, update the appropriate payload fields of + the message. + + """ + p = MsgLinuxProcessSocketQueues._parser.parse(d) + for n in self.__class__.__slots__: + setattr(self, n, getattr(p, n)) + + def to_binary(self): + """Produce a framed/packed SBP message. + + """ + c = containerize(exclude_fields(self)) + self.payload = MsgLinuxProcessSocketQueues._parser.build(c) + return self.pack() + + def to_json_dict(self): + self.to_binary() + d = super( MsgLinuxProcessSocketQueues, self).to_json_dict() + j = walk_json_dict(exclude_fields(self)) + d.update(j) + return d + +SBP_MSG_LINUX_SOCKET_USAGE = 0x7F05 +class MsgLinuxSocketUsage(SBP): + """SBP class for message MSG_LINUX_SOCKET_USAGE (0x7F05). + + You can have MSG_LINUX_SOCKET_USAGE inherit its fields directly + from an inherited SBP object, or construct it inline using a dict + of its fields. + + + Summaries the socket usage across the system. + + + Parameters + ---------- + sbp : SBP + SBP parent object to inherit from. + avg_queue_depth : int + average socket queue depths across all sockets on the system + max_queue_depth : int + the max queue depth seen within the reporting period + socket_state_counts : array + A count for each socket type reported in the `socket_types_reported` field, +the first entry corresponds to the first enabled bit in `types_reported`. + + socket_type_counts : array + A count for each socket type reported in the `socket_types_reported` field, +the first entry corresponds to the first enabled bit in `types_reported`. + + sender : int + Optional sender ID, defaults to SENDER_ID (see sbp/msg.py). + + """ + _parser = construct.Struct( + 'avg_queue_depth' / construct.Int32ul, + 'max_queue_depth' / construct.Int32ul, + 'socket_state_counts' / construct.Array(16, construct.Int16ul), + 'socket_type_counts' / construct.Array(16, construct.Int16ul),) + __slots__ = [ + 'avg_queue_depth', + 'max_queue_depth', + 'socket_state_counts', + 'socket_type_counts', + ] + + def __init__(self, sbp=None, **kwargs): + if sbp: + super( MsgLinuxSocketUsage, + self).__init__(sbp.msg_type, sbp.sender, sbp.length, + sbp.payload, sbp.crc) + self.from_binary(sbp.payload) + else: + super( MsgLinuxSocketUsage, self).__init__() + self.msg_type = SBP_MSG_LINUX_SOCKET_USAGE + self.sender = kwargs.pop('sender', SENDER_ID) + self.avg_queue_depth = kwargs.pop('avg_queue_depth') + self.max_queue_depth = kwargs.pop('max_queue_depth') + self.socket_state_counts = kwargs.pop('socket_state_counts') + self.socket_type_counts = kwargs.pop('socket_type_counts') + + def __repr__(self): + return fmt_repr(self) + + @staticmethod + def from_json(s): + """Given a JSON-encoded string s, build a message object. + + """ + d = json.loads(s) + return MsgLinuxSocketUsage.from_json_dict(d) + + @staticmethod + def from_json_dict(d): + sbp = SBP.from_json_dict(d) + return MsgLinuxSocketUsage(sbp, **d) + + + def from_binary(self, d): + """Given a binary payload d, update the appropriate payload fields of + the message. + + """ + p = MsgLinuxSocketUsage._parser.parse(d) + for n in self.__class__.__slots__: + setattr(self, n, getattr(p, n)) + + def to_binary(self): + """Produce a framed/packed SBP message. + + """ + c = containerize(exclude_fields(self)) + self.payload = MsgLinuxSocketUsage._parser.build(c) + return self.pack() + + def to_json_dict(self): + self.to_binary() + d = super( MsgLinuxSocketUsage, self).to_json_dict() + j = walk_json_dict(exclude_fields(self)) + d.update(j) + return d + + +msg_classes = { + 0x7F00: MsgLinuxCpuState, + 0x7F01: MsgLinuxMemState, + 0x7F02: MsgLinuxSysState, + 0x7F03: MsgLinuxProcessSocketCounts, + 0x7F04: MsgLinuxProcessSocketQueues, + 0x7F05: MsgLinuxSocketUsage, +} \ No newline at end of file diff --git a/python/sbp/table.py b/python/sbp/table.py index b4dc094870..b253793bb8 100755 --- a/python/sbp/table.py +++ b/python/sbp/table.py @@ -19,6 +19,7 @@ from . import bootload as boot from . import file_io as file_io from . import flash as flash +from . import linux as linux from . import logging as log from . import navigation as nav from . import observation as obs @@ -42,6 +43,7 @@ + boot.msg_classes.items() + file_io.msg_classes.items() + flash.msg_classes.items() + + linux.msg_classes.items() + log.msg_classes.items() + nav.msg_classes.items() + obs.msg_classes.items() diff --git a/python/tests/sbp/test_table.py b/python/tests/sbp/test_table.py index ba432070a9..006a15a17a 100644 --- a/python/tests/sbp/test_table.py +++ b/python/tests/sbp/test_table.py @@ -16,6 +16,7 @@ from sbp import bootload as boot from sbp import file_io as file_io from sbp import flash as flash +from sbp import linux as linux from sbp import logging as log from sbp import navigation as nav from sbp import observation as obs @@ -43,7 +44,7 @@ def test_table_count(): Test number of available messages to deserialize. """ - number_of_messages = 152 + number_of_messages = 158 assert len(_SBP_TABLE) == number_of_messages def test_table_unqiue_count(): @@ -54,6 +55,7 @@ def test_table_unqiue_count(): + len(boot.msg_classes) + len(file_io.msg_classes) + len(flash.msg_classes) + + len(linux.msg_classes) + len(log.msg_classes) + len(nav.msg_classes) + len(obs.msg_classes) diff --git a/spec/yaml/swiftnav/sbp/linux.yaml b/spec/yaml/swiftnav/sbp/linux.yaml new file mode 100644 index 0000000000..ff304ba248 --- /dev/null +++ b/spec/yaml/swiftnav/sbp/linux.yaml @@ -0,0 +1,196 @@ +# Copyright (C) 2015 Swift Navigation Inc. +# Contact: Fergus Noble +# +# This source is subject to the license found in the file 'LICENSE' which must +# be be distributed together with this source. All other rights reserved. +# +# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. + +package: swiftnav.sbp.linux +description: | + Linux state monitoring. + +stable: False +public: False + +include: + - types.yaml + +definitions: + + - MSG_LINUX_CPU_STATE: + id: 0x7F00 + short_desc: List CPU state on the system + desc: | + This message indicates the process state of the top 10 heaviest + consumers of CPU on the system. + fields: + - index: + type: u8 + desc: sequence of this status message, values from 0-9 + - pid: + type: u16 + desc: the PID of the process + - pcpu: + type: u8 + desc: percent of cpu used, expressed as a fraction of 256 + - tname: + type: string + size: 15 + desc: fixed length string representing the thread name + - cmdline: + type: string + desc: the command line (as much as it fits in the remaining packet) + + - MSG_LINUX_MEM_STATE: + id: 0x7F01 + short_desc: List CPU state on the system + desc: | + This message indicates the process state of the top 10 heaviest + consumers of memory on the system. + fields: + - index: + type: u8 + desc: sequence of this status message, values from 0-9 + - pid: + type: u16 + desc: the PID of the process + - pmem: + type: u8 + desc: percent of memory used, expressed as a fraction of 256 + - tname: + type: string + size: 15 + desc: fixed length string representing the thread name + - cmdline: + type: string + desc: the command line (as much as it fits in the remaining packet) + + - MSG_LINUX_SYS_STATE: + id: 0x7F02 + short_desc: CPU, Memory and Process Starts/Stops + desc: | + This presents a summary of CPU and memory utilization. + fields: + - mem_total: + type: u16 + desc: total system memory + - pcpu: + type: u8 + desc: percent of total cpu currently utilized + - pmem: + type: u8 + desc: percent of total memory currently utilized + - procs_starting: + type: u16 + desc: number of processes that started during collection phase + - procs_stopping: + type: u16 + desc: number of processes that stopped during collection phase + - pid_count: + type: u16 + desc: the count of processes on the system + + - MSG_LINUX_PROCESS_SOCKET_COUNTS: + id: 0x7F03 + short_desc: A list of processes with high socket counts + desc: | + Top 10 list of processes with high socket counts. + fields: + - index: + type: u8 + desc: sequence of this status message, values from 0-9 + - pid: + type: u16 + desc: the PID of the process in question + - socket_count: + type: u16 + desc: the number of sockets the process is using + - socket_types: + type: u16 + desc: | + A bitfield indicating the socket types used: + 0x1 (tcp), 0x2 (udp), 0x4 (unix stream), 0x8 (unix dgram), 0x10 (netlink), + and 0x8000 (unknown) + - socket_states: + type: u16 + desc: | + A bitfield indicating the socket states: + 0x1 (established), 0x2 (syn-sent), 0x4 (syn-recv), 0x8 (fin-wait-1), + 0x10 (fin-wait-2), 0x20 (time-wait), 0x40 (closed), 0x80 (close-wait), + 0x100 (last-ack), 0x200 (listen), 0x400 (closing), 0x800 (unconnected), + and 0x8000 (unknown) + - cmdline: + type: string + desc: the command line of the process in question + + - MSG_LINUX_PROCESS_SOCKET_QUEUES: + id: 0x7F04 + short_desc: A list of processes with deep socket queues + desc: | + Top 10 list of sockets with deep queues. + fields: + - index: + type: u8 + desc: sequence of this status message, values from 0-9 + - pid: + type: u16 + desc: the PID of the process in question + - recv_queued: + type: u16 + desc: the total amount of receive data queued for this process + - send_queued: + type: u16 + desc: the total amount of send data queued for this process + - socket_types: + type: u16 + desc: | + A bitfield indicating the socket types used: + 0x1 (tcp), 0x2 (udp), 0x4 (unix stream), 0x8 (unix dgram), 0x10 (netlink), + and 0x8000 (unknown) + - socket_states: + type: u16 + desc: | + A bitfield indicating the socket states: + 0x1 (established), 0x2 (syn-sent), 0x4 (syn-recv), 0x8 (fin-wait-1), + 0x10 (fin-wait-2), 0x20 (time-wait), 0x40 (closed), 0x80 (close-wait), + 0x100 (last-ack), 0x200 (listen), 0x400 (closing), 0x800 (unconnected), + and 0x8000 (unknown) + - address_of_largest: + type: string + size: 64 + desc: | + Address of the largest queue, remote or local depending on the directionality + of the connection. + - cmdline: + type: string + desc: the command line of the process in question + + - MSG_LINUX_SOCKET_USAGE: + id: 0x7F05 + short_desc: Summary of socket usage across the system + desc: | + Summaries the socket usage across the system. + fields: + - avg_queue_depth: + type: u32 + desc: average socket queue depths across all sockets on the system + - max_queue_depth: + type: u32 + desc: the max queue depth seen within the reporting period + - socket_state_counts: + type: array + size: 16 + fill: u16 + desc: | + A count for each socket type reported in the `socket_types_reported` field, + the first entry corresponds to the first enabled bit in `types_reported`. + - socket_type_counts: + type: array + size: 16 + fill: u16 + desc: | + A count for each socket type reported in the `socket_types_reported` field, + the first entry corresponds to the first enabled bit in `types_reported`.