This is a discussion on Re: pass-through error codes within the SNMP Coders forums, part of the Networking and Network Related category; --===============1735756101== Content-Type: multipart/alternative; boundary="----=_Part_30867_8071286.1161871986691" ------=_Part_30867_8071286.1161871986691 Content-Type: text/plain; charset=ISO-8859-1; ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
--===============1735756101==
Content-Type: multipart/alternative; boundary="----=_Part_30867_8071286.1161871986691" ------=_Part_30867_8071286.1161871986691 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I've created two patches (one for pass.c and the other for pass_persist.c) for the Net-SNMP version 5.4.pre4 files (but to be considered for a future 5.4.x release). Basically I created the function check_set_error() which checks for possible error strings in response to a pass-through set request and that function is used for both pass and pass_persist. I have added that function in pass.cas there are some other functions declared there that are common to both pass.c and pass_persist.c (such as asc2bin, bin2asc, etc). I am not sure whether some error codes (for example "tooBig") make sense or will ever be used by a pass-through script/executable. But I have included all the possible error codes for completeness. Feel free to remove any which are defintely not applicable and should not be included. And obviously feel free to add/modify/delete anything else as required. The two patches are as follows. *** net-snmp-5.4.pre4/agent/mibgroup/ucd-snmp/pass.c Thu Aug 18 02:44:02 2005 --- patched/pass.c Thu Oct 26 15:38:08 2006 *************** *** 151,156 **** --- 151,203 ---- return 3 * n - 1; } + /* + * This is also called from pass_persist.c + */ + int + check_set_error(const char *buf) + { + if (!strncasecmp(buf, "too-big", 7)) { + return SNMP_ERR_TOOBIG; + } else if (!strncasecmp(buf, "no-such-name", 12)) { + return SNMP_ERR_NOSUCHNAME; + } else if (!strncasecmp(buf, "bad-value", 9)) { + return SNMP_ERR_BADVALUE; + } else if (!strncasecmp(buf, "read-only", 9)) { + return SNMP_ERR_READONLY; + } else if (!strncasecmp(buf, "gen-error", 9)) { + return SNMP_ERR_GENERR; + } else if (!strncasecmp(buf, "no-access", 9)) { + return SNMP_ERR_NOACCESS; + } else if (!strncasecmp(buf, "wrong-type", 10)) { + return SNMP_ERR_WRONGTYPE; + } else if (!strncasecmp(buf, "wrong-length", 12)) { + return SNMP_ERR_WRONGLENGTH; + } else if (!strncasecmp(buf, "wrong-encoding", 14)) { + return SNMP_ERR_WRONGENCODING; + } else if (!strncasecmp(buf, "wrong-value", 11)) { + return SNMP_ERR_WRONGVALUE; + } else if (!strncasecmp(buf, "no-creation", 11)) { + return SNMP_ERR_NOCREATION; + } else if (!strncasecmp(buf, "inconsistent-value", 18)) { + return SNMP_ERR_INCONSISTENTVALUE; + } else if (!strncasecmp(buf, "resource-unavailable", 20)) { + return SNMP_ERR_RESOURCEUNAVAILABLE; + } else if (!strncasecmp(buf, "commit-failed", 13)) { + return SNMP_ERR_COMMITFAILED; + } else if (!strncasecmp(buf, "undo-failed", 11)) { + return SNMP_ERR_UNDOFAILED; + } else if (!strncasecmp(buf, "authorization-error", 19)) { + return SNMP_ERR_AUTHORIZATIONERROR; + } else if (!strncasecmp(buf, "not-writable", 12)) { + return SNMP_ERR_NOTWRITABLE; + } else if (!strncasecmp(buf, "inconsistent-name", 17)) { + return SNMP_ERR_INCONSISTENTNAME; + } + + return SNMP_ERR_NOERROR; + } + void init_pass(void) { *************** *** 514,525 **** exec_command(passthru); DEBUGMSGTL(("ucd-snmp/pass", "pass-running returned: %s", passthru->output)); ! if (!strncasecmp(passthru->output, "not-writable", 12)) { ! return SNMP_ERR_NOTWRITABLE; ! } else if (!strncasecmp(passthru->output, "wrong-type", 10)) { ! return SNMP_ERR_WRONGTYPE; ! } ! return SNMP_ERR_NOERROR; } } if (snmp_get_do_debugging()) { --- 561,568 ---- exec_command(passthru); DEBUGMSGTL(("ucd-snmp/pass", "pass-running returned: %s", passthru->output)); ! ! return check_set_error(buf); } } if (snmp_get_do_debugging()) { *** net-snmp-5.4.pre4/agent/mibgroup/ucd-snmp/pass_persist.c Wed Oct 18 04:59:10 2006 --- patched/pass_persist.c Thu Oct 26 15:40:40 2006 *************** *** 63,68 **** --- 63,69 ---- extern int bin2asc(char *p, size_t n); extern int snmp_oid_min_compare(const oid *, size_t, const oid *, size_t); + extern int check_set_error(const char *buf); /* * the relocatable extensible commands variables *************** *** 492,509 **** return SNMP_ERR_NOTWRITABLE; } ! if (!strncasecmp(buf, "not-writable", 12)) { ! return SNMP_ERR_NOTWRITABLE; ! } else if (!strncasecmp(buf, "wrong-type", 10)) { ! return SNMP_ERR_WRONGTYPE; ! } else if (!strncasecmp(buf, "wrong-length", 12)) { ! return SNMP_ERR_WRONGLENGTH; ! } else if (!strncasecmp(buf, "wrong-value", 11)) { ! return SNMP_ERR_WRONGVALUE; ! } else if (!strncasecmp(buf, "inconsistent-value", 18)) { ! return SNMP_ERR_INCONSISTENTVALUE; ! } ! return SNMP_ERR_NOERROR; } } if (snmp_get_do_debugging()) { --- 493,499 ---- return SNMP_ERR_NOTWRITABLE; } ! return check_set_error(buf); } } if (snmp_get_do_debugging()) { ------=_Part_30867_8071286.1161871986691 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline I've created two patches (one for pass.c and the other for pass_persist.c) for the Net-SNMP version 5.4.pre4 files (but to be considered for a future 5.4.x release).<br><br>Basically I created the function check_set_error() which checks for possible error strings in response to a pass-through set request and that function is used for both pass and pass_persist. I have added that function in pass.c as there are some other functions declared there that are common to both pass.c and pass_persist.c (such as asc2bin, bin2asc, etc). I am not sure whether some error codes (for example "tooBig") make sense or will ever be used by a pass-through script/executable. But I have included all the possible error codes for completeness. Feel free to remove any which are defintely not applicable and should not be included. And obviously feel free to add/modify/delete anything else as required. <br><br>The two patches are as follows.<br><br><br>*** net-snmp-5.4.pre4/agent/mibgroup/ucd-snmp/pass.c Thu Aug 18 02:44:02 2005<br>--- patched/pass.c Thu Oct 26 15:38:08 2006<br>***************<br>*** 151,156 ****<br> --- 151,203 ----<br> return 3 * n - 1;<br> }<br> <br>+ /*<br>+ * This is also called from pass_persist.c <br>+ */<br>+ int<br>+ check_set_error(const char *buf)<br>+ {<br>+ if (!strncasecmp(buf, "too-big", 7)) { <br>+ &nb sp; return SNMP_ERR_TOOBIG;<br>+ } else if (!strncasecmp(buf, "no-such-name", 12)) {<br>+ &n bsp; return SNMP_ERR_NOSUCHNAME;<br>+ } else if (!strncasecmp(buf, "bad-value", 9)) {<br>+ &n bsp; return SNMP_ERR_BADVALUE; <br>+ } else if (!strncasecmp(buf, "read-only", 9)) {<br>+ &n bsp; return SNMP_ERR_READONLY;<br>+ } else if (!strncasecmp(buf, "gen-error", 9)) {<br>+ &n bsp; return SNMP_ERR_GENERR;<br>+ } else if (!strncasecmp(buf, "no-access", 9)) { <br>+ &nb sp; return SNMP_ERR_NOACCESS;<br>+ } else if (!strncasecmp(buf, "wrong-type", 10)) {<br>+ &n bsp; return SNMP_ERR_WRONGTYPE;<br>+ } else if (!strncasecmp(buf, "wrong-length", 12)) {<br> +   ; return SNMP_ERR_WRONGLENGTH;<br>+ } else if (!strncasecmp(buf, "wrong-encoding", 14)) {<br>+ &n bsp; return SNMP_ERR_WRONGENCODING;<br>+ &nbs p; } else if (!strncasecmp(buf, "wrong-value", 11)) { <br>+ &nb sp; return SNMP_ERR_WRONGVALUE;<br>+ } else if (!strncasecmp(buf, "no-creation", 11)) {<br>+ &n bsp; return SNMP_ERR_NOCREATION;<br>+ } else if (!strncasecmp(buf, "inconsistent-value", 18)) { <br>+ &nb sp; return SNMP_ERR_INCONSISTENTVALUE;<br>+ } else if (!strncasecmp(buf, "resource-unavailable", 20)) {<br>+ &n bsp; return SNMP_ERR_RESOURCEUNAVAILABLE;<br>+ &nbs p; } else if (!strncasecmp(buf, "commit-failed", 13)) { <br>+ &nb sp; return SNMP_ERR_COMMITFAILED;<br>+   ; } else if (!strncasecmp(buf, "undo-failed", 11)) {<br>+ &n bsp; return SNMP_ERR_UNDOFAILED;<br>+ } else if (!strncasecmp(buf, "authorization-error", 19)) { <br>+ &nb sp; return SNMP_ERR_AUTHORIZATIONERROR;<br>+   ; } else if (!strncasecmp(buf, "not-writable", 12)) {<br>+ &n bsp; return SNMP_ERR_NOTWRITABLE;<br>+ } else if (!strncasecmp(buf, "inconsistent-name", 17)) { <br>+ &nb sp; return SNMP_ERR_INCONSISTENTNAME;<br>+ & nbsp; }<br>+ <br>+ return SNMP_ERR_NOERROR;<br>+ }<br>+ <br> void<br> init_pass(void)<br> {<br>***************<br>*** 514,525 ****<br> exec_command(passthru); <br> &nbs p; DEBUGMSGTL(("ucd-snmp/pass", "pass-running returned: %s",<br> & nbsp; &nb sp;   ; passthru->output));<br>! &n bsp; if (!strncasecmp(passthru->output, "not-writable", 12)) { <br>! &nb sp;   ; return SNMP_ERR_NOTWRITABLE;<br>!   ; } else if (!strncasecmp(passthru->output, "wrong-type", 10)) {<br>! &n bsp; &nbs p; return SNMP_ERR_WRONGTYPE;<br>! &n bsp; }<br>! &n bsp; return SNMP_ERR_NOERROR; <br> &nbs p; }<br> }<br> if (snmp_get_do_debugging()) {<br>--- 561,568 ----<br> &nbs p; exec_command(passthru);<br>   ; & nbsp; DEBUGMSGTL(("ucd-snmp/pass", "pass-running returned: %s", <br> &nbs p; &n bsp; passthru->output));<br>! <br>! &nb sp; return check_set_error(buf);<br> & nbsp; }<br> }<br> if (snmp_get_do_debugging()) {<br><br><br>*** net-snmp-5.4.pre4/agent/mibgroup/ucd-snmp/pass_persist.c Wed Oct 18 04:59:10 2006 <br>--- patched/pass_persist.c Thu Oct 26 15:40:40 2006<br>***************<br>*** 63,68 ****<br>--- 63,69 ----<br> extern int bin2asc(char *p, size_t n);<br> extern int snmp_oid_min_compare(const oid *, size_t, const oid *, <br> &nbs p; &n bsp; &nbs p; size_t);<br>+ extern int check_set_error(const char *buf);<br> <br> /*<br> * the relocatable extensible commands variables <br>***************<br>*** 492,509 ****<br> &n bsp; return SNMP_ERR_NOTWRITABLE; <br> &nbs p; }<br> <br>! &nb sp; if (!strncasecmp(buf, "not-writable", 12)) {<br>! &n bsp; &nbs p; return SNMP_ERR_NOTWRITABLE;<br>!   ; } else if (!strncasecmp(buf, "wrong-type", 10)) { <br>! &nb sp;   ; return SNMP_ERR_WRONGTYPE;<br>! &n bsp; } else if (!strncasecmp(buf, "wrong-length", 12)) {<br>! &n bsp; &nbs p; return SNMP_ERR_WRONGLENGTH;<br>!   ; } else if (!strncasecmp(buf, "wrong-value", 11)) { <br>! &nb sp;   ; return SNMP_ERR_WRONGVALUE;<br>! & nbsp; } else if (!strncasecmp(buf, "inconsistent-value", 18)) {<br>! &n bsp; &nbs p; return SNMP_ERR_INCONSISTENTVALUE;<br>! &n bsp; }<br>! &n bsp; return SNMP_ERR_NOERROR; <br> &nbs p; }<br> }<br> if (snmp_get_do_debugging()) {<br>--- 493,499 ----<br> &nbs p; return SNMP_ERR_NOTWRITABLE;<br> & nbsp; &nb sp; }<br> <br>! &nb sp; return check_set_error(buf);<br> & nbsp; } <br> }<br> if (snmp_get_do_debugging()) {<br><br> ------=_Part_30867_8071286.1161871986691-- --===============1735756101== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=...057&dat=121642 --===============1735756101== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/...et-snmp-coders --===============1735756101==-- |
![]() |
| Thread Tools | |
| Display Modes | |
|
|