Re: MODE_SET_*
Dave Shield <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 2005-10-17 at 16:07 +0200, Roman Medina-Heigl Hernandez wrote:
> NetSNMP::agent's API shows 7 different SET states:
[snip]
> Where could I get an explanation for them?
See the file AGENT.txt - in particular, section 8.
The API that it describes is obsolete now, but the
basic multi-pass SET model is mostly the same.
> Why don't we have one and
> only MODE_SET state (like in GET or GETNEXT)?
Because changing settings is a lot more complex than
simply reporting them. Particularly ensuring that
either everything gets changed, or nothing does.
(The "as if simultaneously" behaviour).
> Really I only need to implement a simple SET: my program should check
> whether received OID is the right one, then store the value and exit.
But what if the agent is handling some other, more complex assignment
as part of the same request. Just because your particular SET handling
is (apparently) simple, doesn't mean that the whole agent can be so
forgiving.
And you haven't actually said anything about checking whether the value
that's received is acceptable or not.
> I've thought of implementing all of this in one state (for instance,
> MODE_SET_RESERVE1), but I don't know if that's not good...
Typically, you should check the requested value is OK in the RESERVE1
pass. If you are *certain* that the assignment can't possibly fail,
then it's safe to do this in the COMMIT pass. Otherwise, you should
do it in the ACTION pass, and be ready to reverse it in the UNDO pass.
> Example code for man page states the following:
> } elsif ($request_info->getMode() ==
> MODE_SET_ACTION) {
> # ... (or use the value)
> $value = $request->getValue();
> Is there any constrain which avoid to getValue() in MODE_SET_RESERVE1
> state?
No - you can certainly use 'getValue()' in the RESERVE1 pass.
In fact, I'd expect you to - if only to check that the value
is OK. It's *updating* the internal value that should wait
until ACTION or COMMIT.
> Does setError() only works on MODE_SET_RESERVE1 state?
No - setError can be used in *any* of the SET passes.
Except COMMIT - by this point, it's too late to change
your mind, and things *must* succeed. Anything that can
potentially fail should be done in an earlier pass, with
appropriate UNDO-style processing to reverse it.
Dave
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
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