]>
Commit | Line | Data |
---|---|---|
c04fda28 | 1 | /* |
4ac4a490 | 2 | * Copyright (C) 1996-2017 The Squid Software Foundation and contributors |
c04fda28 AJ |
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 | ||
85269fdf | 9 | /* |
10 | * RFC 1908: Coexistence between SNMPv1 and SNMPv2 | |
11 | */ | |
12 | /********************************************************************** | |
13 | * | |
14 | * Copyright 1997 by Carnegie Mellon University | |
26ac0430 | 15 | * |
85269fdf | 16 | * All Rights Reserved |
26ac0430 | 17 | * |
85269fdf | 18 | * Permission to use, copy, modify, and distribute this software and its |
19 | * documentation for any purpose and without fee is hereby granted, | |
20 | * provided that the above copyright notice appear in all copies and that | |
21 | * both that copyright notice and this permission notice appear in | |
22 | * supporting documentation, and that the name of CMU not be | |
23 | * used in advertising or publicity pertaining to distribution of the | |
24 | * software without specific, written prior permission. | |
26ac0430 | 25 | * |
85269fdf | 26 | * CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING |
27 | * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL | |
28 | * CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | |
29 | * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
30 | * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | |
31 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | |
32 | * SOFTWARE. | |
26ac0430 | 33 | * |
85269fdf | 34 | * Author: Ryan Troll <ryan+@andrew.cmu.edu> |
26ac0430 | 35 | * |
85269fdf | 36 | **********************************************************************/ |
37 | ||
f7f3304a | 38 | #include "squid.h" |
85269fdf | 39 | |
85269fdf | 40 | #if HAVE_UNISTD_H |
41 | #include <unistd.h> | |
42 | #endif | |
43 | #if HAVE_STDLIB_H | |
44 | #include <stdlib.h> | |
45 | #endif | |
46 | #if HAVE_SYS_TYPES_H | |
47 | #include <sys/types.h> | |
48 | #endif | |
49 | #if HAVE_CTYPE_H | |
50 | #include <ctype.h> | |
51 | #endif | |
52 | #if HAVE_GNUMALLOC_H | |
53 | #include <gnumalloc.h> | |
482aa790 | 54 | #elif HAVE_MALLOC_H |
85269fdf | 55 | #include <malloc.h> |
56 | #endif | |
57 | #if HAVE_MEMORY_H | |
58 | #include <memory.h> | |
59 | #endif | |
32d002cb | 60 | #if HAVE_STRING_H |
85269fdf | 61 | #include <string.h> |
62 | #endif | |
32d002cb | 63 | #if HAVE_STRINGS_H |
85269fdf | 64 | #include <strings.h> |
65 | #endif | |
66 | #if HAVE_BSTRING_H | |
67 | #include <bstring.h> | |
68 | #endif | |
69 | #if HAVE_SYS_SOCKET_H | |
70 | #include <sys/socket.h> | |
71 | #endif | |
72 | #if HAVE_NETINET_IN_H | |
73 | #include <netinet/in.h> | |
74 | #endif | |
75 | #if HAVE_ARPA_INET_H | |
76 | #include <arpa/inet.h> | |
77 | #endif | |
78 | #if HAVE_SYS_TIME_H | |
79 | #include <sys/time.h> | |
80 | #endif | |
81 | #if HAVE_NETDB_H | |
82 | #include <netdb.h> | |
83 | #endif | |
84 | ||
85269fdf | 85 | #include "asn1.h" |
602d9612 | 86 | #include "snmp.h" |
85269fdf | 87 | #include "snmp_api_error.h" |
602d9612 A |
88 | #include "snmp_error.h" |
89 | #include "snmp_pdu.h" | |
90 | #include "snmp_vars.h" | |
85269fdf | 91 | |
92 | #include "util.h" | |
93 | ||
94 | /* | |
95 | * RFC 1908: Coexistence between SNMPv1 and SNMPv2 | |
96 | * | |
97 | * These convert: | |
98 | * | |
99 | * V1 PDUs from an ** AGENT ** to V2 PDUs for an ** MANAGER ** | |
100 | * V2 PDUs from an ** MANAGER ** to V1 PDUs for an ** AGENT ** | |
101 | * | |
102 | * We will never convert V1 information from a manager into V2 PDUs. V1 | |
26ac0430 | 103 | * requests are always honored by V2 agents, and the responses will be |
85269fdf | 104 | * valid V1 responses. (I think. XXXXX) |
105 | * | |
106 | */ | |
468ae12b | 107 | int |
43d4303e | 108 | snmp_coexist_V2toV1(struct snmp_pdu *PDU) |
85269fdf | 109 | { |
43d4303e | 110 | /* Per 3.1.1: |
111 | */ | |
112 | switch (PDU->command) { | |
85269fdf | 113 | |
43d4303e | 114 | case SNMP_PDU_GET: |
115 | case SNMP_PDU_GETNEXT: | |
32d002cb | 116 | #if SNMP_PDU_SET |
43d4303e | 117 | case SNMP_PDU_SET: |
a56db080 | 118 | #endif |
26ac0430 AJ |
119 | return (1); |
120 | break; | |
85269fdf | 121 | |
43d4303e | 122 | case SNMP_PDU_GETBULK: |
26ac0430 AJ |
123 | PDU->non_repeaters = 0; |
124 | PDU->max_repetitions = 0; | |
125 | PDU->command = SNMP_PDU_GETNEXT; | |
126 | return (1); | |
127 | break; | |
85269fdf | 128 | |
43d4303e | 129 | default: |
26ac0430 AJ |
130 | snmplib_debug(2, "Unable to translate PDU %d to SNMPv1!\n", PDU->command); |
131 | snmp_set_api_error(SNMPERR_PDU_TRANSLATION); | |
132 | return (0); | |
43d4303e | 133 | } |
134 | } | |
f53969cc | 135 |