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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors