Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Value
- type OID = [Integer]
- type OIDS = [OID]
- data V2
- data V3
- data Version
- data Packet
- data Header a
- newtype Community = Community ByteString
- newtype ID = ID Int32
- newtype MaxSize = MaxSize Integer
- data Flag = Flag Reportable PrivAuth
- data SecurityModel = UserBasedSecurityModel
- data SecurityParameter = SecurityParameter {}
- type Reportable = Bool
- data PrivAuth
- type EngineBootId = Int32
- type PrivacyParameter = ByteString
- type EngineTime = Int32
- type EngineId = ByteString
- data PDU a where
- CryptedPDU :: ByteString -> PDU V3
- data Request
- = GetRequest {
- rid :: RequestId
- es :: ErrorStatus
- ei :: ErrorIndex
- | GetNextRequest {
- rid :: RequestId
- es :: ErrorStatus
- ei :: ErrorIndex
- | GetResponse {
- rid :: RequestId
- es :: ErrorStatus
- ei :: ErrorIndex
- | SetRequest {
- rid :: RequestId
- es :: ErrorStatus
- ei :: ErrorIndex
- | GetBulk {
- rid :: RequestId
- es :: ErrorStatus
- ei :: ErrorIndex
- | Inform {
- rid :: RequestId
- es :: ErrorStatus
- ei :: ErrorIndex
- | V2Trap {
- rid :: RequestId
- es :: ErrorStatus
- ei :: ErrorIndex
- | Report {
- rid :: RequestId
- es :: ErrorStatus
- ei :: ErrorIndex
- = GetRequest {
- type RequestId = Int32
- type ErrorStatus = Integer
- type ErrorIndex = Integer
- newtype Suite = Suite [Coupla]
- data Coupla = Coupla {}
- newtype ContextEngineID = ContextEngineID ByteString
- newtype ContextName = ContextName ByteString
- class HasItem a where
- class HasV2 a where
- getCommunity :: Header a -> Community
- setCommunity :: Community -> Header a -> Header a
- class HasV3 a where
- getID :: Header a -> ID
- getMaxSize :: Header a -> MaxSize
- getFlag :: Header a -> Flag
- getSecurityModel :: Header a -> SecurityModel
- getSecurityParameter :: Header a -> SecurityParameter
- getAuthoritiveEngineId :: Header a -> ByteString
- getAuthoritiveEngineBoots :: Header a -> Int32
- getAuthoritiveEngineTime :: Header a -> Int32
- getUserName :: Header a -> ByteString
- getAuthenticationParameters :: Header a -> ByteString
- getPrivacyParameters :: Header a -> ByteString
- getContextEngineID :: PDU a -> ContextEngineID
- getContextName :: PDU a -> ContextName
- setID :: ID -> Header a -> Header a
- setMaxSize :: MaxSize -> Header a -> Header a
- setFlag :: Flag -> Header a -> Header a
- setSecurityModel :: SecurityModel -> Header a -> Header a
- setSecurityParameter :: SecurityParameter -> Header a -> Header a
- setAuthoritiveEngineId :: ByteString -> Header a -> Header a
- setAuthoritiveEngineBoots :: Int32 -> Header a -> Header a
- setAuthoritiveEngineTime :: Int32 -> Header a -> Header a
- setUserName :: ByteString -> Header a -> Header a
- setAuthenticationParameters :: ByteString -> Header a -> Header a
- setPrivacyParameters :: ByteString -> Header a -> Header a
- setContextEngineID :: ContextEngineID -> PDU a -> PDU a
- setContextName :: ContextName -> PDU a -> PDU a
- class Construct a where
- initial :: a
- getVersion :: Packet -> Version
- getRequest :: Packet -> Request
- setRequest :: Request -> Packet -> Packet
- getRid :: Packet -> RequestId
- setRid :: RequestId -> Packet -> Packet
- getSuite :: Packet -> Suite
- setSuite :: Suite -> Packet -> Packet
- getErrorStatus :: Packet -> ErrorStatus
- setErrorStatus :: ErrorStatus -> Packet -> Packet
- setCommunityP :: Community -> Packet -> Packet
- setIDP :: ID -> Packet -> Packet
- setMaxSizeP :: MaxSize -> Packet -> Packet
- setUserNameP :: ByteString -> Packet -> Packet
- getAuthenticationParametersP :: Packet -> ByteString
- setAuthenticationParametersP :: ByteString -> Packet -> Packet
- setReportableP :: Reportable -> Packet -> Packet
- setPrivAuthP :: PrivAuth -> Packet -> Packet
- getEngineIdP :: Packet -> EngineId
- setEngineIdP :: EngineId -> Packet -> Packet
- getEngineBootsP :: Packet -> EngineBootId
- setEngineBootsP :: EngineBootId -> Packet -> Packet
- getEngineTimeP :: Packet -> Int32
- setEngineTimeP :: Int32 -> Packet -> Packet
- getPrivParametersP :: Packet -> ByteString
- setPrivParametersP :: ByteString -> Packet -> Packet
- passwordToKey :: AuthType -> Password -> EngineId -> Key
- signPacket :: AuthType -> Key -> Packet -> Packet
- data AuthType
- data PrivType
- type Password = ByteString
- type Key = ByteString
- cleanPass :: ByteString
- type Salt = ByteString
- type Raw = ByteString
- type Encrypted = ByteString
- type Rand32 = Int32
- type Rand64 = Int64
- desEncrypt :: Key -> EngineBootId -> Rand32 -> Raw -> (Encrypted, Salt)
- desDecrypt :: Key -> Salt -> Encrypted -> Raw
- aesEncrypt :: Key -> EngineBootId -> EngineTime -> Rand64 -> Raw -> (Encrypted, Salt)
- aesDecrypt :: Key -> Salt -> EngineBootId -> EngineTime -> Encrypted -> Raw
- toSalt :: Int32 -> Int32 -> ByteString
- data ClientException
snmp types
Snmp data types
top level types
Phantom type for version 2 (Header V2, PDU V2)
Phantom type for version 3 (Header V3, PDU V3)
Snmp version tag
Top level type, which describe snmp packet
header
Snmp header without version tag
header snmpV2
(snmp2 only) Community for 2(1) version
header snmpV3
(snmp3 only) Message Identifier (like RequestId in PDU)
(snmp3 only) Message max size must be > 484
(snmp3 only) rfc3412, message flag
data SecurityModel Source
(snmp3 only) rfc3412, security model
type Reportable = Bool Source
(snmp3 only) rfc3412, as PrivAuth
(snmp3 only) rfc3412, type for create message flag
type EngineBootId = Int32 Source
type PrivacyParameter = ByteString Source
type EngineTime = Int32 Source
type EngineId = ByteString Source
PDU
Snmp body
CryptedPDU :: ByteString -> PDU V3 |
PDU universal
requests
GetRequest | |
| |
GetNextRequest | |
| |
GetResponse | |
| |
SetRequest | |
| |
GetBulk | |
| |
Inform | |
| |
V2Trap | |
| |
Report | |
|
type ErrorStatus = Integer Source
Error status
type ErrorIndex = Integer Source
Error index
Variable bindings
PDU snmpV3
newtype ContextEngineID Source
(snmp3 only) rfc3412, types for ScopedPDU
some classes and helpers
universal, for work with both versions
some universal getters, setters
v2 only, for work with Header V2
(snmp2 only) getters, setters for work with Header V2
getCommunity :: Header a -> Community Source
setCommunity :: Community -> Header a -> Header a Source
v3 only, for work with Header V3, PDU V3
(snmp3 only) getters, setters for work with Header V3 and PDU V3.
getID :: Header a -> ID Source
getMaxSize :: Header a -> MaxSize Source
getFlag :: Header a -> Flag Source
getSecurityModel :: Header a -> SecurityModel Source
getSecurityParameter :: Header a -> SecurityParameter Source
getAuthoritiveEngineId :: Header a -> ByteString Source
getAuthoritiveEngineBoots :: Header a -> Int32 Source
getAuthoritiveEngineTime :: Header a -> Int32 Source
getUserName :: Header a -> ByteString Source
getAuthenticationParameters :: Header a -> ByteString Source
getPrivacyParameters :: Header a -> ByteString Source
getContextEngineID :: PDU a -> ContextEngineID Source
getContextName :: PDU a -> ContextName Source
setID :: ID -> Header a -> Header a Source
setMaxSize :: MaxSize -> Header a -> Header a Source
setFlag :: Flag -> Header a -> Header a Source
setSecurityModel :: SecurityModel -> Header a -> Header a Source
setSecurityParameter :: SecurityParameter -> Header a -> Header a Source
setAuthoritiveEngineId :: ByteString -> Header a -> Header a Source
setAuthoritiveEngineBoots :: Int32 -> Header a -> Header a Source
setAuthoritiveEngineTime :: Int32 -> Header a -> Header a Source
setUserName :: ByteString -> Header a -> Header a Source
setAuthenticationParameters :: ByteString -> Header a -> Header a Source
setPrivacyParameters :: ByteString -> Header a -> Header a Source
setContextEngineID :: ContextEngineID -> PDU a -> PDU a Source
setContextName :: ContextName -> PDU a -> PDU a Source
create new Packet
helpers for work with Packet
universal
getVersion :: Packet -> Version Source
getRequest :: Packet -> Request Source
setRequest :: Request -> Packet -> Packet Source
setErrorStatus :: ErrorStatus -> Packet -> Packet Source
v2 only
setCommunityP :: Community -> Packet -> Packet Source
v3 only
setMaxSizeP :: MaxSize -> Packet -> Packet Source
setUserNameP :: ByteString -> Packet -> Packet Source
setReportableP :: Reportable -> Packet -> Packet Source
setPrivAuthP :: PrivAuth -> Packet -> Packet Source
getEngineIdP :: Packet -> EngineId Source
setEngineIdP :: EngineId -> Packet -> Packet Source
setEngineBootsP :: EngineBootId -> Packet -> Packet Source
getEngineTimeP :: Packet -> Int32 Source
setEngineTimeP :: Int32 -> Packet -> Packet Source
setPrivParametersP :: ByteString -> Packet -> Packet Source
authentication
passwordToKey :: AuthType -> Password -> EngineId -> Key Source
create auth key from password and context engine id
type Password = ByteString Source
type Key = ByteString Source
priv
type Salt = ByteString Source
type Raw = ByteString Source
type Encrypted = ByteString Source
desEncrypt :: Key -> EngineBootId -> Rand32 -> Raw -> (Encrypted, Salt) Source
aesEncrypt :: Key -> EngineBootId -> EngineTime -> Rand64 -> Raw -> (Encrypted, Salt) Source
aesDecrypt :: Key -> Salt -> EngineBootId -> EngineTime -> Encrypted -> Raw Source
toSalt :: Int32 -> Int32 -> ByteString Source
exceptions
data ClientException Source
some exception
usage example
Here example for snmpV2
import Network.Protocol.Snmp import Control.Applicative import Network.Socket.ByteString (recv, sendAll) import Network.Socket hiding (recv, sendAll) -- create new empty packet v2 :: Packet v2 = initial Version2 community = Community "hello" oi = Coupla [1,3,6,1,2,1,1,4,0] Zero -- set community, oid packet :: Community -> Coupla -> Packet packet community oi = setCommunityP community . setSuite (Suite [oi]) $ v2 -- here must be code for create udp socket makeSocket :: Hostname -> Port -> IO Socket makeSocket = undefined main :: IO () main = do socket <- makeSocket "localhost" "161" sendAll socket $ encode $ setRequest (GetRequest 1 0 0) packet result <- decode <$> recv socket 1500 :: IO Packet print $ getSuite result