snmp-0.2.1.1: API for write snmp client.

Safe HaskellNone
LanguageHaskell2010

Network.Protocol.Snmp

Contents

Synopsis

snmp types

type OID = [Integer]

Standard ASN.1 Object ID (OID)

type OIDS = [OID] Source

top level types

data V2 Source

Phantom type for version 2 (Header V2, PDU V2)

data V3 Source

Phantom type for version 3 (Header V3, PDU V3)

data Packet Source

Top level type, which describe snmp packet

header

data Header a Source

Snmp header without version tag

header snmpV2

newtype Community Source

(snmp2 only) Community for 2(1) version

Constructors

Community ByteString 

header snmpV3

newtype ID Source

(snmp3 only) Message Identifier (like RequestId in PDU)

Constructors

ID Int32 

Instances

newtype MaxSize Source

(snmp3 only) Message max size must be > 484

Constructors

MaxSize Integer 

data Flag Source

(snmp3 only) rfc3412, message flag

Constructors

Flag Reportable PrivAuth 

data SecurityModel Source

(snmp3 only) rfc3412, security model

type Reportable = Bool Source

(snmp3 only) rfc3412, as PrivAuth

data PrivAuth Source

(snmp3 only) rfc3412, type for create message flag

Instances

PDU

data PDU a where Source

Snmp body

Constructors

CryptedPDU :: ByteString -> PDU V3 

PDU universal

type RequestId = Int32 Source

Request id

type ErrorStatus = Integer Source

Error status

type ErrorIndex = Integer Source

Error index

newtype Suite Source

Variable bindings

Constructors

Suite [Coupla] 

data Coupla Source

Coupla oid -> value

Constructors

Coupla 

Fields

oid :: OID
 
value :: Value
 

Instances

PDU snmpV3

newtype ContextEngineID Source

(snmp3 only) rfc3412, types for ScopedPDU

some classes and helpers

universal, for work with both versions

class HasItem a where Source

some universal getters, setters

Instances

v2 only, for work with Header V2

class HasV2 a where Source

(snmp2 only) getters, setters for work with Header V2

Instances

v3 only, for work with Header V3, PDU V3

class HasV3 a where Source

(snmp3 only) getters, setters for work with Header V3 and PDU V3.

Instances

create new Packet

class Construct a where Source

initial new object, like mempty for monoid

Methods

initial :: a Source

helpers for work with Packet

universal

v2 only

v3 only

authentication

passwordToKey :: AuthType -> Password -> EngineId -> Key Source

create auth key from password and context engine id

signPacket :: AuthType -> Key -> Packet -> Packet Source

(only V3) sign Packet

data AuthType Source

Constructors

MD5 
SHA 

Instances

data PrivType Source

Constructors

DES 
AES 

Instances

priv

exceptions

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