]>
Commit | Line | Data |
---|---|---|
5c193dec | 1 | /* |
77b1029d | 2 | * Copyright (C) 1996-2020 The Squid Software Foundation and contributors |
5c193dec 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 | ||
b5638623 | 9 | #ifndef SQUID_SNMP_ASN1_H |
10 | #define SQUID_SNMP_ASN1_H | |
d60c11be | 11 | |
8bde32ea | 12 | /* |
13 | * Definitions for Abstract Syntax Notation One, ASN.1 | |
14 | * As defined in ISO/IS 8824 and ISO/IS 8825 | |
15 | * | |
8bde32ea | 16 | */ |
d60c11be | 17 | /********************************************************************** |
18 | * | |
19 | * Copyright 1997 by Carnegie Mellon University | |
c5dd4956 | 20 | * |
d60c11be | 21 | * All Rights Reserved |
c5dd4956 | 22 | * |
d60c11be | 23 | * Permission to use, copy, modify, and distribute this software and its |
24 | * documentation for any purpose and without fee is hereby granted, | |
25 | * provided that the above copyright notice appear in all copies and that | |
26 | * both that copyright notice and this permission notice appear in | |
27 | * supporting documentation, and that the name of CMU not be | |
28 | * used in advertising or publicity pertaining to distribution of the | |
29 | * software without specific, written prior permission. | |
c5dd4956 | 30 | * |
d60c11be | 31 | * CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING |
32 | * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL | |
33 | * CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR | |
34 | * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
35 | * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, | |
36 | * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS | |
37 | * SOFTWARE. | |
c5dd4956 | 38 | * |
d60c11be | 39 | **********************************************************************/ |
8bde32ea | 40 | |
41 | #ifndef EIGHTBIT_SUBIDS | |
88c4e50c | 42 | typedef u_int oid; |
8bde32ea | 43 | #define MAX_SUBID 0xFFFFFFFF |
44 | #else | |
43d4303e | 45 | typedef u_char oid; |
8bde32ea | 46 | #define MAX_SUBID 0xFF |
47 | #endif | |
48 | ||
f53969cc SM |
49 | #define MAX_OID_LEN 128 /* max subid's in an oid, per SNMP spec. */ |
50 | ||
51 | #define ASN_BOOLEAN (0x01) | |
52 | #define ASN_INTEGER (0x02) | |
53 | #define ASN_BIT_STR (0x03) | |
54 | #define ASN_OCTET_STR (0x04) | |
55 | #define ASN_NULL (0x05) | |
56 | #define ASN_OBJECT_ID (0x06) | |
57 | #define ASN_SEQUENCE (0x10) | |
58 | #define ASN_SET (0x11) | |
59 | ||
60 | #define ASN_UNIVERSAL (0x00) | |
8bde32ea | 61 | #define ASN_APPLICATION (0x40) |
f53969cc SM |
62 | #define ASN_CONTEXT (0x80) |
63 | #define ASN_PRIVATE (0xC0) | |
8bde32ea | 64 | |
f53969cc SM |
65 | #define ASN_PRIMITIVE (0x00) |
66 | #define ASN_CONSTRUCTOR (0x20) | |
8bde32ea | 67 | |
f53969cc | 68 | #define ASN_LONG_LEN (0x80) |
8bde32ea | 69 | #define ASN_EXTENSION_ID (0x1F) |
f53969cc | 70 | #define ASN_BIT8 (0x80) |
8bde32ea | 71 | |
f53969cc SM |
72 | #define IS_CONSTRUCTOR(byte) ((byte) & ASN_CONSTRUCTOR) |
73 | #define IS_EXTENSION_ID(byte) (((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID) | |
8bde32ea | 74 | |
d60c11be | 75 | #ifdef __cplusplus |
e1381638 | 76 | extern "C" { |
d60c11be | 77 | #endif |
8bde32ea | 78 | |
f53969cc SM |
79 | u_char *asn_build_header(u_char *, int *, u_char, int); |
80 | u_char *asn_parse_int(u_char *, int *, u_char *, int *, int); | |
81 | u_char *asn_parse_unsigned_int(u_char *, int *, u_char *, u_int *, int); | |
82 | u_char *asn_build_int(u_char *, int *, u_char, int *, int); | |
83 | u_char *asn_build_unsigned_int(u_char *, int *, u_char, u_int *, int); | |
84 | u_char *asn_parse_string(u_char *, int *, u_char *, u_char *, int *); | |
85 | u_char *asn_build_string(u_char *, int *, u_char, u_char *, int); | |
86 | u_char *asn_parse_header(u_char *, int *, u_char *); | |
87 | u_char *asn_build_header_with_truth(u_char *, int *, u_char, int, int); | |
88 | ||
89 | u_char *asn_parse_length(u_char *, u_int *); | |
90 | u_char *asn_build_length(u_char *, int *, int, int); | |
91 | u_char *asn_parse_objid(u_char *, int *, u_char *, oid *, int *); | |
92 | u_char *asn_build_objid(u_char *, int *, u_char, oid *, int); | |
93 | u_char *asn_parse_null(u_char *, int *, u_char *); | |
94 | u_char *asn_build_null(u_char *, int *, u_char); | |
d60c11be | 95 | |
7274dc31 | 96 | #if 0 |
f53969cc SM |
97 | u_char *asn_parse_bitstring(u_char *, int *, u_char *, u_char *, int *); |
98 | u_char *asn_build_bitstring(u_char *, int *, u_char, u_char *, int); | |
d60c11be | 99 | |
7274dc31 | 100 | #endif |
f53969cc | 101 | u_char *asn_build_exception(u_char *, int *, u_char); |
d60c11be | 102 | |
103 | #ifdef __cplusplus | |
104 | } | |
f7640449 | 105 | |
468ae12b | 106 | #endif |
b5638623 | 107 | |
f53969cc SM |
108 | #endif /* SQUID_SNMP_ASN1_H */ |
109 |