hostres_scalars.c (302408) | hostres_scalars.c (310899) |
---|---|
1/*- 2 * Copyright (c) 2005-2006 The FreeBSD Project 3 * All rights reserved. 4 * 5 * Author: Victor Cruceru <soc-victor@freebsd.org> 6 * 7 * Redistribution of this software and documentation and use in source and 8 * binary forms, with or without modification, are permitted provided that --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/*- 2 * Copyright (c) 2005-2006 The FreeBSD Project 3 * All rights reserved. 4 * 5 * Author: Victor Cruceru <soc-victor@freebsd.org> 6 * 7 * Redistribution of this software and documentation and use in source and 8 * binary forms, with or without modification, are permitted provided that --- 12 unchanged lines hidden (view full) --- 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: stable/11/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c 240354 2012-09-11 08:33:16Z glebius $ | 29 * $FreeBSD: stable/11/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_scalars.c 310899 2016-12-31 10:28:59Z ngie $ |
30 */ 31 32/* 33 * Host Resources MIB scalars implementation for SNMPd. 34 */ 35 36#include <sys/types.h> 37#include <sys/sysctl.h> --- 150 unchanged lines hidden (view full) --- 188 "sysctl({CTL_KERN,KERN_BOOTFILE}) failed: %m"); 189 return (SNMP_ERR_GENERR); 190 } 191 192 if ((buf = malloc(buf_len)) == NULL) { 193 syslog(LOG_ERR, "malloc failed"); 194 return (SNMP_ERR_GENERR); 195 } | 30 */ 31 32/* 33 * Host Resources MIB scalars implementation for SNMPd. 34 */ 35 36#include <sys/types.h> 37#include <sys/sysctl.h> --- 150 unchanged lines hidden (view full) --- 188 "sysctl({CTL_KERN,KERN_BOOTFILE}) failed: %m"); 189 return (SNMP_ERR_GENERR); 190 } 191 192 if ((buf = malloc(buf_len)) == NULL) { 193 syslog(LOG_ERR, "malloc failed"); 194 return (SNMP_ERR_GENERR); 195 } |
196 if (sysctl(mib, 2, buf, &buf_len, NULL, 0)) { | 196 if (sysctl(mib, 2, buf, &buf_len, NULL, 0)) { |
197 syslog(LOG_ERR, 198 "sysctl({CTL_KERN,KERN_BOOTFILE}) failed: %m"); 199 free(buf); 200 return (SNMP_ERR_GENERR); 201 } 202 203 boot_line = buf; 204 HRDBG("kernel boot file: %s", boot_line); --- 86 unchanged lines hidden (view full) --- 291 292 phys_mem_size = physmem / 1024; 293 } 294 295 if (phys_mem_size > UINT32_MAX) 296 *ms = UINT32_MAX; 297 else 298 *ms = phys_mem_size; | 197 syslog(LOG_ERR, 198 "sysctl({CTL_KERN,KERN_BOOTFILE}) failed: %m"); 199 free(buf); 200 return (SNMP_ERR_GENERR); 201 } 202 203 boot_line = buf; 204 HRDBG("kernel boot file: %s", boot_line); --- 86 unchanged lines hidden (view full) --- 291 292 phys_mem_size = physmem / 1024; 293 } 294 295 if (phys_mem_size > UINT32_MAX) 296 *ms = UINT32_MAX; 297 else 298 *ms = phys_mem_size; |
299 return (SNMP_ERR_NOERROR); | 299 return (SNMP_ERR_NOERROR); |
300} 301 302/* 303 * Try to use the s_date_time parameter as a DateAndTime TC to fill in 304 * the second parameter. 305 * Returns 0 on succes and -1 for an error. 306 * Bug: time zone info is not used 307 */ --- 47 unchanged lines hidden (view full) --- 355 * Set system date and time. Timezone is not changed 356 */ 357static int 358OS_setSystemDate(const struct timeval *timeval_to_set) 359{ 360 if (settimeofday(timeval_to_set, NULL) == -1) { 361 syslog(LOG_ERR, "settimeofday failed: %m"); 362 return (SNMP_ERR_GENERR); | 300} 301 302/* 303 * Try to use the s_date_time parameter as a DateAndTime TC to fill in 304 * the second parameter. 305 * Returns 0 on succes and -1 for an error. 306 * Bug: time zone info is not used 307 */ --- 47 unchanged lines hidden (view full) --- 355 * Set system date and time. Timezone is not changed 356 */ 357static int 358OS_setSystemDate(const struct timeval *timeval_to_set) 359{ 360 if (settimeofday(timeval_to_set, NULL) == -1) { 361 syslog(LOG_ERR, "settimeofday failed: %m"); 362 return (SNMP_ERR_GENERR); |
363 } | 363 } |
364 return (SNMP_ERR_NOERROR); 365} 366 367/* 368 * prototype of this function was genrated by gensnmptree tool in header file 369 * hostres_tree.h 370 * Returns SNMP_ERR_NOERROR on success 371 */ 372int 373op_hrSystem(struct snmp_context *ctx, struct snmp_value *value, 374 u_int sub, u_int iidx __unused, enum snmp_op curr_op) 375{ 376 int err; 377 u_char *str; 378 379 switch (curr_op) { 380 | 364 return (SNMP_ERR_NOERROR); 365} 366 367/* 368 * prototype of this function was genrated by gensnmptree tool in header file 369 * hostres_tree.h 370 * Returns SNMP_ERR_NOERROR on success 371 */ 372int 373op_hrSystem(struct snmp_context *ctx, struct snmp_value *value, 374 u_int sub, u_int iidx __unused, enum snmp_op curr_op) 375{ 376 int err; 377 u_char *str; 378 379 switch (curr_op) { 380 |
381 case SNMP_OP_GET: | 381 case SNMP_OP_GET: |
382 switch (value->var.subs[sub - 1]) { 383 384 case LEAF_hrSystemUptime: 385 return (OS_getSystemUptime(&value->v.uint32)); 386 387 case LEAF_hrSystemDate: 388 return (OS_getSystemDate(value)); 389 --- 103 unchanged lines hidden --- | 382 switch (value->var.subs[sub - 1]) { 383 384 case LEAF_hrSystemUptime: 385 return (OS_getSystemUptime(&value->v.uint32)); 386 387 case LEAF_hrSystemDate: 388 return (OS_getSystemDate(value)); 389 --- 103 unchanged lines hidden --- |