在什么情况下,“SNMPERR_SUCCESS”错误被抛出 [英] In what situation , "SNMPERR_SUCCESS" error is thrown
问题描述
任何人都可以帮忙知道我们什么时候会收到SNMPERR_SUCCESS错误。
从snmp_api.h的描述中,我看到这是非pdu成功代码。
这是什么意思。?
我有一个场景,我正在尝试打开一个snmp会话。
作为回报,它将要捕获我的代码块,说无法打开带有错误代码(0,0)的snmp会话。
我明白(0,0)表示SNMPERR_SUCCESS。但我想知道可能是什么问题。如果它意味着成功代码。为什么它在错误列表中。
如果我弄错了,请纠正我。并帮我分析一下
提前致谢。
Can anyone please help in knowing when will we get the SNMPERR_SUCCESS error.
From the description of snmp_api.h, I see this is the non-pdu success code.
What does that mean.?
I have a scenario where I am trying to open a snmp session.
In return, it is going to catch block of my code saying failed to open snmp session with error code (0,0).
I understood that (0,0) means SNMPERR_SUCCESS. But I want to know what could be the problem. if it means a success code. why is it in error list.
Please correct me if I have mistaken. and help me to analyse further
Thanks in advance.
推荐答案
这只是成功的回报价值。它是错误定义列表的一部分,也有一个表示没有错误发生的值。
您的代码不应该将该值解释为错误。
[更新]
从评论中可以看出,失败的功能是snmp_open
:
It is just the success return value. It is part of the error definition list to have also a value indicating that no error occured.
Your code should not interpret that value as error.
[UPDATE]
From comments it has become clear that the failing function issnmp_open
:
struct snmp_session * snmp_open ( struct snmp_session *);
此函数不返回 SNMP_ERR *
代码但指针。如果失败,则返回 NULL
,并且可以检索错误代码:
This function does not return a SNMP_ERR*
code but a pointer. When this fails, NULL
is returned and the error code can be retrieved:
struct snmp_session session;
struct snmp_session *handle;
snmp_sess_init(&session);
// Set session parameters here
handle = snmp_open(&session);
if (NULL == handle)
{
// handle error here
int liberr, syserr,
char *errstr;
snmp_error(&session, &liberr, &syserr, &errstr);
printf("SNMP open error %s.\n", errstr);
free(errstr);
}
这篇关于在什么情况下,“SNMPERR_SUCCESS”错误被抛出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!