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