Hi!
To write a value, we need to assign a function to write_method. The
function will be called several time with a different action each time
(RESERVE1, RESERVE2, ACTION, COMMIT, UNDO, FREE). The function will also
have access to OID to be written and to the value from GET.
Looking at interfaces.c, I see:
#v+
long admin_status = 0;
long oldadmin_status = 0;
[...]
int
writeIfEntry(int action,
u_char * var_val,
u_char var_val_type,
size_t var_val_len,
u_char * statP, oid * name, size_t name_len)
{
[...]
case ACTION:
/*
* Save the old value, in case of UNDO
*/
oldadmin_status = admin_status;
admin_status = (int) *var_val;
break;
#v-
This is a bit odd for me. Let's suppose that I use:
snmpset ifAdminStatus.5 = up ifAdminStatus.6 = up
Since I suppose that before each phase (RESERVE1, RESERVE2, etc), we go
into var_ifEntry, then admin_status is set correctly each time. However,
oldadmin_status seems inaccurate to me. ACTION will be executed for
column 5 first then for column 6 and the only value of oldadmin_status
we have saved would be the second one, right?
Moreover, since ACTION cannot fail, UNDO is not necessary and
oldadmin_status is not really used, therefore I suppose that there is no
real bug. But looking at at.c, I see that this is the same logic. There
is only one instance of oldarp_row, therefore, writing several values
while one of them is failing will lead to undo only one.
Please, correct me if I am wrong.
Another question: what is the best way to pass an object to the
write_method? For example, if I need some expensive processing to find
an object, I would like to not redo it in write_method. Since,
write_method is always immediatly called after the var_* method, I could
put a pointer to my object in some global variable. Is there a cleaner
way? For example, using the statP pointer (I don't need the current
value)?
BTW, why is there a lookup before each action? I mean, the workflow is:
var_atEntry lookups the entry and sets write_method.
write_arp is called with action == RESERVE1
var_atEntry lookups the entry and sets write_method.
write_arp is called with action == RESERVE2
var_atEntry lookups the entry and sets write_method.
write_arp is called with action == ACTION
var_atEntry lookups the entry and sets write_method.
write_arp is called with action == COMMIT
var_atEntry lookups the entry and sets write_method.
write_arp is called with action == FREE
The workflow could be more efficient with:
var_atEntry lookups the entry and sets write_method.
write_arp is called with action == RESERVE1
write_arp is called with action == RESERVE2
write_arp is called with action == ACTION
write_arp is called with action == COMMIT
write_arp is called with action == FREE
Why is var_atEntry called so many times while always giving the same
result?
--
I AM NOT LICENSED TO DO ANYTHING
I AM NOT LICENSED TO DO ANYTHING
I AM NOT LICENSED TO DO ANYTHING
-+- Bart Simpson on chalkboard in episode 4F08
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users