Query



Summary


#include <rssnmp/query.h>
Function Description
rssnmp_query_New() Variable initializer.
rssnmp_query_Free() Variable destructor.
rssnmp_query_Print() Variable print method.
rssnmp_query_SetRequestID() Set query request ID, that will be used in the SNMP packets.
rssnmp_query_AddVariable() Add a new varbind to the query.
rssnmp_query_Exec() Execute query.
rssnmp_query_GetResult() Get the query result.


Initializer and destructor

Synopsis

rssnmp_query_t rssnmp_query_New(rssnmp_device_t d, int type);

void rssnmp_query_Free(rssnmp_query_t q);

void rssnmp_query_Print(rssnmp_query_t q, FILE *fp, char *offset);

Description

The only parameters needed to instance a query are the device and the query type (GET, WALK or BULK).

Return Value

Returns NULL on error.



Query type definitions


#define RSSNMP_QUERY_TYPE_GET 1
#define RSSNMP_QUERY_TYPE_WALK 2
#define RSSNMP_QUERY_TYPE_BULK 3


Query setup

Synopsis

int rssnmp_query_SetRequestID(rssnmp_query_t q, uint32_t request_id);

int rssnmp_query_AddVariable(rssnmp_query_t q, rssnmp_oid_t *oid, int oid_size);

Description

Set the request ID that will be used in the SNMP packet with the rssnmp_query_SetRequestID() method and add variables to the query using the rssnmp_query_AddVariable() method.

Return Value

Both methods will return 0 upon success.



Execute and get query results

Synopsis

rssnmp_result_t rssnmp_query_Exec(rssnmp_query_t q, int sockfd);

rssnmp_result_t rssnmp_query_GetResult(rssnmp_query_t q);

Description

Once the query is created and all variables of interested added to it, you can execute the query using the rssnmp_query_Exec() method, providing a UDP socket in sockfd. It will return the query result in a rssnmp_result_t variable, that can also be obtained using the method rssnmp_query_GetResult().

Return Value

Both methods will return a rssnmp_result_t variable containing the query result or NULL on error.