PERFORCE change 82338 for review

Victor Cruceru soc-victor at FreeBSD.org
Sat Aug 20 21:28:26 GMT 2005


http://perforce.freebsd.org/chv.cgi?CH=82338

Change 82338 by soc-victor at soc-victor_82.76.158.176 on 2005/08/20 21:28:04

	Step #1 instrumenting hrPrinterTable: "borrowed" some code form /usr/src/usr.sbin/lpr.
	A lot of cleanup needed.

Affected files ...

.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile#21 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_printer_tbl.c#1 add
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c#20 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.h#24 edit

Differences ...

==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/Makefile#21 (text+ko) ====

@@ -37,9 +37,10 @@
 	hostres_diskstorage_tbl.c \
 	hostres_partition_tbl.c \
 	hostres_network_tbl.c \
-	hostres_swinstalled_tbl.c 	
+	hostres_swinstalled_tbl.c \
+	hostres_printer_tbl.c	
 	
-WARNS?=	6
+WARNS?=	3
 #Not having NDEBUG defined will enable assertions and a lot of output on stderr
 CFLAGS+=	-DNDEBUG
 XSYM=	host hrStorageOther hrStorageRam hrStorageVirtualMemory \

==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c#20 (text+ko) ====

@@ -216,7 +216,13 @@
 	hrState_g.hrSWInstalled_tbl_age = 0;
 	hrState_g.os_pkg_last_change = 0;
 	hrState_g.hr_sw_installed_full_upd_tick = 0;
-		
+	
+	
+	/*data structures initialization for hrPrinterTable*/			
+	TAILQ_INIT(&hrState_g.hr_printer_tbl);
+	hrState_g._printcapdb = NULL;
+	
+			
 	hrState_g.hr_storage_tick = 0;
 	hrState_g.hr_fs_tick = 0;
 	hrState_g.hr_swrun_tick = 0;
@@ -225,6 +231,7 @@
 	hrState_g.hr_disk_storage_tick = 0;
 	hrState_g.hr_partition_tick = 0;
 	hrState_g.hr_network_tick = 0;
+	hrState_g.hr_printer_tick = 0;
 	
 	hrState_g.hrStorage_tbl_age = 0;		
 	hrState_g.hrFS_tbl_age = 0;		
@@ -232,7 +239,8 @@
 	hrState_g.hrDevice_tbl_age = 0;	
 	hrState_g.hrDiskStorage_age = 0;	
 	hrState_g.hrPartition_tbl_age = 0;		
-	hrState_g.hrNetwork_tbl_age = 0;		
+	hrState_g.hrNetwork_tbl_age = 0;	
+	hrState_g.hrPrinter_tbl_age = 0;	
 	
 	init_hrStorage_tbl_v();
 	init_hrFS_tbl_v();
@@ -246,6 +254,7 @@
         init_hrNetwork_tbl_v();	
 
         init_hrSWInstalled_tbl_v();	
+        init_hrPrinter_tbl_v();	
 
 	if ((hrState_g.devd_sock = create_devd_socket()) < 0) {
 		HR_DPRINTF((stderr, "Failed to create the socket to devd pipe.\n"));			
@@ -320,6 +329,7 @@
 	fini_hrPartition_tbl_v();
 	fini_hrNetwork_tbl_v();
 	fini_hrSWInstalled_tbl_v();
+	fini_hrPrinter_tbl_v();
 
 	hrState_g.hr_storage_tick = 0;
 	hrState_g.hr_fs_tick = 0;
@@ -375,36 +385,7 @@
 	return (0);
 }
 
-/*
-HOST RESOURCES mib module idle function
-returns nothing
-*/
-static
-void hostres_idle_v(void) {
-#if 0
-	if ( (time(NULL) - hrState_g.hrStorage_tbl_age) > HR_STORAGE_TBL_REFRESH ) {
-		HR_DPRINTF((stderr, "%s: hrStorageTable needs refresh\n ", __func__));
-		refresh_hrStorage_tbl_v();
-	}
-
-	if ( (time(NULL) - hrState_g.hrFS_tbl_age) > HR_FS_TBL_REFRESH ) {
-		HR_DPRINTF((stderr, "%s: hrFSTable needs refresh\n ", __func__));
-		refresh_hrFS_tbl_v();
-	}
-	if ( (time(NULL) - hrState_g.hrSWRun_tbl_age) > HR_SWRUN_TBL_REFRESH ) {
-		HR_DPRINTF((stderr, "%s: hrSWRunTable needs refresh\n ", __func__));
-		refresh_hrSWRun_tbl_v();
-	}
-	
-	if ( (time(NULL) - hrState_g.hrDevice_tbl_age) > HR_DEVICE_TBL_REFRESH ) {
-		HR_DPRINTF((stderr, "%s: hrDeviceTable needs refresh\n ", __func__));
-		refresh_hrDevice_tbl_v();
-	}
-
 
-        HR_DPRINTF((stderr, "[%s] done.\n ", __func__));		
-#endif	
-}
 
 /*
 HOST RESOURCES mib module dump function
@@ -475,7 +456,7 @@
 	"This module implements the host resource mib (rfc 2790)",
 	hostres_init,
 	hostres_fini,
-	hostres_idle_v,		
+	NULL,			/*idle function, do not use it*/
 	hostres_dump_v,		
 	hostres_config_v,		
 	hostres_start_v,
@@ -486,23 +467,6 @@
 };
 
 
-/*
-Next items are not implemented yet. 
-Once one of them is implemented it will be moved into its own C file
-*/
-
-
-
-
-int op_hrPrinterTable(struct snmp_context *ctx __unused, 
-                struct snmp_value *value __unused, 
-		u_int sub __unused, 
-		u_int iidx __unused, 
-		enum snmp_op curr_op __unused)
-{
-	return  (SNMP_ERR_NOSUCHNAME);
-}
-
 
 
 

==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.h#24 (text+ko) ====

@@ -294,15 +294,7 @@
 STAILQ_HEAD(partition_map_list, PartitionNameMapEntry);
 
 
-enum DeviceStatus {
-	DS_UNKNOWN	=	1,
-	DR_RUNNING	=	2,
-	DS_WARNING	=	3,
-	DS_TESTING	=	4,
-	DS_DOWN		=	5		
-};
 
-
 /*
  * This structure is used to hold a SNMP table entry
  * for HOST-RESOURCES-MIB's hrNetworkTable
@@ -321,6 +313,37 @@
 
 /*
  * This structure is used to hold a SNMP table entry
+ * for HOST-RESOURCES-MIB's hrPrinterTable
+ */
+
+struct hrPrinterTblEntry {
+	int32_t		index;
+	int32_t		status;
+	u_char		detectedErrorState[2];
+	TAILQ_ENTRY(hrPrinterTblEntry) link;		
+#define HR_PRINTER_FOUND		0x001	
+	uint32_t	flags;
+	
+};
+TAILQ_HEAD(printer_tbl, hrPrinterTblEntry);
+
+
+
+
+
+enum DeviceStatus {
+	DS_UNKNOWN	=	1,
+	DR_RUNNING	=	2,
+	DS_WARNING	=	3,
+	DS_TESTING	=	4,
+	DS_DOWN		=	5		
+};
+
+
+
+
+/*
+ * This structure is used to hold a SNMP table entry
  * for HOST-RESOURCES-MIB's hrDeviceTable
  */
 struct hrDeviceTblEntry {
@@ -513,7 +536,7 @@
 	partition_tbl	hr_partition_tbl;	/*the head of the list with hrPatitionTable's entries */	
 	uint32_t 	next_hrPartition_index;	/*next int available for indexing the hrPartitionTable*/
 	time_t		hrPartition_tbl_age; 
-	uint64_t 	hr_partition_tick;	/*last (agent) tick when hrDeviceTable was updated */
+	uint64_t 	hr_partition_tick;	/*last (agent) tick when hrPartitionTable was updated */
 	
 	/* 
 	 * next items are used for hrNetworksTable 
@@ -522,7 +545,7 @@
 	struct 
 	network_tbl	hr_network_tbl;		/*the head of the list with hrNetworkTable's entries */	
 	time_t		hrNetwork_tbl_age; 
-	uint64_t 	hr_network_tick;	/*last (agent) tick when hrDeviceTable was updated */
+	uint64_t 	hr_network_tick;	/*last (agent) tick when hrNetworkTable was updated */
 
 	/* 
 	 * next items are used for hrSWInstalledTable 
@@ -539,7 +562,17 @@
 
 	time_t		hrSWInstalled_tbl_age; 
 	time_t		os_pkg_last_change;
-				
+
+	/* 
+	 * next items are used for hrSWInstalledTable 
+	 */
+
+	struct 
+	printer_tbl	hr_printer_tbl;		/*the head of the list with hrPrinterTable's entries */	
+	time_t		hrPrinter_tbl_age; 
+	uint64_t 	hr_printer_tick;	/*last (agent) tick when hrPrinterTable was updated */
+	char **		_printcapdb;
+					
 };
 
 /*
@@ -772,5 +805,22 @@
 
 void refresh_hrSWInstalled_tbl_v(void);
 
+
+/*
+ * Init the things for hrPrinterTable 
+ */
+void init_hrPrinter_tbl_v(void);
+
+/*
+ * Finalization routine for hrPrinterTable
+ * It destroys the lists and frees any allocated heap memory
+ */
+void fini_hrPrinter_tbl_v(void);
+
+#define HR_PRINTER_TBL_REFRESH	7
+
+void refresh_hrPrinter_tbl_v(void);
+
+
 #endif /*__HOSTRES_SNMP_H_INCLUDED__ */
 


More information about the p4-projects mailing list