net-snmp库snmp API解读分析
导读
net-snmp API分为两种,一种叫传统API(Traditional API),一种叫单个API(Single API)。早期的neet-snmp没有考虑到多线程的问题,所有的会话共享同一个资源,这些就是传统API,后来支持多线程的就叫做单个API。详细的内容在源码根目录下的README.thread文件里有详细介绍,这里贴出一部分关键内容。
The functions in the following table are functionally equivalent,
with the exception of these behaviors:
- The Traditional API manages many sessions
- The Traditional API passes a struct snmp_session pointer,
and touches the Sessions list
- The Single API manages only one session
- The Single API passes an opaque pointer, and does not use Sessions list
Traditional Single Comment
=========== ============== =======
snmp_sess_init snmp_sess_init Call before either open
snmp_open snmp_sess_open Single not on Sessions list
snmp_sess_session Exposes snmp_session pointer
snmp_send snmp_sess_send Send one APDU
snmp_async_send snmp_sess_async_send Send one APDU with callback
snmp_select_info snmp_sess_select_info Which session(s) have input
snmp_read snmp_sess_read Read APDUs
snmp_timeout snmp_sess_timeout Check for timeout
snmp_close snmp_sess_close Single not on Sessions list
snmp_synch_response snmp_sess_synch_response Send/receive one APDU
snmp_error snmp_sess_error Get library,system errno
注:
1)分析采用的示例代码源自net-snmp官方教程中一片异步APP代码,详细可以点击这里
2)只列出了若干个API,更多的可以查看源码
3)这里分析的net-snmp源码版本为5.6.1
正文
导读
net-snmp API分为两种,一种叫传统API(Traditional API),一种叫单个API(Single API)。早期的neet-snmp没有考虑到多线程的问题,所有的会话共享同一个资源,这些就是传统API,后来支持多线程的就叫做单个API。详细的内容在源码根目录下的README.thread文件里有详细介绍,这里贴出一部分关键内容。
The functions in the following table are functionally equivalent,
with the exception of these behaviors:
- The Traditional API manages many sessions
- The Traditional API passes a struct snmp_session pointer,
and touches the Sessions list
- The Single API manages only one session
- The Single API passes an opaque pointer, and does not use Sessions list
Traditional Single Comment
=========== ============== =======
snmp_sess_init snmp_sess_init Call before either open
snmp_open snmp_sess_open Single not on Sessions list
snmp_sess_session Exposes snmp_session pointer
snmp_send snmp_sess_send Send one APDU
snmp_async_send snmp_sess_async_send Send one APDU with callback
snmp_select_info snmp_sess_select_info Which session(s) have input
snmp_read snmp_sess_read Read APDUs
snmp_timeout snmp_sess_timeout Check for timeout
snmp_close snmp_sess_close Single not on Sessions list
snmp_synch_response snmp_sess_synch_response Send/receive one APDU
snmp_error snmp_sess_error Get library,system errno
注:
1)分析采用的示例代码源自net-snmp官方教程中一片异步APP代码,详细可以点击这里
2)只列出了若干个API,更多的可以查看源码
3)这里分析的net-snmp源码版本为5.6.1
正文