📄 setup.c
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/unxagent/sun/setup.c,v 1.2 2001/11/09 21:49:03 josh Exp $ *//* * Copyright (C) 1999-2005 Wind River Systems, Inc. * All rights reserved. Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. *//**************************************************************************** * Copyright 1988-1997 Epilogue Technology Corporation. * Copyright 1998 Integrated Systems, Inc. * All rights reserved. ****************************************************************************//* * $Log: setup.c,v $ * Revision 1.2 2001/11/09 21:49:03 josh * unxagent demo path adjustment, first pass * * Revision 1.1.1.1 2001/11/05 17:49:17 tneale * Tornado shuffle * * Revision 7.9 2001/01/19 22:25:03 paul * Update copyright. * * Revision 7.8 2000/07/10 15:55:17 mrf * Add configuration for Cygnus NT environment with associated changes. * * Revision 7.7 2000/03/17 00:15:32 meister * Update copyright message * * Revision 7.6 1998/06/23 22:07:31 sar * Add some include files to keep compilers happy * * Revision 7.5 1998/06/03 22:07:20 sar * Update code to use common string macros * Modify the init of sysuptime so we count time from when the * agent started instead of when the system started * * Revision 7.4 1998/02/25 04:58:23 sra * Update copyrights. * * Revision 7.3 1997/03/20 06:54:14 sra * DFARS-safe copyright text. Zap! * * Revision 7.2 1997/02/25 10:58:16 sra * Update copyright notice, dust under the bed. * * Revision 7.1 1997/01/08 23:01:49 sar * Updated copyright and modified include files to use envoy/h as * appropriate * * Revision 7.0 1996/03/15 22:07:57 sar * Updated revision to 7.0 and copyright to 96 * * Revision 6.1 1995/11/01 01:03:00 sar * removed casts of 0 and added pp style argument lists * * Revision 6.0 1995/05/31 21:49:49 sra * Release 6.0. * * Revision 5.0 1994/05/16 16:20:43 sar * Updated revision to 5.0 and copyright to include 1994 * * Revision 4.0 1993/06/24 17:34:02 sar * Updated rev to 4.0 copyright to 93 * * Revision 3.3 1993/06/13 02:53:35 sar * Removed sysent.h and libc.h and moved them into envoy.h * for mach386. * * Revision 3.2 1993/05/19 20:19:44 sar * name_to_long could have reached the end of a non void function. * * Revision 3.1 1993/05/13 22:20:00 sar * Added defines, includes (<sysent.h>, <errno.h>, <libc.h>) and casts * (struct sockaddr *) as well as changed memfoo to MEMFOO and objidcmp * to llist_cmp to get rid of warnings. * * Revision 3.0 1992/04/03 19:53:44 dab * Release 3.0 * * Revision 2.101 92/02/04 10:47:30 dab * Updated for release 3.0 of SNMP. * * Revision 2.100 92/02/03 16:46:16 dab * Generic unix SNMP agent. * * * Rev 2.1 09 Apr 1990 14:22:40 * Made the compilation of strnicmp() depend on the STRNICMP preprocessor * symbol. * * Rev 2.0 31 Mar 1990 15:34:14 * Initial revision. * *//* [clearcase]modification history-------------------01a,19apr05,job update copyright notices*/#include <sys/types.h>#include <wrn/wm/snmp/engine/snmp.h>#include <wrn/wm/snmp/engine/buildpkt.h>#include <wrn/wm/snmp/engine/auxfuncs.h>#include "snmpvars.h"#include <sys/types.h>#include <sys/socket.h>#include <sys/time.h>#include <netinet/in.h>#include <net/if.h>#if !INSTALL_on_ntgcc#include <netinet/if_ether.h>#endif#include <errno.h>#include <unistd.h>#include <arpa/inet.h>#include <netdb.h>#include <ctype.h>#include "../agent.h"#include "general.h"extern int errno;/**********************************************************************//* *//* Initialize the relatively static parts of the MIB *//* *//**********************************************************************/int setup_mib(){struct hostent *host;if (trace_level > 0) printf("Initializing MIB...\n");/* get the current time */(void) gettimeofday(&boot_at, 0);/* Get a local IP address */ (void)gethostname(snmp_sysName, MAX_SYSNAME);if ((host = gethostbyname(snmp_sysName)) == 0) { printf("Can not obain local IP address -- is \"%s\" in \"/etc/hosts\"?\n", snmp_sysName); exit(1); } { u_long tlong; tlong = ntohl(*(u_long *)(host->h_addr)); MEMCPY(snmp_local_ip_address, &tlong, 4); }return 0;}int name_to_ulong(char *tname, u_long *tlong){struct hostent *host;if (isdigit(*tname)) *tlong = (u_long)inet_addr(tname);else { if ((host = gethostbyname(tname)) == 0) return -1; *tlong = *(u_long *)(host->h_addr); }return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -