]> git.ipfire.org Git - thirdparty/squid.git/blame - lib/snmplib/snmp_api_error.c
Cleanup: un-wrap C++ header includes
[thirdparty/squid.git] / lib / snmplib / snmp_api_error.c
CommitLineData
85269fdf 1/*
2 * Error routines concerning the error status of the SNMP API.
3 *
4 * Sometimes things don't work out the way we wanted.
5 *
6 */
7/***************************************************************************
8 *
9 * Copyright 1997 by Carnegie Mellon University
26ac0430 10 *
85269fdf 11 * All Rights Reserved
26ac0430 12 *
85269fdf 13 * Permission to use, copy, modify, and distribute this software and its
14 * documentation for any purpose and without fee is hereby granted,
15 * provided that the above copyright notice appear in all copies and that
16 * both that copyright notice and this permission notice appear in
17 * supporting documentation, and that the name of CMU not be
18 * used in advertising or publicity pertaining to distribution of the
19 * software without specific, written prior permission.
26ac0430 20 *
85269fdf 21 * CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
22 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
23 * CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
24 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
25 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
26 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
27 * SOFTWARE.
26ac0430 28 *
85269fdf 29 * Author: Ryan Troll <ryan+@andrew.cmu.edu>
26ac0430 30 *
85269fdf 31 ***************************************************************************/
32
f7f3304a 33#include "squid.h"
85269fdf 34#include "snmp_api_error.h"
35
85269fdf 36/***************************************************************************
37 *
38 ***************************************************************************/
39
40int snmp_errno = 0;
41
26ac0430 42static const char *api_errors[17] = {
43d4303e 43 "Unknown Error",
44 "Generic Error",
45 "Invalid local port",
46 "Unknown host",
47 "Unknown session",
48 "Too Long",
49
50 "Encoding ASN.1 Information", /* 6 */
51 "Decoding ASN.1 Information", /* 7 */
52 "PDU Translation error",
53 "OS Error",
54 "Invalid Textual OID",
85269fdf 55
43d4303e 56 "Unable to fix PDU",
57 "Unsupported SNMP Type",
58 "Unable to parse PDU",
59 "Packet Error",
60 "No Response From Host",
85269fdf 61
43d4303e 62 "Unknown Error"
85269fdf 63};
64
468ae12b 65void
43d4303e 66snmp_set_api_error(int x)
85269fdf 67{
43d4303e 68 snmp_errno = x;
85269fdf 69}
70
5c52f59a 71const char *
43d4303e 72snmp_api_error(int err)
85269fdf 73{
43d4303e 74 int foo = (err * -1);
75 if ((foo < SNMPERR_GENERR) ||
26ac0430
AJ
76 (foo > SNMPERR_LAST))
77 foo = 0;
85269fdf 78
43d4303e 79 return (api_errors[foo]);
85269fdf 80}
81
468ae12b 82int
43d4303e 83snmp_api_errno(void)
85269fdf 84{
43d4303e 85 return (snmp_errno);
85269fdf 86}
87
5c52f59a 88const char *
43d4303e 89api_errstring(int snmp_errnumber)
85269fdf 90{
43d4303e 91 return (snmp_api_error(snmp_errnumber));
85269fdf 92}