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