我也使用 Net-snmp 工作了一段时间,我与您分享我的观察。
也许这会对你有所帮助。
1. 结构树 *next;
struct tree * next; /* Next node in hashed list of names */
Net-snmp 功能提供按模块“名称”查询,
Object 当查询的对象名称(字符串)为 ASCII 时,i.e.
$ snmptranslate -On -IR bundleSize
-
-
.1.3.6.1.4.1.26149.2.1.2.2.1.9
它有一个大小为 128 的散列表(内部)数据结构“桶”。
哈希函数:
name_hash(str*) - return some of ASCII value.
然后这个哈希值被传递到一个宏中NBUCKET(x) - 返回索引 (0-127)。
冲突通过如下链接解决。桶[中]->下一个->下一个->下一个........
其代码位于parse.c --
tree->next
and 'bucket'
按以下方式管理:
tp->hash = name_hash(tp->name); // Fist find hash value as some of ASCII
b = BUCKET(tp->hash); // map hash value into (0-127)
if (buckets[b]) // check for collision
tp->next = buckets[b]; // collision is resolved ny chan chain
buckets[b] = tp; // new coming node become first node in chain
2.int修改;
- The module containing this node.
- 有一个“struct module”类型的链表
- modid 是模块链表中的序列号。
- 序列号从0开始。
- modid= 模块开始读取的编号
- parse.h 'find_module(int modid)' 中定义的函数返回节点地址
存储有关模块的信息。
parse.h 中名为“模块兼容性”的数据结构:
This is an array of structre 'module compatability' use to store compatible
basic MIB name (RFC's defined).
const char *old_module; // snmp-v1
const char *new_module; // snmp-v2