coexistance.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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  * RFC 1908: Coexistence between SNMPv1 and SNMPv2
11  */
12 /**********************************************************************
13  *
14  * Copyright 1997 by Carnegie Mellon University
15  *
16  * All Rights Reserved
17  *
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.
25  *
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.
33  *
34  * Author: Ryan Troll <ryan+@andrew.cmu.edu>
35  *
36  **********************************************************************/
37 
38 #include "squid.h"
39 
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>
54 #elif HAVE_MALLOC_H
55 #include <malloc.h>
56 #endif
57 #if HAVE_MEMORY_H
58 #include <memory.h>
59 #endif
60 #if HAVE_STRING_H
61 #include <string.h>
62 #endif
63 #if HAVE_STRINGS_H
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 
85 #include "asn1.h"
86 #include "snmp.h"
87 #include "snmp_api_error.h"
88 #include "snmp_error.h"
89 #include "snmp_pdu.h"
90 #include "snmp_vars.h"
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
103  * requests are always honored by V2 agents, and the responses will be
104  * valid V1 responses. (I think. XXXXX)
105  *
106  */
107 int
109 {
110  /* Per 3.1.1:
111  */
112  switch (PDU->command) {
113 
114  case SNMP_PDU_GET:
115  case SNMP_PDU_GETNEXT:
116 #if SNMP_PDU_SET
117  case SNMP_PDU_SET:
118 #endif
119  return (1);
120  break;
121 
122  case SNMP_PDU_GETBULK:
123  PDU->non_repeaters = 0;
124  PDU->max_repetitions = 0;
125  PDU->command = SNMP_PDU_GETNEXT;
126  return (1);
127  break;
128 
129  default:
130  snmplib_debug(2, "Unable to translate PDU %d to SNMPv1!\n", PDU->command);
132  return (0);
133  }
134 }
135 
SQUIDCEXTERN void snmplib_debug(int, const char *,...) PRINTF_FORMAT_ARG2
Definition: snmplib_debug.c:21
void snmp_set_api_error(int)
#define SNMPERR_PDU_TRANSLATION
int snmp_coexist_V2toV1(struct snmp_pdu *PDU)
Definition: coexistance.c:108
#define SNMP_PDU_GETNEXT
Definition: snmp_pdu.h:93
int max_repetitions
Definition: snmp_pdu.h:60
#define SNMP_PDU_GET
Definition: snmp_pdu.h:92
int command
Definition: snmp_pdu.h:51
#define SNMP_PDU_GETBULK
Definition: snmp_pdu.h:99
int non_repeaters
Definition: snmp_pdu.h:59

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors