]> git.ipfire.org Git - thirdparty/squid.git/blob - include/asn1.h
48d5b7367f76e78bac4b3fe0e6d54f6c8f92a7e0
[thirdparty/squid.git] / include / asn1.h
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 #ifndef SQUID_SNMP_ASN1_H
10 #define SQUID_SNMP_ASN1_H
11
12 /*
13 * Definitions for Abstract Syntax Notation One, ASN.1
14 * As defined in ISO/IS 8824 and ISO/IS 8825
15 *
16 */
17 /**********************************************************************
18 *
19 * Copyright 1997 by Carnegie Mellon University
20 *
21 * All Rights Reserved
22 *
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.
30 *
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.
38 *
39 **********************************************************************/
40
41 #ifndef EIGHTBIT_SUBIDS
42 typedef u_int oid;
43 #define MAX_SUBID 0xFFFFFFFF
44 #else
45 typedef u_char oid;
46 #define MAX_SUBID 0xFF
47 #endif
48
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)
61 #define ASN_APPLICATION (0x40)
62 #define ASN_CONTEXT (0x80)
63 #define ASN_PRIVATE (0xC0)
64
65 #define ASN_PRIMITIVE (0x00)
66 #define ASN_CONSTRUCTOR (0x20)
67
68 #define ASN_LONG_LEN (0x80)
69 #define ASN_EXTENSION_ID (0x1F)
70 #define ASN_BIT8 (0x80)
71
72 #define IS_CONSTRUCTOR(byte) ((byte) & ASN_CONSTRUCTOR)
73 #define IS_EXTENSION_ID(byte) (((byte) & ASN_EXTENSION_ID) == ASN_EXTENSION_ID)
74
75 #ifdef __cplusplus
76 extern "C" {
77 #endif
78
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);
95
96 u_char *asn_build_exception(u_char *, int *, u_char);
97
98 #ifdef __cplusplus
99 }
100
101 #endif
102
103 #endif /* SQUID_SNMP_ASN1_H */
104