net-snmp库snmp API解读分析

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

正文


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值