net-snmp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,39 @@
1
+ module Net
2
+ module SNMP
3
+ class OID
4
+ def initialize(oid)
5
+ @oid = oid
6
+ @oid_ptr = FFI::MemoryPointer.new(:ulong, Constants::MAX_OID_LEN)
7
+ @oid_len_ptr = FFI::MemoryPointer.new(:size_t)
8
+ @oid_len_ptr.write_int(Constants::MAX_OID_LEN)
9
+
10
+ if @oid =~ /^[\d\.]*$/
11
+ if Wrapper.read_objid(@oid, @oid_ptr, @oid_len_ptr) == 0
12
+ Wrapper.snmp_perror(@oid)
13
+ end
14
+ else
15
+ if Wrapper.get_node(@oid, @oid_ptr, @oid_len_ptr) == 0
16
+ Wrapper.snmp_perror(@oid)
17
+ end
18
+ end
19
+
20
+ end
21
+
22
+ def oid
23
+ @oid
24
+ end
25
+
26
+ def c_oid
27
+ @oid_ptr.read_array_of_long(@oid_len_ptr.read_int).join(".")
28
+ end
29
+
30
+ def pointer
31
+ @oid_ptr
32
+ end
33
+ def length_pointer
34
+ @oid_len_ptr
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,80 @@
1
+ module Net
2
+ module SNMP
3
+ class PDU
4
+ extend Forwardable
5
+ attr_accessor :struct, :varbinds, :callback
6
+ def_delegators :struct, :reqid, :pointer, :errstat, :errindex, :non_repeaters=
7
+
8
+ def initialize(arg)
9
+ @varbinds = []
10
+ case arg
11
+ when FFI::Pointer
12
+ @struct = Wrapper::SnmpPdu.new(arg)
13
+ v = @struct[:variables]
14
+ if v
15
+ @varbinds << Varbind.from_pointer(v)
16
+ end
17
+
18
+ while( !(v = Wrapper::VariableList.new(v).next_variable).null? )
19
+ @varbinds << Varbind.from_pointer(v)
20
+ end
21
+ when Fixnum
22
+ @struct = Wrapper.snmp_pdu_create(arg)
23
+ else
24
+ raise "invalid type"
25
+ end
26
+ end
27
+
28
+ # For getbulk requests, repeaters and maxreps are stored in errstat and errindex
29
+ def non_repeaters=(nr)
30
+ @struct.errstat = nr
31
+ end
32
+ def non_repeaters
33
+ @struct.errstat
34
+ end
35
+ def max_repetitions=(mr)
36
+ @struct.errindex = mr
37
+ end
38
+ def max_repetitions
39
+ @struct.errindex
40
+ end
41
+
42
+
43
+ def add_varbind(options)
44
+
45
+ options[:type] ||= case options[:value]
46
+ when String
47
+ Constants::ASN_OCTET_STR
48
+ when nil
49
+ Constants::ASN_NULL
50
+ else
51
+ raise "Unknown value type"
52
+ end
53
+
54
+ value_len = case options[:value]
55
+ when String
56
+ options[:value].length
57
+ else
58
+ 0
59
+ end
60
+
61
+
62
+ oid = Net::SNMP::OID.new(options[:oid])
63
+
64
+ var_ptr = Wrapper.snmp_pdu_add_variable(@struct.pointer, oid.pointer, oid.length_pointer.read_int, options[:type], options[:value], value_len)
65
+ varbind = Varbind.new(var_ptr)
66
+ #Wrapper.print_varbind(varbind.struct)
67
+ varbinds << varbind
68
+ end
69
+
70
+ def error?
71
+ errstat != 0
72
+ end
73
+
74
+ def error_message
75
+ Wrapper::snmp_errstring(errstat)
76
+ end
77
+
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,223 @@
1
+ require 'forwardable'
2
+ require 'pp'
3
+ module Net
4
+ module SNMP
5
+ class Session
6
+ extend Forwardable
7
+ attr_accessor :struct, :callback
8
+ def_delegator :@struct, :pointer
9
+ @sessions = []
10
+ @requests = {}
11
+ class << self
12
+ attr_accessor :sessions, :requests
13
+ def open(options)
14
+ session = new(options)
15
+ if block_given?
16
+ yield session
17
+ end
18
+ session
19
+ end
20
+ end
21
+
22
+ def initialize(options)
23
+ options[:community] ||= "public"
24
+ options[:community_len] = options[:community].length
25
+ options[:version] ||= Constants::SNMP_VERSION_1
26
+ @callback = options[:callback]
27
+ @requests = {}
28
+ self.class.sessions << self
29
+ @sess = Wrapper::SnmpSession.new(nil)
30
+ Wrapper.snmp_sess_init(@sess.pointer)
31
+ #options.each_pair {|k,v| ptr.send("#{k}=", v)}
32
+ @sess.community = FFI::MemoryPointer.from_string(options[:community])
33
+ @sess.community_len = options[:community].length
34
+ @sess.peername = FFI::MemoryPointer.from_string(options[:peername])
35
+ @sess.version = case options[:version].to_s
36
+ when '1'
37
+ Constants::SNMP_VERSION_1
38
+ when '2', '2c'
39
+ Constants::SNMP_VERSION_2c
40
+ when '3'
41
+ Constants::SNMP_VERSION_3
42
+ else
43
+ Constants::SNMP_VERSION_1
44
+ end
45
+
46
+
47
+ if options[:timeout]
48
+ @sess.timeout = options[:timeout] * 1000000
49
+ end
50
+ if options[:retries]
51
+ @sess.retries = options[:retries]
52
+ end
53
+
54
+
55
+ if @sess.version == Constants::SNMP_VERSION_3
56
+ @sess.securityLevel = options[:security_level] || Constants::SNMP_SEC_LEVEL_NOAUTH
57
+
58
+ oid = Net::SNMP::OID.new("1.3.6.1.6.3.10.1.1.2")
59
+ @sess.securityAuthProto = case options[:auth_protocol]
60
+ when :sha1
61
+ Net::SNMP::OID.new("1.3.6.1.6.3.10.1.1.3").pointer
62
+ when :md5
63
+ Net::SNMP::OID.new("1.3.6.1.6.3.10.1.1.2").pointer
64
+ when nil
65
+ Net::SNMP::OID.new("1.3.6.1.6.3.10.1.1.1").pointer
66
+ end
67
+
68
+ @sess.securityAuthProtoLen = 10
69
+ @sess.securityAuthKeyLen = Constants::USM_AUTH_KU_LEN
70
+
71
+ if options[:context]
72
+ @sess.contextName = FFI::MemoryPointer.from_string(options[:context])
73
+ @sess.contextNameLen = options[:context].length
74
+
75
+ end
76
+
77
+ if options[:username]
78
+ @sess.securityName = FFI::MemoryPointer.from_string(options[:username])
79
+ @sess.securityNameLen = options[:username].length
80
+ end
81
+ auth_len_ptr = FFI::MemoryPointer.new(:size_t)
82
+ auth_len_ptr.write_int(Constants::USM_AUTH_KU_LEN)
83
+ key_result = Wrapper.generate_Ku(@sess.securityAuthProto, @sess.securityAuthProtoLen, options[:password], options[:password].length, @sess.securityAuthKey, auth_len_ptr)
84
+ @sess.securityAuthKeyLen = auth_len_ptr.read_int
85
+ unless key_result == Constants::SNMPERR_SUCCESS
86
+ Wrapper.snmp_perror("netsnmp")
87
+ end
88
+
89
+ end
90
+
91
+
92
+ @sess.callback = lambda do |operation, session, reqid, pdu_ptr, magic|
93
+ pdu = Net::SNMP::PDU.new(pdu_ptr)
94
+ run_callbacks(operation, reqid, pdu, magic)
95
+ 0
96
+ end
97
+
98
+ @struct = Wrapper.snmp_open(@sess.pointer)
99
+ #@handle = Wrapper.snmp_sess_open(@sess.pointer)
100
+ #@struct = Wrapper.snmp_sess_session(@handle)
101
+ end
102
+
103
+
104
+
105
+ def run_callbacks(operation, reqid, pdu, magic)
106
+ callback.call(operation, reqid, pdu, magic) if callback
107
+ if self.class.requests[reqid]
108
+ self.class.requests[reqid].call(pdu)
109
+ self.class.requests.delete(reqid)
110
+ end
111
+ end
112
+
113
+
114
+
115
+
116
+ #
117
+
118
+ def get(oidlist, options = {}, &block)
119
+ pdu = Net::SNMP::PDU.new(Constants::SNMP_MSG_GET)
120
+ oidlist = [oidlist] unless oidlist.kind_of?(Array)
121
+ oidlist.each do |oid|
122
+ pdu.add_varbind(:oid => oid)
123
+ end
124
+ send_pdu(pdu, &block)
125
+ end
126
+
127
+ def get_next(oidlist, options = {}, &block)
128
+ pdu = Net::SNMP::PDU.new(Constants::SNMP_MSG_GETNEXT)
129
+ oidlist = [oidlist] unless oidlist.kind_of?(Array)
130
+ oidlist.each do |oid|
131
+ pdu.add_varbind(:oid => oid)
132
+ end
133
+ send_pdu(pdu, &block)
134
+ end
135
+
136
+ def get_bulk(oidlist, options = {}, &block)
137
+ pdu = Net::SNMP::PDU.new(Constants::SNMP_MSG_GETBULK)
138
+ oidlist = [oidlist] unless oidlist.kind_of?(Array)
139
+ oidlist.each do |oid|
140
+ pdu.add_varbind(:oid => oid)
141
+ end
142
+ pdu.non_repeaters = options[:non_repeaters] || 0
143
+ pdu.max_repetitions = options[:max_repetitions] || 10
144
+ send_pdu(pdu,&block)
145
+ end
146
+
147
+
148
+
149
+ def set(oidlist, options = {}, &block)
150
+ pdu = Net::SNMP::PDU.new(Constants::SNMP_MSG_SET)
151
+ oidlist.each do |oid|
152
+ pdu.add_varbind(:oid => oid[0], :type => oid[1], :value => oid[2])
153
+ end
154
+ send_pdu(pdu, &block)
155
+ end
156
+
157
+
158
+
159
+
160
+ def error(msg)
161
+ Wrapper.snmp_perror("snmp_error")
162
+ Wrapper.snmp_sess_perror( "snmp_error", @sess.pointer)
163
+ #Wrapper.print_session(self.struct)
164
+ raise Net::SNMP::Error.new({:session => self}), msg
165
+ end
166
+
167
+ # def dispatcher
168
+ # fdset = Net::SNMP::Wrapper.get_fd_set
169
+ # num_fds = FFI::MemoryPointer.new(:int)
170
+ # tval = Net::SNMP::Wrapper::TimeVal.new
171
+ # block = FFI::MemoryPointer.new(:int)
172
+ # block.write_int(0)
173
+ #
174
+ # # Note.. for some reason, snmp_sess_select_info changes block to be 1.
175
+ # Net::SNMP::Wrapper.snmp_sess_select_info(@handle, num_fds, fdset, tval.pointer, block )
176
+ # if num_fds.read_int > 0
177
+ # zero = Wrapper::TimeVal.new(:tv_sec => 0, :tv_usec => 0)
178
+ # #Wrapper.print_timeval(zero)
179
+ #
180
+ # num_ready = Net::SNMP::Wrapper.select(num_fds.read_int, fdset, nil, nil, zero.pointer)
181
+ # Net::SNMP::Wrapper.snmp_sess_read(@handle, fdset)
182
+ # end
183
+ # end
184
+
185
+
186
+ private
187
+ def send_pdu(pdu, &block)
188
+
189
+
190
+ if defined?(EM) && EM.reactor_running? && !block_given?
191
+ f = Fiber.current
192
+
193
+ send_pdu pdu do | response |
194
+ f.resume(response)
195
+ end
196
+ Fiber.yield
197
+ else
198
+ if block
199
+ self.class.requests[pdu.reqid] = block
200
+ if (status = Net::SNMP::Wrapper.snmp_send(@struct, pdu.pointer)) == 0
201
+ error("snmp_get async failed")
202
+ end
203
+ nil
204
+ else
205
+ response_ptr = FFI::MemoryPointer.new(:pointer)
206
+
207
+ #Net::SNMP::Wrapper.print_session(@struct)
208
+ #Net::SNMP::Wrapper.print_pdu(pdu.struct)
209
+ status = Wrapper.snmp_synch_response(@struct, pdu.pointer, response_ptr)
210
+
211
+ if status != 0
212
+ error("snmp_get failed #{status}")
213
+ else
214
+ #Net::SNMP::Wrapper.print_pdu(Net::SNMP::Wrapper::SnmpPdu.new(response_ptr.read_pointer))
215
+ Net::SNMP::PDU.new(response_ptr.read_pointer)
216
+ end
217
+ end
218
+ end
219
+
220
+ end
221
+ end
222
+ end
223
+ end
@@ -0,0 +1,36 @@
1
+ module Net
2
+ module SNMP
3
+ class Varbind
4
+ attr_accessor :struct
5
+
6
+ def initialize(ptr)
7
+ @struct = Net::SNMP::Wrapper::VariableList.new(ptr)
8
+ end
9
+
10
+ def self.from_pointer(ptr)
11
+ new(ptr)
12
+ end
13
+
14
+ def object_type
15
+ @struct.type
16
+ end
17
+
18
+ def oid
19
+ @struct.name.read_array_of_long(@struct.name_length).join(".")
20
+ end
21
+
22
+ def name
23
+ oid
24
+ end
25
+
26
+ def value
27
+ case object_type
28
+ when Constants::ASN_OCTET_STR
29
+ struct.val[:string].read_string(struct.val_len)
30
+ when Constants::ASN_INTEGER, Net::SNMP::ASN_COUNTER
31
+ struct.val[:integer].read_int
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ module Net
2
+ module Snmp
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,382 @@
1
+ module Net
2
+ module SNMP
3
+ module Wrapper
4
+ extend NiceFFI::Library
5
+ ffi_lib "/opt/local/lib/libnetsnmp.dylib"
6
+ #ffi_lib "netsnmp"
7
+ typedef :u_long, :oid
8
+
9
+ class Counter64 < NiceFFI::Struct
10
+ layout(
11
+ :high, :u_long,
12
+ :low, :u_long
13
+ )
14
+ end
15
+
16
+ class TimeVal < NiceFFI::Struct
17
+ layout(:tv_sec, :long, :tv_usec, :long)
18
+ end
19
+ def self.print_timeval(tv)
20
+ puts "tv_sec = #{tv.tv_sec}, tv_usec = #{tv.tv_usec} "
21
+ end
22
+
23
+
24
+ class NetsnmpVardata < FFI::Union
25
+ layout(
26
+ :integer, :pointer,
27
+ :string, :pointer,
28
+ :objid, :pointer,
29
+ :bitstring, :pointer,
30
+ :counter64, :pointer,
31
+ :float, :pointer,
32
+ :double, :pointer
33
+ )
34
+ end
35
+
36
+ def self.print_varbind(v)
37
+ puts "---------------------VARBIND------------------------"
38
+ puts %{
39
+ name_length #{v.name_length}
40
+ name #{v.name.read_array_of_long(v.name_length).join(".")}
41
+ type = #{v.type}
42
+
43
+ }
44
+ end
45
+ # puts "Vardata size = #{NetsnmpVardata.size}"
46
+ class VariableList < NiceFFI::Struct
47
+ layout(
48
+ :next_variable, :pointer,
49
+ :name, :pointer,
50
+ :name_length, :size_t,
51
+ :type, :u_char,
52
+ :val, NetsnmpVardata,
53
+ :val_len, :size_t,
54
+ :name_loc, [:oid, Net::SNMP::MAX_OID_LEN],
55
+ :buf, [:u_char, 40],
56
+ :data, :pointer,
57
+ :dataFreeHook, callback([ :pointer ], :void),
58
+ :index, :int
59
+ )
60
+ end
61
+
62
+ #puts "VariableList size = #{VariableList.size}"
63
+
64
+ def self.print_pdu(p)
65
+ puts "--------------PDU---------------"
66
+ puts %{
67
+ version = #{p.version}
68
+ command = #{p.command}
69
+ errstat = #{p.errstat}
70
+ errindex = #{p.errindex}
71
+ }
72
+ v = p.variables.pointer
73
+ puts "-----VARIABLES------"
74
+ while !v.null? do
75
+ var = VariableList.new v
76
+ print_varbind(var)
77
+ v = var.next_variable
78
+ end
79
+
80
+ end
81
+ class SnmpPdu < NiceFFI::Struct
82
+ layout(
83
+ :version, :long,
84
+ :command, :int,
85
+ :reqid, :long,
86
+ :msgid, :long,
87
+ :transid, :long,
88
+ :sessid, :long,
89
+ :errstat, :long,
90
+ :errindex, :long,
91
+ :time, :u_long,
92
+ :flags, :u_long,
93
+ :securityModel, :int,
94
+ :securityLevel, :int,
95
+ :msgParseModel, :int,
96
+ :transport_data, :pointer,
97
+ :transport_data_length, :int,
98
+ :tDomain, :pointer,
99
+ :tDomainLen, :size_t,
100
+ :variables, VariableList.typed_pointer,
101
+ :community, :pointer,
102
+ :community_len, :size_t,
103
+ :enterprise, :pointer,
104
+ :enterprise_length, :size_t,
105
+ :trap_type, :long,
106
+ :specific_type, :long,
107
+ :agent_addr, [:uchar, 4],
108
+ :contextEngineID, :pointer,
109
+ :contextEngineIDLen, :size_t,
110
+ :contextName, :pointer,
111
+ :contextNameLen, :size_t,
112
+ :securityEngineID, :pointer,
113
+ :securityEngineIDLen, :size_t,
114
+ :securityName, :pointer,
115
+ :securityNameLen, :size_t,
116
+ :priority, :int,
117
+ :range_subid, :int,
118
+ :securityStateRef, :pointer
119
+ )
120
+
121
+ end
122
+ # puts "snmppdu size = #{SnmpPdu.size}"
123
+ callback(:snmp_callback, [ :int, :pointer, :int, :pointer, :pointer ], :int)
124
+ callback(:netsnmp_callback, [ :int, :pointer, :int, :pointer, :pointer ], :int)
125
+ def self.print_session(s)
126
+ puts "-------------------SESSION---------------------"
127
+ puts %{
128
+ peername = #{s.peername.read_string}
129
+ community = #{s.community.read_string(s.community_len)}
130
+ s_errno = #{s.s_errno}
131
+ s_snmp_errno = #{s.s_snmp_errno}
132
+ securityAuthKey = #{s.securityAuthKey.to_ptr.read_string}
133
+
134
+ }
135
+ end
136
+ class SnmpSession < NiceFFI::Struct
137
+ layout(
138
+ :version, :long,
139
+ :retries, :int,
140
+ :timeout, :long,
141
+ :flags, :u_long,
142
+ :subsession, :pointer,
143
+ :next, :pointer,
144
+ :peername, :pointer,
145
+ :remote_port, :u_short,
146
+ :localname, :pointer,
147
+ :local_port, :u_short,
148
+ :authenticator, callback([ :pointer, :pointer, :pointer, :uint ], :pointer),
149
+ :callback, :netsnmp_callback,
150
+ :callback_magic, :pointer,
151
+ :s_errno, :int,
152
+ :s_snmp_errno, :int,
153
+ :sessid, :long,
154
+ :community, :pointer,
155
+ :community_len, :size_t,
156
+ :rcvMsgMaxSize, :size_t,
157
+ :sndMsgMaxSize, :size_t,
158
+ :isAuthoritative, :u_char,
159
+ :contextEngineID, :pointer,
160
+ :contextEngineIDLen, :size_t,
161
+ :engineBoots, :u_int,
162
+ :engineTime, :u_int,
163
+ :contextName, :pointer,
164
+ :contextNameLen, :size_t,
165
+ :securityEngineID, :pointer,
166
+ :securityEngineIDLen, :size_t,
167
+ :securityName, :pointer,
168
+ :securityNameLen, :size_t,
169
+ :securityAuthProto, :pointer,
170
+ :securityAuthProtoLen, :size_t,
171
+ :securityAuthKey, [:u_char, 32],
172
+ :securityAuthKeyLen, :size_t,
173
+ :securityAuthLocalKey, :pointer,
174
+ :securityAuthLocalKeyLen, :size_t,
175
+ :securityPrivProto, :pointer,
176
+ :securityPrivProtoLen, :size_t,
177
+ :securityPrivKey, [:u_char, 32],
178
+ :securityPrivKeyLen, :size_t,
179
+ :securityPrivLocalKey, :pointer,
180
+ :securityPrivLocalKeyLen, :size_t,
181
+ :securityModel, :int,
182
+ :securityLevel, :int,
183
+ :paramName, :pointer,
184
+ :securityInfo, :pointer,
185
+ :myvoid, :pointer
186
+ )
187
+ end
188
+ class Tree < NiceFFI::Struct
189
+ layout(
190
+ :child_list, :pointer,
191
+ :next_peer, :pointer,
192
+ :next, :pointer,
193
+ :parent, :pointer,
194
+ :label, :string,
195
+ :subid, :u_long,
196
+ :modid, :int,
197
+ :number_modules, :int,
198
+ :module_list, :pointer,
199
+ :tc_index, :int,
200
+ :type, :int,
201
+ :access, :int,
202
+ :status, :int,
203
+ :enums, :pointer,
204
+ :ranges, :pointer,
205
+ :indexes, :pointer,
206
+ :augments, :pointer,
207
+ :varbinds, :pointer,
208
+ :hint, :pointer,
209
+ :units, :pointer,
210
+ :printomat, callback([:pointer, :pointer, :pointer, :int, :pointer, :pointer, :pointer, :pointer], :int),
211
+ :printer, callback([:pointer, :pointer, :pointer, :pointer, :pointer], :void),
212
+ :description, :pointer,
213
+ :reference, :pointer,
214
+ :reported, :int,
215
+ :defaultValue, :pointer
216
+ )
217
+ # struct tree *child_list; /* list of children of this node */
218
+ # struct tree *next_peer; /* Next node in list of peers */
219
+ # struct tree *next; /* Next node in hashed list of names */
220
+ # struct tree *parent;
221
+ # char *label; /* This node's textual name */
222
+ # u_long subid; /* This node's integer subidentifier */
223
+ # int modid; /* The module containing this node */
224
+ # int number_modules;
225
+ # int *module_list; /* To handle multiple modules */
226
+ # int tc_index; /* index into tclist (-1 if NA) */
227
+ # int type; /* This node's object type */
228
+ # int access; /* This nodes access */
229
+ # int status; /* This nodes status */
230
+ # struct enum_list *enums; /* (optional) list of enumerated integers */
231
+ # struct range_list *ranges;
232
+ # struct index_list *indexes;
233
+ # char *augments;
234
+ # struct varbind_list *varbinds;
235
+ # char *hint;
236
+ # char *units;
237
+ # int (*printomat) (u_char **, size_t *, size_t *, int,
238
+ # const netsnmp_variable_list *,
239
+ # const struct enum_list *, const char *,
240
+ # const char *);
241
+ # void (*printer) (char *, const netsnmp_variable_list *, const struct enum_list *, const char *, const char *); /* Value printing function */
242
+ # char *description; /* description (a quoted string) */
243
+ # char *reference; /* references (a quoted string) */
244
+ # int reported; /* 1=report started in print_subtree... */
245
+ # char *defaultValue;
246
+ end
247
+ attach_function :init_mib, [], :void
248
+ attach_function :read_all_mibs, [], :void
249
+ attach_function :get_tree_head, [], Tree.typed_pointer
250
+ attach_function :get_tree, [:pointer, :int, :pointer], Tree.typed_pointer
251
+
252
+
253
+ # puts "snmp_session size = #{SnmpSession.size}"
254
+ attach_function :snmp_open, [ :pointer ], SnmpSession.typed_pointer
255
+ attach_function :snmp_errstring, [:int], :string
256
+ attach_function :snmp_close, [ :pointer ], :int
257
+ attach_function :snmp_close_sessions, [ ], :int
258
+ attach_function :snmp_send, [ :pointer, :pointer ], :int
259
+ attach_function :snmp_async_send, [ :pointer, :pointer, :netsnmp_callback, :pointer ], :int
260
+ attach_function :snmp_read, [ :pointer ], :void
261
+ attach_function :snmp_free_pdu, [ :pointer ], :void
262
+ attach_function :snmp_free_var, [ :pointer ], :void
263
+ attach_function :snmp_free_varbind, [ :pointer ], :void
264
+ attach_function :snmp_select_info, [ :pointer, :pointer, :pointer, :pointer ], :int
265
+ attach_function :snmp_timeout, [ ], :void
266
+
267
+ attach_function :snmp_get_next_msgid, [ ], :long
268
+ attach_function :snmp_get_next_reqid, [ ], :long
269
+ attach_function :snmp_get_next_sessid, [ ], :long
270
+ attach_function :snmp_get_next_transid, [ ], :long
271
+ attach_function :snmp_oid_compare, [ :pointer, :uint, :pointer, :uint ], :int
272
+ attach_function :snmp_oid_ncompare, [ :pointer, :uint, :pointer, :uint, :uint ], :int
273
+ attach_function :snmp_oidtree_compare, [ :pointer, :uint, :pointer, :uint ], :int
274
+ attach_function :snmp_oidsubtree_compare, [ :pointer, :uint, :pointer, :uint ], :int
275
+ attach_function :netsnmp_oid_compare_ll, [ :pointer, :uint, :pointer, :uint, :pointer ], :int
276
+ attach_function :netsnmp_oid_equals, [ :pointer, :uint, :pointer, :uint ], :int
277
+ # attach_function :netsnmp_oid_tree_equals, [ :pointer, :uint, :pointer, :uint ], :int
278
+ attach_function :netsnmp_oid_is_subtree, [ :pointer, :uint, :pointer, :uint ], :int
279
+ attach_function :netsnmp_oid_find_prefix, [ :pointer, :uint, :pointer, :uint ], :int
280
+ attach_function :init_snmp, [ :string ], :void
281
+ attach_function :snmp_pdu_build, [ :pointer, :pointer, :pointer ], :pointer
282
+ attach_function :snmpv3_parse, [ :pointer, :pointer, :pointer, :pointer, :pointer ], :int
283
+ attach_function :snmpv3_packet_build, [ :pointer, :pointer, :pointer, :pointer, :pointer, :uint ], :int
284
+ # attach_function :snmpv3_packet_rbuild, [ :pointer, :pointer, :pointer, :pointer, :pointer, :uint ], :int
285
+ attach_function :snmpv3_make_report, [ :pointer, :int ], :int
286
+ attach_function :snmpv3_get_report_type, [ :pointer ], :int
287
+ attach_function :snmp_pdu_parse, [ :pointer, :pointer, :pointer ], :int
288
+ attach_function :snmpv3_scopedPDU_parse, [ :pointer, :pointer, :pointer ], :pointer
289
+ attach_function :snmp_store, [ :string ], :void
290
+ attach_function :snmp_shutdown, [ :string ], :void
291
+ attach_function :snmp_pdu_add_variable, [ :pointer, :pointer, :uint, :u_char, :pointer, :size_t ], :pointer
292
+ attach_function :snmp_varlist_add_variable, [ :pointer, :pointer, :uint, :u_char, :pointer, :uint ], :pointer
293
+ attach_function :snmp_add_var, [ :pointer, :pointer, :uint, :char, :string ], :int
294
+ attach_function :snmp_duplicate_objid, [ :pointer, :uint ], :pointer
295
+ attach_function :snmp_increment_statistic, [ :int ], :u_int
296
+ attach_function :snmp_increment_statistic_by, [ :int, :int ], :u_int
297
+ attach_function :snmp_get_statistic, [ :int ], :u_int
298
+ attach_function :snmp_init_statistics, [ ], :void
299
+ attach_function :create_user_from_session, [ :pointer ], :int
300
+ # attach_function :snmp_get_fd_for_session, [ :pointer ], :int
301
+ attach_function :snmp_open_ex, [ :pointer, callback([ :pointer, :pointer, :pointer, :int ], :int), callback([ :pointer, :pointer, :pointer, :uint ], :int), callback([ :pointer, :pointer, :int ], :int), callback([ :pointer, :pointer, :pointer, :pointer ], :int), callback([ :pointer, :pointer, :pointer, :pointer, :pointer ], :int), callback([ :pointer, :uint ], :int) ], :pointer
302
+ attach_function :snmp_set_do_debugging, [ :int ], :void
303
+ attach_function :snmp_get_do_debugging, [ ], :int
304
+ attach_function :snmp_error, [ :pointer, :pointer, :pointer, :pointer ], :void
305
+ attach_function :snmp_sess_init, [ :pointer ], :void
306
+ attach_function :snmp_sess_open, [ :pointer ], :pointer
307
+ attach_function :snmp_sess_pointer, [ :pointer ], :pointer
308
+ attach_function :snmp_sess_session, [ :pointer ], SnmpSession.typed_pointer
309
+ attach_function :snmp_sess_transport, [ :pointer ], :pointer
310
+ attach_function :snmp_sess_transport_set, [ :pointer, :pointer ], :void
311
+ attach_function :snmp_sess_add_ex, [ :pointer, :pointer, callback([ :pointer, :pointer, :pointer, :int ], :int), callback([ :pointer, :pointer, :pointer, :uint ], :int), callback([ :pointer, :pointer, :int ], :int), callback([ :pointer, :pointer, :pointer, :pointer ], :int), callback([ :pointer, :pointer, :pointer, :pointer, :pointer ], :int), callback([ :pointer, :uint ], :int), callback([ :pointer, :pointer, :uint ], :pointer) ], :pointer
312
+ attach_function :snmp_sess_add, [ :pointer, :pointer, callback([ :pointer, :pointer, :pointer, :int ], :int), callback([ :pointer, :pointer, :int ], :int) ], :pointer
313
+ attach_function :snmp_add, [ :pointer, :pointer, callback([ :pointer, :pointer, :pointer, :int ], :int), callback([ :pointer, :pointer, :int ], :int) ], :pointer
314
+ attach_function :snmp_add_full, [ :pointer, :pointer, callback([ :pointer, :pointer, :pointer, :int ], :int), callback([ :pointer, :pointer, :pointer, :uint ], :int), callback([ :pointer, :pointer, :int ], :int), callback([ :pointer, :pointer, :pointer, :pointer ], :int), callback([ :pointer, :pointer, :pointer, :pointer, :pointer ], :int), callback([ :pointer, :uint ], :int), callback([ :pointer, :pointer, :uint ], :pointer) ], :pointer
315
+ attach_function :snmp_sess_send, [ :pointer, :pointer ], :int
316
+ attach_function :snmp_sess_async_send, [ :pointer, :pointer, :netsnmp_callback, :pointer ], :int
317
+ attach_function :snmp_sess_select_info, [ :pointer, :pointer, :pointer, :pointer, :pointer ], :int
318
+ attach_function :snmp_sess_read, [ :pointer, :pointer ], :int
319
+ attach_function :snmp_sess_timeout, [ :pointer ], :void
320
+ attach_function :snmp_sess_close, [ :pointer ], :int
321
+ attach_function :snmp_sess_error, [ :pointer, :pointer, :pointer, :pointer ], :void
322
+ attach_function :netsnmp_sess_log_error, [ :int, :string, :pointer ], :void
323
+ attach_function :snmp_sess_perror, [ :string, :pointer ], :void
324
+ attach_function :snmp_pdu_type, [ :int ], :string
325
+
326
+
327
+
328
+ attach_function :asn_check_packet, [ :pointer, :uint ], :int
329
+ attach_function :asn_parse_int, [ :pointer, :pointer, :pointer, :pointer, :uint ], :pointer
330
+ attach_function :asn_build_int, [ :pointer, :pointer, :u_char, :pointer, :uint ], :pointer
331
+ attach_function :asn_parse_unsigned_int, [ :pointer, :pointer, :pointer, :pointer, :uint ], :pointer
332
+ attach_function :asn_build_unsigned_int, [ :pointer, :pointer, :u_char, :pointer, :uint ], :pointer
333
+ attach_function :asn_parse_string, [ :pointer, :pointer, :pointer, :pointer, :pointer ], :pointer
334
+ attach_function :asn_build_string, [ :pointer, :pointer, :u_char, :pointer, :uint ], :pointer
335
+ attach_function :asn_parse_header, [ :pointer, :pointer, :pointer ], :pointer
336
+ attach_function :asn_parse_sequence, [ :pointer, :pointer, :pointer, :u_char, :string ], :pointer
337
+ attach_function :asn_build_header, [ :pointer, :pointer, :u_char, :uint ], :pointer
338
+ attach_function :asn_build_sequence, [ :pointer, :pointer, :u_char, :uint ], :pointer
339
+ attach_function :asn_parse_length, [ :pointer, :pointer ], :pointer
340
+ attach_function :asn_build_length, [ :pointer, :pointer, :uint ], :pointer
341
+ attach_function :asn_parse_objid, [ :pointer, :pointer, :pointer, :pointer, :pointer ], :pointer
342
+ attach_function :asn_build_objid, [ :pointer, :pointer, :u_char, :pointer, :uint ], :pointer
343
+ attach_function :asn_parse_null, [ :pointer, :pointer, :pointer ], :pointer
344
+ attach_function :asn_build_null, [ :pointer, :pointer, :u_char ], :pointer
345
+ attach_function :asn_parse_bitstring, [ :pointer, :pointer, :pointer, :pointer, :pointer ], :pointer
346
+ attach_function :asn_build_bitstring, [ :pointer, :pointer, :u_char, :pointer, :uint ], :pointer
347
+ attach_function :asn_parse_unsigned_int64, [ :pointer, :pointer, :pointer, :pointer, :uint ], :pointer
348
+ attach_function :asn_build_unsigned_int64, [ :pointer, :pointer, :u_char, :pointer, :uint ], :pointer
349
+ attach_function :asn_parse_signed_int64, [ :pointer, :pointer, :pointer, :pointer, :uint ], :pointer
350
+ attach_function :asn_build_signed_int64, [ :pointer, :pointer, :u_char, :pointer, :uint ], :pointer
351
+ attach_function :asn_build_float, [ :pointer, :pointer, :u_char, :pointer, :uint ], :pointer
352
+ attach_function :asn_parse_float, [ :pointer, :pointer, :pointer, :pointer, :uint ], :pointer
353
+ attach_function :asn_build_double, [ :pointer, :pointer, :u_char, :pointer, :uint ], :pointer
354
+ attach_function :asn_parse_double, [ :pointer, :pointer, :pointer, :pointer, :uint ], :pointer
355
+
356
+ attach_function :snmp_pdu_create, [:int], SnmpPdu.typed_pointer
357
+ attach_function :get_node, [:pointer, :pointer, :pointer], :int
358
+ attach_function :read_objid, [:string, :pointer, :pointer], :int
359
+ attach_function :snmp_add_null_var, [:pointer, :pointer, :size_t], :pointer
360
+ attach_function :snmp_sess_synch_response, [:pointer, :pointer, :pointer], :int
361
+ attach_function :snmp_synch_response, [:pointer, :pointer, :pointer], :int
362
+ attach_function :snmp_parse_oid, [:string, :pointer, :pointer], :pointer
363
+ attach_function :snmp_api_errstring, [ :int ], :string
364
+ attach_function :snmp_perror, [ :string ], :void
365
+ attach_function :snmp_set_detail, [ :string ], :void
366
+
367
+ attach_function :snmp_select_info, [:pointer, :pointer, :pointer, :pointer], :int
368
+ attach_function :select, [:int, :pointer, :pointer, :pointer, :pointer], :int
369
+ attach_function :snmp_read, [:pointer], :void
370
+ attach_function :generate_Ku, [:pointer, :int, :string, :int, :pointer, :pointer], :int
371
+ #attach_function :send_easy_trap, [:int, :int], :void
372
+ #attach_function :send_trap_vars, [:int, :int, :pointer], :void
373
+ #attach_function :send_v2trap, [:pointer], :void
374
+
375
+ def self.get_fd_set
376
+ FFI::MemoryPointer.new(:pointer, 128)
377
+ end
378
+
379
+
380
+ end
381
+ end
382
+ end