I changed my scli sources yesterday to use the glib-2.0. Since
glib-2.0 has some nice new features, it might be possible to
simplify some of the internals by reusing more glib stuff. If
someone sees a problem with moving to glib-2.0, please let me
know.
I also played some time with the idea to separate out the SNMP
implementation. I did just that yesterday by creating a package
tentatively called gsnmp. The idea here would be that others
can reuse the glib-based SNMP library easily. Now, making this
split would imply that scli has another dependency. If you think
this is a problem, please let me know.
There is another open question: Should the scli stubs also become a
reusable separate package? It would make sense if there are people
who are interested to develop other applications that make use of
the stubs. One could package this as gsnmpietf (stubs for the
IETF MIBs), gsnmpnortel, gsnmpcisco, ...
Having stub packages would allow to write simple programs such as the
one below without having to deal with all the nasty SNMP/MIB
things. But perhaps I am starting to overdo modularization? Comments
are welcome.
/js
#include <gsnmp.h>
#include <ietf/snmpv2-mib.h>
static void
ping(GSnmpSession *s)
{
snmpv2_mib_system_t *system;
snmpv2_mib_get_system(s, &system, SNMPV2_MIB_SYSDESCR);
if (! s->error_status && system) {
g_print("%.*s\n", system->_sysDescrLength, system->sysDescr);
}
if (system) snmpv2_mib_free_system(system);
}
int
main(int argc, char **argv)
{
GSnmpSession *s;
if (! g_snmp_init(FALSE)) {
exit(1);
}
s = g_snmp_session_new(G_SNMP_TDOMAIN_UDP_IPV4, "localhost", 161);
if (! s) {
exit(1);
}
s->rcomm = "public";
s->version = G_SNMP_V1;
ping(s);
g_snmp_session_destroy(s);
return 0;
}