|
|
The syntax of MIB objects is modeled by the OS (Object Syntax) structure:
typedef int (*IFP) ();The syntaxes defined by the Internet-standard MIB are already implemented:typedef struct object_syntax { char *os_name; /* syntax name */
int os_type; /* syntax type */ IFP os_decode; IFP os_free; /* free data */
} *OS; #define NULLOS ((OS) 0)
Internet-standard MIB defined syntaxes
Syntax | Structure type |
---|---|
INTEGER | integer |
OctetString | struct _OctetString |
ObjectID | struct OIDentifier |
NULL | char |
DisplayString | struct _OctetString |
IpAddress | struct sockaddr_in |
NetworkAddress | struct sockaddr_in |
Counter | integer |
Gauge | integer |
TimeTicks | integer |
ClnpAddress | struct _OctetString |
To take a syntax name and get back the structure, use the routine text2syn().
Here are the structures and routines used to implement some of these low-level MIB abstractions: Integer, OctetString, ObjectID, and IPAddress.
integer is used for the INTEGER, Counter, Gauge, and TimeTicks syntaxes. The definition is:
typedef int integer;
struct _OctetString is used for the OctetString, DisplayString, and ClnpAddress syntaxes. The definition is:
typedef struct _OctetString { unsigned char *octet_ptr; /* list of octets */ long length; /* number of elements */ };
struct OIDentifier is used for the ObjectID syntax. The definition is:
typedef struct OIDentifier { int oid_nelem; /* number of sub-identifiers */unsigned int *oid_elements; /* the (ordered) list of sub-identifiers */ } OIDentifier, *OID; #define NULLOID ((OID) 0)
struct sockaddr_in is used for the IpAddress and NetworkAddress syntaxes. It is assumed that you are familiar with this structure. If not, consult the file /usr/include/sys/netinet/in.h.