aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2007-03-16 16:13:00 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2007-03-16 16:13:00 +0000
commit49bcd246d4d27474b235a5fe5e18d4617b1d52e0 (patch)
treefcb109d91041d5451bf4acef117b915b4c774af7
parent41247fcd422715241c4098dac563106119513af6 (diff)
output "anything" with selector==queried MIB
svn path=/trunk/externals/iem/snmp/; revision=7497
-rw-r--r--get-help.pd32
-rw-r--r--get.c25
2 files changed, 37 insertions, 20 deletions
diff --git a/get-help.pd b/get-help.pd
index a3965b4..7636df8 100644
--- a/get-help.pd
+++ b/get-help.pd
@@ -1,9 +1,8 @@
-#N canvas 39 0 849 551 10;
+#N canvas 0 46 849 470 10;
#X msg 207 274 disconnect;
#X msg 139 152 get SNMPv2-MIB::system.sysUpTime.0;
#X obj 121 379 print result;
#X msg 202 177 get SNMPv2-MIB::system.sysDescr.0;
-#X msg 205 204 get system.sysDescr.0;
#X obj 121 299 snmp/get;
#X msg 121 92 connect localhost public;
#X floatatom 172 321 2 0 0 1 status - -;
@@ -13,10 +12,25 @@
#X text 470 154 query a MIB;
#X text 110 22 [snmp/get] communicates with a network entity usigng
SNMP GET requests;
-#X connect 0 0 5 0;
-#X connect 1 0 5 0;
-#X connect 3 0 5 0;
-#X connect 4 0 5 0;
-#X connect 5 0 2 0;
-#X connect 5 1 7 0;
-#X connect 6 0 5 0;
+#X msg 212 211 get system.sysDescr.1;
+#X msg 211 240 get system.sysContact.0;
+#X msg 365 328 set get \$1;
+#X symbolatom 365 303 0 0 0 0 - - -;
+#X msg 32 245 raw \$1;
+#X obj 32 224 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
+1;
+#X msg 365 357 get IF-MIB::ifInOctets.2 \, get IF-MIB::ifOutOctets.2
+;
+#X connect 0 0 4 0;
+#X connect 1 0 4 0;
+#X connect 3 0 4 0;
+#X connect 4 0 2 0;
+#X connect 4 1 6 0;
+#X connect 5 0 4 0;
+#X connect 11 0 4 0;
+#X connect 12 0 4 0;
+#X connect 13 0 17 0;
+#X connect 14 0 13 0;
+#X connect 15 0 4 0;
+#X connect 16 0 15 0;
+#X connect 17 0 4 0;
diff --git a/get.c b/get.c
index 6f62c16..d871809 100644
--- a/get.c
+++ b/get.c
@@ -36,6 +36,8 @@ typedef struct _snmpget
int x_raw; /* if set, the raw string is output; no interpretation is done */
} t_snmpget;
+static void snmpget_disconnect(t_snmpget *x);
+
static void snmpget_get(t_snmpget *x, t_symbol *s)
{
if(NULL!=x->x_session){
@@ -84,24 +86,25 @@ static void snmpget_get(t_snmpget *x, t_symbol *s)
case ASN_GAUGE: case ASN_COUNTER:
case ASN_INTEGER:
{
+ t_atom aflist[2];
long v=(long)(*vars->val.integer);
- outlet_float(x->out_data, (t_float)v);
+ unsigned short lo=(unsigned short)v;
+ unsigned short hi=(unsigned short)(v>>16);
+ SETFLOAT(aflist+0, hi);
+ SETFLOAT(aflist+1, lo);
+ outlet_anything(x->out_data,
+ s,
+ 2, aflist);
+ //outlet_float(x->out_data, (t_float)v);
}
break;
- /*
- case ASN_OCTET_STR:
- {
- outlet_symbol(x->out_data, gensym(vars->val.string));
- }
- break;
- */
default:
snprint_value(mybuf, sizeof(mybuf), vars->name, vars->name_length, vars);
binbuf_text(bbuf, mybuf, strlen(mybuf));
int ac=binbuf_getnatom(bbuf);
t_atom*av=binbuf_getvec(bbuf);
outlet_list(x->out_data,
- gensym("list"),
+ s,
ac, av);
}
} else {
@@ -109,13 +112,14 @@ static void snmpget_get(t_snmpget *x, t_symbol *s)
ap=&atm;
snprint_value(mybuf, sizeof(mybuf), vars->name, vars->name_length, vars);
SETSYMBOL(ap, gensym(mybuf));
- outlet_anything(x->out_data, gensym("raw"), 1, ap);
+ outlet_anything(x->out_data, s, 1, ap);
}
if(bbuf)binbuf_free(bbuf);
}
}
} else {
error("[snmp/get] error while synching");
+ snmpget_disconnect(x);
}
snmp_free_pdu(response);
} else {
@@ -124,7 +128,6 @@ static void snmpget_get(t_snmpget *x, t_symbol *s)
}
-
/*
connect <host>[:<port>] <community>
*/