-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | AgentX protocol for write SNMP subagents -- @package agentx @version 0.2.0.0 module Network.Protocol.Snmp.AgentX.Packet -- | Packet type, describe agentx packet. data Packet mkPacket :: Version -> PDU -> Flags -> SessionID -> TransactionID -> PacketID -> Packet pdu :: ArrowApply cat => Lens cat Packet PDU flags :: ArrowApply cat => Lens cat Packet Flags tid :: ArrowApply cat => Lens cat Packet TransactionID pid :: ArrowApply cat => Lens cat Packet PacketID sid :: ArrowApply cat => Lens cat Packet SessionID -- | rfc 2741, section 6.2 data PDU -- | section 6.2.1 Open :: Timeout -> OID -> Description -> PDU -- | section 6.2.2 Close :: Reason -> PDU -- | section 6.2.3 Register :: MContext -> Timeout -> Priority -> RangeSubid -> OID -> UpperBound -> PDU -- | section 6.2.4 Unregister :: MContext -> Priority -> RangeSubid -> OID -> UpperBound -> PDU -- | section 6.2.5 Get :: MContext -> [OID] -> PDU -- | section 6.2.6 GetNext :: MContext -> [SearchRange] -> PDU -- | section 6.2.7 GetBulk :: MContext -> NonRepeaters -> MaxRepeaters -> [SearchRange] -> PDU -- | section 6.2.8 TestSet :: MContext -> [VarBind] -> PDU -- | section 6.2.9 CommitSet :: PDU -- | section 6.2.9 UndoSet :: PDU -- | section 6.2.9 CleanupSet :: PDU -- | section 6.2.10 Notify :: MContext -> [VarBind] -> PDU -- | section 6.2.11 Ping :: MContext -> PDU -- | section 6.2.12 IndexAllocate :: MContext -> [VarBind] -> PDU -- | section 6.2.13 IndexDeallocate :: MContext -> [VarBind] -> PDU -- | section 6.2.14 AddAgentCaps :: MContext -> OID -> Description -> PDU -- | section 6.2.15 RemoveAgentCaps :: MContext -> OID -> PDU -- | section 6.2.16 Response :: SysUptime -> TaggedError -> Index -> [VarBind] -> PDU -- | packet id in header, rfc 2741, section 6.1 data PacketID -- | session id in header, rfc 2741, section 6.1 data SessionID -- | transaction id in header, rfc 2741, section 6.1 data TransactionID -- | header flags, rfc 2741, section 6.1 data Flags type InstanceRegistration = Bool type NewIndex = Bool type AnyIndex = Bool type NonDefaultContext = Bool type BigEndian = Bool mkFlags :: InstanceRegistration -> NewIndex -> AnyIndex -> NonDefaultContext -> BigEndian -> Flags instanceRegistration :: ArrowApply cat => Lens cat Flags InstanceRegistration newIndex :: ArrowApply cat => Lens cat Flags NewIndex anyIndex :: ArrowApply cat => Lens cat Flags AnyIndex nonDefaultContext :: ArrowApply cat => Lens cat Flags NonDefaultContext bigEndian :: ArrowApply cat => Lens cat Flags BigEndian -- | used for getnext and other requests (rfc 2741, section5.2 ) data SearchRange -- | create SearchRange mkSearchRange :: OID -> OID -> Bool -> SearchRange startOID :: ArrowApply cat => Lens cat SearchRange OID endOID :: ArrowApply cat => Lens cat SearchRange OID include :: ArrowApply cat => Lens cat SearchRange Bool -- | containt oid and value (rfc 2741, section 5.4) data VarBind -- | constructor for VarBind mkVarBind :: OID -> Value -> VarBind vboid :: ArrowApply cat => Lens cat VarBind OID vbvalue :: ArrowApply cat => Lens cat VarBind Value -- | rfc 2571 section 3.3.1, rfc 2741 section 6.1.1 Context data Context type SysUptime = Word32 type Index = Word16 type NonRepeaters = Word16 type MaxRepeaters = Word16 -- | rfc 2741, 6.2.16, Error status in agentx-response-pdu data RError NoAgentXError :: RError OpenFailed :: RError NotOpen :: RError IndexWrongType :: RError IndexAlreadyAllocated :: RError IndexNonAvailable :: RError IndexNotAllocated :: RError UnsupportedContext :: RError DuplicateRegistration :: RError UnknownRegistration :: RError UnknownAgentCaps :: RError RParseError :: RError RequestDenied :: RError ProcessingError :: RError -- | result for undoSetAIO (rfc 2741, section 7.2.4.3) data UndoError NoUndoError :: UndoError UndoFailed :: UndoError -- | result for testSetAIO (rfc 2741, section 7.2.4.1) data TestError NoTestError :: TestError TooBig :: TestError NoSuchName :: TestError BadValue :: TestError ReadOnly :: TestError GenError :: TestError NoAccess :: TestError WrongType :: TestError WrongLength :: TestError WrongEncoding :: TestError WrongValue :: TestError NoCreation :: TestError InconsistentValue :: TestError ResourceUnavailable :: TestError NotWritable :: TestError InconsistentName :: TestError -- | result for commitSetAIO (rfc 2741, section 7.2.4.2) data CommitError NoCommitError :: CommitError CommitFailed :: CommitError -- | Error with Tag instance data TaggedError Tagged :: a -> TaggedError -- | get body size from header bodySizeFromHeader :: ByteString -> Int64 -- | helper for convert econvert :: (Enum a, Enum b) => a -> b module Network.Protocol.Snmp.AgentX.MIBTree -- | MIBTree, state transformer, with Module under ground type MIBTree = StateT Module -- | internal state for build SNMP submodule data Module -- | Constructor for Module mkModule :: OID -> [MIB] -> IO Module -- | build tree and init module initModule :: MIBTree IO () -- | register all MIBs in snmp server registerFullTree :: (Monad m, MonadIO m, Functor m) => MIBTree m () unregisterFullTree :: (Monad m, MonadIO m, Functor m) => MIBTree m () askTree :: (Monad m, MonadIO m, Functor m) => MIBTree m (Tree IValue) regByDiff :: (Monad m, MonadIO m, Functor m) => Tree IValue -> Tree IValue -> MIBTree m () moduleOID :: ArrowApply cat => Lens cat Module OID register :: ArrowApply cat => Lens cat Module (MVar ([(OID, Maybe Context)], [(OID, Maybe Context)])) zipper :: ArrowApply cat => Lens cat Module (Zipper Tree IValue) ou :: ArrowApply cat => Lens cat Module (Zipper Tree IUpdate) -- | find one MIB findOne :: OID -> Maybe Context -> MIBTree IO MIB -- | like findOne, but for many paths findMany :: [OID] -> Maybe Context -> MIBTree IO [MIB] -- | find next node in MIBTree findNext :: SearchRange -> Maybe Context -> MIBTree IO MIB -- | like findNext findManyNext :: [SearchRange] -> Maybe Context -> MIBTree IO [MIB] type Parent = String type Name = String -- | MIB describe objects and object-types in internal tree with data. data MIB -- | accessor for OID oi :: MIB -> OID -- | accessor for PVal val :: MIB -> PVal -- | accessor for Maybe Context context :: MIB -> Maybe Context -- | Constructor for MIB, create Object in mib tree mkObject :: Integer -> Parent -> Name -> Maybe Update -> MIB -- | Constructor for MIB, create Object-Type in mib tree mkObjectType :: Integer -> Parent -> Name -> Maybe Context -> PVal -> MIB -- | check MIB subtype isObjectType :: MIB -> Bool -- | Update, for rebuild oid tree in runtime newtype Update Update :: IO [MIB] -> Update unUpdate :: Update -> IO [MIB] -- | Wrapper for value data PVal Read :: IO Value -> PVal readAIO :: PVal -> IO Value ReadWrite :: IO Value -> (Value -> IO CommitError) -> (Value -> IO TestError) -> (Value -> IO UndoError) -> PVal readAIO :: PVal -> IO Value commitSetAIO :: PVal -> Value -> IO CommitError testSetAIO :: PVal -> Value -> IO TestError undoSetAIO :: PVal -> Value -> IO UndoError -- | check for PVal isWritable :: PVal -> Bool -- | PVal constructor for read only value rsValue :: Value -> PVal -- | PVal constructor for read only IO Value rdValue :: IO Value -> PVal -- | PVal constructor for read write value rwValue :: IO Value -> (Value -> IO CommitError) -> (Value -> IO TestError) -> (Value -> IO UndoError) -> PVal -- | wrap MIBTree action, get MIB tree before and after, register added -- mibs, unregister removed mibs regWrapper :: (Monad m, MonadIO m, Functor m) => MIBTree m x -> MIBTree m x -- | convert MIB to VarBind mibToVarBind :: MIB -> IO VarBind module Network.Protocol.Snmp.AgentX.Types data SubAgentState SubAgentState :: IORef SysUptime -> IORef PacketID -> TVar Module -> Socket -> IORef (Maybe SessionID) -> IORef (Map TransactionID Transaction) -> SubAgentState sysuptime :: SubAgentState -> IORef SysUptime packetCounter :: SubAgentState -> IORef PacketID mibs :: SubAgentState -> TVar Module sock :: SubAgentState -> Socket sessions :: SubAgentState -> IORef (Maybe SessionID) transactions :: SubAgentState -> IORef (Map TransactionID Transaction) data Transaction Transaction :: Maybe Context -> [VarBind] -> TransactionState -> Transaction tcontext :: Transaction -> Maybe Context vblist :: Transaction -> [VarBind] statusV :: Transaction -> TransactionState -- | run MIBTree in SubAgent context, without lock, if trees was changed, -- retry runMIBTree :: MIBTree IO a -> SubAgent a type SubAgent = ReaderT SubAgentState IO data TransactionState TestSetT :: TransactionState CommitSetT :: TransactionState UndoSetT :: TransactionState CleanupSetT :: TransactionState instance Show TransactionState instance Eq TransactionState instance Ord TransactionState instance Enum TransactionState instance Show Transaction module Network.Protocol.Snmp.AgentX.Handlers -- | processing request, return response route :: Packet -> SubAgent (Maybe Packet) module Network.Protocol.Snmp.AgentX.Service -- | start agent agent :: FilePath -> OID -> Maybe Client -> [MIB] -> IO () -- | start agent with socket exit when catch sigQUIT, sigTERM, -- keyboardSignal show MIB tree when catch sigUSR1 runAgent :: OID -> [MIB] -> Maybe Client -> Socket -> IO () -- | if you need client newtype Client Client :: Pipe Packet Packet SubAgent () -> Client runClient :: Client -> Pipe Packet Packet SubAgent () -- | simple request for client, if you dont need response. request :: Packet -> Pipe Packet Packet SubAgent () -- | as request, but you can work with response. requestWithResponse :: Packet -> Pipe Packet Packet SubAgent Packet instance Default Client module Network.Protocol.Snmp.AgentX -- | MIB describe objects and object-types in internal tree with data. data MIB -- | Snmp data types data Value :: * OI :: OID -> Value Zero :: Value Integer :: Int32 -> Value String :: ByteString -> Value IpAddress :: Word8 -> Word8 -> Word8 -> Word8 -> Value Counter32 :: Word32 -> Value Gauge32 :: Word32 -> Value TimeTicks :: Word32 -> Value Opaque :: ByteString -> Value Counter64 :: Word64 -> Value ZeroDotZero :: Value NoSuchInstance :: Value NoSuchObject :: Value EndOfMibView :: Value -- | Wrapper for value data PVal Read :: IO Value -> PVal readAIO :: PVal -> IO Value ReadWrite :: IO Value -> (Value -> IO CommitError) -> (Value -> IO TestError) -> (Value -> IO UndoError) -> PVal readAIO :: PVal -> IO Value commitSetAIO :: PVal -> Value -> IO CommitError testSetAIO :: PVal -> Value -> IO TestError undoSetAIO :: PVal -> Value -> IO UndoError -- | PVal constructor for read write value rwValue :: IO Value -> (Value -> IO CommitError) -> (Value -> IO TestError) -> (Value -> IO UndoError) -> PVal -- | PVal constructor for read only value rsValue :: Value -> PVal -- | PVal constructor for read only IO Value rdValue :: IO Value -> PVal -- | Update, for rebuild oid tree in runtime newtype Update Update :: IO [MIB] -> Update unUpdate :: Update -> IO [MIB] -- | Constructor for MIB, create Object in mib tree mkObject :: Integer -> Parent -> Name -> Maybe Update -> MIB -- | Constructor for MIB, create Object-Type in mib tree mkObjectType :: Integer -> Parent -> Name -> Maybe Context -> PVal -> MIB -- | result for commitSetAIO (rfc 2741, section 7.2.4.2) data CommitError NoCommitError :: CommitError CommitFailed :: CommitError -- | result for testSetAIO (rfc 2741, section 7.2.4.1) data TestError NoTestError :: TestError TooBig :: TestError NoSuchName :: TestError BadValue :: TestError ReadOnly :: TestError GenError :: TestError NoAccess :: TestError WrongType :: TestError WrongLength :: TestError WrongEncoding :: TestError WrongValue :: TestError NoCreation :: TestError InconsistentValue :: TestError ResourceUnavailable :: TestError NotWritable :: TestError InconsistentName :: TestError -- | result for undoSetAIO (rfc 2741, section 7.2.4.3) data UndoError NoUndoError :: UndoError UndoFailed :: UndoError -- | rfc 2571 section 3.3.1, rfc 2741 section 6.1.1 Context data Context -- | start agent agent :: FilePath -> OID -> Maybe Client -> [MIB] -> IO () -- | start agent with socket exit when catch sigQUIT, sigTERM, -- keyboardSignal show MIB tree when catch sigUSR1 runAgent :: OID -> [MIB] -> Maybe Client -> Socket -> IO () -- | if you need client data Client