]>
Commit | Line | Data |
---|---|---|
7a14d768 MS |
1 | /* |
2 | * "$Id$" | |
3 | * | |
4 | * SNMP definitions for the Common UNIX Printing System (CUPS). | |
5 | * | |
6 | * This API is PRIVATE and subject to change. No third-party applications | |
7 | * should use the SNMP API defined in this file. | |
8 | * | |
d1c13e16 | 9 | * Copyright 2007-2009 by Apple Inc. |
7a14d768 MS |
10 | * Copyright 2006-2007 by Easy Software Products, all rights reserved. |
11 | * | |
12 | * These coded instructions, statements, and computer programs are the | |
13 | * property of Apple Inc. and are protected by Federal copyright | |
14 | * law. Distribution and use rights are outlined in the file "LICENSE.txt" | |
15 | * "LICENSE" which should have been included with this file. If this | |
16 | * file is missing or damaged, see the license at "http://www.cups.org/". | |
7a14d768 MS |
17 | * |
18 | * This file is subject to the Apple OS-Developed Software exception. | |
19 | */ | |
20 | ||
21 | #ifndef _CUPS_SNMP_H_ | |
22 | # define _CUPS_SNMP_H_ | |
23 | ||
24 | ||
25 | /* | |
26 | * Include necessary headers. | |
27 | */ | |
28 | ||
29 | #include "http.h" | |
30 | ||
31 | ||
32 | /* | |
33 | * Constants... | |
34 | */ | |
35 | ||
36 | #define CUPS_SNMP_PORT 161 /* SNMP well-known port */ | |
37 | #define CUPS_SNMP_MAX_OID 128 /* Maximum number of OID numbers */ | |
38 | #define CUPS_SNMP_MAX_PACKET 1472 /* Maximum size of SNMP packet */ | |
39 | #define CUPS_SNMP_MAX_STRING 512 /* Maximum size of string */ | |
40 | #define CUPS_SNMP_VERSION_1 0 /* SNMPv1 */ | |
41 | ||
42 | ||
43 | /* | |
44 | * Types... | |
45 | */ | |
46 | ||
47 | enum cups_asn1_e /**** ASN1 request/object types ****/ | |
48 | { | |
49 | CUPS_ASN1_END_OF_CONTENTS = 0x00, /* End-of-contents */ | |
50 | CUPS_ASN1_BOOLEAN = 0x01, /* BOOLEAN */ | |
51 | CUPS_ASN1_INTEGER = 0x02, /* INTEGER or ENUMERATION */ | |
52 | CUPS_ASN1_BIT_STRING = 0x03, /* BIT STRING */ | |
53 | CUPS_ASN1_OCTET_STRING = 0x04, /* OCTET STRING */ | |
54 | CUPS_ASN1_NULL_VALUE = 0x05, /* NULL VALUE */ | |
55 | CUPS_ASN1_OID = 0x06, /* OBJECT IDENTIFIER */ | |
56 | CUPS_ASN1_SEQUENCE = 0x30, /* SEQUENCE */ | |
57 | CUPS_ASN1_HEX_STRING = 0x40, /* Binary string aka Hex-STRING */ | |
58 | CUPS_ASN1_COUNTER = 0x41, /* 32-bit unsigned aka Counter32 */ | |
59 | CUPS_ASN1_GAUGE = 0x42, /* 32-bit unsigned aka Gauge32 */ | |
60 | CUPS_ASN1_TIMETICKS = 0x43, /* 32-bit unsigned aka Timeticks32 */ | |
61 | CUPS_ASN1_GET_REQUEST = 0xa0, /* GetRequest-PDU */ | |
62 | CUPS_ASN1_GET_NEXT_REQUEST = 0xa1, /* GetNextRequest-PDU */ | |
63 | CUPS_ASN1_GET_RESPONSE = 0xa2 /* GetResponse-PDU */ | |
64 | }; | |
65 | typedef enum cups_asn1_e cups_asn1_t; /**** ASN1 request/object types ****/ | |
66 | ||
d1c13e16 | 67 | typedef struct cups_snmp_string_s /**** String value ****/ |
7a14d768 MS |
68 | { |
69 | unsigned char bytes[CUPS_SNMP_MAX_STRING]; | |
70 | /* Bytes in string */ | |
71 | int num_bytes; /* Number of bytes */ | |
d1c13e16 | 72 | } cups_snmp_string_t; |
7a14d768 MS |
73 | |
74 | union cups_snmp_value_u /**** Object value ****/ | |
75 | { | |
76 | int boolean; /* Boolean value */ | |
77 | int integer; /* Integer value */ | |
78 | unsigned counter; /* Counter value */ | |
79 | unsigned gauge; /* Gauge value */ | |
80 | unsigned timeticks; /* Timeticks value */ | |
81 | int oid[CUPS_SNMP_MAX_OID]; /* OID value */ | |
d1c13e16 | 82 | cups_snmp_string_t string; /* String value */ |
7a14d768 MS |
83 | }; |
84 | ||
85 | typedef struct cups_snmp_s /**** SNMP data packet ****/ | |
86 | { | |
87 | const char *error; /* Encode/decode error */ | |
88 | http_addr_t address; /* Source address */ | |
89 | int version; /* Version number */ | |
90 | char community[CUPS_SNMP_MAX_STRING]; | |
91 | /* Community name */ | |
92 | cups_asn1_t request_type; /* Request type */ | |
93 | int request_id; /* request-id value */ | |
94 | int error_status; /* error-status value */ | |
95 | int error_index; /* error-index value */ | |
96 | int object_name[CUPS_SNMP_MAX_OID]; | |
97 | /* object-name value */ | |
98 | cups_asn1_t object_type; /* object-value type */ | |
99 | union cups_snmp_value_u | |
100 | object_value; /* object-value value */ | |
101 | } cups_snmp_t; | |
102 | ||
103 | typedef void (*cups_snmp_cb_t)(cups_snmp_t *packet, void *data); | |
104 | ||
105 | /* | |
106 | * Prototypes... | |
107 | */ | |
108 | ||
109 | # ifdef __cplusplus | |
110 | extern "C" { | |
111 | # endif /* __cplusplus */ | |
112 | ||
113 | extern void _cupsSNMPClose(int fd) _CUPS_API_1_4; | |
114 | extern int *_cupsSNMPCopyOID(int *dst, const int *src, int dstsize) | |
115 | _CUPS_API_1_4; | |
116 | extern const char *_cupsSNMPDefaultCommunity(void) _CUPS_API_1_4; | |
117 | extern int _cupsSNMPIsOID(cups_snmp_t *packet, const int *oid) | |
118 | _CUPS_API_1_4; | |
119 | extern int _cupsSNMPIsOIDPrefixed(cups_snmp_t *packet, | |
120 | const int *prefix) _CUPS_API_1_4; | |
20fbc903 MS |
121 | extern char *_cupsSNMPOIDToString(const int *src, char *dst, |
122 | size_t dstsize) _CUPS_API_1_4; | |
7a14d768 MS |
123 | extern int _cupsSNMPOpen(int family) _CUPS_API_1_4; |
124 | extern cups_snmp_t *_cupsSNMPRead(int fd, cups_snmp_t *packet, | |
125 | double timeout) _CUPS_API_1_4; | |
126 | extern void _cupsSNMPSetDebug(int level) _CUPS_API_1_4; | |
20fbc903 MS |
127 | extern int *_cupsSNMPStringToOID(const char *src, |
128 | int *dst, int dstsize) | |
129 | _CUPS_API_1_4; | |
7a14d768 MS |
130 | extern int _cupsSNMPWalk(int fd, http_addr_t *address, int version, |
131 | const char *community, const int *prefix, | |
132 | double timeout, cups_snmp_cb_t cb, | |
133 | void *data) _CUPS_API_1_4; | |
134 | extern int _cupsSNMPWrite(int fd, http_addr_t *address, int version, | |
135 | const char *community, | |
136 | cups_asn1_t request_type, | |
137 | const unsigned request_id, | |
138 | const int *oid) _CUPS_API_1_4; | |
139 | ||
140 | # ifdef __cplusplus | |
141 | } | |
142 | # endif /* __cplusplus */ | |
143 | #endif /* !_CUPS_SNMP_H_ */ | |
144 | ||
145 | ||
146 | /* | |
147 | * End of "$Id$". | |
148 | */ |