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