Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from ctypes import *
- # C define statements! (#define SMI_VERSION_MAJOR 0)
- SMI_LIBRARY_VERSION = c_char_p("2:25:0")
- #extern const char *smi_library_version; ?? what to do with this. hrmm.
- SMI_VERSION_MAJOR= 0
- SMI_VERSION_MINOR= 4
- SMI_VERSION_PATCHLEVEL= 5
- SMI_VERSION_STRING = c_char_p("0.4.5")
- #extern const char *smi_version_string; ?? what to do with this. hrmm.
- SMI_FLAG_NODESCR = 0x0800 #/* do not load descriptions/references. */
- SMI_FLAG_VIEWALL = 0x1000 #/* all modules are `known', need no views. */
- SMI_FLAG_ERRORS = 0x2000 #/* print parser errors. */
- SMI_FLAG_RECURSIVE = 0x4000 #/* recursively parse imported modules. */
- SMI_FLAG_STATS = 0x8000 #/* print statistics after parsing module. */
- SMI_FLAG_MASK = (SMI_FLAG_NODESCR,SMI_FLAG_VIEWALL,SMI_FLAG_STATS,SMI_FLAG_RECURSIVE,SMI_FLAG_ERRORS)
- SMI_NODEKIND_UNKNOWN=0x0000 #/* should not occur */
- SMI_NODEKIND_NODE=0x0001
- SMI_NODEKIND_SCALAR=0x0002
- SMI_NODEKIND_TABLE=0x0004
- SMI_NODEKIND_ROW=0x0008
- SMI_NODEKIND_COLUMN=0x0010
- SMI_NODEKIND_NOTIFICATION= 0x0020
- SMI_NODEKIND_GROUP=0x0040
- SMI_NODEKIND_COMPLIANCE=0x0080
- SMI_NODEKIND_CAPABILITIES =0x0100
- SMI_NODEKIND_ANY=0xffff
- SMI_RENDER_NUMERIC=0x01 # render as numeric values
- SMI_RENDER_NAME=0x02 # render as names
- SMI_RENDER_QUALIFIED= 0x04 # render names with module prefix
- SMI_RENDER_FORMAT=0x08 # render by applying the type's format if type is given and format is present
- SMI_RENDER_PRINTABLE =0x10 # render string values as a printable string if all octets are isprint()
- SMI_RENDER_UNKNOWN=0x20 # render even unknown items as strings ("<unknown>") so that we never get NULL
- SMI_RENDER_ALL=0xff # render as `human friendly' as possible
- SMI_UNKNOWN_LABEL =c_char_p("<unknown>")
- # misc typedef mappings of SMI types to ctypes
- SmiNodekind = c_uint
- SmiIdentifier = c_char_p
- SmiSubid = c_uint
- SmiUnsigned32 = c_ulong
- SmiInteger32 = c_long
- SmiUnsigned64 = c_ulonglong
- SmiInteger64 = c_longlong
- SmiFloat32 = c_float
- SmiFloat64 = c_double
- SmiFloat128 = c_longdouble
- SmiLanguage = c_uint
- #/* SmiLanguage -- language of an actual MIB module */
- #typedef enum SmiLanguage {
- SMI_LANGUAGE_UNKNOWN = 0 #/* should not occur */
- SMI_LANGUAGE_SMIV1 = 1
- SMI_LANGUAGE_SMIV2 = 2
- SMI_LANGUAGE_SMING = 3
- SMI_LANGUAGE_SPPI = 4
- #/* SmiBasetype -- base types of all languages */
- #typedef enum SmiBasetype {
- SMI_BASETYPE_UNKNOWN = 0, #/* should not occur */
- SMI_BASETYPE_INTEGER32 = 1 #/* also SMIv1/v2 INTEGER */
- SMI_BASETYPE_OCTETSTRING = 2
- SMI_BASETYPE_OBJECTIDENTIFIER = 3
- SMI_BASETYPE_UNSIGNED32 = 4
- SMI_BASETYPE_INTEGER64 = 5 #/* SMIng and SPPI */
- SMI_BASETYPE_UNSIGNED64 = 6 #/* SMIv2, SMIng and SPPI */
- SMI_BASETYPE_FLOAT32 = 7 #/* only SMIng */
- SMI_BASETYPE_FLOAT64 = 8 #/* only SMIng */
- SMI_BASETYPE_FLOAT128 = 9 #/* only SMIng */
- SMI_BASETYPE_ENUM = 10
- SMI_BASETYPE_BITS = 11 #/* SMIv2, SMIng and SPPI */
- #/* SmiStatus -- values of status levels */
- #typedef enum SmiStatus {
- SMI_STATUS_UNKNOWN = 0 #/* should not occur */
- SMI_STATUS_CURRENT = 1 #/* only SMIv2, SMIng and SPPI */
- SMI_STATUS_DEPRECATED = 2 #/* SMIv1, SMIv2, SMIng and SPPI */
- SMI_STATUS_MANDATORY = 3 #/* only SMIv1 */
- SMI_STATUS_OPTIONAL = 4 #/* only SMIv1 */
- SMI_STATUS_OBSOLETE = 5 #/* SMIv1, SMIv2, SMIng and SPPI */
- #/* SmiAccess -- values of access levels */
- #typedef enum SmiAccess {
- SMI_ACCESS_UNKNOWN = 0 #/* should not occur */
- SMI_ACCESS_NOT_IMPLEMENTED = 1 #/* only for agent capability variations */
- SMI_ACCESS_NOT_ACCESSIBLE = 2 #/* the values 2 to 5 are allowed to be */
- SMI_ACCESS_NOTIFY = 3 #/* compared by relational operators. */
- SMI_ACCESS_READ_ONLY = 4
- SMI_ACCESS_READ_WRITE = 5
- SMI_ACCESS_INSTALL = 6 #/* these three entries are only valid */
- SMI_ACCESS_INSTALL_NOTIFY = 7 #/* for SPPI */
- SMI_ACCESS_REPORT_ONLY = 8
- #/* SmiDecl -- type or statement that leads to a definition */
- #typedef enum SmiDecl {
- SMI_DECL_UNKNOWN = 0 #/* should not occur */
- #/* SMIv1/v2 ASN.1 statements and macros */
- SMI_DECL_IMPLICIT_TYPE = 1
- SMI_DECL_TYPEASSIGNMENT = 2
- SMI_DECL_IMPL_SEQUENCEOF = 4 #/* this will go away */
- SMI_DECL_VALUEASSIGNMENT = 5
- SMI_DECL_OBJECTTYPE = 6 #/* values >= 6 are assumed to be */
- SMI_DECL_OBJECTIDENTITY = 7 #/* registering an OID, see check.c */
- SMI_DECL_MODULEIDENTITY = 8
- SMI_DECL_NOTIFICATIONTYPE = 9
- SMI_DECL_TRAPTYPE = 10
- SMI_DECL_OBJECTGROUP = 11
- SMI_DECL_NOTIFICATIONGROUP = 12
- SMI_DECL_MODULECOMPLIANCE = 13
- SMI_DECL_AGENTCAPABILITIES = 14
- SMI_DECL_TEXTUALCONVENTION = 15
- SMI_DECL_MACRO = 16
- SMI_DECL_COMPL_GROUP = 17
- SMI_DECL_COMPL_OBJECT = 18
- SMI_DECL_IMPL_OBJECT = 19 #/* object label in sth like "iso(1)" */
- #/* SMIng statements */
- SMI_DECL_MODULE = 33
- SMI_DECL_EXTENSION = 34
- SMI_DECL_TYPEDEF = 35
- SMI_DECL_NODE = 36
- SMI_DECL_SCALAR = 37
- SMI_DECL_TABLE = 38
- SMI_DECL_ROW = 39
- SMI_DECL_COLUMN = 40
- SMI_DECL_NOTIFICATION = 41
- SMI_DECL_GROUP = 42
- SMI_DECL_COMPLIANCE = 43
- #/* SmiIndexkind -- actual kind of a table row's index method */
- #typedef enum SmiIndexkind {
- SMI_INDEX_UNKNOWN = 0
- SMI_INDEX_INDEX = 1
- SMI_INDEX_AUGMENT = 2
- SMI_INDEX_REORDER = 3
- SMI_INDEX_SPARSE = 4
- SMI_INDEX_EXPAND = 5
- #/* SmiLanguage -- language of an actual MIB module
- #typedef enum SmiLanguage
- SMI_LANGUAGE_UNKNOWN = 0 # should not occur
- SMI_LANGUAGE_SMIV1 = 1
- SMI_LANGUAGE_SMIV2 = 2
- SMI_LANGUAGE_SMING = 3
- SMI_LANGUAGE_SPPI = 4
- class SmiValue_u(Union):
- """See SmiValue"""
- _fields_ = [("unsigned64",SmiUnsigned64),
- ("integer64",SmiInteger64),
- ("unsigned32",SmiUnsigned32),
- ("integer32",SmiInteger32),
- ("float32",SmiFloat32),
- ("float64",SmiFloat64),
- ("float128",SmiFloat128),
- ("oid",POINTER(SmiSubid)),
- ("ptr",POINTER(c_ubyte)),]
- class SmiValue(Structure):
- """
- typedef struct SmiValue {
- SmiBasetype basetype;
- unsigned int len; /* OID, OctetString, Bits */
- union {
- SmiUnsigned64 unsigned64;
- SmiInteger64 integer64;
- SmiUnsigned32 unsigned32;
- SmiInteger32 integer32;
- SmiFloat32 float32;
- SmiFloat64 float64;
- SmiFloat128 float128;
- SmiSubid *oid;
- unsigned char *ptr; /* OctetString, Bits */
- } value;
- } SmiValue;
- """
- _fields_ = [("basetype",c_uint),
- ("len",c_uint), # OID, OctetString, Bits
- ("value",SmiValue_u),]
- class SmiNode(Structure):
- """
- typedef struct SmiNode {
- SmiIdentifier name;
- unsigned int oidlen;
- SmiSubid *oid; /* array of length oidlen */
- SmiDecl decl;
- SmiAccess access;
- SmiStatus status;
- char *format;
- SmiValue value;
- char *units;
- char *description;
- char *reference;
- SmiIndexkind indexkind; /* only valid for rows */
- int implied; /* only valid for rows */
- int create; /* only valid for rows */
- SmiNodekind nodekind;
- } SmiNode;
- """
- _fields_ = [("name",SmiIdentifier),
- ("oidlen",c_uint),
- ("oid",POINTER(SmiSubid)),
- ("decl",c_uint),
- ("access",c_uint),
- ("status",c_uint),
- ("format",POINTER(c_char_p)),
- ("value",SmiValue),
- ("units",POINTER(c_char_p)),
- ("description",POINTER(c_char_p)),
- ("reference",POINTER(c_char_p)),
- ("indexkind",c_uint),
- ("implied",c_int),
- ("create",c_int),
- ("nodekind",SmiNodekind),]
- # SmiModule -- the main structure of a module
- class SmiModule(Structure):
- """
- typedef struct SmiModule {
- SmiIdentifier name;
- char *path;
- char *organization;
- char *contactinfo;
- char *description;
- char *reference;
- SmiLanguage language;
- int conformance;
- } SmiModule;
- """
- _fields_ = [("name",SmiIdentifier),
- ("path",POINTER(c_char_p)),
- ("organization",POINTER(c_char_p)),
- ("contactinfo",POINTER(c_char_p)),
- ("description",POINTER(c_char_p)),
- ("reference",POINTER(c_char_p)),
- ("language",SmiLanguage),
- ("conformance",c_uint),]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement