php-doc-en/reference/snmp/functions/snmp-set-valueretrieval.xml
2011-08-16 11:38:58 +00:00

184 lines
4.8 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.snmp-set-valueretrieval" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>snmp_set_valueretrieval</refname>
<refpurpose>
Specify the method how the SNMP values will be returned
</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type>
<methodname>snmp_set_valueretrieval</methodname>
<methodparam>
<type>int</type>
<parameter>method</parameter>
<initializer>SNMP_VALUE_LIBRARY</initializer>
</methodparam>
</methodsynopsis>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term>
<parameter>method</parameter>
</term>
<listitem>
<table>
<title>types</title>
<tgroup cols="2">
<tbody>
<row>
<entry>SNMP_VALUE_LIBRARY</entry>
<entry>The return values will be as returned by the Net-SNMP library.</entry>
</row>
<row>
<entry>SNMP_VALUE_PLAIN</entry>
<entry>The return values will be the plain value without the SNMP type hint.</entry>
</row>
<row>
<entry>SNMP_VALUE_OBJECT</entry>
<entry>
The return values will be objects with the properties "value" and "type", where the latter
is one of the SNMP_OCTET_STR, SNMP_COUNTER etc. constants. The
way "value" is returned is based on which one of constants
<constant>SNMP_VALUE_LIBRARY</constant>, <constant>SNMP_VALUE_PLAIN</constant> is set.
</entry>
</row>
</tbody>
</tgroup>
</table>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Using
<function>snmp_set_valueretrieval</function>
</title>
<programlisting role="php">
<![CDATA[
<?php
snmp_set_valueretrieval(SNMP_VALUE_LIBRARY);
$ret = snmpget('localhost', 'public', 'IF-MIB::ifName.1');
// $ret = "STRING: lo"
snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
$ret = snmpget('localhost', 'public', 'IF-MIB::ifName.1');
// $ret = "lo";
snmp_set_valueretrieval(SNMP_VALUE_OBJECT);
$ret = snmpget('localhost', 'public', 'IF-MIB::ifName.1');
// stdClass Object
// (
// [type] => 4 <-- SNMP_OCTET_STR, see constants
// [value] => lo
// )
// PHP 5.4+ examples
snmp_set_valueretrieval(SNMP_VALUE_OBJECT | SNMP_VALUE_PLAIN);
$ret = snmpget('localhost', 'public', 'IF-MIB::ifName.1');
// stdClass Object
// (
// [type] => 4 <-- SNMP_OCTET_STR, see constants
// [value] => lo
// )
snmp_set_valueretrieval(SNMP_VALUE_OBJECT | SNMP_VALUE_LIBRARY);
$ret = snmpget('localhost', 'public', 'IF-MIB::ifName.1');
// stdClass Object
// (
// [type] => 4 <-- SNMP_OCTET_STR, see constants
// [value] => STRING: lo
// )
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>5.4.0</entry>
<entry>
<para>
Constants <constant>SNMP_VALUE_PLAIN</constant> or <constant>SNMP_VALUE_LIBRARY</constant>
may be combined with <constant>SNMP_VALUE_OBJECT</constant>
resulting different way of representing contents of <parameter>value</parameter>
array element in return value of GET-function. If no
<constant>SNMP_VALUE_{PLAIN,LIBRARY}</constant> constant is
accompanying <constant>SNMP_VALUE_OBJECT</constant>,
<constant>SNMP_VALUE_LIBRARY</constant> is used.
</para>
<para>
Prior to 5.4.0 <constant>SNMP_VALUE_OBJECT</constant> effecively meant
<constant>SNMP_VALUE_OBJECT</constant>|<constant>SNMP_VALUE_PLAIN</constant>.
</para>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member>
<function>snmp_get_valueretrieval</function>
</member>
<member><xref linkend="snmp.constants" /></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->