]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/snmp-private.h
Protect against continuing to read from a file at EOF (Issue #5473)
[thirdparty/cups.git] / cups / snmp-private.h
index ae03ca684f932915de7ac7cd5b4b39b381d87529..36130195469367013c83adae5a14cc5f9886325d 100644 (file)
@@ -1,32 +1,22 @@
 /*
- * "$Id$"
+ * Private SNMP definitions for CUPS.
  *
- *   SNMP definitions for the Common UNIX Printing System (CUPS).
+ * Copyright © 2007-2014 by Apple Inc.
+ * Copyright © 2006-2007 by Easy Software Products, all rights reserved.
  *
- *   This API is PRIVATE and subject to change.  No third-party applications
- *   should use the SNMP API defined in this file.
- *
- *   Copyright 2007-2008 by Apple Inc.
- *   Copyright 2006-2007 by Easy Software Products, all rights reserved.
- *
- *   These coded instructions, statements, and computer programs are the
- *   property of Apple Inc. and are protected by Federal copyright
- *   law.  Distribution and use rights are outlined in the file "LICENSE.txt"
- *   "LICENSE" which should have been included with this file.  If this
- *   file is missing or damaged, see the license at "http://www.cups.org/".
- *
- *   This file is subject to the Apple OS-Developed Software exception.
+ * Licensed under Apache License v2.0.  See the file "LICENSE" for more
+ * information.
  */
 
-#ifndef _CUPS_SNMP_H_
-#  define _CUPS_SNMP_H_
+#ifndef _CUPS_SNMP_PRIVATE_H_
+#  define _CUPS_SNMP_PRIVATE_H_
 
 
 /*
  * Include necessary headers.
  */
 
-#include "http.h"
+#include <cups/http.h>
 
 
 /*
  */
 
 #define CUPS_SNMP_PORT         161     /* SNMP well-known port */
+#define CUPS_SNMP_MAX_COMMUNITY        512     /* Maximum size of community name */
 #define CUPS_SNMP_MAX_OID      128     /* Maximum number of OID numbers */
 #define CUPS_SNMP_MAX_PACKET   1472    /* Maximum size of SNMP packet */
-#define CUPS_SNMP_MAX_STRING   512     /* Maximum size of string */
+#define CUPS_SNMP_MAX_STRING   1024    /* Maximum size of string */
 #define CUPS_SNMP_VERSION_1    0       /* SNMPv1 */
 
 
@@ -64,25 +55,22 @@ enum cups_asn1_e                    /**** ASN1 request/object types ****/
 };
 typedef enum cups_asn1_e cups_asn1_t;  /**** ASN1 request/object types ****/
 
-struct cups_snmp_hexstring_s           /**** Hex-STRING value ****/
+typedef struct cups_snmp_string_s      /**** String value ****/
 {
   unsigned char        bytes[CUPS_SNMP_MAX_STRING];
                                        /* Bytes in string */
-  int          num_bytes;              /* Number of bytes */
-};
+  unsigned     num_bytes;              /* Number of bytes */
+} cups_snmp_string_t;
 
 union cups_snmp_value_u                        /**** Object value ****/
 {
   int          boolean;                /* Boolean value */
   int          integer;                /* Integer value */
-  unsigned     counter;                /* Counter value */
+  int          counter;                /* Counter value */
   unsigned     gauge;                  /* Gauge value */
   unsigned     timeticks;              /* Timeticks  value */
   int          oid[CUPS_SNMP_MAX_OID]; /* OID value */
-  char         string[CUPS_SNMP_MAX_STRING];
-                                       /* String value */
-  struct cups_snmp_hexstring_s hex_string;
-                                       /* Hex string value */
+  cups_snmp_string_t string;           /* String value */
 };
 
 typedef struct cups_snmp_s             /**** SNMP data packet ****/
@@ -90,10 +78,10 @@ typedef struct cups_snmp_s          /**** SNMP data packet ****/
   const char   *error;                 /* Encode/decode error */
   http_addr_t  address;                /* Source address */
   int          version;                /* Version number */
-  char         community[CUPS_SNMP_MAX_STRING];
+  char         community[CUPS_SNMP_MAX_COMMUNITY];
                                        /* Community name */
   cups_asn1_t  request_type;           /* Request type */
-  int          request_id;             /* request-id value */
+  unsigned     request_id;             /* request-id value */
   int          error_status;           /* error-status value */
   int          error_index;            /* error-index value */
   int          object_name[CUPS_SNMP_MAX_OID];
@@ -113,34 +101,34 @@ typedef void (*cups_snmp_cb_t)(cups_snmp_t *packet, void *data);
 extern "C" {
 #  endif /* __cplusplus */
 
-extern void            _cupsSNMPClose(int fd) _CUPS_API_1_4;
+extern void            _cupsSNMPClose(int fd) _CUPS_PRIVATE;
 extern int             *_cupsSNMPCopyOID(int *dst, const int *src, int dstsize)
-                           _CUPS_API_1_4;
-extern const char      *_cupsSNMPDefaultCommunity(void) _CUPS_API_1_4;
+                           _CUPS_PRIVATE;
+extern const char      *_cupsSNMPDefaultCommunity(void) _CUPS_PRIVATE;
 extern int             _cupsSNMPIsOID(cups_snmp_t *packet, const int *oid)
-                           _CUPS_API_1_4;
+                           _CUPS_PRIVATE;
 extern int             _cupsSNMPIsOIDPrefixed(cups_snmp_t *packet,
-                                             const int *prefix) _CUPS_API_1_4;
-extern int             _cupsSNMPOpen(int family) _CUPS_API_1_4;
+                                             const int *prefix) _CUPS_PRIVATE;
+extern char            *_cupsSNMPOIDToString(const int *src, char *dst,
+                                             size_t dstsize) _CUPS_PRIVATE;
+extern int             _cupsSNMPOpen(int family) _CUPS_PRIVATE;
 extern cups_snmp_t     *_cupsSNMPRead(int fd, cups_snmp_t *packet,
-                                      double timeout) _CUPS_API_1_4;
-extern void            _cupsSNMPSetDebug(int level) _CUPS_API_1_4;
+                                      double timeout) _CUPS_PRIVATE;
+extern void            _cupsSNMPSetDebug(int level) _CUPS_PRIVATE;
+extern int             *_cupsSNMPStringToOID(const char *src,
+                                             int *dst, int dstsize)
+                                             _CUPS_PRIVATE;
 extern int             _cupsSNMPWalk(int fd, http_addr_t *address, int version,
                                      const char *community, const int *prefix,
                                      double timeout, cups_snmp_cb_t cb,
-                                     void *data) _CUPS_API_1_4;
+                                     void *data) _CUPS_PRIVATE;
 extern int             _cupsSNMPWrite(int fd, http_addr_t *address, int version,
                                       const char *community,
                                       cups_asn1_t request_type,
                                       const unsigned request_id,
-                                      const int *oid) _CUPS_API_1_4;
+                                      const int *oid) _CUPS_PRIVATE;
 
 #  ifdef __cplusplus
 }
 #  endif /* __cplusplus */
-#endif /* !_CUPS_SNMP_H_ */
-
-
-/*
- * End of "$Id$".
- */
+#endif /* !_CUPS_SNMP_PRIVATE_H_ */