4 * SNMP definitions for the Common UNIX Printing System (CUPS).
6 * Copyright 2007-2008 by Apple Inc.
7 * Copyright 2006-2007 by Easy Software Products, all rights reserved.
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/".
15 * This file is subject to the Apple OS-Developed Software exception.
19 # define _CUPS_SNMP_H_
23 * Include necessary headers.
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 */
44 typedef enum cups_asn1_e
/**** ASN1 request/object types ****/
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_APPLICATION
= 0x40, /* Application-specific bit */
55 CUPS_ASN1_COUNTER
= 0x41, /* 32-bit unsigned aka Counter32 */
56 CUPS_ASN1_GAUGE
= 0x42, /* 32-bit unsigned aka Gauge32 */
57 CUPS_ASN1_GET_REQUEST
= 0xa0, /* GetRequest-PDU */
58 CUPS_ASN1_GET_NEXT_REQUEST
= 0xa1, /* GetNextRequest-PDU */
59 CUPS_ASN1_GET_RESPONSE
= 0xa2 /* GetResponse-PDU */
62 typedef struct cups_snmp_s
/**** SNMP data packet ****/
64 const char *error
; /* Encode/decode error */
65 http_addr_t address
; /* Source address */
66 int version
; /* Version number */
67 char community
[CUPS_SNMP_MAX_STRING
];
69 cups_asn1_t request_type
; /* Request type */
70 int request_id
; /* request-id value */
71 int error_status
; /* error-status value */
72 int error_index
; /* error-index value */
73 int object_name
[CUPS_SNMP_MAX_OID
];
74 /* object-name value */
75 cups_asn1_t object_type
; /* object-value type */
78 int boolean
; /* Boolean value */
79 int integer
; /* Integer value */
80 unsigned counter
; /* Counter value */
81 unsigned gauge
; /* Gauge value */
82 int oid
[CUPS_SNMP_MAX_OID
]; /* OID value */
83 char string
[CUPS_SNMP_MAX_STRING
];/* String value */
84 } object_value
; /* object-value value */
94 # endif /* __cplusplus */
96 extern void cupsSNMPClose(int fd
) _CUPS_API_1_4
;
97 extern int *cupsSNMPCopyOID(int *dst
, const int *src
, int dstsize
)
99 extern int cupsSNMPIsOID(cups_snmp_t
*packet
, const int *oid
)
101 extern int cupsSNMPIsOIDPrefixed(cups_snmp_t
*packet
,
102 const int *prefix
) _CUPS_API_1_4
;
103 extern int cupsSNMPOpen(void) _CUPS_API_1_4
;
104 extern cups_snmp_t
*cupsSNMPRead(int fd
, cups_snmp_t
*packet
, int msec
)
106 extern void cupsSNMPSetDebug(int level
) _CUPS_API_1_4
;
107 extern int cupsSNMPWrite(int fd
, http_addr_t
*addr
, int version
,
108 const char *community
,
109 cups_asn1_t request_type
,
110 const unsigned request_id
,
111 const int *oid
) _CUPS_API_1_4
;
115 # endif /* __cplusplus */
116 #endif /* !_CUPS_SNMP_H_ */