Discussion:
AsnBits in SNMP
(too old to reply)
Prasanna
2004-09-11 07:05:29 UTC
Permalink
Hi,

I have written an extention agent for Windows SNMP master agent and
Iam facing problem implementing AsnBits.
I hav to allocate memory to Ptr->dsServerType and fill this
structure with some value and pass this to SNMP master agent.

struct dsTable
{
AsnBits dsServerType;
----
----
}*Ptr;

---------------------------------------------------------------------
dsServerType is of type BITS as defined below in RFC2605:

dsServerType OBJECT-TYPE
SYNTAX BITS {
frontEndDirectoryServer(0),
backEndDirectoryServer(1)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"This object indicates whether the server is
a frontend or, a backend or, both. If the server
is a frontend, then the frontEndDirectoryServer
bit will be set. Similarly for the backend."
::= {dsTableEntry 1}

----------------------------------------------------------------------
AsnBits structure is defined in snmp.h file as

typedef AsnOctetString AsnBits;

typedef struct {
BYTE * stream;
UINT length;
BOOL dynamic;
}AsnOctetString;


so what i do in my code is :

Ptr->dsServerType.length =1;
Ptr->dsServerType.stream =(CHAR *)malloc(sizeof(CHAR));
*Ptr->dsServerType.stream=0x80;
Ptr->dsServerType.dynamic = TRUE;

Actually 0x80 means frontEndDirectoryServer bit is set(1000 0000).

Tell me is this the correct way to assign bit values.Because SNMP
master agent is not able to read the value passed by me ie when i
issue a GET request for this object , the request times out.

Regards,
Prasanna
Arkady Frenkel
2004-09-12 06:34:09 UTC
Permalink
You can ask additionally on comp.protocols.snmp
Arkady
Post by Prasanna
Hi,
I have written an extention agent for Windows SNMP master agent and
Iam facing problem implementing AsnBits.
I hav to allocate memory to Ptr->dsServerType and fill this
structure with some value and pass this to SNMP master agent.
struct dsTable
{
AsnBits dsServerType;
----
----
}*Ptr;
---------------------------------------------------------------------
dsServerType OBJECT-TYPE
SYNTAX BITS {
frontEndDirectoryServer(0),
backEndDirectoryServer(1)
}
MAX-ACCESS read-only
STATUS current
DESCRIPTION
"This object indicates whether the server is
a frontend or, a backend or, both. If the server
is a frontend, then the frontEndDirectoryServer
bit will be set. Similarly for the backend."
::= {dsTableEntry 1}
----------------------------------------------------------------------
AsnBits structure is defined in snmp.h file as
typedef AsnOctetString AsnBits;
typedef struct {
BYTE * stream;
UINT length;
BOOL dynamic;
}AsnOctetString;
Ptr->dsServerType.length =1;
Ptr->dsServerType.stream =(CHAR *)malloc(sizeof(CHAR));
*Ptr->dsServerType.stream=0x80;
Ptr->dsServerType.dynamic = TRUE;
Actually 0x80 means frontEndDirectoryServer bit is set(1000 0000).
Tell me is this the correct way to assign bit values.Because SNMP
master agent is not able to read the value passed by me ie when i
issue a GET request for this object , the request times out.
Regards,
Prasanna
Loading...