# HG changeset patch # User Garrett D'Amore # Date 1290103739 28800 # Node ID 259bb55df8a90fba20c6757f98e56075fce9de47 # Parent 35f707bf8b405d607fbd7fc6566498960a811807 368 snmpdx is obsolete and neesd to go Reviewed by: gwr@nexenta.com Reviewed by: rbg@openrbg.com Approved by: richlowe@richlowe.net diff -r 35f707bf8b40 -r 259bb55df8a9 exception_lists/closed-bins --- a/exception_lists/closed-bins Mon Nov 15 20:03:27 2010 -0800 +++ b/exception_lists/closed-bins Thu Nov 18 10:08:59 2010 -0800 @@ -1,15 +1,33 @@ +./etc/certs ./etc/init.d/llc2 +./etc/rc1.d ./etc/rc1.d/K52llc2 +./etc/rc0.d ./etc/rc0.d/K52llc2 +./etc/rcS.d ./etc/rcS.d/K52llc2 ./etc/llc2 ./etc/llc2/llc2_start.default ./etc/rc2.d/S40llc2 +./etc/snmp +./etc/snmp/conf +./etc/snmp/conf/mibiisa.reg +./etc/snmp/conf/snmp.conf +./lib/crypto ./lib/crypto/kcfd ./lib/libc_i18n.a ./lib/amd64/libc_i18n.a ./lib/sparcv9/libc_i18n.a +./usr/has +./usr/has/bin ./usr/has/bin/patch +./usr/kernel +./usr/kernel/strmod +./usr/kernel/strmod/amd64 +./usr/kernel/strmod/sparcv9 +./usr/kernel/drv +./usr/kenrel/drv/amd64 +./usr/kenrel/drv/sparcv9 ./usr/kernel/drv/amd64/llc2 ./usr/kernel/drv/sparcv9/llc2 ./usr/kernel/drv/llc2.conf @@ -37,12 +55,16 @@ ./usr/lib/localedef/src/iso_8859_1/charmap.src ./usr/lib/localedef/src/iso_8859_1/extension.src ./usr/lib/localedef/src/iso_8859_1/localedef.src +./usr/lib/snmp +./usr/lib/snmp/mibiisa ./usr/bin/kbdcomp ./usr/bin/localedef ./usr/bin/od ./usr/bin/printf ./usr/bin/tr ./usr/bin/tail +./usr/platform/i86pc +./usr/platform/i86pc/lib ./usr/xpg4/bin/alias ./usr/xpg4/bin/bg ./usr/xpg4/bin/cd @@ -64,4 +86,10 @@ ./usr/xpg4/bin/umask ./usr/xpg4/bin/unalias ./usr/xpg4/bin/wait +./usr/xpg6 +./usr/xpg6/bin ./usr/xpg6/bin/tr +./var +./var/snmp +./var/snmp/mib +./var/snmp/mib/sun.mib diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/Makefile --- a/usr/src/cmd/Makefile Mon Nov 15 20:03:27 2010 -0800 +++ b/usr/src/cmd/Makefile Thu Nov 18 10:08:59 2010 -0800 @@ -45,7 +45,6 @@ platexec COMMON_SUBDIRS= \ - agents \ allocate \ availdevs \ lp \ diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/Makefile.check --- a/usr/src/cmd/Makefile.check Mon Nov 15 20:03:27 2010 -0800 +++ b/usr/src/cmd/Makefile.check Thu Nov 18 10:08:59 2010 -0800 @@ -77,7 +77,6 @@ zoneadmd MANIFEST_SUBDIRS= \ - agents/snmp/snmprelayd \ boot/scripts \ cmd-crypto/scripts \ cmd-inet/usr.lib/ilbd \ diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/Makefile --- a/usr/src/cmd/agents/Makefile Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,119 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# - -# cmd/agents/Makefile - -######################################################### -# -# Makefile for the Solstice Enterprise Agent -# -# Targets: -# all - compile everything -# install - create installation directories and copy files -# package - create packages in installation directory -# clean - remove all intermediate files -# clobber - make clean plus removing deliverable files -# lint - run lint on the source files -# -######################################################### - -# OPTIONAL_INCLUDE_FILE:sh = /bin/sh misc.sh ../Makefile.cmd -# include $(OPTIONAL_INCLUDE_FILE) - -include $(SRC)/cmd/Makefile.cmd - -# Use $TARG_SYS for OS dependent variables -# -# TARG_SYS gets defined as SVR4 or SUNOS -# -TARG_SYS:sh = \ - ( \ - UNAME=` uname -r 2>/dev/null` ||.; \ - case $UNAME in \ - '') echo SUNOS;; \ - 4.*) echo SUNOS;; \ - 5.*) echo SVR4;; \ - A.09.*) echo HPUX9;; \ - *) echo SVR4;; \ - esac \ - ) - -ROOTDIR : sh=echo ${ROOTDIR:-"`pwd`"} -PKGLOC : sh=echo ${PKGLOC:-'${ROOTDIR}/PACKAGES.`uname -p`'} - -$(CLOSED_BUILD)AGENTS= $(CLOSED)/cmd/agents/agents - -all := TARGET = all -clean := TARGET = clean -install := TARGET = install -lint := TARGET = lint -clobber := TARGET = clobber - -SUBDIRS = snmp $(AGENTS) - -# -# all -# - -all: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: - -DIRMODE= 0755 -ROOTVAR= $(ROOT)/var - -ROOTDIRS= $(ROOTETC)/snmp \ - $(ROOTETC)/snmp/conf \ - $(ROOTLIB)/snmp \ - $(ROOTBIN) \ - $(ROOTVAR)/snmp \ - $(ROOTVAR)/snmp/mib - -$(ROOTDIRS): - $(INS.dir) - -# -# Need a "make install" target for integrating into Solaris 2.6. -# - -install: $(ROOTDIRS) $(SUBDIRS) - -# -# clean -# - -clean: $(SUBDIRS) - -clobber: $(SUBDIRS) - -# Need a lint target for Solaris2.6 integration. - -lint: $(SUBDIRS) - -include $(SRC)/cmd/Makefile.targ diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/Makefile.vars --- a/usr/src/cmd/agents/Makefile.vars Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright 1998 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. - -#ident "%Z%%M% %I% %E% SMI" - -BIN = bin$(TARGET_ARCH) -LDFLAGS += -g $(LDLIBS) - -# -# Compiler selection -# -TARG_SYS:sh = \ - ( \ - UNAME=` uname -r 2>/dev/null` ||.; \ - case $UNAME in \ - '') echo SUNOS;; \ - 4.*) echo SUNOS;; \ - 5.*) PNAME=`uname -p 2>/dev/null` ||.; \ - case $PNAME in \ - '') echo SVR4;; \ - i386) echo INTEL;; \ - *) echo SVR4;; \ - esac;; \ - *) echo SVR4;; \ - esac \ - ) - -CCC += -norunpath -nolib - -SVR4_STRIP= /usr/ccs/bin/strip -INTEL_STRIP= /usr/ccs/bin/strip -SUNOS_STRIP=/bin/strip -_STRIP=$(SVR4_STRIP) -STRIP=$($(TARG_SYS)_STRIP) - -SVR4_SNMHOME=/opt/SUNWconn/snm -INTEL_SNMHOME= -SUNOS_SNMHOME=/usr/snm -_SNMHOME=$(SVR4_SNMHOME) -SNMHOME=$($(TARG_SYS)_SNMHOME) - -# -# Misc Tools -# - -TEST = test - diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/include/netmgt/netmgt_release.h --- a/usr/src/cmd/agents/include/netmgt/netmgt_release.h Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2000 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#if !defined(lint) && !defined(NOID) -#ifdef SVR4 -#pragma ident "%Z%%M% %I% %E% SMI" -#endif -#endif - -#ifndef lint -#ifndef _release_h -#define _release_h - -static char product_name[]="Product:Site/Domain/SunNet Manager" ; -#ifdef SVR4 -#ifdef i386 -static char release[]="Release:2.3 FCS - Solaris X86" ; -#else -static char release[]="Release:2.3 FCS - Solaris 2" ; -#endif -#else -static char release[]="Release:2.3 FCS - Solaris 1" ; -#endif -#endif /* _release_h */ -#endif /* lint */ diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/include/netmgt/sea_i18n.h --- a/usr/src/cmd/agents/include/netmgt/sea_i18n.h Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ - -/* Copyright 1996 Sun Microsystems, Inc. All Rights Reserved. */ - - -#ifndef sea_1_0_i18n_h -#define sea_1_0_i18n_h - - -#include -#include -#include - -#define SEA_LOCALE_PATH "/opt/SUNWconn/snm/lib/locale" - -#define DOMAIN_LGET "SUNW_SEA_LABELS" -#define DOMAIN_MGET "SUNW_SEA_MESSAGES" -#define DOMAIN_SGET "SUNW_SEA_SCHEMAS" -#define DOMAIN_LIBGET "SUNW_SEA_LIBRARIES" -#define DOMAIN_FGET "SUNW_SEA_FORMATS" - - -#define LGET(s) (char *) dgettext(DOMAIN_LGET, s) -#define MGET(s) (char *) dgettext(DOMAIN_MGET, s) -#define MGET(s) (char *) dgettext(DOMAIN_MGET, s) -#define SGET(s) (char *) dgettext(DOMAIN_SGET, s) -#define LIBGET(s) (char *) dgettext(DOMAIN_LIBGET, s) -#define FGET(s) (char *) dgettext(DOMAIN_FGET, s) - - -#define I18N_KEY 628323 - -#endif /* sea_1_0_i18n_h*/ - diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/Makefile --- a/usr/src/cmd/agents/snmp/Makefile Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -#ident "%Z%%M% %I% %E% SMI" - -SUBDIRS= snmplib \ - agent \ - parser \ - snmprelayd \ - trapsend \ - mib - - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint - -all install clean clobber lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: - diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/THIRDPARTYLICENSE --- a/usr/src/cmd/agents/snmp/THIRDPARTYLICENSE Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ - Copyright 1988, 1989, 1991, 1992 by Carnegie Mellon University - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of CMU not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/THIRDPARTYLICENSE.descrip --- a/usr/src/cmd/agents/snmp/THIRDPARTYLICENSE.descrip Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -PORTIONS OF SNMP FUNCTIONALITY diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/Makefile --- a/usr/src/cmd/agents/snmp/agent/Makefile Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright 1998 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include $(SRC)/cmd/Makefile.cmd - -SUBDIRS= $(MACH) -$(BUILD64)SUBDIRS += $(MACH64) - -all := TARGET= all -install := TARGET= install -clean := TARGET= clean -clobber := TARGET= clobber -lint := TARGET= lint -install_h := TARGET= install_h - -all install clean clobber lint: $(SUBDIRS) - -$(SUBDIRS): FRC - @cd $@; pwd; $(MAKE) $(TARGET) - -FRC: diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/Makefile.com --- a/usr/src/cmd/agents/snmp/agent/Makefile.com Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -LIBRARY = libssagent.a -VERS = .1 -SRCOBJS = node.o access.o agent.o snmpd.o pagent.o subtree.o reg_subtree.o -OBJECTS = $(SRCOBJS) personal.o - -include $(SRC)/lib/Makefile.lib - -LIBS = $(DYNLIB) $(LINTLIB) -SRCS = $(SRCOBJS:%.o=$(SRCDIR)/%.c) personal.c - -$(LINTLIB):= SRCS = $(SRCDIR)/$(LINTSRC) -LDLIBS += -lssasnmp -lc -lsocket -lnsl - -CLEANFILES += personal.c personal.lex.c - -MAPFILES = ../agent-mapfile-vers - -CPPFLAGS = -I. -I.. -I../../snmplib $(CPPFLAGS.master) -LINTFLAGS64 += -errchk=longptr64 -# -# This library has references to hooks that are defined by the programs -# that link with it; need to turn off -zdefs. -# -ZDEFS = - -.KEEP_STATE: - -all: $(LIBS) - -personal.c: ../personal.y - $(YACC.y) ../personal.y - $(MV) y.tab.c personal.c - -personal.lex.c: ../personal.l - $(LEX.l) ../personal.l > personal.lex.c - -pics/personal.o: personal.c personal.lex.c - $(COMPILE.c) -o pics/personal.o personal.c - $(POST_PROCESS_O) - -lint: lintcheck - -include $(SRC)/lib/Makefile.targ diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/access.c --- a/usr/src/cmd/agents/snmp/agent/access.c Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1054 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include -#include -#include -#include -#include -#include -#include - -#include "impl.h" -#include "error.h" -#include "trace.h" -#include "asn1.h" -#include "snmp.h" -#include "trap.h" - -#include "agent_msg.h" -#include "access.h" - -#define WILD_CARD_HOST_NAME "*" -#define WILD_CARD_ADDRESS 0 - -#define MAX_BUF_SIZE 256 - -/***** STATIC VARIABLES *****/ - -static Manager *first_manager = NULL; -static Community *first_community = NULL; - -static EFilter *first_efilter = NULL; - -static NameOidPair *first_name_oid_pair = NULL; - - -void init_manager_set () -{ - first_community = NULL; /* TODO: check this out */ - first_manager = NULL; -} - -void set_first_manager (Manager *mgr) -{ - first_manager = mgr; -} - -Manager * get_curr_manager_set () -{ - return first_manager; -} - -/***********************************************************/ - -/* - * returns 0 if OK - * 1 if error - * -1 if fatal error - */ - -Manager* manager_add(char *name, char *error_label) -{ - IPAddress ip_address; - Manager *new; - Manager *m; - - - error_label[0] = '\0'; - - - if(name == NULL) - { - (void)sprintf(error_label, "BUG: manager_add(): name is NULL"); - return NULL; - } - - - /* skip the ip adx for wild-card host */ - - if(strcmp(name,WILD_CARD_HOST_NAME)){ - /* try to find the IP address from the name */ - if(name_to_ip_address(name, &ip_address, error_label)) - { - return NULL; - } - } - - - /* checking for dup is on the wild-card host name */ - - - /* check if this manager does not already exist */ - if(strcmp(name,WILD_CARD_HOST_NAME)){ - for(m = first_manager; m; m = m->next_manager) - { - if(ip_address.s_addr == m->ip_address.s_addr) - { - (void)sprintf(error_label, ERR_MSG_MANAGER_DUP, name); - return m; - } - } - }else{ - for(m = first_manager; m; m = m->next_manager) - { - if(!strcmp(m->name,name)) - { - return m; - } - } - } - - - /* allocate, initialize and link the new manager */ - new = (Manager *) calloc(1,sizeof(Manager)); - if(new == NULL) - { - (void)sprintf(error_label, ERR_MSG_ALLOC); - return NULL; - } - new->next_manager = NULL; - new->name = NULL; - - new->name = strdup(name); - if(new->name == NULL) - { - (void)sprintf(error_label, ERR_MSG_ALLOC); - free(new); - return NULL; - } - - /* ip adx for wild-card host should be zero */ - - if(strcmp(name,WILD_CARD_HOST_NAME)){ - new->ip_address.s_addr = ip_address.s_addr; - }else{ - new->ip_address.s_addr = WILD_CARD_ADDRESS; - - } - - new->next_manager = first_manager; - first_manager = new; - - - return new; -} - -/***********************************************************/ - -/* - * returns a pointer to the manager if the request succeeds, - * otherwise returns NULL - */ - -Manager *is_valid_manager(Address *address, Manager **mngr) -{ - Manager *m; - - *mngr = NULL; - - if(address == NULL) - { - error("BUG: is_valid_manager(): address is NULL"); - return NULL; - } - - if(first_manager == NULL) - { - return NULL; - } - - for(m = first_manager; m; m = m->next_manager) - { - if(address->sin_addr.s_addr == m->ip_address.s_addr) - { - *mngr = m; - return m; - } - } - - /* check for wild-card host */ - for(m = first_manager; m; m = m->next_manager) - { - if(!strcmp(m->name,WILD_CARD_HOST_NAME)){ - *mngr = m; - return m; - } - } - - return m; -} - -/***********************************************************/ - -void delete_manager_list() -{ - Manager *next; - - - while(first_manager) - { - next = first_manager->next_manager; - - if(first_manager->name) - { - free(first_manager->name); - } - - free(first_manager); - - first_manager = next; - } - - first_manager = NULL; -} - -void manager_list_free(Manager *mngr) -{ - Manager *next; - - - while(mngr) - { - next = mngr->next_manager; - - if(mngr->name) - { - free(mngr->name); - } - - free(mngr); - - mngr = next; - } - - mngr = NULL; -} - -void sub_member_free(SubMember *mem) -{ - Manager *mngr; - - if(mem==NULL) return; - mem->count--; - if(mem->count<0){ - mngr = mem->first_manager; - manager_list_free(mngr); - if(mem->community_string != NULL) free(mem->community_string); - free(mem); - } -} - -void sub_group_list_free(SubGroup *group) -{ - SubGroup *next; - - - while(group) - { - next = group->next_sub_group; - - if(group->first_sub_member != NULL) - { - sub_member_free(group->first_sub_member); - } - - free(group); - - group = next; - } - -} - -void trap_slot_list_free(TrapSlot *slot) -{ - TrapSlot *next; - - - while(slot) - { - next = slot->next_trap_slot; - if(slot->first_sub_group != NULL) - { - sub_group_list_free(slot->first_sub_group); - } - - free(slot); - - slot = next; - } - -} - - -void delete_efilter_list() -{ - EFilter *next; - - - while(first_efilter) - { - next = first_efilter->next_efilter; - - if(first_efilter->name) - { - free(first_efilter->name); - } - - free(first_efilter); - - first_efilter = next; - } - - first_efilter = NULL; -} - -/***********************************************************/ - -void trace_managers() -{ - Manager *m; - AccessServer *as; - - trace("MANAGERS:\n"); - trace("---------\n"); - for(m = first_manager; m; m = m->next_manager) - { - trace("%-30s %-20s\n", - m->name, - !strcmp(m->name,WILD_CARD_HOST_NAME)? - "0":inet_ntoa(m->ip_address) ); - for(as=m->first_acc_server;as;as=as->next_acc_server) - trace_access_server(as); - - } - trace("\n"); -} - - -/***********************************************************/ - -/* - * returns 0 if OK - * 1 if error - * -1 if fatal error - */ - -int community_add(char *name, int type, char *error_label) -{ - int ret; - Community *new; - Community *c; - Community *last = NULL; - - - error_label[0] = '\0'; - - if(name == NULL) - { - (void)sprintf(error_label, "BUG: community_add(): name is NULL"); - return -1; - } - - if(name[0] == '\0') - { - (void)sprintf(error_label, "BUG: community_add(): name is empty"); - return -1; - } - - if( (type != READ_ONLY) && (type != READ_WRITE) ) - { - (void)sprintf(error_label, "BUG: community_add(): bad type (%d)", type); - return -1; - } - - for(c = first_community; c; c = c->next_community) - { - ret = strcmp(name, c->name); - if(ret > 0) - { - break; - } - else - if(ret == 0) - { - (void)sprintf(error_label, ERR_MSG_COMMUNITY_DUP, name); - return 1; - } - - last = c; - } - - new = (Community *) calloc(1,sizeof(Community)); - if(new == NULL) - { - (void)sprintf(error_label, ERR_MSG_ALLOC); - return -1; - } - new->next_community = NULL; - new->name = NULL; - - new->name = strdup(name); - if(new->name == NULL) - { - (void)sprintf(error_label, ERR_MSG_ALLOC); - free(new); - return -1; - } - - new->type = type; - - if(last) - { - last->next_community = new; - } - else - { - first_community = new; - } - new->next_community = c; - - - return 0; -} - -int get_access_type(Manager *mngr,char *name) -{ - AccessServer *as; - AccessPolicy *ap; - Community *comm; - - if(name==NULL || mngr==NULL) return NULL; - for(as=mngr->first_acc_server;as;as=as->next_acc_server) - { - if((ap=as->first_acc_policy)!=NULL) - for(comm=ap->first_community;comm;comm=comm->next_community) - if(comm->name!=NULL && !strcmp(name,comm->name)) - return ap->access_type; - } - return -1; -} - - -/***********************************************************/ - -/* returns True or False */ - -int is_valid_community(char *name, int type, Manager *mngr) -{ - int access_type; - - - if(name == NULL) - { - error("BUG: is_valid_community(): name is NULL"); - return False; - } - - if( (type != GETNEXT_REQ_MSG ) - && (type != GET_REQ_MSG) - && (type != SET_REQ_MSG) ) - { - error("BUG: is_valid_community(): bad type(0x%x)", type); - return False; - } - - if(mngr==NULL) return True; /* accept reqs from any hosts */ - - if(mngr->first_acc_server!=NULL){ - if( (access_type = get_access_type(mngr,name)) == -1) - return False; - } - - if(type != SET_REQ_MSG) - { - return True; - } - else - { - if(access_type == READ_WRITE) - { - return True; - } - else - { - return False; - } - } - -} - - -/***********************************************************/ - -void delete_community_list() -{ - Community *next; - - - while(first_community) - { - next = first_community->next_community; - - if(first_community->name) - { - free(first_community->name); - } - - free(first_community); - - first_community = next; - } - - first_community = NULL; -} - - -/***********************************************************/ - -void trace_access_server(AccessServer *as) -{ - AccessPolicy *ap; - - if(as==NULL) return; - if( (ap=as->first_acc_policy)!=NULL ) - trace_access_policy(ap); -} - -void trace_access_policy(AccessPolicy *ap) -{ - Community *c; - - if(ap==NULL) return; - trace("\tCOMMUNITIES("); - switch(ap->access_type) - { - case READ_ONLY: - trace("%s", "READ_ONLY"); - break; - case READ_WRITE: - trace("%s", "READ_WRITE"); - break; - } - trace("): "); - for(c=ap->first_community;c;c=c->next_community) - trace_communities(c); - trace("\n"); -} - -void trace_communities(Community *c) -{ - - - trace(" %s", c->name); -} - - -/***********************************************************/ -void community_list_free(Community *comm) -{ - Community *next; - - - while(comm) - { - next = comm->next_community; - - if(comm->name) - { - free(comm->name); - } - - free(comm); - - comm = next; - } - - comm = NULL; -} - -void access_policy_list_delete(AccessPolicy *ap) -{ - if(ap==NULL) return; - ap->count--; - if(ap->count<=0){ - free(ap); - } -} - -void access_policy_list_free(AccessPolicy *ap) -{ - if(ap==NULL) return; - ap->count--; - if(ap->count<=0){ - community_list_free(ap->first_community); - free(ap); - } -} - -void access_server_delete(AccessServer *as) -{ - if(as==NULL) return; - access_policy_list_delete(as->first_acc_policy); - free(as); -} - -void access_server_free(AccessServer *as) -{ - if(as==NULL) return; - access_policy_list_free(as->first_acc_policy); - free(as); -} - -void agent_manager_list_free(Manager *mgr) -{ - Manager *nextmgr; - AccessServer *as, *last=NULL; - - if (mgr == NULL) - return; - - while(mgr) - { - nextmgr = mgr->next_manager; - - as = mgr->first_acc_server; - while (as) { - last = as->next_acc_server; - access_server_delete(as); - as = last; - } - - if(mgr->name) - free(mgr->name); - - free(mgr); - - mgr = nextmgr; - } - - mgr = NULL; -} - -void access_server_add_tail(Manager* mngr, AccessServer *acc_server) -{ - AccessServer *as, *last=NULL; - - if(mngr==NULL || acc_server==NULL) return; - for(as=mngr->first_acc_server;as;as=as->next_acc_server) - last = as; - - if(last==NULL){ - mngr->first_acc_server = acc_server; - }else{ - last->next_acc_server = acc_server; - } - acc_server->next_acc_server = NULL; - acc_server->attached = TRUE; -} - -void community_attach(AccessPolicy *ap, Community *comm) -{ - if(ap==NULL || comm==NULL) return; - if(ap->first_community==NULL) - ap->first_community = comm; - else{ - comm->next_community = ap->first_community; - ap->first_community = comm; - } -} - - -EFilter* efilter_add(char *name, char *error_label) -{ - EFilter *new; - EFilter *m; - - - error_label[0] = '\0'; - - - if(name == NULL) - { - (void)sprintf(error_label, "BUG: efilter_add(): name is NULL"); - return NULL; - } - - - for(m = first_efilter; m; m = m->next_efilter) - { - if(!strcmp(m->name,name)) - { - return m; - } - } - - - /* allocate, initialize and link the new efilter */ - new = (EFilter *) calloc(1,sizeof(EFilter)); - if(new == NULL) - { - (void)sprintf(error_label, ERR_MSG_ALLOC); - return NULL; - } - new->next_efilter = NULL; - new->name = NULL; - - new->name = strdup(name); - if(new->name == NULL) - { - (void)sprintf(error_label, ERR_MSG_ALLOC); - free(new); - return NULL; - } - - new->enterprise = enterprise_name_to_oid(new->name); - - new->next_efilter = first_efilter; - first_efilter = new; - - return new; -} - -TrapSlot* trap_slot_add(int num,EFilter *efilter,char *error_label) -{ - TrapSlot *new; - TrapSlot *m; - - - if(efilter==NULL) return NULL; - if(num < 0) - { - (void)sprintf(error_label, "BUG: trap_slot_add(): name is NULL"); - return NULL; - } - - - for(m = efilter->first_trap_slot; m; m = m->next_trap_slot) - { - if(m->num == num) - { - return m; - } - } - - - /* allocate, initialize and link the new efilter */ - new = (TrapSlot *) calloc(1,sizeof(TrapSlot)); - if(new == NULL) - { - (void)sprintf(error_label, ERR_MSG_ALLOC); - return NULL; - } - new->num = num; - new->next_trap_slot = efilter->first_trap_slot; - efilter->first_trap_slot = new; - - return new; -} - -void sub_group_add_tail(TrapSlot *slot, SubGroup *group) -{ - SubGroup *sg, *last =NULL; - - if(slot==NULL || group==NULL) return; - for(sg=slot->first_sub_group;sg;sg=sg->next_sub_group) - last = sg; - - if(last==NULL){ - slot->first_sub_group = group; - }else{ - last->next_sub_group = group; - } - group->next_sub_group = NULL; -} - -void mem_filter_join(int low, int high,SubMember *mem,EFilter *filter) -{ - /* find the trap slot in the filter */ - /* create subgroup, attach submember to subgroup */ - /* insert subgroup into the trap slot */ - - int idx; - TrapSlot *slot; - SubGroup *group; - - if(low<0 || high<0 || filter==NULL || mem==NULL) return; - for(idx=low;idx<=high;idx++){ - slot = trap_slot_add(idx,filter,error_label); - if(slot==NULL) continue; - group = calloc(1,sizeof(SubGroup)); - if(group==NULL){ - error("malloc() failed"); - } - /* The efilter list may contain duplicate entries because - the agent ACL file may be read several times. This seems - to be necessary to mantain other functionality in the ACL - such as specifying managers. The following hack makes sure - the trap is sent to each host only by not allowing duplicate - members in an efilter. - */ - if (slot->first_sub_group == NULL) { /* always add initial first_sub_group */ - sub_group_add_tail(slot,group); - group->first_sub_member = mem; - mem->count++; - }else { /* at least one sub_group exists */ - if (strcmp(slot->first_sub_group->first_sub_member->first_manager->name, - mem->first_manager->name)) { /* check for duplicate member */ - sub_group_add_tail(slot,group); - group->first_sub_member = mem; - mem->count++; - } else /* don't add duplicate */ - free(group); - } - } -} - -static void trace_hosts(Manager *mngr) -{ - Manager *m; - - for(m=mngr;m;m=m->next_manager){ - trace("\t\t%s %s\n", - m->name, - inet_ntoa(m->ip_address)); - } -} - -static void trace_sub_member(SubMember *mem) -{ - if(mem==NULL) return; - if(mem->community_string != NULL) - trace("\tcommunity-string: %s\n",mem->community_string); - trace_hosts(mem->first_manager); -} - -static void trace_sub_group(SubGroup *group) -{ - if(group==NULL) return; - trace_sub_member(group->first_sub_member); -} - -static void trace_trap_slot(TrapSlot *slot) -{ - SubGroup *group; - - if(slot==NULL) return; - trace("\ttrap-num=%d",slot->num); - for(group=slot->first_sub_group;group;group=group->next_sub_group) - trace_sub_group(group); -} - -void trace_filter() -{ - EFilter *filter; - TrapSlot *slot; - - trace("#EFILTER:\n"); - for(filter=first_efilter;filter;filter=filter->next_efilter) - { - trace("enterprise=\"%s\"\n",filter->name); - for(slot=filter->first_trap_slot;slot;slot=slot->next_trap_slot) - trace_trap_slot(slot); - } - trace("\n"); -} - -/**** Enterprise related functions *****/ - -void trace_name_oid_pair() -{ - NameOidPair *np; - - trace("NAME_OID_PAIR:\n"); - for(np=first_name_oid_pair;np;np=np->next) - trace("name: %s oid: %s\n",np->name,SSAOidString(np->oid)); - trace("\n"); -} - -Oid *enterprise_name_to_oid(char *name) -{ - NameOidPair *np; - - if(name == NULL) return NULL; - for(np=first_name_oid_pair;np;np=np->next){ - if(np->name!=NULL && !strcmp(name,np->name)) - return np->oid; - } - return NULL; -} - -static NameOidPair* set_name_and_oid_pair(char *inbuf) -{ - char *str; - char *name_str, *oid_str; - Oid *oid = NULL; - NameOidPair *np; - - if ((inbuf== NULL) || (inbuf[0]== '#')) return NULL; - - /* first " for name */ - if ((str = strchr(inbuf, '"')) == NULL) return NULL; - str++; - name_str = str; - - /* second " for name */ - if ((str = strchr(str, '"')) == NULL) return NULL; - *str = '\0'; - - str++; - /* first " for oid_str*/ - if ((str = strchr(str, '"')) == NULL) return NULL; - str++; - oid_str = str; - - /* second " for oid_str*/ - if ((str = strchr(str, '"')) == NULL) return NULL; - *str = '\0'; - oid = SSAOidStrToOid(oid_str,error_label); - - np = calloc(1,sizeof(NameOidPair)); - if(np==NULL){ - error("calloc failed"); - return NULL; - } - np->oid = oid; - np->name = strdup(name_str); - - if (np->name == NULL) { - free(np); - return(NULL); - } - - return np; -} - -static void insert_name_oid_pair(char *name_str,char* oid_str) -{ - char inbuf[MAX_BUF_SIZE]; - NameOidPair *np; - - (void)sprintf(inbuf,"\"%s\" \"%s\"\n",name_str,oid_str); - if( (np=set_name_and_oid_pair(inbuf)) != NULL){ - np->next = first_name_oid_pair; - first_name_oid_pair = np; - } -} - -void load_enterprise_oid(char* filename) -{ - FILE *fd; - char inbuf[MAX_BUF_SIZE]; - NameOidPair *np; - - if(filename==NULL) return; - fd = fopen(filename,"r"); - if(fd==NULL){ - error("can open the file %s",filename); - return; - } - while(fgets(inbuf,MAX_BUF_SIZE,fd)){ - if( (np=set_name_and_oid_pair(inbuf)) != NULL){ - /* insert np */ - np->next = first_name_oid_pair; - first_name_oid_pair = np; - } - } - /* insert a couple of extra name-oid pairs: - sun, snmp - */ - insert_name_oid_pair("snmp", "1.3.6.1.2.1.11"); - insert_name_oid_pair("sun", "1.3.6.1.4.1.42.2.1.1"); - - (void)fclose(fd); -} - -static EFilter* find_efilter(Oid* oid) -{ - EFilter *filter; - - for(filter=first_efilter;filter;filter=filter->next_efilter) - { - if(SSAOidCmp(filter->enterprise,oid)==0) return filter; - } - return NULL; -} - -static TrapSlot* find_trap_slot(int num,EFilter *filter) -{ - TrapSlot *slot; - - for(slot=filter->first_trap_slot;slot;slot=slot->next_trap_slot) - if(slot->num==num) return slot; - return NULL; -} - -void trap_filter_action(Oid *oid,int generic,int specific, - uint32_t time_stamp,SNMP_variable *variables) -{ - EFilter *filter; - TrapSlot *slot; - SubGroup *group; - Manager *manager; - static Subid snmp_subids[] = {1,3,6,1,2,1,11}; - static Oid snmp_oid = {snmp_subids, 7}; - int trap_num; - IPAddress my_ip_address; - - (void)memset(&my_ip_address, 0, sizeof(IPAddress)); - - if(oid==NULL) return; - if( (filter=find_efilter(oid))==NULL ) return; - if(SSAOidCmp(oid,&snmp_oid)==0) - trap_num = generic; - else - trap_num = specific; - if( (slot=find_trap_slot(trap_num,filter))==NULL ) return; - for(group=slot->first_sub_group;group;group=group->next_sub_group){ - if(group->first_sub_member!=NULL){ - for(manager=group->first_sub_member->first_manager;manager; - manager=manager->next_manager){ - trap_send_raw(&(manager->ip_address),my_ip_address, - group->first_sub_member->community_string,0, - oid,generic,specific, SNMP_TRAP_PORT,time_stamp, - variables,error_label); - } - } - } -} - diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/access.h --- a/usr/src/cmd/agents/snmp/agent/access.h Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,186 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 1998 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include -#include "impl.h" -#include "pdu.h" - -#ifndef _ACCESS_H_ -#define _ACCESS_H_ - -#define READ_ONLY 1 -#define READ_WRITE 2 - -typedef struct _Community { - struct _Community *next_community; - char *name; - int type; -} Community; - -typedef struct _AccessPolicy { - Community *first_community; - int access_type; /* one access type for all the communities */ - int count; -} AccessPolicy; - -typedef struct _AccessServer { - struct _AccessServer *next_acc_server; - AccessPolicy *first_acc_policy; - int attached; -} AccessServer; - -typedef struct _Manager { - struct _Manager *next_manager; - char *name; - IPAddress ip_address; - AccessServer *first_acc_server; -} Manager; - -/**************************************************** - --------------- -| Manager |--> -| xxxxxxx | -| :name | -| :ip_address | --------------- - | - V ----------- -------------- ------------- -| Manager |-->| AccessServer |-->| AccessServer|--> ----------- -------------- ------------- - | 0 - 0 (link to shared object) - V V - ------------- --------- --------- - |AccessPolicy|-->|Community|-->|Community|--> - |xxxxxxxxxxxx| |xxxxxxxxx| --------- - |:access_type| |:name | - ------------- --------- -1 -******************************************************/ -typedef struct _SubMember { - Manager *first_manager; - char *community_string; - int count; -} SubMember; - -typedef struct _SubGroup { - struct _SubGroup *next_sub_group; - SubMember *first_sub_member; -} SubGroup; - -typedef struct _TrapSlot { - struct _TrapSlot *next_trap_slot; - SubGroup *first_sub_group; - int num; -} TrapSlot; - -typedef struct _EFilter { - struct _EFilter *next_efilter; - TrapSlot *first_trap_slot; - Oid *enterprise; - char *name; - int type; /* generic or specific */ -} EFilter; - -/**************************************************** - --------------- -| EFilter |--> -| xxxxxxx | -| :enterprise | --------------- - | next_efilter - V ----------- first_trap_slot ----------- next_trap_slot --------- -|EFilter |--------------->| TrapSlot |---------------->| TrapSlot|--> ----------- | xxxxxxxxx | --------- - | | : num | - V ----------- - | first_sub_group - V - ------------------ ------------ - | SubGroup |next_sub_group | SubGroup | - | xxxxxxxxxxxxxxxx|--------------> ---------- - ------------------ - 0 first_sub_member - 0 - V - ----------------- - | SubMember |first_manager --------- - | xxxxxxxxxxxxxxx |------------>| Manager | - |:community_string| --------- - ----------------- - -******************************************************/ -typedef struct _NameOidPair { - struct _NameOidPair *next; - char *name; - Oid *oid; -} NameOidPair; - -/* routines for trap */ -extern EFilter* efilter_add(char* name, char *error_label); -extern TrapSlot* trap_slot_add(int num,EFilter *efilter,char *error_label); -extern void sub_group_add_tail(TrapSlot *slot,SubGroup *group); -extern void sub_member_free(SubMember *mem); -extern void sub_group_list_free(SubGroup *group); -extern void trap_slot_list_free(TrapSlot *slot); -extern void mem_filter_join(int low,int high,SubMember *mem,EFilter *filter); -extern void trace_filter(); - -extern void init_manager_set(); -extern Manager* get_curr_manager_set(); -extern Manager* manager_add(char *name, char *error_label); -extern Manager* is_valid_manager(Address *address, Manager **mngr); -extern void delete_manager_list(); -extern void manager_list_free(Manager *mngr); -extern void trace_managers(); - -extern int community_add(char *name, int type, char *error_label); -extern int is_valid_community(char *name, int type, Manager *mngr); -extern void delete_community_list(); -extern void trace_communities(Community *c); -extern void trace_access_server(AccessServer *as); -extern void trace_access_policy(AccessPolicy *ap); - -extern void community_attach(AccessPolicy *ap, Community *comm); -extern void access_server_add_tail(Manager* mngr, AccessServer *acc_server); -extern void access_server_free(AccessServer *as); -extern void access_policy_list_free(AccessPolicy *ap); -extern int get_access_type(Manager *mngr,char *name); - -/* name oid pair loading */ -extern void trace_name_oid_pair(); -extern Oid *enterprise_name_to_oid(char *name); -extern void load_enterprise_oid(char* filename); - -extern void trap_filter_action(Oid *oid,int generic,int specific, - uint32_t time_stamp,SNMP_variable *variables); - -#endif diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/agent-mapfile-vers --- a/usr/src/cmd/agents/snmp/agent/agent-mapfile-vers Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -# -# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# - -# -# MAPFILE HEADER START -# -# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. -# Object versioning must comply with the rules detailed in -# -# usr/src/lib/README.mapfiles -# -# You should not be making modifications here until you've read the most current -# copy of that file. If you need help, contact a gatekeeper for guidance. -# -# MAPFILE HEADER END -# - -$mapfile_version 2 - -SYMBOL_VERSION SUNW_1.1 { - global: - SSAMain; - SSARegSubagent; - SSAGetTrapPort; - SSASubagentOpen; - _SSASendTrap; - _SSASendTrap2; - _SSASendTrap3; - SSAAgentIsAlive; - SSARegSubtree; - numTrapElem; - callItem; - trapTableMap; - trapBucket; - numCallItem; - trapEnterpriseInfo; - trapAnyEnterpriseInfo; - local: - *; -}; - -SYMBOL_VERSION SUNWprivate_1.1 { - global: - load_enterprise_oid; - delete_manager_list; - access_policy_list_free; - delete_community_list; - trace_managers; - mem_filter_join; - trap_filter_action; - access_server_add_tail; - access_server_free; - init_manager_set; - set_first_manager; - get_curr_manager_set; - manager_list_free; - sub_member_free; - agent_process; - efilter_add; - manager_add; - community_attach; - trace_filter; - get_access_type; - is_valid_manager; - is_valid_community; - agent_manager_list_free; - _SSASendTrap4; - local: - *; -}; diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/agent.c --- a/usr/src/cmd/agents/snmp/agent/agent.c Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1446 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include -#include -#include -#include -#include -#include -#include -#include - - -#include "impl.h" -#include "error.h" -#include "trace.h" -#include "snmp.h" -#include "pdu.h" -#include "request.h" -#include "trap.h" - -#include "node.h" -#include "access.h" - -static int ssa_mem_free = 1; /* on */ - -#if defined(_LP64) -#define COLUMN_OFFSET(x) (x) * 2 -#else -#define COLUMN_OFFSET(x) (x) -#endif - -#define OCTET_STRING 2 - -/***** LOCAL VARIABLES *****/ - -/* - * The idea of these cache variables is to avoid to call - * the same *(entry->get) function for variables contained - * in a single SNMP PDU. - * - * There is still a problem in this mechanism. - * When you query a whole table row by row and when - * you reached the end of the table, the *(entry->get) - * will be called several times: - * - for the first column, *(entry->get) will be called - * once to find that the end of the table is reached - * (==> the knowledge that we reached the last row is cached) - * and then *(entry->get) will be called on the first row of - * the same table (==> the first row is cached). - * - Same behaviour for all the remaining columns - * - * Possible solutions: - * - two caches but this implies the copy of the cached - * structures + all theis pointers - * - only one cache + caching the knowledge that we reached the last - * row ??? - * - */ - -static Entry *cache_input_entry = NULL; -static Subid cache_input_index[MAX_OID_LEN]; -static void *cache_output_pointer = NULL; -static int cache_output_snmp_error = -1; -static Subid cache_output_index[MAX_OID_LEN]; - - -/***** LOCAL FUNCTIONS *****/ - -static int agent_get_next(SNMP_pdu *pdu, char *error_label); -static int agent_get_next_loop(SNMP_variable *variable, Node *node, Oid *suffix); -static int agent_get(SNMP_pdu *pdu, char *error_label); -static int agent_set(int pass, SNMP_pdu *pdu, char *error_label); - - -/****************************************************************/ - -/* returns: */ -/* 0 in case of success (the pdu should be sent */ -/* back to its originator even if an SNMP error */ -/* was detected) */ -/* -1 in case of failure (no pdu should be sent */ -/* back) */ - -int agent_process(Address *address, SNMP_pdu *pdu) -{ - int snmpEnableAuthTraps = FALSE; - Manager *mngr; - - - if(pdu == NULL) - { - error("BUG: agent_process(): pdu is NULL"); - return -1; - } - - - /* check host */ - if(is_valid_manager(address,&mngr) == NULL) - { - error("agent_process(): unauthorized manager (%s)", - ip_address_string(&(address->sin_addr))); - - snmpEnableAuthTraps = request_snmpEnableAuthTraps(error_label); - switch(snmpEnableAuthTraps) - { - case TRUE: - if(trap_send_to_all_destinators(NULL, - SNMP_TRAP_AUTHFAIL, 0, - NULL, error_label)) - { - error("trap_send_to_all_destinators() failed: %s\n", - error_label); - } - break; - - case FALSE: - default: - break; - } - - return -1; - } - - /* if mngr == NULL -> allow requests from any hosts */ - - /* check pdu type */ - if(pdu->type != GETNEXT_REQ_MSG - && (pdu->type != GET_REQ_MSG) - && (pdu->type != SET_REQ_MSG) ) - { - error("agent_process(): bad PDU type (0x%x)", pdu->type); - return -1; - } - - - /* check host */ - if(!is_valid_community(pdu->community, pdu->type,mngr)) - { - /* - * Earlier, the community name is displayed here - * in this error message. But since these error - * messages are readable by all users, it is not advisible - * to display community names in the error messages. - */ - error("agent_process() : bad community from %s", - ip_address_string(&(address->sin_addr))); - - snmpEnableAuthTraps = request_snmpEnableAuthTraps(error_label); - switch(snmpEnableAuthTraps) - { - case TRUE: - if(trap_send_to_all_destinators(NULL, - SNMP_TRAP_AUTHFAIL, 0, - NULL, error_label)) - { - error("trap_send_to_all_destinators() failed: %s\n", - error_label); - } - break; - - case FALSE: - default: - break; - } - - return -1; - } - - - if(cache_input_entry != NULL && cache_output_pointer != NULL) - if(ssa_mem_free != 0 && cache_input_entry->dealloc != NULL){ - (*(cache_input_entry->dealloc))(cache_output_pointer); - cache_output_pointer = NULL; - } - - cache_input_entry = NULL; - - switch(pdu->type) - { - case GETNEXT_REQ_MSG: - if(agent_get_next(pdu, error_label)) - { - error("agent_get_next() failed: %s", error_label); - return -1; - } - return 0; - - case GET_REQ_MSG: - if(agent_get(pdu, error_label)) - { - error("agent_get() failed: %s", error_label); - return -1; - } - return 0; - - case SET_REQ_MSG: - switch(agent_set(FIRST_PASS, pdu, error_label)) - { - case 0: - switch(agent_set(SECOND_PASS, pdu, error_label)) - { - case 0: - case 1: - return 0; - - case -1: - error("agent_set(SECOND_PASS) failed: %s", - error_label); - return -1; - } - - /* never reached */ - break; - - case 1: - return 0; - - case -1: - error("agent_set(FIRST_PASS) failed: %s", - error_label); - return -1; - } - } - - /* never reached */ - return -1; -} - - -/****************************************************************/ - -/* returns: */ -/* 0 in case of success (the pdu should be sent */ -/* back to its originator even if an SNMP error */ -/* was detected) */ -/* -1 in case of failure (no pdu should be sent */ -/* back) */ - -static int agent_get_next(SNMP_pdu *pdu, char *error_label) -{ - SNMP_variable *variable; - Node *node; - Oid suffix; - int index = 1; - int snmp_error; - - - error_label[0] = '\0'; - - pdu->type = GET_RSP_MSG; - - for(variable = pdu->first_variable; variable; variable = variable->next_variable) - { - node = node_find(NEXT_ENTRY, &(variable->name), &suffix); - if(node == NULL) - { - pdu->error_status = SNMP_ERR_NOSUCHNAME; - pdu->error_index = index; - return 0; - } - /* we should not forget to free suffix.subids */ - - if(trace_level > 0) - { - trace("!! getnext(): processing the variable %s\n\n", - node->label); - } - - if(variable->type != NULLOBJ) - { - error("ASN.1 type (0x%x) is not NULL for node %s", - variable->type, node->label); - variable->type = NULLOBJ; - } - - if(variable->val.string) - { - error("val is not NULL for node %s", - node->label); - free(variable->val.string); - variable->val.string = NULL; - } - - if(variable->val_len) - { - error("val_len is not 0 for node %s", - node->label); - variable->val_len = 0; - } - - snmp_error = agent_get_next_loop(variable, node, &suffix); - - if(snmp_error != SNMP_ERR_NOERROR) - { - pdu->error_status = snmp_error; - pdu->error_index = index; - return 0; - } - - index++; - } - - return 0; -} - - -/* This function will free suffix->subids */ -/* It returns a positive snmp_error code. */ -static int -agent_get_next_loop(SNMP_variable *variable, Node *node, Oid *suffix) -{ - Object *object; - Column *column; - Entry *entry; - Integer integer = 0; - Integer *integer_ptr; - String string = { NULL, 0 }; - String *string_ptr; - Oid oid = { NULL, 0 }; - Oid *oid_ptr; - char *pointer; - int snmp_error; - Subid index[MAX_OID_LEN]; - Index *pIndex; - int index_len; - - /* create index struct */ - IndexType index_obj; - int index_buffer[256]; - - int was_cached ; - int i; - int get_entry; - - bzero(index, sizeof(Subid) * MAX_OID_LEN); - bzero(&index_obj, sizeof(index_obj)); - bzero(index_buffer, sizeof(index_buffer)); - index_obj.value = index_buffer; - - if(node == NULL) - { - if(trace_level > 0) - { - trace("!! End of MIB\n\n"); - } - - SSAOidZero(suffix); - return SNMP_ERR_NOSUCHNAME; - } - - if(trace_level > 0) - trace("!! Trying %s with suffix %s\n\n", - node->label, SSAOidString(suffix)); - - switch(node->type) - { - case OBJECT: - object = node->data.object; - - switch(suffix->len) - { - case 0: - if( !(object->access & READ_FLAG) ) - return SNMP_ERR_NOSUCHNAME; - - switch(object->asn1_type) - { - case INTEGER: - case COUNTER: - case GAUGE: - case TIMETICKS: - snmp_error = (*(object->get))(&integer); - break; - - case OBJID: - snmp_error = (*(object->get))(&oid); - if(snmp_error != SNMP_ERR_NOERROR && - ssa_mem_free != 0){ - if(object->dealloc != NULL) - (*(object->dealloc))(&oid); - } - break; - - case STRING: - case IPADDRESS: - case OPAQUE: - snmp_error = (*(object->get))(&string); - if(snmp_error != SNMP_ERR_NOERROR && - ssa_mem_free != 0){ - if(object->dealloc != NULL) - (*(object->dealloc))(&string); - } - break; - } - - if(snmp_error != SNMP_ERR_NOERROR) - { - if(snmp_error < 0) - { - error("the get() method of %s returned %d", - node->label, - snmp_error); - snmp_error = SNMP_ERR_GENERR; - } - return snmp_error; - } - - /* variable->name */ - SSAOidZero(&(variable->name)); - variable->name.subids = (Subid *) malloc((object->name.len + 1) * - (int32_t)sizeof(Subid)); - (void)memcpy(variable->name.subids, object->name.subids, - object->name.len * (int32_t)sizeof(Subid)); - variable->name.subids[object->name.len] = 0; - variable->name.len = object->name.len + 1; - - /* variable->type */ - variable->type = object->asn1_type; - - /* variable->val, variable->val_len */ - switch(object->asn1_type) - { - case INTEGER: - case COUNTER: - case GAUGE: - case TIMETICKS: - variable->val.integer = (Integer *) malloc(sizeof(Integer)); - *(variable->val.integer) = integer; - variable->val_len = sizeof(Integer); - break; - - case OBJID: - variable->val.objid = (Subid *) malloc(oid.len * - (int32_t)sizeof(Subid)); - (void)memcpy(variable->val.objid, oid.subids, oid.len * - (int32_t)sizeof(Subid)); - variable->val_len = oid.len * - (int32_t)sizeof(Subid); - if(ssa_mem_free !=0 && object->dealloc != NULL) - (*(object->dealloc))(&oid); - break; - - case STRING: - case IPADDRESS: - case OPAQUE: - variable->val.string = (u_char *) malloc(string.len); - (void)memcpy(variable->val.string, string.chars, string.len); - variable->val_len = string.len; - if(ssa_mem_free != 0 && object->dealloc != NULL) - (*(object->dealloc))(&string); - break; - - } - - return SNMP_ERR_NOERROR; - - - case 1: - if(suffix->subids[0] != 0) - { - SSAOidZero(suffix); - return SNMP_ERR_NOSUCHNAME; - } - SSAOidZero(suffix); - - return agent_get_next_loop(variable, node->next, suffix); - - default: - SSAOidZero(suffix); - return SNMP_ERR_NOSUCHNAME; - } - - - case COLUMN: - column = node->data.column; - entry = column->entry; - pIndex = entry->first_index; - - if( !(column->access & READ_FLAG) ) - { - SSAOidZero(suffix); - return SNMP_ERR_NOSUCHNAME; - } - - if (entry->n_indexs < 0 || entry->n_indexs > MAX_OID_LEN) { - SSAOidZero(suffix); - return SNMP_ERR_NOSUCHNAME; - } - - index_len = 0; - for (pIndex=entry->first_index; pIndex; pIndex=pIndex->next_index) - { - if (pIndex->index_type == OCTET_STRING) - index_len = index_len + (pIndex->index_len)+1; /* add extra suffix for str len */ - else - index_len = index_len +1; /* one subid per index */ - } - index_obj.len = index_len; - - for (i=0; i < suffix->len; i++) - { - index[i] = suffix->subids[i]; - index_obj.value[i] = suffix->subids[i]; - } - - for (i = suffix->len; i < index_len; i++) /* Zero out remainder of suffixes */ - { - index[i] = 0; - index_obj.value[i] = 0; - } - - for (i=0; i < index_len; i++) - { - if ((cache_input_entry == entry) && (cache_input_index[i] == index[i])) - was_cached = 1; - else - { - was_cached = 0; - break; - } - - } - - if (was_cached) - { - pointer = cache_output_pointer; - snmp_error = cache_output_snmp_error; - for (i=0;i < index_len; i++) - index[i]= cache_output_index[i]; - } - else - { - if (cache_input_entry != NULL && cache_output_pointer != NULL) - if (ssa_mem_free!=0 && cache_input_entry->dealloc != NULL) - { - (*(cache_input_entry->dealloc))(cache_output_pointer); - cache_output_pointer = NULL; - } - cache_input_entry= entry; - for (i=0; i < index_len; i++) - cache_input_index[i] = index[i]; - - if (suffix->len == 0) - get_entry = FIRST_ENTRY; - else - get_entry = NEXT_ENTRY; - - snmp_error = (*(entry->get)) (get_entry, &pointer,&index_obj); - - for (i=0; i< index_len; i++) - index[i] = index_obj.value[i]; - cache_output_pointer = pointer; - cache_output_snmp_error = snmp_error; - for (i=0; i < index_len; i++) - cache_output_index[i] = index[i]; - } - - if (suffix->len !=0) - SSAOidZero(suffix); - - if(pointer == NULL) - { - if(snmp_error == END_OF_TABLE) - { - if(trace_level > 0) - { - trace("!! End of table %s\n\n", - node->parent->parent->label); - } - return agent_get_next_loop(variable, node->next, suffix); - } - - if(snmp_error < 0) - { - error("the get() method of %s returned %d", - node->parent->label, - snmp_error); - snmp_error = SNMP_ERR_GENERR; - } - return snmp_error; - } - - /* variable->name */ - SSAOidZero(&(variable->name)); - variable->name.subids = (Subid *) malloc((column->name.len + index_len) * sizeof(Subid)); - memcpy(variable->name.subids, column->name.subids, column->name.len * sizeof(Subid)); - for (i=0; i < index_len; i++) - variable->name.subids[column->name.len + i] = index[i]; - variable->name.len = column->name.len + index_len; - - /* variable->type */ - variable->type = column->asn1_type; - - /* variable->val, variable->val_len */ - switch(column->asn1_type) - { - case INTEGER: - case COUNTER: - case GAUGE: - case TIMETICKS: - integer_ptr = (Integer *) (pointer + - COLUMN_OFFSET(column->offset)); - variable->val.integer = (Integer *) malloc(sizeof(Integer)); - *(variable->val.integer) = *integer_ptr; - variable->val_len = sizeof(Integer); - break; - - case OBJID: - oid_ptr = (Oid *) (pointer + - COLUMN_OFFSET(column->offset)); - /* fix the null subid */ - if(oid_ptr->subids == NULL){ - variable->val.objid = NULL; - }else{ - variable->val.objid = (Subid *) malloc(oid_ptr->len * - (int32_t)sizeof(Subid)); - (void)memcpy(variable->val.objid, oid_ptr->subids, oid_ptr->len * - (int32_t)sizeof(Subid)); - } - variable->val_len = oid_ptr->len * - (int32_t)sizeof(Subid); - break; - - case STRING: - case IPADDRESS: - case OPAQUE: - string_ptr = (String *) (pointer + - COLUMN_OFFSET(column->offset)); - if(string_ptr->chars == NULL){ - variable->val.string =(u_char*)NULL; - }else{ - variable->val.string = (u_char *) malloc(string_ptr->len); - (void)memcpy(variable->val.string, string_ptr->chars, string_ptr->len); - } - variable->val_len = string_ptr->len; - break; - } - - - return SNMP_ERR_NOERROR; - - - case NODE: - return agent_get_next_loop(variable, node->next, suffix); - } - - /* never reached */ - return -1; -} - - -/****************************************************************/ - -/* returns: */ -/* 0 in case of success (the pdu should be sent */ -/* back to its originator even if an SNMP error */ -/* was detected) */ -/* -1 in case of failure (no pdu should be sent */ -/* back) */ - -static int agent_get(SNMP_pdu *pdu, char *error_label) -{ - SNMP_variable *variable; - Node *node; - Object *object; - Column *column; - Entry *entry=NULL; - Oid suffix; - int index_err = 1; - Integer integer; - Oid oid; - String string; - Integer *integer_ptr; - Oid *oid_ptr; - String *string_ptr; - int snmp_error; - char *pointer=NULL; - Subid index[MAX_OID_LEN]; - - /* create index struct */ - IndexType index_obj; - int index_buffer[256]; - - int was_cached; - int i; - Index *pIndex; - int index_len; - - index_obj.len = 0; - index_obj.type = 0; - index_obj.value = index_buffer; - - - error_label[0] = '\0'; - - pdu->type = GET_RSP_MSG; - - for(variable = pdu->first_variable; variable; variable = variable->next_variable) - { - node = node_find(EXACT_ENTRY, &(variable->name), &suffix); - if(node == NULL) - { - pdu->error_status = SNMP_ERR_NOSUCHNAME; - pdu->error_index = index_err; - return 0; - } - /* we should not forget to free suffix.subids */ - - if(trace_level > 0) - { - trace("!! get(): processing the variable %s\n\n", - node->label); - } - - if(variable->type != NULLOBJ) - { - error("agent_get(): ASN.1 type (0x%x) is not NULL for node %s", - variable->type, - node->label); - variable->type = NULLOBJ; - } - - if(variable->val.string) - { - error("agent_get(): val is not NULL for node %s", node->label); - free(variable->val.string); - variable->val.string = NULL; - } - - if(variable->val_len) - { - error("agent_get(): val_len is not 0 for node %s", node->label); - variable->val_len = 0; - } - - switch(node->type) - { - case OBJECT: - object = node->data.object; - - if( (suffix.len != 1) - || (suffix.subids[0] != 0) ) - { - pdu->error_status = SNMP_ERR_NOSUCHNAME; - pdu->error_index = index_err; - SSAOidZero(&suffix); - return 0; - } - - if( !(object->access & READ_FLAG) ) - { - pdu->error_status = SNMP_ERR_NOSUCHNAME; - pdu->error_index = index_err; - SSAOidZero(&suffix); - return 0; - } - - switch(object->asn1_type) - { - case INTEGER: - case COUNTER: - case GAUGE: - case TIMETICKS: - snmp_error = (*(object->get))(&integer); - break; - - case OBJID: - snmp_error = (*(object->get))(&oid); - if(snmp_error != SNMP_ERR_NOERROR && - ssa_mem_free != 0){ - if(object->dealloc != NULL) - (*(object->dealloc))(&oid); - } - break; - - case STRING: - case IPADDRESS: - case OPAQUE: - snmp_error = (*(object->get))(&string); - if(snmp_error != SNMP_ERR_NOERROR && - ssa_mem_free != 0){ - if(object->dealloc != NULL) - (*(object->dealloc))(&string); - } - break; - } - - if(snmp_error != SNMP_ERR_NOERROR) - { - if(snmp_error < 0) - { - error("the get() method of %s returned %d", - node->label, - snmp_error); - snmp_error = SNMP_ERR_GENERR; - } - pdu->error_status = snmp_error; - pdu->error_index = index_err; - SSAOidZero(&suffix); - return 0; - } - - /* variable->name */ - - /* variable->type */ - variable->type = object->asn1_type; - - /* variable->val, variable->val_len */ - switch(object->asn1_type) - { - case INTEGER: - case COUNTER: - case GAUGE: - case TIMETICKS: - variable->val.integer = (Integer *) malloc(sizeof(Integer)); - *(variable->val.integer) = integer; - variable->val_len = sizeof(Integer); - break; - - case OBJID: - variable->val.objid = (Subid *) malloc(oid.len * - (int32_t)sizeof(Subid)); - (void)memcpy(variable->val.objid, oid.subids, oid.len * - (int32_t)sizeof(Subid)); - variable->val_len = oid.len * - (int32_t)sizeof(Subid); - if (ssa_mem_free != 0){ - if(object->dealloc != NULL) - (*(object->dealloc))(&oid); - } - break; - - case STRING: - case IPADDRESS: - case OPAQUE: - variable->val.string = (u_char *) malloc(string.len); - (void)memcpy(variable->val.string, string.chars, string.len); - variable->val_len = string.len; - /*if(snmp_error != SNMP_ERR_NOERROR &&*/ - if (ssa_mem_free != 0){ - if(object->dealloc != NULL) - (*(object->dealloc))(&string); - } - break; - } - - - break; - - - case COLUMN: - column = node->data.column; - entry = column->entry; - pIndex=entry->first_index; - - if( !(column->access & READ_FLAG) ) - { - pdu->error_status = SNMP_ERR_NOSUCHNAME; - pdu->error_index = index_err; - SSAOidZero(&suffix); - return 0; - } - - if (suffix.subids == NULL) { - pdu->error_status = SNMP_ERR_NOSUCHNAME; - pdu->error_index = index_err; - SSAOidZero(&suffix); - return 0; - } - - index_len = 0; - for (pIndex=entry->first_index; pIndex; pIndex=pIndex->next_index) - { - if (pIndex->index_type == OCTET_STRING) - index_len = index_len + (pIndex->index_len)+1; /* add extra suffix for str len */ - else - index_len = index_len +1; /* one subid per index */ - } - - - for (i=0; i < index_len; i++) - { - index[i] = suffix.subids[i]; - index_obj.value[i] = suffix.subids[i]; - } - index_obj.len = index_len; - for (i=0; i < index_len; i++) - { - if( (cache_input_entry == entry) && (cache_input_index[i] == index[i]) ) - was_cached = 1; - else - { - was_cached = 0; - break; - } - } - if (was_cached) - { - pointer = cache_output_pointer; - snmp_error = cache_output_snmp_error; - } - else - { - if(cache_input_entry != NULL && cache_output_pointer != NULL) - if(ssa_mem_free != 0 && cache_input_entry->dealloc != NULL) - { - (*(cache_input_entry->dealloc))(cache_output_pointer); - cache_output_pointer = NULL; - } - cache_input_entry = entry; - for (i=0; i < index_len; i++) - cache_input_index[i] = index[i]; - snmp_error = (*(entry->get))(EXACT_ENTRY,&pointer,&index_obj); - cache_output_pointer = pointer; - cache_output_snmp_error = snmp_error; - } - - - if(pointer == NULL) - { - if(snmp_error < 0) - { - error("the get() method of %s returned %d", - node->parent->label, - snmp_error); - snmp_error = SNMP_ERR_GENERR; - } - - pdu->error_status = snmp_error; - pdu->error_index = index_err; - SSAOidZero(&suffix); - return 0; - } - - /* variable->type */ - variable->type = column->asn1_type; - - /* variable->val, variable->val_len */ - switch(column->asn1_type) - { - case INTEGER: - case COUNTER: - case GAUGE: - case TIMETICKS: - integer_ptr = (Integer *) (pointer + - COLUMN_OFFSET(column->offset)); - variable->val.integer = (Integer *) malloc(sizeof(Integer)); - *(variable->val.integer) = *integer_ptr; - variable->val_len = sizeof(Integer); - break; - - case OBJID: - oid_ptr = (Oid *) (pointer + - COLUMN_OFFSET(column->offset)); - variable->val.objid = (Subid *) malloc(oid_ptr->len * - (int32_t)sizeof(Subid)); - (void)memcpy(variable->val.objid, oid_ptr->subids, oid_ptr->len * - (int32_t)sizeof(Subid)); - variable->val_len = oid_ptr->len * - (int32_t)sizeof(Subid); - break; - - case STRING: - case IPADDRESS: - case OPAQUE: - string_ptr = (String *) (pointer + - COLUMN_OFFSET(column->offset)); - variable->val.string = (u_char *) malloc(string_ptr->len); - (void)memcpy(variable->val.string, string_ptr->chars, string_ptr->len); - variable->val_len = string_ptr->len; - break; - } - - break; - - - case NODE: - pdu->error_status = SNMP_ERR_NOSUCHNAME; - pdu->error_index = index_err; - SSAOidZero(&suffix); - return 0; - } - - SSAOidZero(&suffix); - - index_err++; - } - /* Moved this down from the column loop because the cache must be - freed only when the required columns in the row are all read. - - Added pointer check because pointer will point to nothing - if this is a non-column get. - - Added setting cache_output_pointer to NULL because if it is not - NULL, the next iteration of agent_process will try to delete it */ - /* Bug fix 4127458 . Added check to see if entry has been initialized */ - if(ssa_mem_free != 0 && entry != NULL && entry->dealloc != NULL && pointer != NULL){ - /* remember to turn off the caching */ - (*(entry->dealloc))(pointer); - pointer = cache_output_pointer = NULL; - } - - return 0; -} - - -/****************************************************************/ - -/* returns */ -/* 0 in case of success. If we are in the */ -/* FIRST_PASS, we should go to the second pass. */ -/* -1 in case of failure. If we are in the */ -/* FIRST_PASS, we should not go to the */ -/* second pass and no pdu should be sent back. */ -/* 1 If we are in the FIRST_PASS, we should not go */ -/* to the second pass but a pdu */ -/* with an SNMP error should be sent back to its */ -/* originator */ - -static int agent_set(int pass, SNMP_pdu *pdu, char *error_label) -{ - SNMP_variable *variable; - Node *node; - Object *object; - Column *column; - Entry *entry; - Oid suffix; - int index = 1; - Integer integer = 0; - Oid oid = { NULL, 0 }; - String string = { NULL, 0 }; - int snmp_error; - int i; - - /* create index struct */ - IndexType index_obj; - int index_buffer[256]; - - index_obj.len = 0; - index_obj.value = index_buffer; - - error_label[0] = '\0'; - - pdu->type = GET_RSP_MSG; - - for(variable = pdu->first_variable; variable; variable = variable->next_variable) - { - node = node_find(EXACT_ENTRY, &(variable->name), &suffix); - if(node == NULL) - { - pdu->error_status = SNMP_ERR_NOSUCHNAME; - pdu->error_index = index; - return 1; - } - /* we should not forget to free suffix.subids */ - - if(trace_level > 0) - { - trace("!! set(%s): processing the variable %s\n\n", - (pass == FIRST_PASS)? "FIRST_PASS": "SECOND_PASS", - node->label); - } - -/* - if(variable->val.string == NULL) - { - (void)sprintf(error_label, "val.string is NULL for node %s", - node->label); - SSAOidZero(&suffix); - return -1; - } - - if(variable->val_len == 0) - { - (void)sprintf(error_label, "val_len is 0 for node %s", - node->label); - SSAOidZero(&suffix); - return -1; - } -*/ - - switch(node->type) - { - case OBJECT: - object = node->data.object; - - /* check the ASN.1 type */ - if(variable->type != object->asn1_type) - { - (void)sprintf(error_label, "wrong ASN.1 type (0x%x) for node %s", - variable->type, node->label); - SSAOidZero(&suffix); - return -1; - } - - /* check the suffix */ - if( (suffix.len != 1) - || (suffix.subids[0] != 0) ) - { - pdu->error_status = SNMP_ERR_NOSUCHNAME; - pdu->error_index = index; - SSAOidZero(&suffix); - return 1; - } - - /* check the access */ - if( !(object->access & WRITE_FLAG) ) - { - pdu->error_status = SNMP_ERR_READONLY; - pdu->error_index = index; - SSAOidZero(&suffix); - return 1; - } - - /* check the value length */ - switch(object->asn1_type) - { - case INTEGER: - case COUNTER: - case GAUGE: - case TIMETICKS: - case IPADDRESS: - if(variable->val_len != 4) - { - (void)sprintf(error_label, "val_len is not 4 (%d) for node %s", - variable->val_len, node->label); - SSAOidZero(&suffix); - return -1; - } - - if(variable->val.integer == NULL) - { - (void)sprintf(error_label, "val.integer is NULL for node %s", - node->label); - SSAOidZero(&suffix); - return -1; - } - - break; - } - - /* in case of enumerated integer, check the value */ - if( (object->asn1_type == INTEGER) - && (object->first_enum != NULL) ) - { - Enum *enums; - - - integer = *(variable->val.integer); - - for(enums = object->first_enum; enums; enums = enums->next_enum) - { - if(enums->value == integer) - { - break; - } - } - - if(enums == NULL) - { - pdu->error_status = SNMP_ERR_BADVALUE; - pdu->error_index = index; - SSAOidZero(&suffix); - return 1; - } - } - - switch(object->asn1_type) - { - case INTEGER: - case COUNTER: - case GAUGE: - case TIMETICKS: - integer = *(variable->val.integer); - - snmp_error = (*(object->set))(pass, &integer); - break; - - case OBJID: - if(SSAOidInit(&oid, variable->val.objid, - variable->val_len / (int32_t)sizeof(Subid), - error_label)) { - SSAOidZero(&suffix); - return -1; - } - - snmp_error = (*(object->set))(pass, &oid); - SSAOidZero(&oid); - break; - - case STRING: - case IPADDRESS: - case OPAQUE: - if(SSAStringInit(&string, variable->val.string, - variable->val_len, error_label)) { - SSAOidZero(&suffix); - return -1; - } - - snmp_error = (*(object->set))(pass, &string); - SSAStringZero(&string); - break; - } - - if(snmp_error != SNMP_ERR_NOERROR) - { - if(snmp_error < 0) - { - error("the set(%s) method of %s returned %d", - (pass == FIRST_PASS)? "FIRST_PASS": "SECOND_PASS", - node->label, snmp_error); - snmp_error = SNMP_ERR_GENERR; - } - pdu->error_status = snmp_error; - pdu->error_index = index; - SSAOidZero(&suffix); - return 1; - } - - break; - - - case COLUMN: - column = node->data.column; - entry = column->entry; - - /* check the ASN.1 type */ - if(variable->type != column->asn1_type) - { - (void)sprintf(error_label, "wrong ASN.1 type (0x%x) for node %s", - variable->type, node->label); - SSAOidZero(&suffix); - return -1; - } - - /* check the suffix */ - if (suffix.subids == NULL) - { - pdu->error_status = SNMP_ERR_NOSUCHNAME; - pdu->error_index = index; - SSAOidZero(&suffix); - return 1; - } - - /* check the access */ - if( !(column->access & WRITE_FLAG) ) - { - pdu->error_status = SNMP_ERR_READONLY; - pdu->error_index = index; - SSAOidZero(&suffix); - return 1; - } - - /* check the value length */ - switch(column->asn1_type) - { - case INTEGER: - case COUNTER: - case GAUGE: - case TIMETICKS: - case IPADDRESS: - if(variable->val_len != 4) - { - (void)sprintf(error_label, "val_len is not 4 (%d) for node %s", - variable->val_len, node->label); - SSAOidZero(&suffix); - return -1; - } - - if(variable->val.integer == NULL) - { - (void)sprintf(error_label, "val.integer is NULL for node %s", - node->label); - SSAOidZero(&suffix); - return -1; - } - - break; - } - - /* in case of enumerated integer, check the value */ - if( (column->asn1_type == INTEGER) - && (column->first_enum != NULL) ) - { - Enum *enums; - - - integer = *(variable->val.integer); - - for(enums = column->first_enum; enums; enums = enums->next_enum) - { - if(enums->value == integer) - { - break; - } - } - - if(enums == NULL) - { - pdu->error_status = SNMP_ERR_BADVALUE; - pdu->error_index = index; - SSAOidZero(&suffix); - return 1; - } - } - - switch(column->asn1_type) - { - case INTEGER: - case COUNTER: - case GAUGE: - case TIMETICKS: - integer = *(variable->val.integer); - - break; - - case OBJID: - if(SSAOidInit(&oid, variable->val.objid, - variable->val_len / (int32_t)sizeof(Subid), error_label)) { - SSAOidZero(&suffix); - return -1; - } - - break; - - case STRING: - case IPADDRESS: - case OPAQUE: - if(SSAStringInit(&string, variable->val.string, variable->val_len, error_label)) - { - SSAOidZero(&suffix); - return -1; - } - - break; - } - - index_obj.len = suffix.len; - for (i = 0; i < suffix.len; i++) - { - index_obj.value[i] = suffix.subids[i]; - } - - - switch(column->asn1_type) - { - case INTEGER: - case COUNTER: - case GAUGE: - case TIMETICKS: - snmp_error = (*(column->set))(pass, index_obj, &integer); - break; - - case OBJID: - snmp_error = (*(column->set))(pass, index_obj, &oid); - break; - - case STRING: - case IPADDRESS: - case OPAQUE: - snmp_error = (*(column->set))(pass, index_obj, &string); - break; - } - - switch(column->asn1_type) - { - case OBJID: - SSAOidZero(&oid); - break; - - case STRING: - case IPADDRESS: - case OPAQUE: - SSAStringZero(&string); - break; - } - - if(snmp_error != SNMP_ERR_NOERROR) - { - if(snmp_error < 0) - { - error("the set(%s) method of %s returned %d", - (pass == FIRST_PASS)? "FIRST_PASS": "SECOND_PASS", - node->parent->label, - snmp_error); - snmp_error = SNMP_ERR_GENERR; - } - - pdu->error_status = snmp_error; - pdu->error_index = index; - SSAOidZero(&suffix); - return 1; - } - - break; - - - case NODE: - pdu->error_status = SNMP_ERR_NOSUCHNAME; - pdu->error_index = index; - SSAOidZero(&suffix); - return 1; - } - - SSAOidZero(&suffix); - - index++; - } - - return 0; -} - - -/****************************************************************/ - -/* flag == 0 means turn off auto mem free */ -void SSAAutoMemFree(int flag) -{ - ssa_mem_free = flag; -} - - diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/agent.h --- a/usr/src/cmd/agents/snmp/agent/agent.h Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 1996 Sun Microsystems, Inc. All Rights Reserved. - * Use is subject to license terms. - */ - -#ifndef _AGENT_H_ -#define _AGENT_H_ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/***** GLOBAL FUNCTIONS *****/ - -extern int agent_process(Address *address, SNMP_pdu *pdu); - - -#endif diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/agent_msg.h --- a/usr/src/cmd/agents/snmp/agent/agent_msg.h Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,77 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 1997 Sun Microsystems, Inc. All Rights Reserved. - * Use is subject to license terms. - */ -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifndef _AGENT_MSG_H_ -#define _AGENT_MSG_H_ - - -/***** TRACING MESSAGES *****/ - -#define MSG_SIGHUP "signal SIGHUP(%d) received" - -#define MSG_READING_CONFIG "re-reading its configuration file %s..." -#define MSG_CONFIG_READED "...configuration re-read" - - -/***** SYSTEM ERRORS ****/ - -#define ERR_MSG_SOCKET "socket() failed %s" -#define ERR_MSG_BIND "bind() failed on UDP port %d %s" -#define ERR_MSG_SELECT "select() failed %s" -#define ERR_MSG_FORK "fork() failed %s" -#define ERR_MSG_FCLOSE "fclose(%s) failed %s" -#define ERR_MSG_CHDIR "chdir(%s) failed %s" -#define ERR_MSG_OPEN "can't open config file %s %s" -#define ERR_MSG_FSTAT "can't stat config file %s %s" -#define ERR_MSG_MMAP "can't mmap config file %s %s" -#define ERR_MSG_MUNMAP "munmap() failed %s" -#define ERR_MSG_CLOSE "close() failed %s" - - -/***** PDU RELATED ERRORS *****/ - -#define ERR_MSG_PDU_RECEIVED "error while receiving a pdu from %s: %s" -#define ERR_MSG_PDU_PROCESS "unable to process a pdu from %s" -#define ERR_MSG_SNMP_ERROR "SNMP error (%s, %lu) sent back to %s" -#define ERR_MSG_PDU_SEND "error while sending a pdu back to %s: %s" - - -/***** MISCELLANEOUS *****/ - -#define ERR_MSG_ALLOC "cannot allocate memory" - -#define ERR_MSG_MANAGER_DUP "the manager %s already exists" -#define ERR_MSG_COMMUNITY_DUP "the community %s already exists" - -#define ERR_MSG_MY_IP_ADDRESS "unable to get my IP address: %s" - -#define ERR_MSG_VARBIND_LIMIT "unable to handle SNMP request with more than 32 variables" - -#define ERR_MSG_UNKNOWN_FRAGMENT "unknown PDU fragment received from agent %s (%s)" -#define ERR_MSG_AGENT_NOT_RESPONDING "agent %s not responding" - - -#endif diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/amd64/Makefile --- a/usr/src/cmd/agents/snmp/agent/amd64/Makefile Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2004 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include ../Makefile.com -include $(SRC)/lib/Makefile.lib.64 - -install: all $(ROOTLIBS64) $(ROOTLINKS64) diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/conf/agent.conf --- a/usr/src/cmd/agents/snmp/agent/conf/agent.conf Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,69 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# Copyright 1996 Sun Microsystems, Inc. All Rights Reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# - -# -# Configuration file of an SNMP agent -# - -################## -# access control # -################## - -# The list of community names needed for read/write access -# to the entire MIB. -# If the list is empty, the only valid community name is "public" -# and its access type is read-only - -communities = { - public read-only - private read-write -} - -# The list of hosts that can send SNMP queries. -# If this list is empty, all the hosts are allowed to -# send SNMP queries. - -managers = { -} - - -################### -# trap parameters # -################### - -# The community name to be used in traps. - -trap-community = SNMP-trap - -# The list of hosts where traps should be sent to. - -trap-recipients = -{ - splat - panda -} - diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/config.h --- a/usr/src/cmd/agents/snmp/agent/config.h Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1998 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifndef _CONFIG_H_ -#define _CONFIG_H_ - -extern void config_init(char *); -extern void sec_config_init(char *); - -#endif - diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/config.l --- a/usr/src/cmd/agents/snmp/agent/config.l Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,87 +0,0 @@ -%{ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 1996 Sun Microsystems, Inc. All Rights Reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/***** DEFINES *****/ - -/* -#define DEBUG_LEX printf("\tLEX: %s(%d) at line %d\n", yytext, yyval, yylineno); -*/ -#define DEBUG_LEX - - -/***** STATIC VARIABLES *****/ - -static int token_value; - - -%} - -%% - -#.*\n { ; } -[ \t\n]* { ; } - -\{ { DEBUG_LEX return OPENBRACKET; } -\} { DEBUG_LEX return CLOSEBRACKET; } -= { DEBUG_LEX return EQUAL; } -\, { DEBUG_LEX return COMA; } - -[cC][oO][mM][mM][uU][nN][iI][tT][iI][eE][sS] { DEBUG_LEX return COMMUNITIES; } -[rR][eE][aA][dD][-][oO][nN][lL][yY] { DEBUG_LEX return READONLY; } -[rR][eE][aA][dD][-][wW][rR][iI][tT][eE] { DEBUG_LEX return READWRITE; } - -[mM][aA][nN][aA][gG][eE][rR][sS] { DEBUG_LEX return MANAGERS; } - -[tT][rR][aA][pP][-][cC][oO][mM][mM][uU][nN][iI][tT][yY] { DEBUG_LEX return TRAPCOMMUNITY; } -[tT][rR][aA][pP][-][rR][eE][cC][iI][pP][iI][eE][nN][tT][sS] { DEBUG_LEX return TRAPDESTINATORS; } - -[a-zA-Z][_a-zA-Z0-9-]* { DEBUG_LEX return IDENTIFIER; } - -. { error_exit("syntax error in %s at line %d: the token %s is not valid", - config_file, yylineno, yytext); - } - - -%% - -#undef input -#undef unput -#undef output - -/* -# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar) -# define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;} -# define output(c) (void)putc(c,yyout) -*/ - -#define input() (((yytchar=*lexinput++)=='\n'?(yylineno++,yytchar):yytchar)==EOF?0:yytchar) -#define unput(c) {yytchar= (c); if(yytchar=='\n')yylineno--;*--lexinput = yytchar;} -#define output(c) - -/*************************************************************************/ - diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/i386/Makefile --- a/usr/src/cmd/agents/snmp/agent/i386/Makefile Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 1998, 2001 by Sun Microsystems, Inc. -# All rights reserved. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include ../Makefile.com - -install: $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/llib-lssagent --- a/usr/src/cmd/agents/snmp/agent/llib-lssagent Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* LINTLIBRARY */ -/* PROTOLIB1 */ - -#include -#include -#include -#include -#include -#include -#include diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/node.c --- a/usr/src/cmd/agents/snmp/agent/node.c Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,210 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1998 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include -#include -#include -#include - -#include "impl.h" -#include "error.h" -#include "trace.h" - -#include "agent_msg.h" -#include "node.h" - - -/***** STATIC VARIABLES ******/ - -static Node *root_node = &node_table[0]; - - -/*****************************************************************/ - -Node *node_find(int search_type, Oid *name, Oid *suffix) -{ - int i; - Node *parent; - Node *previous; - Node *node; - - - if( (name == NULL) - || (name->len < 1) - || (name->subids[0] != root_node->subid) ) - { - suffix->subids = NULL; - suffix->len = 0; - - if(trace_level > 0) - { - trace("node_find() returned NULL\n\n"); - } - - return NULL; - } - - parent = root_node; - for(i = 1; i < name->len; i++) - { - previous = NULL; - - for(node = parent->first_child; node; node = node->next_peer) - { - if(node->subid > name->subids[i]) - { - switch(search_type) - { - case NEXT_ENTRY: - suffix->len = 0; - suffix->subids = NULL; - - if(trace_level > 0) - { - trace("node_find() returned %s with no suffix\n\n", - node->label); - } - - return node; - - case EXACT_ENTRY: - node = NULL; - break; - } - - break; - } - - if(node->subid == name->subids[i]) - { - parent = node; - break; - } - - previous = node; - } - - if(node == NULL) - { - switch(search_type) - { - case NEXT_ENTRY: - suffix->subids = NULL; - suffix->len = 0; - - if(previous) - { - if(trace_level > 0) - { - if(previous->next) - { - trace("node_find() returned %s with no suffix\n\n", - previous->next->label); - } - else - { - trace("node_find() returned NULL\n\n"); - } - } - - return previous->next; - } - else - { - if(trace_level > 0) - { - if(parent->next) - { - trace("node_find() returned %s with no suffix\n\n", - parent->next->label); - } - else - { - trace("node_find() returned NULL\n\n"); - } - } - - return parent->next; - } - - case EXACT_ENTRY: - suffix->subids = NULL; - suffix->len = 0; - - if(trace_level > 0) - { - trace("node_find() returned NULL\n\n"); - } - - return NULL; - } - } - - if( (node->type == COLUMN) - || (node->type == OBJECT) ) { - suffix->len = name->len - (i + 1); - if (suffix->len) { - suffix->subids = (Subid *) malloc(suffix->len * - (int32_t)sizeof(Subid)); - if (suffix->subids == NULL) { - error(ERR_MSG_ALLOC); - return NULL; - } - - (void)memcpy(suffix->subids, &(name->subids[i + 1]), - suffix->len * (int32_t)sizeof(Subid)); - } else - suffix->subids = NULL; - - if(trace_level > 0) { - trace("node_find() returned %s with suffix %s\n\n", - parent->label, SSAOidString(suffix)); - } - - return node; - } - } - - suffix->len = 0; - suffix->subids = NULL; - - if(trace_level > 0) - { - trace("node_find() returned %s with no suffix\n\n", - node->label); - } - - return node; -} - - -/*****************************************************************/ - - - - diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/node.h --- a/usr/src/cmd/agents/snmp/agent/node.h Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,155 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved. - * Use is subject to license terms. - */ - -#ifndef _NODE_H_ -#define _NODE_H_ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include "asn1.h" -#define COLUMN 1 -#define OBJECT 2 -#define NODE 3 - -#define READ_FLAG 0x1 -#define WRITE_FLAG 0x2 - - -typedef struct _Enum { - struct _Enum *next_enum; - char *label; - Integer value; -} Enum; - -typedef struct _Object { - Oid name; - u_char asn1_type; - Enum *first_enum; - int access; - int type; - int (*get)(); - int (*set)(); - void (*dealloc)(); -} Object; - -typedef struct _Index { - struct _Index *next_index; - char *label; - int index_type; - int index_len; /* for strings only */ - struct _Node *node; -} Index; - -typedef struct _Entry { - struct _Index *first_index; - int n_indexs; - int (*get)(); - void (*dealloc)(); -} Entry; - - -typedef struct _Column { - Oid name; - u_char asn1_type; - Enum *first_enum; - int access; - int type; - int (*get)(); - int (*set)(); - Entry *entry; - int offset; -} Column; - - -typedef struct _Node { - struct _Node *parent; - struct _Node *first_child; - struct _Node *next_peer; - struct _Node *next; - - char *label; - Subid subid; - - int type; - union { - Object *object; - Column *column; - } data; -} Node; - -struct CallbackItem { - Object *ptr; - int type,next; -}; -struct TrapHndlCxt { - char name[256]; - int is_sun_enterprise; - int generic,specific; -}; - -struct TrapEnterpriseInfo { - Subid subids[7]; -}; - -/* Handling arbitrary length enterprise OID in traps */ -struct TrapAnyEnterpriseInfo { - Subid subids[MAX_OID_LEN+1]; -}; - - -extern Enum enum_table[]; -extern int enum_table_size; - -extern Object object_table[]; -extern int object_table_size; - -extern Index index_table[]; -extern int index_table_size; - -extern Entry entry_table[]; -extern int entry_table_size; - -extern Column column_table[]; -extern int column_table_size; - -extern Node node_table[]; -extern int node_table_size; - -extern struct CallbackItem *callItem; -extern int numCallItem; - -extern int *trapTableMap; - -extern struct TrapHndlCxt *trapBucket; -extern int numTrapElem; - -extern struct TrapEnterpriseInfo *trapEnterpriseInfo; -/* For arbitrary length enterprise OID in traps - bug 4133978 */ -extern struct TrapAnyEnterpriseInfo *trapAnyEnterpriseInfo; - - -extern Node *node_find(int search_type, Oid *name, Oid *suffix); - -#endif diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/pagent.c --- a/usr/src/cmd/agents/snmp/agent/pagent.c Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,147 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 1996 Sun Microsystems, Inc. All Rights Reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include -#include -#include -#include -#include -#include - -#include "impl.h" -#include "error.h" -#include "trace.h" -#include "pdu.h" - -#include "pagent.h" -#include "subtree.h" - - -/***** STATIC VARIABLES *****/ - -/* the agent list */ -Agent *first_agent = NULL; - - -/***** STATIC FUNCTIONS *****/ - -static void agent_free(Agent *ap); - - -/****************************************************************/ - -void trace_agents() -{ - Agent *ap; - - - trace("AGENTS:\n"); - for(ap = first_agent; ap; ap = ap->next_agent) - { - trace("\t%-30s %-30s %8d\n", - ap->name, - address_string(&(ap->address)), - ap->timeout); - } - trace("\n"); -} - - -/****************************************************************/ - -/* We must invoke subtree_list_delete() before invoking */ -/* this function because the first_agent_subtree member */ -/* of the agent structures should be NULL */ - -void agent_list_delete() -{ - Agent *ap = first_agent; - Agent *next; - - - while(ap) - { - next = ap->next_agent; - - agent_free(ap); - - ap = next; - } - - first_agent = NULL; - - return; -} - - -/****************************************************************/ - -/* The fisrt_agent_subtree member of the agent */ -/* structure should be NULL */ - -static void agent_free(Agent *ap) -{ - if(ap == NULL) - { - return; - } - - if(ap->first_agent_subtree) - { - error("BUG: agent_free(): first_agent_subtree not NULL"); - } - - free(ap->name); - free(ap); - - return; -} - -/****************************************************************/ - -/* agent_find() is used to check if we have not */ -/* two SNMP agents registered on the same UDP port */ - -Agent *agent_find(Address *address) -{ - Agent *ap; - - - for(ap = first_agent; ap; ap = ap->next_agent) - { - if(ap->address.sin_port == address->sin_port) - { - return ap; - } - } - - return NULL; -} - - -/****************************************************************/ - diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/pagent.h --- a/usr/src/cmd/agents/snmp/agent/pagent.h Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1998, 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _PAGENT_H -#define _PAGENT_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -#define SSA_OPER_STATUS_ACTIVE 1 -#define SSA_OPER_STATUS_NOT_IN_SERVICE 2 -#define SSA_OPER_STATUS_NOT_READY 3 -#define SSA_OPER_STATUS_CREATE_AND_WAIT 4 -#define SSA_OPER_STATUS_DESTROY 5 - -/* - * This macro depends on the AgentStatus field in MIB object in the - * relay agent - */ - -typedef struct _Agent { - int timeout; - int agent_id; - int agent_status; - char *personal_file; - char *config_file; - char *executable; - char *version_string; - char *protocol; - int process_id; - char *name; - int system_up_time; - int watch_dog_time; - - Address address; - struct _Agent *next_agent; - struct _Subtree *first_agent_subtree; - - int tree_index; - int table_index; -} Agent; - - -/* the agent list */ -extern Agent *first_agent; - -/* the address is a unique key for an agent */ -extern Agent *agent_find(Address *address); - -/* We must invoke subtree_list_delete() before invoking */ -/* this function because the first_agent_subtree member */ -/* of the agent structures should be NULL */ -extern void agent_list_delete(void); -extern void trace_agents(void); - -#ifdef __cplusplus -} -#endif - -#endif /* _PAGENT_H */ diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/personal.l --- a/usr/src/cmd/agents/snmp/agent/personal.l Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,150 +0,0 @@ -%{ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* -#define DEBUG_LEX printf("\tLEX: %s(%d) at line %d\n", yytext, yyval, yylineno); -*/ -#define DEBUG_LEX - - -#define QUOTED_STRING_SIZE 100 - -static int lex_bug4163217 = 1; -static char quoted_string[QUOTED_STRING_SIZE]; -static int token_value; - -static void get_quoted_string(); - -%} - -%% - -#.*\n { ; } -[ \t\n]* { ; } -\" { get_quoted_string(); - if (lex_bug4163217) return QUOTEDSTRING; - } - -\{ { DEBUG_LEX if (lex_bug4163217) return OPENBRACKET; } -\} { DEBUG_LEX if (lex_bug4163217) return CLOSEBRACKET; } -\. { DEBUG_LEX if (lex_bug4163217) return DOT; } -= { DEBUG_LEX if (lex_bug4163217) return EQUAL; } -\, { DEBUG_LEX if (lex_bug4163217) return COMA; } -\[ { DEBUG_LEX if (lex_bug4163217) return OPENSQUAREBRACKET; } -\] { DEBUG_LEX if (lex_bug4163217) return CLOSESQUAREBRACKET; } -\- { DEBUG_LEX if (lex_bug4163217) return MINUS; } - -[0-9]+ { DEBUG_LEX token_value = atoi(yytext); - if (lex_bug4163217) return NUMBER; - } - -[mM][aA][cC][rR][oO][sS] { DEBUG_LEX if (lex_bug4163217) return MACROS; } -[aA][gG][eE][nN][tT][sS] { DEBUG_LEX if (lex_bug4163217) return AGENTS; } -[nN][aA][mM][eE] { DEBUG_LEX if (lex_bug4163217) return NAME; } -[sS][uU][bB][tT][rR][eE][eE][sS] { DEBUG_LEX if (lex_bug4163217) return SUBTREES; } -[tT][aA][bB][lL][eE][sS] { DEBUG_LEX if (lex_bug4163217) return TABLES; } -[tT][aA][bB][lL][eE] { DEBUG_LEX if (lex_bug4163217) return TABLE; } -[cC][oO][lL][uU][mM][nN][sS] { DEBUG_LEX if (lex_bug4163217) return COLUMNS; } -[iI][nN][dD][eE][xX][sS] { DEBUG_LEX if (lex_bug4163217) return INDEXS; } -[iI][nN][dD][eE][xX][eE][sS] { DEBUG_LEX if (lex_bug4163217) return INDEXS; } -[tT][iI][mM][eE][oO][uU][tT] { DEBUG_LEX if (lex_bug4163217) return TIMEOUT; } -[pP][oO][rR][tT] { DEBUG_LEX if (lex_bug4163217) return PORT; } -[wW][aA][tT][cC][hH][-_][dD][o0][gG][-_][tT][iI][mM][eE] { DEBUG_LEX if (lex_bug4163217) return WATCHDOGTIME; } - -[cC][oO][mM][mM][uU][nN][iI][tT][iI][eE][sS] { DEBUG_LEX if (lex_bug4163217) return COMMUNITIES; } -[rR][eE][aA][dD][-][oO][nN][lL][yY] { DEBUG_LEX if (lex_bug4163217) return READONLY; } -[rR][eE][aA][dD][-][wW][rR][iI][tT][eE] { DEBUG_LEX if (lex_bug4163217) return READWRITE; } -[mM][aA][nN][aA][gG][eE][rR][sS] { DEBUG_LEX if (lex_bug4163217) return MANAGERS; } -[tT][rR][aA][pP] { DEBUG_LEX if (lex_bug4163217) return TRAP; } -[tT][rR][aA][pP][-][nN][uU][mM] { DEBUG_LEX if (lex_bug4163217) return TRAPNUM; } -[tT][rR][aA][pP][-][cC][oO][mM][mM][uU][nN][iI][tT][yY] { DEBUG_LEX if (lex_bug4163217) return TRAPCOMMUNITY; } -[tT][rR][aA][pP][-][rR][eE][cC][iI][pP][iI][eE][nN][tT][sS] { DEBUG_LEX if (lex_bug4163217) return TRAPDESTINATORS; } - -[aA][cC][lL] { DEBUG_LEX if (lex_bug4163217) return ACL; } -[aA][cC][cC][eE][sS][sS] { DEBUG_LEX if (lex_bug4163217) return ACCESS; } -[hH][oO][sS][tT][sS] { DEBUG_LEX if (lex_bug4163217) return HOSTS; } - -mib-2 { DEBUG_LEX if (lex_bug4163217) return MIB2; } -sun { DEBUG_LEX if (lex_bug4163217) return SUN; } -enterprise { DEBUG_LEX if (lex_bug4163217) return ENTERPRISE; } - -[a-zA-Z\*][_a-zA-Z0-9-]* { DEBUG_LEX if (lex_bug4163217) return IDENTIFIER; } - -. { error_exit("syntax error in %s at line %d: the token %s is not valid", - current_filename, yylineno, yytext); - } - - -%% - -#undef input -#undef unput -#undef output - -/* -# define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar) -# define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;} -# define output(c) (void)putc(c,yyout) -*/ - -#define input() (((yytchar=*lexinput++)=='\n'?(yylineno++,yytchar):yytchar)==EOF?0:yytchar) -#define unput(c) {yytchar= (c); if(yytchar=='\n')yylineno--;*--lexinput = yytchar;} -#define output(c) - -/*************************************************************************/ - -static void get_quoted_string() -{ - int i = 0; - int c; - - - c = input(); - while( (c != 0) && (c != '"') ) - { - if(c == '\n') - { - error_exit("syntax error at line %d: can not have a \\n in a quoted string", yylineno); - } - - if(i < QUOTED_STRING_SIZE - 1) - { - quoted_string[i++] = c; - } - - c = input(); - } - quoted_string[i] = '\0'; - - if(c == 0) - { - error_exit("syntax error at line %d: have not found a quote before the end of file", yylineno); - } -} - - diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/personal.y --- a/usr/src/cmd/agents/snmp/agent/personal.y Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1914 +0,0 @@ -%{ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -%} - -%start configuration - -%token NUMBER -%token MACROS -%token EQUAL -%token OPENBRACKET -%token CLOSEBRACKET -%token IDENTIFIER -%token MIB2 -%token SUN -%token ENTERPRISE -%token DOT -%token AGENTS -%token NAME -%token SUBTREES -%token TABLES -%token TABLE -%token COLUMNS -%token INDEXS -%token TIMEOUT -%token PORT -%token QUOTEDSTRING -%token COMA -%token MINUS -%token OPENSQUAREBRACKET -%token CLOSESQUAREBRACKET -%token WATCHDOGTIME - -/* support SNMP security(5-13-96) */ -%token COMMUNITIES -%token READONLY -%token READWRITE -%token MANAGERS -%token TRAPCOMMUNITY -%token TRAPDESTINATORS -%token ACL -%token ACCESS -%token TRAPNUM -%token HOSTS -%token TRAP - -%{ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "impl.h" -#include "error.h" -#include "trace.h" -#include "pdu.h" - -#include "pagent.h" -#include "subtree.h" - -/** SNMP security (5-13-96) */ -#include "trap.h" -#include "agent_msg.h" -#include "access.h" -#include "snmpd.h" - - -/***** DEFINE *****/ - -/* -#define DEBUG_YACC(string) printf("\t\tYACC: %s: %s at line %d\n", string, yytext, yylineno); -*/ -#define DEBUG_YACC(string) - -#define SNMPRELAY_SUFFIX ".snmprelay" - - -/***** TYPEDEF *****/ - -typedef struct _Macro { - struct _Macro *next_macro; - char *label; - Oid name; -} Macro; - -#include "table.h" -static int table_index=0; - - -/* -typedef struct _Table { - struct _Table *next_table; - Agent *agent; - Oid name; - Subid regTblStartColumn; - Subid regTblEndColumn; - Subid regTblStartRow; - Subid regTblEndRow; -} Table; -*/ - - - -/***** STATIC VARIABLES AND FUNCTIONS *****/ - -/* access control(6-20-96) */ -static AccessServer *static_access_server=NULL; -static AccessPolicy *static_access_policy=NULL; -static Community *static_community=NULL; - -/* trap filter (6-25-96) */ -static SubMember *static_sub_member=NULL; -static Manager *static_host=NULL; -static EFilter *static_filter=NULL; -static int static_trap_low=-1; -static int static_trap_high=-1; - -/* snmp security(5-13-96) */ -static int community_type = 0; -static char *current_filename = NULL; - -/* lexinput points to the current focus point in the config file */ -static char *lexinput; - -/* first_macro is the begining of the list */ -/* of the user defined macros */ - -static Macro *first_macro = NULL; - - -/* first_table is the begining of the list */ -/* of tables supported by the agents */ - -static Table *first_table = NULL; -static Table *last_table = NULL; - - -/* the boolean parsing_oid is used to */ -/* know if we are parsing an */ -/* object identifier or not. */ - -static int parsing_oid = False; - - -/* here are the values of the predifined macros */ -/* that can be used in the configuration file */ - -static Subid subids_mib2[] = { 1, 3, 6, 1, 2, 1 }; -static int mib2_len = 6; -static Subid subids_enterprise[] = { 1, 3, 6, 1, 4, 1 }; -static int enterprise_len = 6; -static Subid subids_sun[] = { 1, 3, 6, 1, 4, 1, 42 }; -static int sun_len = 7; - - -/* the 2 static variables static_subids and */ -/* static_len are used when parsing an */ -/* object identifier. Then the boolean */ -/* parsing_oid should be true. When a new sub- */ -/* identifier (or a list of sub-identifiers) */ -/* is found, we use the function */ -/* subids_cat to append it to the static_subids.*/ - -static Subid *static_subids = NULL; -static int static_len = 0; -static int subids_cat(Subid *subids, int len); - - -/* macro_add() is used to append a macro to */ -/* the macro list. macro_find is used to find */ -/* a macro in the macro list */ - -static Macro *macro_add(char *label, Subid *subids, int len); -static Macro *macro_find(char *label); -static void macro_free(Macro *mp); -static void macro_list_delete(); - - -static void table_free(Table *tp); -static void table_list_delete(); - -extern int SSARegSubagent(Agent *); -extern int SSASubagentOpen(int, char *); -extern int SSARegSubtable(SSA_Table *); - -/* static_label is used when parsing a macro */ -static char *static_label = NULL; - -/* static_agent is used when parsing an agent */ -static Agent *static_agent = NULL; - -/* static_table is used when parsing n table */ -static Table *static_table = NULL; - -/* static_inf_value and static_max_value are */ -/* used when parsing a range */ -static int static_inf_value = -1; -static int static_sup_value = -1; - -static int count; -%} - -%% - - -configuration : agents | macros agents | snmp_security - { - DEBUG_YACC("configuration") - } - -/******************* SNMP security (5-13-96) *********/ -snmp_security : acls trap_block /*trapcommunity trapdestinators*/ - { - DEBUG_YACC("security configuration") - } - -/***************/ -/* accesscontrol */ -/***************/ - -acls : /*empty */ | t_acls t_equal t_openbracket acls_list t_closebracket - { - DEBUG_YACC("acls_list") - } - | t_acls t_equal t_openbracket error t_closebracket - { - error("BUG: acl stmt parsing error at line %d",yylineno); - if(static_access_policy != NULL){ - access_policy_list_free(static_access_policy); - static_access_policy = NULL; - } - } - -acls_list : /*empty*/ | acls_list acl_item - { - DEBUG_YACC("acls_list") - } - -acl_item : t_openbracket - { - static_access_policy = calloc(1,sizeof(AccessPolicy)); - if(static_access_policy == NULL) - { - error("calloc() failed"); - YYERROR; - } - } communities_stmt acl_access - { - if(static_access_policy!=NULL) - static_access_policy->access_type = community_type; - } hosts t_closebracket - { - /* create AccessServer */ - /* put the AccessPolicy into AccessServer */ - /* put AccessServer into corresponding manager */ - static_access_server = NULL; - static_access_policy = NULL; - static_community = NULL; - community_type = 0; - } - -communities_stmt : t_communities t_equal communities_set - { - DEBUG_YACC("communities_stmt"); - } - -communities_set : communities_set t_coma community_elem | community_elem - { - DEBUG_YACC("communities_set"); - } - -community_elem : ct_identifier - { - if(static_access_policy==NULL){ - error("acl statement error"); - YYERROR; - } - /* add community into AccessPolicy */ - static_community = calloc(1, sizeof(Community)); - if(static_community == NULL) - { - error("calloc() failed"); - YYERROR; - } - static_community->name = strdup(yytext); - community_attach(static_access_policy,static_community); - static_community = NULL; - } - -acl_access: t_access t_equal acl_access_type - { - DEBUG_YACC("acl_access") - } - -acl_access_type : t_readonly | t_readwrite - { - DEBUG_YACC("acl_access_type") - } - -hosts : t_managers t_equal hosts_list - { - DEBUG_YACC("hosts") - } - -hosts_list : hosts_list t_coma host_item | host_item - { - DEBUG_YACC("hosts_list"); - } - -host_item : ct_identifier - { - /* add the host item to manager list */ - /* it should return the pointer if exists */ - Manager *res; - - DEBUG_YACC("manager_item") - - res = manager_add(yytext, error_label); - if(res==NULL){ - error("error in %s at line %d: %s", - current_filename? current_filename: -"???", - yylineno, error_label); - } - static_access_server = calloc(1,sizeof(AccessServer)); - if(static_access_server == NULL) - { - error("malloc() failed"); - if(static_access_policy) - access_policy_list_free(static_access_policy); - YYERROR; - } - if(static_access_policy!=NULL) - static_access_policy->count++; - static_access_server->first_acc_policy = static_access_policy; - access_server_add_tail(res,static_access_server); - static_access_server = NULL; - } - - -/************/ -/* managers */ -/************/ - -/* -managers : t_managers t_equal t_openbracket managers_list t_closebracket - { - DEBUG_YACC("agents") - } - - -managers_list : | managers_list list_separator manager_item - { - DEBUG_YACC("managers_list") - } - - -manager_item : ct_identifier - { - Manager *res; - - DEBUG_YACC("manager_item") - - res = manager_add(yytext, error_label); - if(res==NULL){ - error("error in %s at line %d: %s", - current_filename? current_filename: -"???", - yylineno, error_label); - } - } -*/ - -/*** trap hanlding (6-25-96) */ -trap_block : t_trap t_equal t_openbracket trap_list t_closebracket - { - DEBUG_YACC("trap_block") - } - | t_trap t_equal t_openbracket error t_closebracket - { - /* clean up */ - if(static_sub_member != NULL){ - sub_member_free(static_sub_member); - static_sub_member=NULL; - } - } - -trap_list : /*empty*/ | trap_list trap_item - { - DEBUG_YACC("trap_list") - } - -trap_item : t_openbracket - { - /* create submember */ - static_sub_member = calloc(1,sizeof(SubMember)); - if(static_sub_member == NULL) - { - error("malloc() failed"); - YYERROR; - } - } trap_community_string trap_interest_hosts - { - /* attach submember to subgroup */ - } enterprise_list t_closebracket - { - static_sub_member = NULL; - } - -trap_community_string : t_trapcommunity t_equal ct_identifier - { - /* set the community field in submember */ - if(static_sub_member != NULL) - { - static_sub_member->community_string = strdup(yytext); - if(static_sub_member == NULL) - { - error(ERR_MSG_ALLOC); - YYERROR; - } - }else{ - error("BUG: missing trap community name"); - } - } - -trap_interest_hosts : t_hosts t_equal trap_interest_hosts_list - { - DEBUG_YACC("trap_interest_hosts") - } - -trap_interest_hosts_list : trap_interest_hosts_list t_coma - trap_interest_host_item | trap_interest_host_item - { - DEBUG_YACC("trap_interest_hosts_list") - } - -trap_interest_host_item : ct_identifier - { - DEBUG_YACC("trap_interest_host_item") - /* attach host to the submember */ - if(static_sub_member==NULL){ - error("trap statement error"); - YYERROR; - }else{ - static_host = calloc(1,sizeof(Manager)); - if(static_host == NULL) - { - error("malloc() failed"); - YYERROR; - } - static_host->name = strdup(yytext); - if(name_to_ip_address(static_host->name, - &static_host->ip_address,error_label)){ - error("unknown host %s",static_host->name); - free(static_host); - static_host=NULL; - YYERROR; - } - static_host->next_manager = static_sub_member->first_manager; - static_sub_member->first_manager=static_host; - static_host=NULL; - } - } - -enterprise_list : /* empty */ | enterprise_list enterprise_item - { - DEBUG_YACC("enterprise_list") - } - -enterprise_item : t_openbracket enterprise_stmt trap_number_stmt - t_closebracket - { - DEBUG_YACC("enterprise_item") - } - -enterprise_stmt : ENTERPRISE t_equal t_quotedstring - { - /* currently, it supports single enterprise */ - - DEBUG_YACC("enterprise_stmt") - /* add or find the enterprise */ - static_filter = efilter_add(quoted_string,error_label); - if(static_filter==NULL){ - error("error in %s at line %d: %s", - current_filename?current_filename:"???", - yylineno,error_label); - } - } - -trap_number_stmt : t_trap_num t_equal trap_number_list - { - DEBUG_YACC("trap_number_stmt") - } - -trap_number_list : trap_number_item - { - DEBUG_YACC("trap_number_list") - } - | trap_number_list t_coma trap_number_item - { - DEBUG_YACC("trap_number_list") - } - -trap_number_item : trap_range - { - DEBUG_YACC("trap_number_item") - /* for each trap, find/add to the - enterprise, and add_tailthe subgroup - to each trap */ - - if(static_filter!=NULL){ - /* expand the trap */ - mem_filter_join(static_trap_low, - static_trap_high,static_sub_member, - static_filter); - }else{ - error("error in enterprise statement"); - YYERROR; - } - } - -trap_range : NUMBER - { - /* starting trap num */ - static_trap_low = token_value; - } - t_minus NUMBER - { - /* ending trap num */ - static_trap_high = token_value; - } - | NUMBER - { - /* start & end num the same */ - DEBUG_YACC("trap_range") - static_trap_low=static_trap_high=token_value; - } - - -/* -trapcommunity : t_trapcommunity t_equal ct_identifier - { - DEBUG_YACC("trap_community") - - if(trap_community) - { - error("BUG: trap_community not NULL in trap_community"); - } - - trap_community = strdup(yytext); - if(trap_community == NULL) - { - error(ERR_MSG_ALLOC); - YYERROR; - } - } -*/ - -/*******************/ -/* trapdestinators */ -/*******************/ -/* - -trapdestinators : t_trapdestinators t_equal t_openbracket trapdestinators_list t_closebracket - { - DEBUG_YACC("trapdestinators") - } - - -trapdestinators_list : | trapdestinators_list list_separator trapdestinator_item - { - DEBUG_YACC("trapdestinators_list") - } - - -trapdestinator_item : ct_identifier - { - int res; - - DEBUG_YACC("trapdestinator_item") - - res = trap_destinator_add(yytext, error_label); - switch(res) - { - case 0: - break; - - case 1: - error("error in %s at line %d: %s", - current_filename? current_filename: -"???", - yylineno, error_label); - break; - - default: - error("fatal error in %s at line %d: %s", - current_filename? current_filename: -"???", - yylineno, error_label); - YYERROR; - } - } - -*/ - -/******************* SNMP security (5-13-96) *********/ - - - - -/**********/ -/* macros */ -/**********/ - -macros : t_macros t_equal t_openbracket macros_list t_closebracket - { - DEBUG_YACC("macros") - } - - -macros_list : /* empty */ | macros_list macro_item - { - DEBUG_YACC("macros_list") - } - - -macro_item : label t_equal - { - if(parsing_oid != False) - { - error("BUG at line %d: parsing_oid not False in macro_item", yylineno); - } - parsing_oid = True; - - if(static_subids != NULL) - { - error("BUG at line %d: static_subids not NULL in macro_item", yylineno); - } - if(static_len != 0) - { - error("BUG at line %d: static_len not 0 in macro_item", yylineno); - } - } - subids_list - { - DEBUG_YACC("macro_item") - - if(macro_add(static_label, static_subids, static_len) == NULL) - { - error("error at line %d", yylineno); - YYERROR; - } - - parsing_oid = False; - free(static_label); - static_label = NULL; - free(static_subids); - static_subids = NULL; - static_len = 0; - } - - -label : t_identifier - { - DEBUG_YACC("label") - - if(static_label != NULL) - { - error("BUG at line %d: static_label not NULL in label", yylineno); - } - static_label = strdup(yytext); - if(static_label == NULL) - { - error("malloc() failed"); - YYERROR; - } - } - - - -/**********/ -/* agents */ -/**********/ - -agents : t_agents t_equal t_openbracket agents_list t_closebracket - { - DEBUG_YACC("agents") - } - - -agents_list : agent_item | agents_list agent_item - { - DEBUG_YACC("agents_list") - } - - -agent_item : t_openbracket - { - if(static_agent != NULL) - { - error("BUG at line %d: static_agent not NULL in agent", yylineno); - } - static_agent = malloc(sizeof(Agent)); - if(static_agent == NULL) - { - error("malloc() failed"); - YYERROR; - } - (void)memset(static_agent, 0, sizeof(Agent)); - /* LINTED */ - static_agent->agent_id = (int32_t)getpid(); - static_agent->agent_status = SSA_OPER_STATUS_NOT_IN_SERVICE; - static_agent->personal_file = strdup (current_filename); - } - name subtrees_tables timeout optional_watch_dog_time optional_port t_closebracket - { - DEBUG_YACC("agent_item"); - - /* add the agent id to agent, currently, agent_id is pid */ - if(first_agent == NULL) - { - static_agent->next_agent = NULL; - } - else - { - static_agent->next_agent = first_agent; - } - first_agent = static_agent; - - /* if port is 0, assigned a non-reserved available port */ - if(static_agent->address.sin_port == 0 && agent_port_number != -1) - static_agent->address.sin_port = agent_port_number; - else if(static_agent->address.sin_port==0) - static_agent->address.sin_port = - get_a_non_reserved_port(); - if (agent_port_number == -1) - agent_port_number = static_agent->address.sin_port; - - /* the registration is for confirmation and - fill in extra value */ - static_agent->agent_status = SSA_OPER_STATUS_ACTIVE; - if(SSARegSubagent(static_agent) == 0) - { - error("subagent registration failed"); - YYERROR; - } - static_agent = NULL; - } - - -name : t_name t_equal t_quotedstring - { - DEBUG_YACC("name") - - if(static_agent->name != NULL) - { - error("BUG at line %d: static_agent->name not NULL in name", yylineno); - } - static_agent->name = strdup(quoted_string); - if(static_agent->name == NULL) - { - error("malloc() failed"); - YYERROR; - } -/* - * Increased the num. of retries for SSASubagentOpen in order to insure success - * typically for boot time race condition between the master and subagent - * Initial sleep is introduced to increase the probability of success the very - * first time. This could be removed at a later time, after modifying the timeout - * parameters for the subagent - */ - (void)sleep(15); - count=1; - while(count) { - if( (static_agent->agent_id = - SSASubagentOpen(max_agent_reg_retry,static_agent->name)) == INVALID_HANDLER ) - { - if (count == 5) { - error_exit("subagent registration failed"); - YYERROR; - } - } - if (static_agent->agent_id ) break; - count++; - } - if(SSARegSubagent(static_agent) == 0) - { - error("subagent registration failed"); - YYERROR; - } - /* LINTED */ - static_agent->process_id = (int32_t)getpid(); - } - - -subtrees_tables : subtrees tables | subtrees | tables - { - DEBUG_YACC("subtrees_tables") - } - - -subtrees : t_subtrees t_equal t_openbracket - { - if(parsing_oid != False) - { - error("BUG at line %d: parsing_oid is not False in subtrees", yylineno); - } - parsing_oid = True; - - if(static_subids != NULL) - { - error("BUG at line %d: static_subids not NULL in subtrees", yylineno); - } - if(static_len != 0) - { - error("BUG at line %d: static_len not 0 in subtrees", yylineno); - } - } - subtrees_list t_closebracket - { - DEBUG_YACC("subtrees") - - if(parsing_oid != True) - { - error("BUG at line %d: parsing_oid is not True in subtrees", yylineno); - } - parsing_oid = False; - } - - -subtrees_list : /* empty */ | subtrees_list_coma_separated - { - DEBUG_YACC("subtrees_list") - } - - -subtrees_list_coma_separated : subtree_item | subtrees_list_coma_separated t_coma subtree_item - { - DEBUG_YACC("subtrees_list_coma_separated") - } - - -subtree_item : subids_list - { - DEBUG_YACC("subtree_item") - - if(parsing_oid != True) - { - error("BUG at line %d: parsing_oid is not True in subtree_item", yylineno); - } - - if(subtree_add(static_agent, static_subids, static_len) == -1) - { - error("error at line %d", yylineno); - YYERROR; - } - - free(static_subids); - static_subids = NULL; - static_len = 0; - } - - -tables : t_tables t_equal t_openbracket tables_list t_closebracket - { - DEBUG_YACC("tables") - } - - -tables_list : /* empty */ | tables_list table_item - { - DEBUG_YACC("tables_list") - } - - -table_item : t_openbracket - { - if(static_agent == NULL) - { - error("BUG at line %d: static_agent is NULL in table_item", yylineno); - } - - if(static_table) - { - error("BUG at line %d: static_table not NULL in table_item", yylineno); - } - - static_table = calloc(1,sizeof(Table)); - if(static_table == NULL) - { - error("malloc() failed"); - YYERROR; - } - static_table->regTblStatus = - SSA_OPER_STATUS_NOT_IN_SERVICE; - static_table->next_table = NULL; - static_table->agent = static_agent; - if(static_agent!=NULL) - static_table->regTblAgentID = - static_agent->agent_id; - static_table->regTblOID.subids = NULL; - static_table->regTblOID.len = 0; - static_table->regTblStartColumn = 0; - static_table->regTblEndColumn = 0; - static_table->regTblIndex = ++table_index; -/* - static_table->indexs.subids = NULL; - static_table->indexs.len = 0; -*/ - } - table columns indexs t_closebracket - { - DEBUG_YACC("table_item") - - if(static_table == NULL) - { - error_exit("BUG at line %d: static_table is NULL in table_item", yylineno); - } - - /* register the table, if register fails, delete - the table */ - if(SSARegSubtable(static_table)==0){ - /* unregister the table */ - - error_exit("TABLE CONFIG"); - } - - - if(last_table) - { - last_table->next_table = static_table; - } - else - { - first_table = static_table; - } - last_table = static_table; - static_table = NULL; - } - - -table : t_table t_equal - { - if(parsing_oid != False) - { - error("BUG at line %d: parsing_oid is not False in tables", yylineno); - } - - parsing_oid = True; - } - subids_list - { - DEBUG_YACC("table") - - if(parsing_oid != True) - { - error("BUG at line %d: parsing_oid is not True in tables", yylineno); - } - parsing_oid = False; - - if(static_table == NULL) - { - error_exit("BUG at line %d: static_table is NULL in table", yylineno); - } - - static_table->regTblOID.subids = static_subids; - static_subids = NULL; - static_table->regTblOID.len = static_len; - static_len = 0; - } - - -columns : t_columns t_equal range - { - DEBUG_YACC("columns") - - if(static_table == NULL) - { - error_exit("BUG at line %d: static_table is NULL in columns", yylineno); - } - - static_table->regTblStartColumn = static_inf_value; - static_inf_value = -1; - static_table->regTblEndColumn = static_sup_value; - static_sup_value = -1; - } - - -/* -indexs : t_indexs t_equal - { - if(parsing_oid != False) - { - error("BUG at line %d: parsing_oid is not False in indexs", yylineno); - } - - parsing_oid = True; - } - subids_list - { - DEBUG_YACC("indexs") - - if(parsing_oid != True) - { - error("BUG at line %d: parsing_oid is not True in indexs", yylineno); - } - parsing_oid = False; - - if(static_table == NULL) - { - error_exit("BUG at line %d: static_table is NULL in indexs", yylineno); - } - - static_table->indexs.subids = static_subids; - static_subids = NULL; - static_table->indexs.len = static_len; - static_len = 0; - } -*/ - -indexs : t_indexs t_equal range - { - DEBUG_YACC("indexs") - - if(static_inf_value == -1) - { - error("BUG at line %d: static_inf_value is -1", yylineno); - } - if(static_sup_value == -1) - { - error("BUG at line %d: static_sup_value is -1", yylineno); - } - static_table->regTblStartRow = static_inf_value; - static_table->regTblEndRow = static_sup_value; - static_inf_value = -1; - static_sup_value = -1; - } - - -range : t_opensquarebracket t_number - { - if(static_inf_value != -1) - { - error("BUG at line %d: static_inf_value (%d) is not -1 in range", - yylineno, - static_inf_value); - } - - static_inf_value = token_value; - } - t_minus t_number - { - if(static_sup_value != -1) - { - error("BUG at line %d: static_sup_value (%d) is not -1 in range", - yylineno, - static_inf_value); - } - - static_sup_value = token_value; - } - t_closesquarebracket - { - DEBUG_YACC("range") - } - | t_number - { - if(static_inf_value != -1) - { - error("BUG at line %d: static_inf_value (%d) is not -1 in range", - yylineno, - static_inf_value); - } - if(static_sup_value != -1) - { - error("BUG at line %d: static_sup_value (%d) is not -1 in range", - yylineno, - static_sup_value); - } - - static_inf_value = token_value; - static_sup_value = token_value; - } - - -timeout : t_timeout t_equal t_number - { - DEBUG_YACC("subtree") - - static_agent->timeout = token_value; - } - -optional_watch_dog_time : /*empty*/ | t_watch_dog_time t_equal NUMBER - { - DEBUG_YACC("optional_watch_dog_time") - static_agent->watch_dog_time = token_value; - } - -optional_port: /*empty*/ | port - { - DEBUG_YACC("optional_port") - } - -port : t_port t_equal t_number - { - DEBUG_YACC("port") - - if(token_value > 0xFFFF) - { - error("error at line %d: the port number (%d) should not be greater than %d", yylineno, token_value, 0xFFFF); - YYERROR; - } - - /* LINTED */ - static_agent->address.sin_port = (short) token_value; - - if(agent_find(&(static_agent->address))) - { - error("error at line %d: the port number %d is already used by another agent", yylineno, token_value); - YYERROR; - } - } - - - -/***************/ -/* subids_list */ -/***************/ - -subids_list : subid | subids_list t_dot subid - { - DEBUG_YACC("subids_list") - } - - -subid : t_mib2 | t_sun | t_enterprise | t_identifier | t_number - { - DEBUG_YACC("subid") - } - - - -/*******************/ -/* terminal tokens */ -/*******************/ - -/**************** SNMP security (5-13-96) ***/ -ct_identifier : IDENTIFIER - { - DEBUG_YACC("ct_indentifier") - } - -t_communities : COMMUNITIES - { - DEBUG_YACC("t_communities") - } - -t_hosts : HOSTS - { - DEBUG_YACC("t_hosts") - } - -t_acls : ACL - { - DEBUG_YACC("t_acls") - } - -t_access : ACCESS - { - DEBUG_YACC("t_access") - } - -t_readonly : READONLY - { - DEBUG_YACC("t_readonly") - - community_type = READ_ONLY; - } - -t_readwrite : READWRITE - { - DEBUG_YACC("t_readwrite") - - community_type = READ_WRITE; - } - -t_managers : MANAGERS - { - DEBUG_YACC("t_managers") - } - - -t_trap : TRAP - { - DEBUG_YACC("t_trap") - } - -t_trap_num: TRAPNUM - { - DEBUG_YACC("t_trap_num") - } - -t_trapcommunity : TRAPCOMMUNITY - { - DEBUG_YACC("t_trapcommunity") - } - - -/* -t_trapdestinators : TRAPDESTINATORS - { - DEBUG_YACC("t_trapdestinators") - } - -list_separator : | t_coma - { - DEBUG_YACC("list_separator") - } -*/ - - -/**************** SNMP security (5-13-96) ***/ - - -t_number : NUMBER - { - DEBUG_YACC("t_number") - - if(parsing_oid == True) - { - if(subids_cat((Subid *) &token_value, 1) == -1) - { - YYERROR; - } - } - } - - -t_macros : MACROS - { - DEBUG_YACC("t_macros") - } - - -t_equal : EQUAL - { - DEBUG_YACC("t_equal") - } - - -t_minus : MINUS - { - DEBUG_YACC("t_minus") - } - - -t_openbracket : OPENBRACKET - { - DEBUG_YACC("t_openbracket") - } - - -t_closebracket : CLOSEBRACKET - { - DEBUG_YACC("t_closebracket") - } - - -t_opensquarebracket : OPENSQUAREBRACKET - { - DEBUG_YACC("t_opensquarebracket") - } - - -t_closesquarebracket : CLOSESQUAREBRACKET - { - DEBUG_YACC("t_closesquarebracket") - } - - -t_identifier : IDENTIFIER - { - DEBUG_YACC("t_identifier") - - if(parsing_oid == True) - { - Macro *mp; - - - mp = macro_find(yytext); - if(mp == NULL) - { - error("error at line %d: %s is not a macro", yylineno, yytext); - YYERROR; - } - - if(subids_cat(mp->name.subids, mp->name.len) == -1) - { - YYERROR; - } - } - } - - -t_mib2 : MIB2 - { - DEBUG_YACC("t_mib2") - - if(parsing_oid == False) - { - error("BUG at line %d: parsing_oid not True in t_mib2", yylineno); - } - if(subids_cat(subids_mib2, mib2_len) == -1) - { - YYERROR; - } - } - - -t_sun : SUN - { - DEBUG_YACC("t_sun") - - if(parsing_oid == False) - { - error("BUG at line %d: parsing_oid not True in t_sun", yylineno); - } - if(subids_cat(subids_sun, sun_len) == -1) - { - YYERROR; - } - } - - -t_enterprise : ENTERPRISE - { - DEBUG_YACC("t_enterprise") - - if(parsing_oid == False) - { - error("BUG at line %d: parsing_oid not True in t_enterprise", yylineno); - } - if(subids_cat(subids_enterprise, enterprise_len) == -1) - { - YYERROR; - } - } - -t_dot : DOT - { - DEBUG_YACC("t_dot") - } - - -t_agents : AGENTS - { - DEBUG_YACC("t_agents") - } - - -t_name : NAME - { - DEBUG_YACC("t_name") - } - - -t_subtrees : SUBTREES - { - DEBUG_YACC("t_subtrees") - } - - -t_tables : TABLES - { - DEBUG_YACC("t_tables") - } - - -t_table : TABLE - { - DEBUG_YACC("t_table") - } - - -t_columns : COLUMNS - { - DEBUG_YACC("t_columns") - } - - -t_indexs : INDEXS - { - DEBUG_YACC("t_indexs") - } - - -t_timeout : TIMEOUT - { - DEBUG_YACC("t_timeout") - } - -t_watch_dog_time : WATCHDOGTIME - { - DEBUG_YACC("t_watch_dog_time") - } - -t_port : PORT - { - DEBUG_YACC("t_port") - } - - -t_quotedstring : QUOTEDSTRING - { - DEBUG_YACC("t_quotedstring\n") - } - - -t_coma : COMA - { - DEBUG_YACC("t_coma") - } -%% - -#include "personal.lex.c" - -/****************************************************************/ - -static int subids_cat(Subid *subids, int len) -{ - Subid *new_subids; - int new_len; - - - new_len = static_len + len; - /* LINTED */ - new_subids = (Subid *) malloc(new_len * (int32_t)sizeof(Subid)); - if(new_subids == NULL) - { - error("malloc() failed"); - if(static_subids) - { - free(static_subids); - } - static_subids = NULL; - static_len = 0; - return -1; - } - /* LINTED */ - (void)memcpy(new_subids, static_subids, static_len * (int32_t)sizeof(Subid)); - /* LINTED */ - (void)memcpy(&(new_subids[static_len]), subids, len * (int32_t)sizeof(Subid)); - - - if(static_subids) - { - free(static_subids); - } - static_subids = new_subids; - static_len = new_len; - - return 0; -} - - -/****************************************************************/ - -static Macro *macro_add(char *label, Subid *subids, int len) -{ - Macro *new; - - - if(macro_find(label) != NULL) - { - error("%s is already a macro", label); - return NULL; - } - - new = (Macro *) malloc(sizeof(Macro)); - if(new == NULL) - { - error("malloc() failed"); - return NULL; - } - new->label = NULL; - new->name.subids = NULL; - - new->label = strdup(label); - if(new->label == NULL) - { - error("malloc() failed"); - macro_free(new); - return NULL; - } - /* LINTED */ - new->name.subids = (Subid *) malloc(len * (int32_t)sizeof(Subid)); - if(new->name.subids == NULL) - { - error("malloc() failed"); - macro_free(new); - return NULL; - } - /* LINTED */ - (void)memcpy(new->name.subids, subids, len * (int32_t)sizeof(Subid)); - new->name.len = len; - new->next_macro = first_macro; - first_macro = new; - - return new; -} - - -/****************************************************************/ - -static Macro *macro_find(char *label) -{ - Macro *mp; - - - for(mp = first_macro; mp; mp = mp->next_macro) - { - if(strcmp(mp->label, label) == 0) - { - return mp; - } - } - - return NULL; -} - - -/****************************************************************/ - -static void macro_free(Macro *mp) -{ - if(mp == NULL) - { - return; - } - - if(mp->label) - { - free(mp->label); - } - - if(mp->name.subids) - { - free(mp->name.subids); - } - - free(mp); - - return; -} - - -/****************************************************************/ - -static void macro_list_delete() -{ - Macro *mp = first_macro; - Macro *next; - - - while(mp) - { - next = mp->next_macro; - - macro_free(mp); - - mp = next; - } - - first_macro = NULL; - - return; -} - - - -/****************************************************************/ - -int yyerror(char *s) -{ - error("%s at line %d: %s", s, yylineno, yytext); - - return (0); -} - - -/****************************************************************/ - -/* If we have a serious problem, this function will */ -/* terminate (<==> exit) the program */ - -void config_init(char *filename) -{ - struct stat statb; - char *fileaddr; - int fd; - - - yylineno = 1; - - if((fd = open(filename, O_RDONLY)) < 0) - { - error_exit(ERR_MSG_OPEN, - filename, errno_string()); - } - - /* - * get the size of the file - */ - if(fstat(fd, &statb) < 0) - { - error_exit(ERR_MSG_FSTAT, - filename, errno_string()); - } - if(!S_ISREG(statb.st_mode)) - { - error_exit("filename: %s is not a file\n",filename); - } - - /* - * and map it into my address space - */ - if(statb.st_size != 0) - { - /* Purify IPR/IPW error - bug 4124843. yylook wants to - read the last + 1 byte to decide EOF */ - /* LINTED */ - if((fileaddr = (char *) mmap(0, (int32_t)statb.st_size+1, PROT_READ|PROT_WRITE, - MAP_PRIVATE, fd, 0)) <= (char *) 0) - { - error_exit(ERR_MSG_MMAP, - filename, errno_string()); - } - - /* - * set current lex focus on the file - */ - - lexinput = fileaddr; - - /* - * and parse the file - */ - current_filename = filename; - if(yyparse() == 1) - { - error_exit("parsing %s failed", filename); - } - current_filename = NULL; - - /* - * Parsing is finished - * - * unmap the file and close it - */ - - /* Purify IPR/IPW error - bug 4124843 */ - /* LINTED */ - if(munmap(fileaddr, (int32_t)statb.st_size+1) == -1) - { - error(ERR_MSG_MUNMAP, errno_string()); - } - } - else - { - /* empty file, ignore it */ - - error_exit("empty configuration file %s", filename); - } - - if(close(fd) == -1) - { - error(ERR_MSG_CLOSE, errno_string()); - } - - macro_list_delete(); - - - table_list_delete(); - - - if(first_agent == NULL) - { - error_exit("No SNMP agent configured"); - } - - if(trace_level > 0) - { - trace_subtrees(); - trace_agents(); - } -} - - -/****************************************************************/ - -static void table_list_delete() -{ - Table *next; - - while(first_table) - { - next = first_table->next_table; - table_free(first_table); - first_table = next; - } - - first_table = NULL; - last_table = NULL; -} - - -/****************************************************************/ - -static void table_free(Table *tp) -{ - if(tp == NULL) - { - return; - } - - if(tp->regTblOID.subids) - { - free(tp->regTblOID.subids); - } - -/* - if(tp->indexs.subids) - { - free(tp->indexs.subids); - } -*/ - - free(tp); -} - - -/****************************************************************/ - - -/*********** SNMP security (5-13-96) ******/ -/* If we have a serious problem, this function will */ -/* terminate (<==> exit) the program */ - -void sec_config_init(char *filename) -{ - struct stat statb; - char *fileaddr; - int fd; - - - delete_manager_list(); - delete_community_list(); - if(trap_community) - { - free(trap_community); - trap_community = NULL; - } - delete_trap_destinator_list(); - - - yylineno = 1; - - if((fd = open(filename, O_RDONLY)) < 0) - { - error_exit(ERR_MSG_OPEN, - filename, errno_string()); - } - - /* - * get the size of the file - */ - if(fstat(fd, &statb) < 0 ) - { - error_exit(ERR_MSG_FSTAT, - filename, errno_string()); - } - if(!S_ISREG(statb.st_mode)) - { - error_exit("filename: %s is not a file\n",filename); - } - - /* - * and map it into my address space - */ - if(statb.st_size) - { - /* Purify IPR/IPW error - bug 4124843. yylook wants to - read the last + 1 byte to decide EOF */ - /* LINTED */ - if((fileaddr = (char *) mmap(0, (int32_t)statb.st_size+1, PROT_READ|PROT_WRITE, - MAP_PRIVATE, fd, 0)) <= (char *) 0) - { - error_exit(ERR_MSG_MMAP, - filename, errno_string()); - } - - /* - * set current lex focus on the file - */ - - lexinput = fileaddr; - - /* - * and parse the file - */ - - current_filename = filename; - if(yyparse() == 1) - { - error_exit("parsing %s failed", filename); - } - current_filename = NULL; - - /* - * Parsing is finished - * - * unmap the file and close it - */ - - /* Purify IPR/IPW error - bug 4124843 */ - /* LINTED */ - if(munmap(fileaddr, (int32_t)statb.st_size+1) == -1) - { - error(ERR_MSG_MUNMAP, - errno_string()); - } - } - else - { - /* empty file, ignore it */ - - error_exit("empty configuration file %s", filename); - } - - if(close(fd) == -1) - { - error(ERR_MSG_CLOSE, errno_string()); - } - - if(trace_level > 0) - { - trace("\n"); - trace_managers(); - trace_filter(); - trace_trap_destinators(); - } -} -/*********** SNMP security (5-13-96) ******/ - -int yywrap() -{ - return 1; -} - -static int get_a_non_reserved_port() -{ - struct sockaddr_in me; - socklen_t len; - int cnt=0; - int sd; - - sd = socket(AF_INET,SOCK_DGRAM,0); - if(sd<0) return 0; - me.sin_family = AF_INET; - me.sin_addr.s_addr = INADDR_ANY; - - for(;cnt<5;cnt++){ - me.sin_port = htons(0); - if(bind(sd,(struct sockaddr*)&me,sizeof(me))!=0)continue; - len = (socklen_t) sizeof(me); - if(getsockname(sd,(struct sockaddr*)&me, &len)==-1) continue; - (void)close(sd); - return me.sin_port; - } - (void)close(sd); - return 0; -} diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/reg_subtree.c --- a/usr/src/cmd/agents/snmp/agent/reg_subtree.c Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1095 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "asn1.h" -#include "snmp_msg.h" -#include "impl.h" -#include "error.h" -#include "trace.h" -#include "snmp.h" -#include "pdu.h" -#include "request.h" -#include "pagent.h" -#include "subtree.h" -#include "table.h" -#include "trap.h" -#include "node.h" - -#define READ_COMM "public" -#define WRITE_COMM "private" - -#define REG_AGENT_ID 1 -#define REG_AGENT_STATUS 2 -#define REG_AGENT_TIME_OUT 3 -#define REG_AGENT_PORT_NUMBER 4 -#define REG_AGENT_PERSONAL_FILE 5 -#define REG_AGENT_CONFIG_FILE 6 -#define REG_AGENT_EXECUTABLE 7 -#define REG_AGENT_VERSION_NUM 8 -#define REG_AGENT_PROCESS_ID 9 -#define REG_AGENT_NAME 10 -#define REG_AGENT_SYSTEM_UP_TIME 11 - -#define REG_TREE_INDEX 1 -#define REG_TREE_AGENT_ID 2 -#define REG_TREE_OID 3 -#define REG_TREE_STATUS 4 - -#define REG_TBL_INDEX 1 -#define REG_TBL_AGENT_ID 2 -#define REG_TBL_OID 3 -#define REG_TBL_SCOL 4 -#define REG_TBL_ECOL 5 -#define REG_TBL_SROW 6 -#define REG_TBL_EROW 7 -#define REG_TBL_STATUS 8 -#define FAIL 0 -#define SUCCESS 1 - -#define SNMP_COMM_MAX 32 -#define AGENT_CONFIG_FILE "/etc/snmp/conf/snmpd.conf" -#define MAX_CONFIG_FILE 128 -char snmp_fullmib_read_community[SNMP_COMM_MAX] = {NULL}; -char agent_config_file[MAX_CONFIG_FILE] = AGENT_CONFIG_FILE; - -int set_conf_word(); -int agent_read_config(); - -struct cmd { - char *name; - int (*rtn)(); - char *arg1; - int arg2; -} cmds[] = { - { "read-community", set_conf_word, - snmp_fullmib_read_community, SNMP_COMM_MAX }, - { 0, 0, 0, 0} -}; - -/* global variable */ -struct CallbackItem *callItem = NULL; -int numCallItem=0; -int *trapTableMap=NULL; -struct TrapHndlCxt *trapBucket=NULL; -struct TrapEnterpriseInfo *trapEnterpriseInfo=NULL; -/* For arbitrary length enterprise OID in traps - bug 4133978 */ -struct TrapAnyEnterpriseInfo *trapAnyEnterpriseInfo=NULL; -int numTrapElem=0; -extern int dont_read_config_file; - -static Subid reg_subagent_subids[] = { 1,3,6,1,4,1,42,2,15,8,1,0,0 }; -static Oid reg_subagent_oid = {reg_subagent_subids, 13 }; - -static Subid agent_tbl_index_subids[] = { 1,3,6,1,4,1,42,2,15,9,0 }; -static Oid agent_tbl_index_oid = { agent_tbl_index_subids, 11 }; -static Subid reg_tree_ra_subids[] = { 1,3,6,1,4,1,42,2,15,12,1,3,0,0}; -static Oid reg_tree_ra_oid = { reg_tree_ra_subids, 14}; - -static Subid ra_trap_port_subids[] = { 1,3,6,1,4,1,42,2,15,4,0}; -static Oid ra_trap_port_oid = { ra_trap_port_subids, 11}; - -static Subid ra_check_point_subids[] = { 1,3,6,1,4,1,42,2,15,5,0}; -static Oid ra_check_point_oid = { ra_check_point_subids, 11}; - -/* last three numbers are columar obj, agentid, table_id */ -static Subid reg_shared_table_subids[] = { 1,3,6,1,4,1,42,2,15,10,1,0,0,0}; -static Oid reg_shared_table_oid = { reg_shared_table_subids, 14}; - -static int _SSASendTrap_generic(char *, int); -static int _SSASendTrap_generic2(char *, int, IndexType *); - -/* - * agent table id can be: from command line, global var. sap_agent_tbl_id, - * or from getpid(). The agent_id can be less than one. - */ -int -sap_glb_agent_table_id() -{ - return((int)getpid()); -} - -SNMP_variable * -sap_append_integer_variable(SNMP_variable *list, Oid *oid, int num) -{ - SNMP_value value; - - value.v_integer = num; - list = snmp_typed_variable_append(list,oid,INTEGER,&value,error_label); - if(list == NULL){ - error("sap_append_integer_variable failed: oid: %s, value: %d\n", - SSAOidString(oid),num); - } - return(list); -} - -SNMP_variable * -sap_append_variable(SNMP_variable *list, Oid *oid, int num, int type) -{ - SNMP_value value; - - value.v_integer = num; - list = snmp_typed_variable_append(list,oid,type,&value,error_label); - if(list == NULL){ - error("sap_append_variable failed: oid: %s, value: %d, type: %d\n", - SSAOidString(oid),num,type); - } - return(list); -} - -SNMP_variable *sap_append_string_variable(SNMP_variable *list, Oid *oid, char* str) -{ - SNMP_value value; - - if(str == NULL) return NULL; - value.v_string.chars = (u_char *)str; - /* LINTED */ - value.v_string.len = (int)strlen(str); - list = snmp_typed_variable_append(list,oid,STRING,&value,error_label); - if(list == NULL){ - error("sap_append_string_variable failed: oid: %s, value: %s\n" - , SSAOidString(oid),str); - } - return(list); -} - -SNMP_variable *sap_append_oid_variable(SNMP_variable *list, Oid *oid, Oid* name) -{ - SNMP_value value; - - if(oid == NULL || name == NULL) return NULL; - value.v_oid.subids = name->subids; - value.v_oid.len = name->len; - list = snmp_typed_variable_append(list,oid,OBJID,&value,error_label); - if(list == NULL){ - error("sap_append_oid_varaible(%s,%s) failed\n", - SSAOidString(oid),SSAOidString(name)); - } - return(list); -} - - -SNMP_variable *reg_subagent_form_variables(Agent *agent,SNMP_variable *list) -{ - struct tms buffer; - clock_t system_up_time; - - if(agent == NULL){ return NULL; } - - /* set up the index */ - reg_subagent_oid.subids[reg_subagent_oid.len-1] = agent->agent_id; - - reg_subagent_oid.subids[reg_subagent_oid.len-2] = REG_AGENT_PROCESS_ID; - list = sap_append_integer_variable(list,®_subagent_oid,agent->process_id); - if(list == NULL) return list; - - if(agent->agent_status!=0){ - reg_subagent_oid.subids[reg_subagent_oid.len-2] = REG_AGENT_STATUS; - list = sap_append_integer_variable(list,®_subagent_oid,agent->agent_status); - if(list == NULL) return list; - reg_subagent_oid.subids[reg_subagent_oid.len-2] = - REG_AGENT_SYSTEM_UP_TIME; - system_up_time = times(&buffer); - list = sap_append_variable(list, ®_subagent_oid, - /* LINTED */ - (uint32_t)system_up_time, - TIMETICKS); - if(list == NULL) return list; - } - - reg_subagent_oid.subids[reg_subagent_oid.len-2] = REG_AGENT_TIME_OUT; - list = sap_append_integer_variable(list,®_subagent_oid,agent->timeout); - if(list == NULL) return list; - - reg_subagent_oid.subids[reg_subagent_oid.len-2] = REG_AGENT_PORT_NUMBER; - list = sap_append_integer_variable(list,®_subagent_oid,agent->address.sin_port); - if(list == NULL) return list; - - if(agent->personal_file != NULL){ - reg_subagent_oid.subids[reg_subagent_oid.len-2] = - REG_AGENT_PERSONAL_FILE; - list = sap_append_string_variable(list,®_subagent_oid,agent->personal_file); - if(list == NULL) return list; - } - - if(agent->config_file != NULL) { - reg_subagent_oid.subids[reg_subagent_oid.len-2] = - REG_AGENT_CONFIG_FILE; - list = sap_append_string_variable(list,®_subagent_oid,agent->config_file); - if(list == NULL) return list; - } - - if(agent->executable != NULL) { - reg_subagent_oid.subids[reg_subagent_oid.len-2] = - REG_AGENT_EXECUTABLE; - list = sap_append_string_variable(list,®_subagent_oid,agent->executable); - if(list == NULL) return list; - } - - if(agent->version_string != NULL) { - reg_subagent_oid.subids[reg_subagent_oid.len-2] = - REG_AGENT_VERSION_NUM; - list = sap_append_string_variable(list,®_subagent_oid,agent->version_string); - if(list == NULL) return list; - } - - if(agent->name != NULL) { - reg_subagent_oid.subids[reg_subagent_oid.len-2] = - REG_AGENT_NAME; - list = sap_append_string_variable(list,®_subagent_oid,agent->name); - if(list == NULL) return list; - } - - - return(list); - -} - -/* - * temporary using the process id as the agent id - * set the following variables, - * xtimeout - * xportnumber - * xpersonal file - * xconfig file - * executable - * version number - * protocol - * xprocess id - * xagentname - */ -static SNMP_pdu *send_request_to_agent(SNMP_variable *list, int type, - char* community, int port, struct timeval *timeout, - IPAddress *agent_addr) -{ - SNMP_pdu *request, *response=NULL; - - error_label[0] = '\0'; - - request = request_create( (community==NULL?"public":community), type, error_label); - if(request == NULL) - { - return NULL; - } - - if(list == NULL){ - snmp_pdu_free(request); - error("SSARegSubagent failed\n"); - return NULL; - } - - request->first_variable = list; - - /* later change the timeout to user-provided number */ - response = - request_send_to_port_time_out_blocking(agent_addr, port,timeout, request, error_label); - snmp_pdu_free(request); - return response; -} - -SNMP_pdu * -send_request_to_relay_agent(SNMP_variable *list, int type) -{ - char *community = READ_COMM; - struct timeval timeout; - static int my_ip_address_initialized = False; - static IPAddress my_ip_address; - - if (my_ip_address_initialized == False) { - if (get_my_ip_address(&my_ip_address, error_label)) - return (NULL); - my_ip_address_initialized = True; - } - timeout.tv_sec = 100; - timeout.tv_usec = 0; - - if (type == SET_REQ_MSG) - community = WRITE_COMM; - - return (send_request_to_agent(list, type, community, SNMP_PORT, - &timeout, &my_ip_address)); -} - - -static SNMP_variable *create_variable(Oid *name) -{ - SNMP_variable *new; - if((new = snmp_variable_new(error_label)) == NULL) - return NULL; - if(SSAOidCpy(&(new->name),name,error_label)) - { - snmp_variable_free(new); - return NULL; - } - new->type = NULLOBJ; - return new; -} - -int -sap_avail_index(Oid *name, int type) -{ - SNMP_pdu *response; - SNMP_variable *new, *variable; - int idx = 0; - - if ((new = create_variable(name)) == NULL) - return (idx); - - response = send_request_to_relay_agent(new,type); - - if (response == NULL) - return (idx); - - if (response->error_status) { - (void)sprintf(error_label, "%s", - error_status_string(response->error_status)); - snmp_pdu_free(response); - return (idx); - } - - /* need checking the response */ - variable = response->first_variable; - if (SSAOidCmp(&(variable->name), name) - || (variable->type != INTEGER) - || (variable->val.integer == NULL) - || (variable->val_len != sizeof (int)) ) { - (void)sprintf(error_label, ERR_MSG_BAD_RESPONSE); - snmp_pdu_free(response); - return (idx); - } - - idx = *(variable->val.integer); - snmp_pdu_free(response); - return (idx); -} - -/* - * send a request to an agent, return TRUE, if agent response - * otherwise, FALSE - */ -static int probe_agent(Oid *name, int type, char *community, int port, - struct timeval *timeout,IPAddress *agent_addr) -{ - SNMP_pdu *response; - SNMP_variable *new, *variable; - static int my_ip_address_initialized = False; - static IPAddress my_ip_address; - - if(my_ip_address_initialized == False) - { - if(get_my_ip_address(&my_ip_address, error_label)) - { - return NULL; - } - my_ip_address_initialized = True; - } - - if( (new = create_variable(name)) == NULL ) - return -1; - response = send_request_to_agent(new,type,community,port,timeout, - agent_addr!=NULL?agent_addr:&my_ip_address); - if(response == NULL) - { - return FALSE; - } - - - /* need checking the response */ - variable = response->first_variable; - if(SSAOidCmp(&(variable->name), name) ) - { - snmp_pdu_free(response); - return FALSE; - } - snmp_pdu_free(response); - return(TRUE); -} - -/* - * agent_addr == NULL => use the local host address - * community == NULL => public - */ -int -SSAAgentIsAlive(IPAddress *agent_addr, int port, char *community, - struct timeval *timeout) -{ - static Subid system_service_subids[] = {1, 3, 6, 1, 2, 1, 1, 7, 0}; - static Oid system_service_oid = { system_service_subids, 9}; - if (agent_read_config() == -1) { - perror("Can not read configuration file "); - return (-1); - } - community = snmp_fullmib_read_community; - -return (probe_agent(&system_service_oid, GET_REQ_MSG, - community != NULL ? community: "public", - port, timeout, agent_addr)); -} - -int -get_available_index_from_relay_agent() -{ - return(sap_avail_index(&agent_tbl_index_oid,GET_REQ_MSG)); -} - -int -bump_index_of_relay_agent(int num) -{ - SNMP_variable *variable=NULL; - SNMP_pdu *response; - int idx = 0; - - variable = sap_append_integer_variable(variable,&agent_tbl_index_oid,num++); - - if(variable == NULL) - return idx; - - response = send_request_to_relay_agent(variable,SET_REQ_MSG); - - if(response == NULL) - return idx; - - if(response->error_status) { - (void)sprintf(error_label, "%s", - error_status_string(response->error_status)); - snmp_pdu_free(response); - return idx; - } - - /* need checking the response */ - variable = response->first_variable; - if(SSAOidCmp(&(variable->name), &agent_tbl_index_oid) - || (variable->type != INTEGER) - || (variable->val.integer == NULL) - || (variable->val_len != sizeof(int)) ) - { - (void)sprintf(error_label, ERR_MSG_BAD_RESPONSE); - snmp_pdu_free(response); - return idx; - } - idx = *(variable->val.integer); - snmp_pdu_free(response); - return(idx); -} - -int check_dup_agent_name(char *agent_name) -{ - SNMP_variable *variable=NULL; - SNMP_pdu *response; - int res=TRUE; - - variable = sap_append_string_variable(variable,&ra_check_point_oid,agent_name); - if(variable == NULL) return res; - response = send_request_to_relay_agent(variable,SET_REQ_MSG); - if(response == NULL) - { - return res; - } - - if(response->error_status) - { - (void)sprintf(error_label, "%s", - error_status_string(response->error_status)); - snmp_pdu_free(response); - return res; - } - - /* need checking the response */ - variable = response->first_variable; - if(SSAOidCmp(&(variable->name), &ra_check_point_oid) - || (variable->type != STRING) - || (variable->val.string == NULL) - || (variable->val_len == 0) ) - { - (void)sprintf(error_label, ERR_MSG_BAD_RESPONSE); - snmp_pdu_free(response); - return res; - } - res = FALSE; - snmp_pdu_free(response); - /*snmp_variable_free(variable);this mem. is freed above*/ - return(res); -} - - -/* - * mechanism for getting agent id - * first, set relayCheckPoint to agent name - * second, if first successful(no agent name dup.), get the available id - */ -int -SSASubagentOpen(int num_of_retry, char* agent_name) -{ - int i, index; - - if (trace_level > 0) - trace("SSASubagent called with %s\n", agent_name); - - if (check_dup_agent_name(agent_name) == TRUE) - return INVALID_HANDLER; - - for (i = 0; i < num_of_retry; i++) { - if ((index = get_available_index_from_relay_agent()) == 0) - return INVALID_HANDLER; - index++; - if ((bump_index_of_relay_agent(index)) == index ) - return index - 1; - else - if (i > num_of_retry) - return INVALID_HANDLER; - } - return INVALID_HANDLER; -} - -int -SSARegSubagent(Agent* agent) -{ - SNMP_variable *list=NULL; - SNMP_pdu *response; - - /* form variable list */ - list = reg_subagent_form_variables(agent,list); - - if(list == NULL){ - error("SSARegSubagent failed\n"); - return 0; - } - - response = send_request_to_relay_agent(list,SET_REQ_MSG); - if(response == NULL) - return 0; - - if(response->error_status) - { - (void)sprintf(error_label, "%s", - error_status_string(response->error_status)); - snmp_pdu_free(response); - return 0; - } - - snmp_pdu_free(response); - - return 1; -} - - -/* - * register the subtree, index is AgentID.RegTreeIndex - * if the registration is not accepted by the relay agent, - * the error_status is non-zero - */ -int SSARegSubtree(SSA_Subtree *subtree) -{ - Oid *tree_oid = &(subtree->name); - int agent_id = subtree->regTreeAgentID; - SNMP_variable *list=NULL; - SNMP_pdu *response; - int idx = subtree->regTreeIndex; - - /* form variable list */ - reg_tree_ra_oid.subids[reg_tree_ra_oid.len-1] = idx; - reg_tree_ra_oid.subids[reg_tree_ra_oid.len-2] = agent_id; - - if (subtree->regTreeStatus != SSA_OPER_STATUS_NOT_IN_SERVICE) { - reg_tree_ra_oid.subids[reg_tree_ra_oid.len-3] = REG_TREE_OID; - list = sap_append_oid_variable(list,®_tree_ra_oid,tree_oid); - if(list == NULL) return 0; - } - - reg_tree_ra_oid.subids[reg_tree_ra_oid.len-3] = REG_TREE_STATUS; - list = sap_append_integer_variable(list,®_tree_ra_oid,subtree->regTreeStatus); - if(list == NULL) return 0; - - response = send_request_to_relay_agent(list,SET_REQ_MSG); - if(response == NULL) - { - return 0; - } - - if(response->error_status) - { - (void)sprintf(error_label, "%s", - error_status_string(response->error_status)); - snmp_pdu_free(response); - return 0; - } - -/* needs checking - variable = response->first_variable; - if(variable->next_variable - || SSAOidCmp(&(variable->name), ®_tree_ra_oid) - || (variable->type != OBJID) - || (variable->val_len/sizeof(Subid) != tree_oid->len) ) - { - (void)sprintf(error_label, ERR_MSG_BAD_RESPONSE); - snmp_pdu_free(response); - return 0; - } -*/ - snmp_pdu_free(response); - - return idx; - -} - -int SSARegSubtable(SSA_Table *table) -{ - Oid *table_oid = &(table->regTblOID); - int agent_id = table->regTblAgentID; - SNMP_variable *list=NULL; - SNMP_pdu *response; - int idx = table->regTblIndex; - - /* form variable list */ - reg_shared_table_oid.subids[reg_shared_table_oid.len-1] = idx; - reg_shared_table_oid.subids[reg_shared_table_oid.len-2] = agent_id; - - reg_shared_table_oid.subids[reg_shared_table_oid.len-3] = REG_TBL_OID; - list = sap_append_oid_variable(list,®_shared_table_oid,table_oid); - if(list == NULL) return 0; - - reg_shared_table_oid.subids[reg_shared_table_oid.len-3] = REG_TBL_SCOL; - list = sap_append_integer_variable(list,®_shared_table_oid,table->regTblStartColumn); - if(list == NULL) return 0; - - reg_shared_table_oid.subids[reg_shared_table_oid.len-3] = REG_TBL_ECOL; - list = sap_append_integer_variable(list,®_shared_table_oid,table->regTblEndColumn); - if(list == NULL) return 0; - - reg_shared_table_oid.subids[reg_shared_table_oid.len-3] = REG_TBL_SROW; - list = sap_append_integer_variable(list,®_shared_table_oid,table->regTblStartRow); - if(list == NULL) return 0; - - reg_shared_table_oid.subids[reg_shared_table_oid.len-3] = REG_TBL_EROW; - list = sap_append_integer_variable(list,®_shared_table_oid,table->regTblEndRow); - if(list == NULL) return 0; - - - reg_shared_table_oid.subids[reg_shared_table_oid.len-3] = REG_TBL_STATUS; - list = sap_append_integer_variable(list,®_shared_table_oid,table->regTblStatus); - if(list == NULL) return 0; - - response = send_request_to_relay_agent(list,SET_REQ_MSG); - if(response == NULL) - { - return 0; - } - - if(response->error_status) - { - (void)sprintf(error_label, "%s", - error_status_string(response->error_status)); - snmp_pdu_free(response); - return 0; - } - -/* needs checking - variable = response->first_variable; - if(variable->next_variable - || SSAOidCmp(&(variable->name), ®_shared_table_oid) - || (variable->type != OBJID) - || (variable->val_len/sizeof(Subid) != table_oid->len) ) - { - (void)sprintf(error_label, ERR_MSG_BAD_RESPONSE); - snmp_pdu_free(response); - return 0; - } -*/ - snmp_pdu_free(response); - - return idx; - -} - - -int SSAGetTrapPort() { - - if (dont_read_config_file == TRUE) - return (SNMP_TRAP_PORT); - - /* not agent_tbl_index_oid, but trap_port_number */ -return (sap_avail_index(&ra_trap_port_oid, GET_REQ_MSG)); -} - -static int search_trap_num(char* name) -{ - int idx; - if(!name) return -1; - for(idx=0;idxname.subids; - oidLen = ptr->name.len; - for(j=0;jname.subids[j]; - tempArray[oidLen]=0; - ptr->name.len=oidLen+1; - ptr->name.subids=&(tempArray[0]); - - if((ptr->asn1_type == INTEGER) | (ptr->asn1_type == GAUGE) | (ptr->asn1_type == COUNTER) | (ptr->asn1_type == TIMETICKS)){ - ptr->get(&val_integer); - variables = ssa_append_integer_variable(variables,&(ptr->name),val_integer,error_label, ptr->asn1_type); - }else if(ptr->asn1_type == STRING){ - ptr->get(&val_str); - variables = ssa_append_string_variable(variables,&(ptr->name),val_str,error_label); - /* Memory leak fix */ - free((void *)(val_str.chars)); - - }else if(ptr->asn1_type == OBJID){ - ptr->get(&val_oid); - variables = ssa_append_oid_variable(variables,&(ptr->name),val_oid,error_label); - /* Memory leak fix */ - free((void *)(val_oid.subids)); - } - ptr->name.len=oidLen; - ptr->name.subids=oldArray; - - num = callItem[num].next; - if(num <0 ) ptr=NULL; - else ptr = callItem[num].ptr; - } - - time_stamp = -1U; - - if (trap_send_with_more_para(&dest_ip_address, - my_ip_address, NULL, 1, &ent_oid, - generic, specific, trap_port, - time_stamp, variables, error_label)) - (void)printf("trap_send fails!\n"); - - /* Memory leak fix */ - snmp_variable_list_free(variables); - return 0; -} - -static int _SSASendTrap_generic2(char *name, int mode, IndexType *pindex_obj) -{ - IPAddress dest_ip_address, my_ip_address; - int generic; - int specific; - uint32_t time_stamp; - int trap_port = SSAGetTrapPort(); - SNMP_variable *variables=NULL; - Integer val_integer; - String val_str={NULL,0}; - - Oid val_oid, ent_oid; - Subid ent_subids[MAX_OID_LEN]; - int num; - Object *ptr; - int trapNum; - int i; - int n; - Subid tempArray[MAX_OID_LEN],*oldArray; - int oidLen, j; - int length; - - if(!trapBucket) return -1; - - if((trapNum=search_trap_num(name))==-1) return -1; - - if(get_my_ip_address(&dest_ip_address,error_label)== -1) return -1; - if(get_my_ip_address(&my_ip_address,error_label)== -1) return -1; - - generic = trapBucket[trapNum].generic; - specific = trapBucket[trapNum].specific; - - num = trapTableMap[trapNum]; - ptr=callItem[num].ptr; - - - if ( mode == 2 ) { /*_SSASendTrap2*/ - ent_oid.subids = ent_subids; - ent_oid.len = sun_oid.len; - for (i=0;i<7;i++) - ent_subids[i]=trapEnterpriseInfo[trapNum].subids[i]; - } - - /* Handling arbitrary length OIDs. Retaining _SSASendTrap2 to maintain - backward compatibility with subagents created using old mibcodegen - Bug 4133978 */ - if ( mode == 3 ) { /*_SSASendTrap3*/ - Subid k; - ent_oid.subids = ent_subids; - for (i=0;(k=trapAnyEnterpriseInfo[trapNum].subids[i]) !=-1;i++) - ent_subids[i]=k; - ent_oid.len = i; - } - - n=0; /* index to an array of an indices. Point to the first index */ - while(num != -1 && ptr){ - - /* Appending a zero at the end: Bug ID 4103570*/ - oldArray=ptr->name.subids; - oidLen = ptr->name.len; - for(j=0;jname.subids[j]; - tempArray[oidLen]=0; - ptr->name.len=oidLen+1; - length = (ptr->name.len -1); /* for non-scalars don't add trailing yet */ - ptr->name.subids=&(tempArray[0]); - if (ptr->type == 1) { /* scalar value */ - if((ptr->asn1_type == INTEGER) | (ptr->asn1_type == GAUGE) | (ptr->asn1_type == COUNTER) | (ptr->asn1_type == TIMETICKS)){ - ptr->get(&val_integer); - variables = ssa_append_integer_variable(variables,&(ptr->name),val_integer,error_label,ptr->asn1_type); - n++; /* Yes, even scalars need a dummy index */ - }else if(ptr->asn1_type == STRING){ - ptr->get(&val_str); - variables = ssa_append_string_variable(variables,&(ptr->name),val_str,error_label); - /* Memory leak fix */ - free((void *)(val_str.chars)); - n++; - }else if(ptr->asn1_type == OBJID){ - ptr->get(&val_oid); - variables = ssa_append_oid_variable(variables,&(ptr->name),val_oid,error_label); - /* Memory leak fix */ - free((void *)(val_oid.subids)); - n++; - } - } else /* tabular value = 2 */ - { if ((ptr->asn1_type == INTEGER) | (ptr->asn1_type == GAUGE) | (ptr->asn1_type == COUNTER) | (ptr->asn1_type == TIMETICKS)){ - ptr->get(EXACT_ENTRY,&val_integer,&pindex_obj[n]); - for (i=0; i<= pindex_obj[n].len; i++) - ptr->name.subids[length+i] = pindex_obj[n].value[i]; - length = length + pindex_obj[n].len; - ptr->name.len = length; - ptr->name.subids[length] = 0; /* append the trailing Zero */ - variables = ssa_append_integer_variable(variables,&(ptr->name),val_integer,error_label,ptr->asn1_type); - n++; /* done with this index, increment to index for next trap variable */ - }else if(ptr->asn1_type == STRING){ - ptr->get(EXACT_ENTRY,&val_str,&pindex_obj[n]); - for (i=0; i<= pindex_obj[n].len; i++) - ptr->name.subids[length+i] = pindex_obj[n].value[i]; - length = length + pindex_obj[n].len; - ptr->name.len = length; - ptr->name.subids[length] = 0; /* append the trailing Zero */ - variables = ssa_append_string_variable(variables,&(ptr->name),val_str,error_label); - /* Memory leak fix */ - free((void *)(val_str.chars)); - n++; /* index for next trap variable */ - }else if(ptr->asn1_type == OBJID){ - ptr->get(EXACT_ENTRY,&val_oid,&pindex_obj[n]); - for (i=0; i<= pindex_obj[n].len; i++) - ptr->name.subids[length+i] = pindex_obj[n].value[i]; - length = length + pindex_obj[n].len; - ptr->name.len = length; - ptr->name.subids[length] = 0; /* append the trailing Zero */ - variables = ssa_append_oid_variable(variables,&(ptr->name),val_oid,error_label); - /* Memory leak fix */ - free((void *)(val_oid.subids)); - n++; /* index for next trap variable */ - } - - } /* else */ - - - ptr->name.len=oidLen; - ptr->name.subids=oldArray; - - num = callItem[num].next; - if(num <0 ) ptr=NULL; - else ptr = callItem[num].ptr; - } - - time_stamp = -1U; - - if (trap_send_with_more_para(&dest_ip_address, - my_ip_address, NULL, 1, &ent_oid, - generic, specific, trap_port, - time_stamp, variables, error_label)) - (void)printf("trap_send fails!\n"); - - /* Memory leak fix */ - snmp_variable_list_free(variables); - return 0; -} -/* - * This function is similar to one used in mibiisa - * Here, we check the community strings from the snmpd.conf configuration file. - */ -int -agent_read_config() -{ - FILE *hostf; - char linebuff[256]; - struct cmd *cmd; - - if ((hostf = fopen(agent_config_file, "r")) == (FILE *)NULL) { - perror("Can not open agent configuration file"); - return (-1); - } - - for (;;) { - char *ccp; - int cmd_len; - - (void) fgets(linebuff, sizeof (linebuff), hostf); - if (feof(hostf) || ferror(hostf)) - break; - - /* Weed out any comment text */ - if ((ccp = strchr(linebuff, '#')) != (char *)NULL) - *ccp = '\0'; - - /* Zap the newline, if any */ - if ((ccp = strchr(linebuff, '\n')) != (char *)NULL) - *ccp = '\0'; - if ((linebuff[0] == '\0') || (linebuff[0] == '\n')) continue; - - /* Parse off the command name */ - cmd_len = strcspn(linebuff, " \t"); - ccp = linebuff + cmd_len + strspn(linebuff + cmd_len, " \t"); - - /* Look up the command */ - for (cmd = cmds; cmd->name; cmd++) { - if ((strlen(cmd->name) == cmd_len) && - (strncmp(linebuff, cmd->name, cmd_len) == 0)) { - (*cmd->rtn)(ccp, cmd); - goto next; - } - } - - next: - ; - } - -fclose(hostf); -return (0); -} - -int -set_conf_word(string, cmd) -char *string; -struct cmd *cmd; -{ - char *ccp; - /* Take only the first word */ - if ((ccp = strchr(string, ' ')) != (char *)NULL) - *ccp = '\0'; - if ((ccp = strchr(string, '\t')) != (char *)NULL) - *ccp = '\0'; - strncpy(cmd->arg1, string, cmd->arg2); -return (1); -} diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/reg_subtree.h --- a/usr/src/cmd/agents/snmp/agent/reg_subtree.h Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1998, 2001 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#ifndef _REG_SUBTREE_H -#define _REG_SUBTREE_H - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifdef __cplusplus -extern "C" { -#endif - -extern int SSARegSubagent(Agent *agent); -extern int SSARegSubtree(SSA_Subtree *subtree); -extern int SSARegSubtable(SSA_Table *table); -extern int SSAGetTrapPort(void); -/* - * it will request a resource handler(an agent id) from the relay agent, - * it returns the agent id if successful, otherwise, return 0 - * if fails, it will retry "num_of_retry". - */ -extern int SSASubagentOpen(int num_of_retry, char *agent_name); -extern int SSAAgentIsAlive(IPAddress *agent_addr, int port, char *community, - struct timeval *timeout); -/* if flag = 1, turn on the auto mode */ -extern void SSAAutoMemFree(int flag); -extern void _SSASendTrap(char *name); -extern void _SSASendTrap2(char *name); -extern int _SSASendTrap3(char *name); -extern int SSASendTrap4(char *name, IndexType *index_obj); - -#ifdef __cplusplus -} -#endif - -#endif /* _REG_SUBTREE_H */ diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/snmpd.c --- a/usr/src/cmd/agents/snmp/agent/snmpd.c Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,547 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2002, 2003 by Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "impl.h" -#include "error.h" -#include "trace.h" -#include "signals.h" -#include "snmp.h" -#include "pdu.h" -#include "agent_msg.h" -#include "agent.h" -#include "config.h" - -/***** DEFINES *****/ - -#define DEFAULT_POLL_INTERVAL 30 - -/***** IMPORTED VARIABLES *****/ - -/* user defined data */ - -extern char default_config_file[]; -extern char default_sec_config_file[]; -extern char default_error_file[]; - -/***** IMPORTED FUNCTIONS *****/ - -/* user defined functions */ -extern void agent_init(); -extern void agent_end(); -extern void agent_loop(); -extern void agent_select_info(fd_set *fdset, int *numfds); -extern void agent_select_callback(fd_set *fdset); - -/***** STATIC VARIABLES *****/ - -static int sighup = False; -char *config_file = NULL; -char *sec_config_file = NULL; -int agent_port_number = -1; - -int dont_read_config_file = FALSE; - -static int poll_interval = DEFAULT_POLL_INTERVAL; -int max_agent_reg_retry = 10; - -/***** LOCAL FUNCTIONS *****/ - -static void signals_sighup(int siq); -static void signals_exit(int siq); - -static int snmpd_init(int port); -static void print_usage(char *command_name); -static void snmpd_loop(int sd); -static void sap_main(int, char **); - - -/********************************************************************/ - -static void -application_end() -{ - agent_end(); -} - - -/********************************************************************/ - -static void -signals_sighup(int sig) -{ - if(trace_level > 0) - trace("received signal SIGHUP(%d)\n\n", sig); - - error(MSG_SIGHUP, sig); - - sighup = True; -} - - -/********************************************************************/ - -static void -signals_exit(int sig) -{ - - if (trace_level > 0) - trace("received signal %d", sig); - - application_end(); - - exit(1); -} - - -/********************************************************************/ - -static int -snmpd_init(int port) -{ - int sd; - struct sockaddr_in me; - - /* init the config_file pointer and then parse the configuration file */ - - if (port > 0) - agent_port_number = port; - - if (dont_read_config_file == FALSE) { - if (config_file == NULL) - config_file = default_config_file; - config_init(config_file); - } - - if (sec_config_file == NULL) - sec_config_file = default_sec_config_file; - - (void)sec_config_init(sec_config_file); - - /* successfully register the subagent, then set the operation status of - * subagent to run. - */ - sd = socket(AF_INET, SOCK_DGRAM, 0); - if(sd < 0) - error_exit(ERR_MSG_SOCKET, errno_string()); - - /* evaluate the port to be used, the port priority is : - command port > config. file port > def. port */ - if(port == 0 && agent_port_number != 0){ - port = agent_port_number; - } - - me.sin_family = AF_INET; - me.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - me.sin_port = htons(port); - if(bind(sd, (struct sockaddr *)&me, sizeof(me)) != 0) - error_exit(ERR_MSG_BIND, port, errno_string()); - - if(trace_level > 0) - trace("Waiting for incoming SNMP requests on UDP port %d\n\n", port); - - return sd; -} - -static void -snmpd_loop(int sd) -{ - int numfds; - fd_set fdset; - int count; - long long timer; - - struct timeval expire; - struct timeval timeout; - struct timeval now; - - expire.tv_sec = 0; - expire.tv_usec = 0; - - - /* CONSTCOND */ - while (1) { - if (sighup) { - error(MSG_READING_CONFIG, - config_file); - - config_init(config_file); - - error(MSG_READING_CONFIG, sec_config_file); - - (void) sec_config_init(sec_config_file); - - error(MSG_CONFIG_READED); - - sighup = False; - } - - numfds = 0; - FD_ZERO(&fdset); - - numfds = sd + 1; - FD_SET(sd, &fdset); - - agent_select_info(&fdset, &numfds); - - (void) gettimeofday(&now, (struct timezone *)0); - - timer = (long long) (now.tv_sec - expire.tv_sec) * 1000000; - timer += (long long) (now.tv_usec - expire.tv_usec); - - if (timer >= 0) { - /* now > timeval + poll_interval */ - timeout.tv_sec = 0; - timeout.tv_usec = 0; - } else { - timeout.tv_sec = -timer / 1000000; - timeout.tv_usec = -timer % 1000000; - } - - count = select(numfds, &fdset, 0, 0, &timeout); - if (count > 0) { - if (FD_ISSET(sd, &fdset)) { - Address address; - SNMP_pdu *pdu; - - if ((pdu = snmp_pdu_receive(sd, &address, - error_label)) == NULL) { - error(ERR_MSG_PDU_RECEIVED, - address_string(&address), - error_label); - continue; - } - - if (agent_process(&address, pdu) == -1) { - error(ERR_MSG_PDU_PROCESS, - address_string(&address)); - snmp_pdu_free(pdu); - continue; - } - - if (pdu->error_status == - SNMP_ERR_AUTHORIZATIONERROR) { - snmp_pdu_free(pdu); - continue; - } - - if ((pdu->error_status != SNMP_ERR_NOERROR) - && (pdu->error_status != SNMP_ERR_NOSUCHNAME)) { - error(ERR_MSG_SNMP_ERROR, - error_status_string(pdu->error_status), - pdu->error_index, - address_string(&address)); - } - - if (snmp_pdu_send(sd, &address, pdu, - error_label) == -1) { - error(ERR_MSG_PDU_SEND, - address_string(&address), - error_label); - snmp_pdu_free(pdu); - continue; - } - - snmp_pdu_free(pdu); - } - - agent_select_callback(&fdset); - } else { - switch (count) { - case 0: - (void) gettimeofday(&expire, - (struct timezone *) 0); - expire.tv_sec = expire.tv_sec + poll_interval; - agent_loop(); - break; - - case -1: - if (errno == EINTR) { - continue; - } else if (errno == EBADF) { - FD_CLR(sd, &fdset); - fprintf(stderr, "select() failed %s\n", - errno_string()); - continue; - } else { - error_exit(ERR_MSG_SELECT, - errno_string()); - } - } - } - } -} - - -static void print_usage(char *command_name) -{ - (void)fprintf(stderr, "Usage: %s [-h]\n\ -\t[-k (don't read config file)]\n\ -\t[-p port ]\n\ -\t[-c config-file (default %s)]\n\ -\t[-a sec-config-file (default %s)]\n\ -\t[-i poll-interval (default %d seconds)]\n\ -\t[-d trace-level (range 0..%d, default %d)]\n\n", - command_name, - default_config_file, - default_sec_config_file, - DEFAULT_POLL_INTERVAL, - TRACE_LEVEL_MAX, - trace_level); - exit(1); -} - - -static void -sap_main(argc, argv) - int argc; - char *argv[]; -{ - int arg; - int port = 0; - int sd; - char *str; - int level; - char *error_file = NULL; - - - - error_init(argv[0], application_end); - - /* parse arguments */ - - for(arg = 1; arg < argc; arg++) - { - if(argv[arg][0] == '-') - { - switch(argv[arg][1]) - { - case 'k': - dont_read_config_file = TRUE; - break; - case 'h': - case '?': - print_usage(argv[0]); - - /* never reached */ - return; - - case 'p': - arg++; - if(arg >= argc) - { - (void)fprintf(stderr, "Must have another argument following the -p option\n"); - print_usage(argv[0]); - } - - /* LINTED */ - port = (int32_t)strtol(argv[arg], &str, 10); - if(argv[arg] == str) - { - (void)fprintf(stderr, "Not a valid integer following the -p option: %s\n", argv[arg]); - print_usage(argv[0]); - } - - break; - - case 'c': - arg++; - if(arg >= argc) - { - (void)fprintf(stderr, "Must have a configuration file name following the -c option\n"); - print_usage(argv[0]); - } - - config_file = (char *) strdup(argv[arg]); - if(config_file == NULL) - { - (void)fprintf(stderr, "%s\n", ERR_MSG_ALLOC); - exit(1); - } - - break; - - case 'a': - arg++; - if(arg >= argc) - { - (void)fprintf(stderr, "Must have a security configuration file name following the -a option\n"); - print_usage(argv[0]); - } - - sec_config_file = (char *) strdup(argv[arg]); - if(sec_config_file == NULL) - { - (void)fprintf(stderr, "%s\n", ERR_MSG_ALLOC); - exit(1); - } - - break; - - - case 'i': - arg++; - if(arg >= argc) - { - (void)fprintf(stderr, "Must have another argument following the -i option\n"); - print_usage(argv[0]); - } - - /* LINTED */ - poll_interval = (int32_t)strtol(argv[arg], &str, 10); - if(argv[arg] == str) - { - (void)fprintf(stderr, "Not a valid integer following the -i option: %s\n", argv[arg]); - print_usage(argv[0]); - } - if(poll_interval <= 0) - { - (void)fprintf(stderr, "The poll-interval must be greater than 0: %d\n", poll_interval); - print_usage(argv[0]); - } - - break; - - case 'd': - arg++; - if(arg >= argc) - { - (void)fprintf(stderr, "Must have another argument following the -d option\n"); - print_usage(argv[0]); - } - - /* LINTED */ - level = (int32_t)strtol(argv[arg], &str, 10); - if(argv[arg] == str) - { - (void)fprintf(stderr, "Not a valid integer following the -d option: %s\n", argv[arg]); - print_usage(argv[0]); - } - if(trace_set(level, error_label)) - { - print_usage(argv[0]); - } - - break; - - default: - (void)fprintf(stderr, "Invalid option: -%c\n", argv[arg][1]); - print_usage(argv[0]); - } - continue; - } - } - - - if(error_file == NULL) - { - error_file = default_error_file; - } - error_open(error_file); - - if(trace_level == 0) - { - /* run the daemon in backgound */ - - pid_t pid; - - pid = fork(); - switch(pid) - { - case -1: - error_exit(ERR_MSG_FORK, errno_string()); - - /* never reached */ - return; - - case 0: /* child process */ - break; - - default: /* parent process */ - exit(0); - } - } - - if(fclose(stdin) == EOF) - { - error(ERR_MSG_FCLOSE, "stdin", errno_string()); - } - - sd = snmpd_init(port); - - if(signals_init(signals_sighup, signals_exit, error_label)) - { - error_exit("signals_init() failed: %s", error_label); - } - - if(trace_level == 0) - { - if(fclose(stdout) == EOF) - { - error(ERR_MSG_FCLOSE, "stdout", errno_string()); - } - } - - if(trace_level == 0) - { - /* backgound */ - - if(chdir("/") == -1) - { - error(ERR_MSG_CHDIR, "/", errno_string()); - } - - /* set process group ID */ - (void)setpgrp(); - - error_close_stderr(); - } - - /* have to be called after error_open() and error_close_stderr() */ - agent_init(); - - snmpd_loop(sd); - - /* never reached */ -} - -void -SSAMain(int argc, char** argv) -{ - sap_main(argc,argv); -} diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/snmpd.h --- a/usr/src/cmd/agents/snmp/agent/snmpd.h Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 1996 Sun Microsystems, Inc. All Rights Reserved. - * Use is subject to license terms. - */ - -/* - * HISTORY - * 5-20-96 Jerry Yeung support security file and subtree reg. - */ - -#ifndef _SNMPD_H_ -#define _SNMPD_H_ - -#pragma ident "%Z%%M% %I% %E% SMI" - -extern char *config_file; -extern char *sec_config_file; -extern int agent_port_number; -extern int max_agent_reg_retry; - -extern void SSAMain(int argc, char** argv); - -#endif diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/sparc/Makefile --- a/usr/src/cmd/agents/snmp/agent/sparc/Makefile Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 1998, 2001 by Sun Microsystems, Inc. -# All rights reserved. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include ../Makefile.com - -install: $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT) diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/sparcv9/Makefile --- a/usr/src/cmd/agents/snmp/agent/sparcv9/Makefile Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 2001 by Sun Microsystems, Inc. -# All rights reserved. -# -# ident "%Z%%M% %I% %E% SMI" -# - -include ../Makefile.com -include $(SRC)/lib/Makefile.lib.64 - -install: all $(ROOTLIBS64) $(ROOTLINKS64) diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/subtree.c --- a/usr/src/cmd/agents/snmp/agent/subtree.c Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,352 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1998 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include -#include -#include -#include -#include - -#include "impl.h" -#include "error.h" -#include "trace.h" -#include "asn1.h" -#include "snmp.h" -#include "pdu.h" - -#include "pagent.h" -#include "subtree.h" - -/***** STATIC VARIABLES *****/ - -static Subtree *first_subtree = NULL; - - -/***** STATIC FUNCTIONS *****/ - -static void subtree_remove_from_agent_list(Subtree *subtree); -static void subtree_free(Subtree *sp); -extern int SSARegSubtree(SSA_Subtree *); - - -/****************************************************************/ -/* currently, the index are processid(agentid) and local index */ - -int subtree_add(Agent *agent, Subid *subids, int len) -{ - - /* call reg. api */ - Subtree *sp; - Subtree *new; - Subtree *last = NULL; - int ret; - - - if(agent == NULL) - { - error("BUG: subtree_add(): agent is NULL"); - return -1; - } - - new = (Subtree *) malloc(sizeof(Subtree)); - if(new == NULL) - { - error("malloc() failed"); - return -1; - } - new->next_subtree = NULL; - new->agent = agent; - new->next_agent_subtree = NULL; - new->name.subids = (Subid *) malloc(len * (int32_t)sizeof(Subid)); - if(new->name.subids == NULL) - { - error("malloc() failed"); - subtree_free(new); - return -1; - } - (void)memcpy(new->name.subids, subids, len * (int32_t)sizeof(Subid)); - new->name.len = len; - - for(sp = first_subtree; sp; sp = sp->next_subtree) - { - ret = SSAOidCmp(&(new->name), &(sp->name)); - if(ret == 0) - { - error("The subtree %s already belongs to the agent %s", - SSAOidString(&(sp->name)), - sp->agent->name); - subtree_free(new); - return -1; - } - else - if(ret < 0) - { - break; - } - - last = sp; - } - - if(last == NULL) - { - new->next_subtree = first_subtree; - first_subtree = new; - } - else - { - new->next_subtree = last->next_subtree; - last->next_subtree = new; - } - - new->next_agent_subtree = agent->first_agent_subtree; - agent->first_agent_subtree = new; - - new->regTreeIndex = ++new->agent->tree_index; - new->regTreeAgentID = new->agent->agent_id; - new->regTreeStatus = SSA_OPER_STATUS_ACTIVE; - if(SSARegSubtree(new)==0) - { - return -1; - } - - return 0; -} - - -/****************************************************************/ - -Subtree *subtree_match(u_char type, Oid *name) -{ - Subtree *sp; - Subtree *last; - - - if(name == NULL) - { - error("subtree_match(): name is NULL"); - return NULL; - } - - if(first_subtree == NULL) - { -/* - if(trace_level > 1) - { - trace("subtree_match() returned NULL\n\n"); - } -*/ - - return NULL; - } - - - if(type == GETNEXT_REQ_MSG) - { - if(SSAOidCmp(name, &(first_subtree->name)) < 0) - { -/* - if(trace_level > 1) - { - trace("subtree_match() returned %s supported by %s\n\n", - SSAOidString(&(first_subtree->name)), - first_subtree->agent->name); - } -*/ - - return first_subtree; - } - } - - last = NULL; - for(sp = first_subtree; sp; sp = sp->next_subtree) - { - if(SSAOidCmp(name, &(sp->name)) < 0) - { - break; - } - - if(sp->name.len <= name->len) - { - int i; - - - for(i = 0; i < sp->name.len; i++) - { - if(sp->name.subids[i] == 0) - { - continue; - } - - if(name->subids[i] != sp->name.subids[i]) - { - break; - } - } - - if(i == sp->name.len) - { - last = sp; - } - } - } - - -/* - if(trace_level > 1) - { - if(last) - { - trace("subtree_match() returned %s supported by %s\n\n", - SSAOidString(&(last->name)), - last->agent->name); - } - else - { - trace("subtree_match() returned NULL\n\n"); - } - } -*/ - - - return last; -} - - -/****************************************************************/ - -void trace_subtrees() -{ - Subtree *sp; - - - trace("SUBTREES:\n"); - for(sp = first_subtree; sp; sp = sp->next_subtree) - { - if(sp->agent) - { - trace("\t%-30s %-30s %d\n", - SSAOidString(&(sp->name)), - sp->agent->name, - sp->agent->address.sin_port); - } - else - { - trace("\t%-30s %-30s\n", - SSAOidString(&(sp->name)), - "NO AGENT!"); - } - } - trace("\n"); -} - - -/****************************************************************/ - -static void subtree_free(Subtree *sp) -{ - if(sp == NULL) - { - return; - } - - if(sp->name.subids) - { - free(sp->name.subids); - } - - free(sp); -} - - -/****************************************************************/ - -void subtree_list_delete() -{ - Subtree *sp = first_subtree; - Subtree *next; - - - while(sp) - { - next = sp->next_subtree; - - subtree_remove_from_agent_list(sp); - - subtree_free(sp); - - sp = next; - } - - first_subtree = NULL; - - return; -} - - -/****************************************************************/ - -static void subtree_remove_from_agent_list(Subtree *subtree) -{ - Agent *agent = subtree->agent; - Subtree *sp; - Subtree *osp; - - - osp = NULL; - for(sp = agent->first_agent_subtree; sp; sp = sp->next_agent_subtree) - { - if(sp == subtree) - { - break; - } - - osp = sp; - } - - if(sp == NULL) - { - error("subtree_remove_from_agent_list() : subtree (0x%x) not found", subtree); - return; - } - - if(osp == NULL) - { - agent->first_agent_subtree = sp->next_agent_subtree; - } - else - { - osp->next_agent_subtree = sp->next_agent_subtree; - } - - subtree->agent = NULL; - - return; -} - - - diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/subtree.h --- a/usr/src/cmd/agents/snmp/agent/subtree.h Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1998 by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#ifndef _SUBTREE_H_ -#define _SUBTREE_H_ - -typedef struct _Subtree { - int regTreeIndex; - int regTreeAgentID; - Oid name; - int regTreeStatus; - struct _Subtree *next_subtree; - struct _Agent *agent; - struct _Subtree *next_agent_subtree; -} Subtree; - -typedef Subtree SSA_Subtree; - -#define INVALID_HANDLER 0 - -extern int subtree_add(Agent *agent, Subid *subids, int len); -extern Subtree *subtree_match(u_char type, Oid *oid); -extern void subtree_list_delete(); -extern void trace_subtrees(); - -#endif /* _SUBTREE_H_ */ diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/agent/table.h --- a/usr/src/cmd/agents/snmp/agent/table.h Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 1996 Sun Microsystems, Inc. All Rights Reserved. - * Use is subject to license terms. - */ - -#ifndef _TABLE_H_ -#define _TABLE_H_ - -#pragma ident "%Z%%M% %I% %E% SMI" - -typedef struct Table { - int regTblIndex; - int regTblAgentID; - Oid regTblOID; - int regTblStartColumn; - int regTblEndColumn; - int regTblStartRow; - int regTblEndRow; - char *regTblView; - int regTblStatus; - struct Table* next_table; - Agent *agent; - -} Table, SSA_Table; - - -#endif diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/mib/Makefile --- a/usr/src/cmd/agents/snmp/mib/Makefile Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License (the "License"). -# You may not use this file except in compliance with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2009 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# snmp/mib/Makefile -# - -include ../../Makefile.vars - -include $(SRC)/cmd/Makefile.cmd - -MIBS = snmpdx.mib -MIBDIR = $(ROOT)/var/snmp/mib -ROOTMIBS = $(MIBS:%=$(MIBDIR)/%) - -$(ROOTMIBS) := FILEMODE = 644 - - -$(MIBDIR)/%: % - $(INS.file) - -install: $(ROOTMIBS) - -clean: - -clobber: - -lint: - -_msg: - - -include $(SRC)/cmd/Makefile.targ diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/mib/draft-ietf-entmib-entmib-02.txt --- a/usr/src/cmd/agents/snmp/mib/draft-ietf-entmib-entmib-02.txt Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2124 +0,0 @@ -#ident "%Z%%M% %I% %E% SMI" - -Draft Entity MIB January 22, 1996 - - - - Entity MIB - - 22 January 1996 - - - Keith McCloghrie - Cisco Systems Inc. - kzm@cisco.com - - Andy Bierman - Bierman Consulting - abierman@west.net - - - - - - Status of this Memo - -This document is an Internet-Draft. Internet-Drafts are working -documents of the Internet Engineering Task Force (IETF), its areas, and -its working groups. Note that other groups may also distribute working -documents as Internet-Drafts. - -Internet-Drafts are draft documents valid for a maximum of six months -and may be updated, replaced, or obsoleted by other documents at any -time. It is inappropriate to use Internet- Drafts as reference material -or to cite them other than as ``work in progress.'' - -To learn the current status of any Internet-Draft, please check the -``1id-abstracts.txt'' listing contained in the Internet- Drafts Shadow -Directories on ds.internic.net (US East Coast), nic.nordu.net (Europe), -ftp.isi.edu (US West Coast), or munnari.oz.au (Pacific Rim). - - - - - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 1] - - - - - -Draft Entity MIB January 22, 1996 - - -1. Introduction - -This memo defines an experimental portion of the Management Information -Base (MIB) for use with network management protocols in the Internet -community. In particular, it describes managed objects used for -managing multiple logical entities managed by a single SNMPv1 agent. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 2] - - - - - -Draft Entity MIB January 22, 1996 - - -2. The SNMPv1 Network Management Framework - -The SNMPv1 Network Management Framework presently consists of two major -components. They are: - -o RFC 1442 [1] which defines the SMI, the mechanisms used for - describing and naming objects for the purpose of management. - -o STD 17, RFC 1213 [2] defines MIB-II, the core set of managed - objects for the Internet suite of protocols. - - -The Framework permits new objects to be defined for the purpose of -experimentation and evaluation. - - -2.1. Object Definitions - -Managed objects are accessed via a virtual information store, termed the -Management Information Base or MIB. Objects in the MIB are defined -using the subset of Abstract Syntax Notation One (ASN.1) defined in the -SMI. In particular, each object type is named by an OBJECT IDENTIFIER, -an administratively assigned name. The object type together with an -object instance serves to uniquely identify a specific instantiation of -the object. For human convenience, we often use a textual string, -termed the descriptor, to refer to the object type. - - - - - - - - - - - - - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 3] - - - - - -Draft Entity MIB January 22, 1996 - - -3. Overview - -There is a need for a standardized way of representing a single agent -which supports multiple instances of one MIB. This is presently true -for at least 3 standard MIBs, and is likely to become true for more and -more MIBs as time passes. For example: - - - multiple instances of a bridge supported within a single device - having a single agent; - - - multiple repeaters supported by a single agent; - - - multiple OSPF backbone areas, each one operating as part of its own - Autonomous System, and each identified by the same area-id (e.g., - 0.0.0.0), supported inside a single router with one agent. - -The fact that it is a single agent in each of these cases implies there -is some relationship which binds all of these entities together. -Effectively, there is some "overall" physical entity which houses the -sum of the things managed by that one agent, i.e., there are multiple -"logical" entities within a single physical entity. Sometimes, the -overall physical entity contains multiple (smaller) physical entities -and each logical entity is associated with a particular physical entity. -Sometimes, the overall physical entity is a "compound" of multiple -physical entities (e.g., a stack of stackable hubs). - -What is needed is a way to determine exactly what logical entities are -managed by the agent (either by SNMPv1 or SNMPv2), and thereby to be -able to communicate with the agent about a particular logical entity. -When different logical entities are associated with different physical -entities within the overall physical entity, it is also useful to be -able to use this information to distinguish between logical entities. - -In these situations, there is no need for varbinds for multiple logical -entities to be referenced in the same SNMPv1 message (although that -might be useful in the future). Rather, it is sufficient, and in some -situations preferable, to have the context/community in the message -identify the logical entity to which the varbinds apply. - - -3.1. Terms - -Some new terms are used throughout this document: - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 4] - - - - - -Draft Entity MIB January 22, 1996 - - - - Naming Scope - A "naming scope" represents the set of information that may be - potentially accessed through a single SNMPv1 operation. All - instances within the naming scope share the same unique identifier - space. For SNMPv1, a naming scope is identified by the value of the - associated 'entLogicalCommunity' instance. - - - Logical Entity - A managed system contains one or more logical entities, each - represented by at most one instantiation of each of a particular - set of MIB objects. A set of management functions is associated - with each logical entity. Examples of logical entities include - routers, bridges, print-servers, etc. - - - Physical Entity - A "physical entity" or "physical component" represents an - identifiable physical resource within a managed system. Zero or - more logical entities may utilize a physical resource at any given - time. It is an implementation-specific manner as to which physical - components are represented by an agent in the EntPhysicalTable. - Typically, physical resources (e.g. communications ports, - backplanes, sensors, daughter-cards, power supplies, the overall - chassis) which can be managed via functions associated with one or - more logical entities are included in the MIB. - - - Containment Tree - Each physical component may optionally be modeled as 'contained' - within another physical component. A "containment-tree" is the - conceptual sequence of entPhysicalIndex values which uniquely - specifies the exact physical location of a physical component - within the managed system. It is generated by 'following and - recording' each 'entPhysicalContainedIn' instance 'up the tree - towards the root', until a value of zero indicating no further - containment is found. - - It is required that physical containment-trees retain their - identity across reboots. Specifically, two identical hardware - configurations should produce the same set of containment-trees for - every corresponding entry in the entPhysicalTable (i.e. the same - set of entPhysicalEntries with the same entPhysicalIndex values, - - Note that chassis slots, which are capable of accepting one or more - module types from one or more vendors, are modeled as containers in - this MIB. The value of entPhysicalContainedIn for a particular - 'module' entity (entPhysicalClass value of 'module(9)') should be - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 5] - - - - - -Draft Entity MIB January 22, 1996 - - - equal to an entPhysicalIndex that represents the parent 'container' - entity (associated entPhysicalClass value of ('container(5)'). An - agent should represent both empty and full containers in the - entPhysicalTable. - - -3.2. Relationship to Community Strings - -For SNMPv1, distinguishing between different logical entities is one -(but not the only) purpose of the community string [6]. This is -accommodated by representing each community string as a logical entity. - -Note that different logical entities may 'share' the same naming scope -(and therefore the same values of entLogicalCommunity). In such a case, -individual logical entities can be identified by examining the -sysORTable within the same naming scope. - - -3.3. Relationship to Proxy Mechanisms - -The Entity MIB is designed to allow functional component discovery. The -administrative relationships between different logical entities are not -visible in any Entity MIB tables. - -The management of administrative framework functions is not an explicit -goal of the Entity MIB WG at this time. This new area of functionality -may be revisited after some operational experience with the Entity MIB -is gained. - - -3.4. Relationship to a Chassis MIB - -Some readers may recall that a previous IETF working group attempted to -define a Chassis MIB. No consensus was reached by that working group, -possibly because its scope was too broad. As such, it is not the -purpose of this MIB to be a "Chassis MIB replacement", nor is it within -the scope of this MIB to contain all the information which might be -necessary to manage a "chassis". On the other hand, the entities -represented by an implementation of this MIB might well be contained in -a chassis. - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 6] - - - - - -Draft Entity MIB January 22, 1996 - - -3.5. Relationship to the Interfaces MIB - -The Entity MIB contains a mapping table identifying physical components -that have 'external values' (e.g. ifIndex) associated with them within a -given naming scope. This table can be used to identify the physical -location of each interface in the ifTable. Since ifIndex values in -different contexts are not related to one another, the interface to -physical component associations are relative to a specific logical -entity within the agent. - - - -3.6. Relationship to the Other MIBs - -The Entity MIB contains a mapping table identifying physical components -that have identifiers from other standard MIBs associated with them. -For example, this table can be used along with the physical mapping -table to identify the physical location of each repeater port in the -rptrPortTable, each bridge port in the dot1dBasePortTable, or each -ifIndex in the ifTable. - - -3.7. Re-Configuration of Entities - -All the MIB objects defined in this MIB have at most a read-only MAX- -ACCESS clause, i.e., none are write-able. This is another conscious -decision by the authors to limit this MIB's scope. It is possible that -this restriction could be lifted after implementation experience. - - -3.8. MIB Structure - -This MIB contains five tables: the entPhysicalTable and the -entLogicalTable each provide a list of entities. The entLPMappingTable -provides mappings between logical and physical entities. The -entAliasMappingTable provides mappings between physical components and -associated identifiers from other MIBs. For example, a physical repeater -port may be associated with an instance of 'rptrPortGroupIndex.1.5', or -'ifIndex.12', or both. The entPhysicalContainsTable provides efficient -discovery of the containment relationships of all physical entities -(also derivable from 'entPhysicalContainedIn' values). - - -The entPhysicalTable contains one row per physical entity, and should -always contains at least one row for an "overall" physical entity. Each - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 7] - - - - - -Draft Entity MIB January 22, 1996 - - -row is indexed by an arbitrary, small integer, and contains a -description and type of the physical entity. It also optionally -contains the index number of another entPhysicalEntry indicating a -containment relationship between the two. - - -The entLogicalTable contains one row per logical entity. Each row is -indexed by an arbitrary, small integer and contains a name, description, -and type of the logical entity. It also contains information to allow -SNMPv1 access to the MIB information for the logical entity. - - -The entLPMappingTable contains mappings between entLogicalIndex values -(logical entities) and entPhysicalIndex values (the physical components -supporting that entity). A logical entity can map to more than one -physical component, and more than one logical entity can map to (share) -the same physical component. - - -The entAliasMappingTable contains mappings between entLogicalIndex, -entPhysicalIndex pairs and 'alias' object identifier values. This -allows resources managed with other MIBs (e.g. repeater ports, bridge -ports, physical and logical interfaces) to be identified in the physical -entity hierarchy. Note that each alias identifier is only relevant in a -particular naming scope. - - -The entPhysicalContainsTable contains simple mappings between -'entPhysicalContainedIn' values for each container/containee -relationship in the managed system. The indexing of this table allows an -NMS to quickly discover the 'entPhysicalIndex' values for all children -of a given physical entity. - - -3.9. Multiple Agents - -Even though a primary motivation for this MIB is to represent the -multiple logical entities supported by a single agent, it is also -possible to use it to represent multiple logical entities supported by -multiple agents (in the same "overall" physical entity). Indeed, it is -implicit in the SNMPv1 architecture, that the number of agents is -transparent to a network management station. - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 8] - - - - - -Draft Entity MIB January 22, 1996 - - -4. Definitions - -ENTITY-MIB DEFINITIONS ::= BEGIN - -IMPORTS - MODULE-IDENTITY, OBJECT-TYPE, - experimental, NOTIFICATION-TYPE - FROM SNMPv2-SMI - DisplayString, AutonomousType, TruthValue - FROM SNMPv2-TC - TAddress - FROM SNMPv2-PARTY-MIB - MODULE-COMPLIANCE, OBJECT-GROUP - FROM SNMPv2-CONF; - -entityMIB MODULE-IDENTITY - LAST-UPDATED "9601200000Z" - ORGANIZATION "IETF ENTMIB Working Group" - CONTACT-INFO - " Keith McCloghrie - Cisco Systems Inc. - 170 West Tasman Drive - San Jose, CA 95134 - 408-526-5260 - kzm@cisco.com - - Andy Bierman - Bierman Consulting - 1200 Sagamore Lane - Ventura, CA 93001 - 805-648-2028 - abierman@west.net" - DESCRIPTION - "The MIB module for representing multiple logical - entities supported by a single SNMP agent." - ::= { experimental xx } - -entityMIBObjects OBJECT IDENTIFIER ::= { entityMIB 1 } - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 9] - - - - - -Draft Entity MIB January 22, 1996 - - --- The Physical Entity Table - -entPhysicalTable OBJECT-TYPE - SYNTAX SEQUENCE OF EntPhysicalEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "This table contains one row per physical entity. There is - always at least one row for an 'overall' physical entity." - ::= { entityMIBObjects 1 } - -entPhysicalEntry OBJECT-TYPE - SYNTAX EntPhysicalEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Information about a particular physical entity. An agent - is expected to represent physical components in as much - detail as possible. If more than one agent within a chassis - implements the Entity MIB, the information retrieved from - each agent must be consistent, but not necessarily - identical." - INDEX { entPhysicalIndex } - ::= { entPhysicalTable 1 } - -EntPhysicalEntry ::= SEQUENCE { - entPhysicalIndex INTEGER, - entPhysicalDescr DisplayString, - entPhysicalVendorType AutonomousType, - entPhysicalContainedIn INTEGER, - entPhysicalClass INTEGER, - entPhysicalParentRelPos INTEGER -} - -entPhysicalIndex OBJECT-TYPE - SYNTAX INTEGER (1..2147483647) - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The value of this object uniquely identifies the physical - entity. The value is a small positive integer; index values - for different physical entities are not necessarily - contiguous." - ::= { entPhysicalEntry 1 } - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 10] - - - - - -Draft Entity MIB January 22, 1996 - - -entPhysicalDescr OBJECT-TYPE - SYNTAX DisplayString - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "A textual description of physical entity." - ::= { entPhysicalEntry 2 } - -entPhysicalVendorType OBJECT-TYPE - SYNTAX AutonomousType - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "An indication of the vendor-specific hardware type of the - physical entity. Note that this is different from the - definition of MIB-II's sysObjectID. - - An agent should set this object to a enterprise-specific - registration identifier value indicating the specific - equipment type in detail. The associated instance of - entPhysicalClass should be used to indicate the general type - of hardware device. - - If no vendor-specific registration identifier exists for - this physical entity, then the value { 0 0 } is returned. If - the value is unknown by this agent, then the special value - 'entPClassUnknown' is returned." - ::= { entPhysicalEntry 3 } - -entPhysicalContainedIn OBJECT-TYPE - SYNTAX INTEGER (0..2147483647) - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The value of entPhysicalIndex for the physical entity which - 'contains' this physical entity. A value of zero indicates - this physical entity is not contained in any other physical - entity. Note that the set of 'containment' relationships - define a strict hierarchy; that is, recursion is not - allowed." - ::= { entPhysicalEntry 4 } - -entPhysicalClass OBJECT-TYPE - SYNTAX INTEGER { - other(1), - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 11] - - - - - -Draft Entity MIB January 22, 1996 - - - unknown(2), - chassis(3), - backplane(4), - container(5), -- slot or daughter-card holder - powerSupply(6), - fan(7), - sensor(8), - module(9), -- plug-in card or daughter-card - port(10) - } - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "An indication of the general hardware type of the physical - entity. - - An agent should set this object to the standard enumeration - value which most accurately indicates the general class of - the physical entity, or the primary class if there is more - than one. - - If no appropriate standard registration identifier exists - for this physical entity, then the value 'other(1)' is - returned. If the value is unknown by this agent, then the - value 'unknown(2)' is returned." - ::= { entPhysicalEntry 5 } - -entPhysicalParentRelPos OBJECT-TYPE - SYNTAX INTEGER (0..2147483647) - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "An indication of the position of this 'child' component - among all its 'sibling' components. The numbering is - relative to the 'parent' component. A component's parent is - identified by the associated instance of the - entPhysicalContainedIn object. An NMS may use this value to - compare against other entPhysicalEntries with the same - parent (same value of entPhysicalContainedIn). - - This value should match any external labeling of the - physical component if possible. For example, an - entPhysicalEntry representing entPhysicalParentRelPos value - of '10'. The entPhysicalContainedIn instance should equal - the entPhysicalIndex for the parent (module 3). The - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 12] - - - - - -Draft Entity MIB January 22, 1996 - - - entPhysicalParentRelPos instance associated with the parent - should be equal to '3'. - - If the physical position of this component does not match - any external labeling, then user documentation or other - external reference material should be used to determine the - parent-relative position. If this is not possible, then the - the agent should assign an arbitrary ordering to a given set - of 'sibling' components, perhaps based on internal - representation of the components. - - If the agent cannot determine the parent-relative position - for some reason, or if the associated value of - entPhysicalContainedIn is '0', then the value '0' is - returned. Otherwise a positive integer is returned, - indicating the parent-relative position of this physical - entity. - - Parent-relative ordering should start from '1' and continue - to 'N', where 'N' represents the highest positioned child - entity. Note that this ordering may be sparse or dense, - depending on agent implementation. The actual values - returned are not globally meaningful, as each 'parent' - component may use different numbering algorithms. The - ordering is only meaningful among siblings of the same - parent component. - - The agent should retain parent-relative position values - across reboots, either through algorithmic assignment or use - of non-volatile storage." - ::= { entPhysicalEntry 6 } - - - - - - - - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 13] - - - - - -Draft Entity MIB January 22, 1996 - - --- The Logical Entity Table -entLogicalTable OBJECT-TYPE - SYNTAX SEQUENCE OF EntLogicalEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "This table contains one row per logical entity." - ::= { entityMIBObjects 2 } - -entLogicalEntry OBJECT-TYPE - SYNTAX EntLogicalEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Information about a particular logical entity. Entities - may be managed by this agent or other SNMP agents (possibly) - in the same chassis." - INDEX { entLogicalIndex } - ::= { entLogicalTable 1 } - -EntLogicalEntry ::= SEQUENCE { - entLogicalIndex INTEGER, - entLogicalDescr DisplayString, - entLogicalType AutonomousType, - entLogicalCommunity OCTET STRING, - entLogicalTAddress TAddress, - entLogicalTDomain OBJECT IDENTIFIER -} - -entLogicalIndex OBJECT-TYPE - SYNTAX INTEGER (1..2147483647) - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The value of this object uniquely identifies the logical - entity. The value is a small positive integer; index values - for different logical entities are are not necessarily - contiguous." - ::= { entLogicalEntry 1 } - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 14] - - - - - -Draft Entity MIB January 22, 1996 - - -entLogicalDescr OBJECT-TYPE - SYNTAX DisplayString - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "A textual description of logical entity." - ::= { entLogicalEntry 2 } - -entLogicalType OBJECT-TYPE - SYNTAX AutonomousType - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "An indication of the type of logical entity. This will - typically be the OBJECT IDENTIFIER name of the node in the - SMI's naming hierarchy which represents the major MIB - module, or the majority of the MIB modules, supported by the - logical entity. For example: - a logical entity of a regular host/router -> mib-2 - a logical entity of a 802.1d bridge -> dot1dBridge - a logical entity of a 802.3 repeater -> - snmpDot3RptrMgmt" - ::= { entLogicalEntry 3 } - -entLogicalCommunity OBJECT-TYPE - SYNTAX OCTET STRING - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "A SNMPv1 community-string which can be used to access - detailed management information for this logical entity. - The agent should allow read access with this community - string (to an appropriate subset of all managed objects) and - may also choose to return a community string based on the - privileges of the request used to read this object (e.g. - only return a string having read-write privileges when - accessed with read-write privileges). - - A conformant SNMP agent may wish to conserve naming scopes - by representing multiple logical entities in a single 'main' - naming scope. This is possible when the logical entities - represented by the same value of entLogicalCommunity have no - object instances in common. For example, 'bridge1' and - 'repeater1' may be part of the main naming scope, but two - additional community strings are needed to represent - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 15] - - - - - -Draft Entity MIB January 22, 1996 - - - 'bridge2' and 'repeater2'. - - Logical entities 'bridge1' and 'repeater1' would be - represented by sysOREntries associated with the 'main' - naming scope. - - For agents not accessible via SNMPv1, the value of this - object is the empty-string." - ::= { entLogicalEntry 4 } - - -entLogicalTAddress OBJECT-TYPE - SYNTAX TAddress - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The transport service address by which the logical entity - receives network management traffic, formatted according to - the corresponding value of entLogicalTDomain. For - snmpUDPDomain, entLogicalTAddress is formatted as a 4-octet - IP Address concatenated with a 2-octet UDP port number." - ::= { entLogicalEntry 5 } - -entLogicalTDomain OBJECT-TYPE - SYNTAX OBJECT IDENTIFIER - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "Indicates the kind of transport service by which the - logical entity receives network management traffic. - Possible values for this object are presently found in the - Transport Mappings for SNMPv2 document (RFC 1449 [8]). [ed - -- RFC 1449 is now historic]" - ::= { entLogicalEntry 6 } - - - - - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 16] - - - - - -Draft Entity MIB January 22, 1996 - - --- entLPMappingTable: for each entity index, there are N --- rows, each representing a physical component --- that is associated with the indicated entity --- --- entity to component table -entLPMappingTable OBJECT-TYPE - SYNTAX SEQUENCE OF EntLPMappingEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "This table contains zero or more rows of logical entity to - physical equipment associations." - ::= { entityMIBObjects 3 } - -entLPMappingEntry OBJECT-TYPE - SYNTAX EntLPMappingEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Information about a particular logical entity to physical - equipment binding." - INDEX { entLogicalIndex, entLPPhysicalIndex } - ::= { entLPMappingTable 1 } - -EntLPMappingEntry ::= SEQUENCE { - entLPPhysicalIndex INTEGER -} - -entLPPhysicalIndex OBJECT-TYPE - SYNTAX INTEGER (1..2147483647) - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The value of this object identifies a particular - entPhysicalEntry associated with the indicated - entLogicalEntity." - ::= { entLPMappingEntry 1 } - - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 17] - - - - - -Draft Entity MIB January 22, 1996 - - --- logical entity/component to alias table -entAliasMappingTable OBJECT-TYPE - SYNTAX SEQUENCE OF EntAliasMappingEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "This table contains zero or more rows of logical entity, - and physical component to external identifier associations." - ::= { entityMIBObjects 4 } - -entAliasMappingEntry OBJECT-TYPE - SYNTAX EntAliasMappingEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "Information about a particular physical equipment, logical - entity to external identifier binding. Note that the same - logical entity/ physical component pair may have an - arbitrary number of external identifier (alias) bindings." - INDEX { entLogicalIndex, entPhysicalIndex, entAliasMappingIndex } - ::= { entAliasMappingTable 1 } - -EntAliasMappingEntry ::= SEQUENCE { - entAliasMappingIndex INTEGER, - entAliasIdentifier OBJECT IDENTIFIER -} - -entAliasMappingIndex OBJECT-TYPE - SYNTAX INTEGER (1..2147483647) - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "The value of this object uniquely identifies the particular - binding for a specific logical entity on a particular - physical component. The value is a small positive integer; - index values for different entAlias mappings are not - necessarily contiguous." - ::= { entAliasMappingEntry 1 } - -entAliasIdentifier OBJECT-TYPE - SYNTAX OBJECT IDENTIFIER - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The value of this object identifies a particular MIB - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 18] - - - - - -Draft Entity MIB January 22, 1996 - - - instance associated with the indicated entPhysicalEntry and - entLogicalEntry pair. - - For example, suppose a physical port was represented by - entPhysicalEntry.3, and entLogicalEntry.1 existed for a - repeater, entLogicalEntry.2 existed for a bridge, and the - bridge port was also represented in the ifTable. Then there - might be three related instances of entAliasIdentifier: - entAliasIdentifier.3.1.1 == rptrPortGroupIndex.5.2 - entAliasIdentifier.3.2.1 == dot1dBasePort.2 - entAliasIdentifier.3.2.2 == ifIndex.2 " - ::= { entAliasMappingEntry 2 } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 19] - - - - - -Draft Entity MIB January 22, 1996 - - --- physical mapping table -entPhysicalContainsTable OBJECT-TYPE - SYNTAX SEQUENCE OF EntPhysicalContainsEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "A table which exposes the container/containee relationships - between physical entities." - ::= { entityMIBObjects 5 } - -entPhysicalContainsEntry OBJECT-TYPE - SYNTAX EntPhysicalContainsEntry - MAX-ACCESS not-accessible - STATUS current - DESCRIPTION - "A single container/containee relationship." - INDEX { entPhysicalIndex, entPhysicalChildIndex } - ::= { entPhysicalContainsTable 1 } - -EntPhysicalContainsEntry ::= SEQUENCE { - entPhysicalChildIndex INTEGER -} - -entPhysicalChildIndex OBJECT-TYPE - SYNTAX INTEGER (1..2147483647) - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The value of entPhysicalIndex for the contained physical - entity." - ::= { entPhysicalContainsEntry 1 } - - - - - - - - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 20] - - - - - -Draft Entity MIB January 22, 1996 - - --- last change timestamp for the whole MIB -entLastChangeTime OBJECT-TYPE - SYNTAX Timestamp - MAX-ACCESS read-only - STATUS current - DESCRIPTION - "The value of sysUpTime at the time any of these events - occur: - * a conceptual row is created or deleted in any of these tables: - - entPhysicalTable - - entLogicalTable - - entLPMappingTable - - entAliasMappingTable - - entPhysicalContainsTable - - * any instance in the following list of objects changes value: - - entPhysicalDescr - - entPhysicalVendorType - - entPhysicalContainedIn - - entPhysicalClass - - entLogicalDescr - - entLogicalType - - entLogicalCommunity - - entLogicalTAddress - - entLogicalTDomain - - entAliasIdentifier - " - ::= { entityMIBObjects 6 } - - - - - - - - - - - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 21] - - - - - -Draft Entity MIB January 22, 1996 - - --- Entity MIB Trap Definitions -entityMIBTraps OBJECT IDENTIFIER ::= { entityMIB 2 } - -entConfigChange NOTIFICATION-TYPE - OBJECTS { - entLastChangeTime - } - STATUS current - DESCRIPTION - "An entConfigChange trap is sent when the value of - entLastChangeTime changes. It can be utilized by an NMS to - trigger logical/physical entity table maintenance polls. - This trap is throttled by the agent. - - The value of entLastChangeTime at the time the - entConfigChange event is detected by the agent is encoded as - a var-bind in the trap. This should be the same value as the - sysUpTime instance included in the trap, but may not be if - trap generation is delayed at all within the agent. - - An agent must take care not to generate more than one - entConfigChange 'trap-event' in a five second period, where - a 'trap-event' is the transmission of a single trap PDU to a - list of trap destinations. If additional configuration - changes occur within the five second 'throttling' period, - then these events should be discarded by the agent. An NMS - should periodically check the value of entLastChangeTime to - detect any missed entConfigChange events due to throttling. - ::= { entityMIBTraps 1 } - - - - - - - - - - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 22] - - - - - -Draft Entity MIB January 22, 1996 - - --- conformance information -entityConformance OBJECT IDENTIFIER ::= { entityMIB 3 } - -entityCompliances OBJECT IDENTIFIER ::= { entityConformance 1 } -entityGroups OBJECT IDENTIFIER ::= { entityConformance 2 } - --- compliance statements - -entityCompliance MODULE-COMPLIANCE - STATUS current - DESCRIPTION - "The compliance statement for SNMPv2 entities - which implement the Entity MIB." - MODULE -- this module - MANDATORY-GROUPS { entityGroup } - ::= { entityCompliances 1 } - - --- units of conformance - -entityGroup OBJECT-GROUP - OBJECTS { entPhysicalDescr, - entPhysicalVendorType, - entPhysicalContainedIn, - entPhysicalClass, - entPhysicalParentRelPos, - entLogicalDescr, - entLogicalType, - entLogicalCommunity, - entLogicalTAddress, - entLogicalTDomain, - entLPPhysicalIndex, - entAliasIdentifier, - entPhysicalChildIndex, - entLastChangeTime, - entConfigChange - } - STATUS current - DESCRIPTION - "The collection of objects which are used to - represent the multiple logical entities, - physical components, interfaces, and port - alias identifiers for which a single agent - provides MIB information." - ::= { entityGroups 1 } - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 23] - - - - - -Draft Entity MIB January 22, 1996 - - -END - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 24] - - - - - -Draft Entity MIB January 22, 1996 - - -5. Usage Examples - -The following sections iterate the instance values for two example -networking devices. These examples are kept simple to make them more -understandable. Auxillary components, such as fans, sensors, empty -slots, and sub-modules are not shown, but should be modeled in real -implementations. - - -5.1. Router/Bridge - -An SNMPv1 router containing two slots. Each slot contains a 3 port -router/bridge module. Each port is represented in the ifTable. There -are two logical instances of OSPF running and two logical bridges: - - Physical entities -- entPhysicalTable: - 1 Field-replaceable physical chassis: - entPhysicalDescr.1 == "Acme Chassis Model 100" - entPhysicalVendorType.1 == acmeProducts.chassisTypes.1 - entPhysicalContainedIn.1 == 0 - entPhysicalClass.1 == chassis(3) - entPhysicalParentRelPos.1 == 0 - - 2 slots within the chassis: - entPhysicalDescr.2 == "Acme Router Chassis Slot 1" - entPhysicalVendorType.2 == acmeProducts.slotTypes.1 - entPhysicalContainedIn.2 == 1 - entPhysicalClass.2 == container(5) - entPhysicalParentRelPos.2 == 1 - - entPhysicalDescr.3 == "Acme Router Chassis Slot 2" - entPhysicalVendorType.3 == acmeProducts.slotTypes.1 - entPhysicalContainedIn.3 == 1 - entPhysicalClass.3 == container(5) - entPhysicalParentRelPos.3 == 2 - - 2 Field-replaceable modules: - Slot 1 contains a module with 3 ports: - entPhysicalDescr.4 == "Acme Router Module Model 10" - entPhysicalVendorType.4 == acmeProducts.moduleTypes.14 - entPhysicalContainedIn.4 == 2 - entPhysicalClass.4 == module(9) - entPhysicalParentRelPos.4 == 1 - - entPhysicalDescr.5 == "Acme Router Ethernet Port 1" - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 25] - - - - - -Draft Entity MIB January 22, 1996 - - - entPhysicalVendorType.5 == acmeProducts.portTypes.2 - entPhysicalContainedIn.5 == 4 - entPhysicalClass.5 == port(10) - entPhysicalParentRelPos.5 == 1 - - entPhysicalDescr.6 == "Acme Router Ethernet Port 2" - entPhysicalVendorType.6 == acmeProducts.portTypes.2 - entPhysicalContainedIn.6 == 4 - entPhysicalClass.6 == port(10) - entPhysicalParentRelPos.6 == 2 - - entPhysicalDescr.7 == "Acme Router Fddi Port 3" - entPhysicalVendorType.7 == acmeProducts.portTypes.3 - entPhysicalContainedIn.7 == 4 - entPhysicalClass.7 == port(10) - entPhysicalParentRelPos.7 == 3 - - Slot 2 contains another 3-port module: - entPhysicalDescr.8 == "Acme Router Module Model 11" - entPhysicalVendorType.8 == acmeProducts.moduleTypes.15 - entPhysicalContainedIn.8 == 3 - entPhysicalClass.8 == module(9) - entPhysicalParentRelPos.8 == 1 - - entPhysicalDescr.9 == "Acme Router Fddi Port 1" - entPhysicalVendorType.9 == acmeProducts.portTypes.3 - entPhysicalContainedIn.9 == 8 - entPhysicalClass.9 == port(10) - entPhysicalParentRelPos.9 == 1 - - entPhysicalDescr.10 == "Acme Router Ethernet Port 2" - entPhysicalVendorType.10 == acmeProducts.portTypes.2 - entPhysicalContainedIn.10 == 8 - entPhysicalClass.10 == port(10) - entPhysicalParentRelPos.10 == 2 - - entPhysicalDescr.11 == "Acme Router Ethernet Port 3" - entPhysicalVendorType.11 == acmeProducts.portTypes.2 - entPhysicalContainedIn.11 == 8 - entPhysicalClass.11 == port(10) - entPhysicalParentRelPos.11 == 3 - - Logical entities -- entLogicalTable - 2 OSPF instances: - entLogicalDescr.1 == "ospf-1" - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 26] - - - - - -Draft Entity MIB January 22, 1996 - - - entLogicalType.1 == ospf - entLogicalCommunity.1 == "public-ospf1" - entLogicalTAddress.1 == 124.125.126.127:161 - entLogicalTDomain.1 == snmpUDPDomain - - entLogicalDescr.2 == "ospf-2" - entLogicalType.2 == ospf - entLogicalCommunity.2 == "public-ospf2" - entLogicalTAddress.2 == 124.125.126.127:161 - entLogicalTDomain.2 == snmpUDPDomain - - 2 logical bridges: - entLogicalDescr.3 == "bridge1" - entLogicalType.3 == dod1dBridge - entLogicalCommunity.3 == "public-bridge1" - entLogicalTAddress.3 == 124.125.126.127:161 - entLogicalTDomain.3 == snmpUDPDomain - - entLogicalDescr.4 == "bridge2" - entLogicalType.4 == dod1dBridge - entLogicalCommunity.4 == "public-bridge2" - entLogicalTAddress.4 == 124.125.126.127:161 - entLogicalTDomain.4 == snmpUDPDomain - -Logical to Physical Mappings: - 1st OSPF instance: uses module 1-port 1 - entLPPhysicalIndex.1.5 == 5 - - 2nd OSPF instance: uses module 2-port 1 - entLPPhysicalIndex.2.9 == 9 - - 1st bridge group: uses module 1, all ports - entLPPhysicalIndex.3.5 == 5 - entLPPhysicalIndex.3.6 == 6 - entLPPhysicalIndex.3.7 == 7 - - 2nd bridge group: uses module 2, all ports - entLPPhysicalIndex.4.9 == 9 - entLPPhysicalIndex.4.10 == 10 - entLPPhysicalIndex.4.11 == 11 - -Logical to Physical to Alias Mappings -- entAliasMappingTable: - Bridge 1 uses Ports 1..3 on Slot 1 - entAliasIdentifier.3.5.1 == dot1dBasePort.1 - entAliasIdentifier.3.5.2 == ifIndex.1 - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 27] - - - - - -Draft Entity MIB January 22, 1996 - - - entAliasIdentifier.3.6.1 == dot1dBasePort.2 - entAliasIdentifier.3.6.2 == ifIndex.2 - entAliasIdentifier.3.7.1 == dot1dBasePort.3 - entAliasIdentifier.3.7.2 == ifIndex.3 - - Bridge 2 uses Ports 1..3 on Slot 2; uses same Bridge MIB and ifIndex - values as Bridge 1, but in a different context, and representing - different physical ports: - entAliasIdentifier.4.9.1 == dot1dBasePort.1 - entAliasIdentifier.4.9.2 == ifIndex.1 - entAliasIdentifier.4.10.1 == dot1dBasePort.2 - entAliasIdentifier.4.10.2 == ifIndex.2 - entAliasIdentifier.4.11.1 == dot1dBasePort.3 - entAliasIdentifier.4.11.2 == ifIndex.3 - -Physical Containment Tree -- entPhysicalContainsTable - chassis has two containers: - entPhysicalChildIndex.1.2 = 2 - entPhysicalChildIndex.1.3 = 3 - - container 1 has a module: - entPhysicalChildIndex.2.4 = 4 - - container 2 has a module - entPhysicalChildIndex.3.8 = 8 - - module 1 has some ports: - entPhysicalChildIndex.4.5 = 5 - entPhysicalChildIndex.4.6 = 6 - entPhysicalChildIndex.4.7 = 7 - - module 2 has some ports: - entPhysicalChildIndex.8.9 = 9 - entPhysicalChildIndex.8.10 = 10 - entPhysicalChildIndex.1.11 = 11 - - -5.2. Repeaters - -An SNMPv1 only, 3-slot Hub with 2 backplane ethernet segments. Slot -three is empty, and the remaining slots contain ethernet repeater -modules. - - Physical entities -- entPhysicalTable: - 1 Field-replaceable physical chassis: - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 28] - - - - - -Draft Entity MIB January 22, 1996 - - - entPhysicalDescr.1 == "Acme Repeater Chassis Model 110" - entPhysicalVendorType.1 == acmeProducts.chassisTypes.2 - entPhysicalContainedIn.1 == 0 - entPhysicalClass.1 == chassis(3) - entPhysicalParentRelPos.1 == 0 - - 2 Chassis Ethernet Backplanes: - entPhysicalDescr.2 == "Ethernet Backplane 1" - entPhysicalVendorType.2 == acmeProducts.backplaneTypes.1 - entPhysicalContainedIn.2 == 1 - entPhysicalClass.2 == backplane(4) - entPhysicalParentRelPos.2 == 1 - - entPhysicalDescr.3 == "Ethernet Backplane 2" - entPhysicalVendorType.3 == acmeProducts.backplaneTypes.1 - entPhysicalContainedIn.3 == 1 - entPhysicalClass.3 == backplane(4) - entPhysicalParentRelPos.3 == 2 - - 3 slots within the chassis: - entPhysicalDescr.4 == "Acme Hub Slot 1" - entPhysicalVendorType.4 == acmeProducts.slotTypes.5 - entPhysicalContainedIn.4 == 1 - entPhysicalClass.4 == container(5) - entPhysicalParentRelPos.4 == 1 - - entPhysicalDescr.5 == "Acme Hub Slot 2" - entPhysicalVendorType.5 == acmeProducts.slotTypes.5 - entPhysicalContainedIn.5 == 1 - entPhysicalClass.5 == container(5) - entPhysicalParentRelPos.5 == 2 - - entPhysicalDescr.6 == "Acme Hub Slot 3" - entPhysicalVendorType.6 == acmeProducts.slotTypes.5 - entPhysicalContainedIn.6 == 1 - entPhysicalClass.6 == container(5) - entPhysicalParentRelPos.6 == 3 - - Slot 1 contains a plug-in module with 4 10-BaseT ports: - entPhysicalDescr.7 == "10Base-T Module Model 14" - entPhysicalVendorType.7 == acmeProducts.moduleTypes.32 - entPhysicalContainedIn.7 == 4 - entPhysicalClass.7 == module(9) - entPhysicalParentRelPos.7 == 1 - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 29] - - - - - -Draft Entity MIB January 22, 1996 - - - entPhysicalDescr.8 == "10Base-T Port 1" - entPhysicalVendorType.8 == acmeProducts.portTypes.10 - entPhysicalContainedIn.8 == 7 - entPhysicalClass.8 == port(10) - entPhysicalParentRelPos.8 == 1 - - entPhysicalDescr.9 == "10Base-T Port 2" - entPhysicalVendorType.9 == acmeProducts.portTypes.10 - entPhysicalContainedIn.9 == 7 - entPhysicalClass.9 == port(10) - entPhysicalParentRelPos.9 == 2 - - entPhysicalDescr.10 == "10Base-T Port 3" - entPhysicalVendorType.10 == acmeProducts.portTypes.10 - entPhysicalContainedIn.10 == 7 - entPhysicalClass.10 == port(10) - entPhysicalParentRelPos.10 == 3 - - entPhysicalDescr.11 == "10Base-T Port 4" - entPhysicalVendorType.11 == acmeProducts.portTypes.10 - entPhysicalContainedIn.11 == 7 - entPhysicalClass.11 == port(10) - entPhysicalParentRelPos.11 == 4 - - Slot 2 contains another ethernet module with 2 ports. - entPhysicalDescr.12 == "Acme 10Base-T Module Model 4" - entPhysicalVendorType.12 == acmeProducts.moduleTypes.30 - entPhysicalContainedIn.12 = 5 - entPhysicalClass.12 == module(9) - entPhysicalParentRelPos.12 == 1 - - entPhysicalDescr.13 == "802.3 AUI Port 1" - entPhysicalVendorType.13 == acmeProducts.portTypes.11 - entPhysicalContainedIn.13 == 12 - entPhysicalClass.13 == port(10) - entPhysicalParentRelPos.13 == 1 - - entPhysicalDescr.14 == "10Base-T Port 2" - entPhysicalVendorType.14 == acmeProducts.portTypes.10 - entPhysicalContainedIn.14 == 12 - entPhysicalClass.14 == port(10) - entPhysicalParentRelPos.14 == 2 - - Logical entities -- entLogicalTable - Repeater 1--comprised of any ports attached to backplane 1 - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 30] - - - - - -Draft Entity MIB January 22, 1996 - - - entLogicalDescr.1 == "repeater1" - entLogicalType.1 == snmpDot3RptrMgt - entLogicalCommunity.1 "public-repeater1" - entLogicalTAddress.1 == 124.125.126.127:161 - entLogicalTDomain.1 == snmpUDPDomain - - Repeater 2--comprised of any ports attached to backplane 2: - entLogicalDescr.2 == "repeater2" - entLogicalType.2 == snmpDot3RptrMgt - entLogicalCommunity.2 == "public-repeater2" - entLogicalTAddress.2 == 124.125.126.127:161 - entLogicalTDomain.2 == snmpUDPDomain - -Logical to Physical Mappings -- entLPMappingTable: - - repeater1 uses backplane 1, slot 1-ports 1 & 2, slot 2-port 1 - entLPPhysicalIndex.1.2 == 2 - entLPPhysicalIndex.1.8 == 8 - entLPPhysicalIndex.1.9 == 9 - entLPPhysicalIndex.1.13 == 13 - - repeater2 uses backplane 2, slot 1-ports 3 & 4, slot 2-port 2 - entLPPhysicalIndex.2.3 == 3 - entLPPhysicalIndex.2.10 == 10 - entLPPhysicalIndex.2.11 == 11 - entLPPhysicalIndex.2.14 == 14 - -Logical to Physical to Alias Mappings -- entAliasMappingTable: - repeater1 uses slot 1-ports 1 & 2, slot 2-port 1 - entAliasIdentifier.1.8.1 == rptrPortGroupIndex.1.1 - entAliasIdentifier.1.9.1 == rptrPortGroupIndex.1.2 - entAliasIdentifier.1.13.1 == rptrPortGroupIndex.2.1 - - repeater2 uses slot 1-ports 3 & 4, slot 2-port 2 - entAliasIdentifier.2.10.1 == rptrPortGroupIndex.1.3 - entAliasIdentifier.2.11.1 == rptrPortGroupIndex.1.4 - entAliasIdentifier.2.14.1 == rptrPortGroupIndex.2.2 - -Physical Containment Tree -- entPhysicalContainsTable - - chassis has two backplanes and three containers: - entPhysicalChildIndex.1.2 = 2 - entPhysicalChildIndex.1.3 = 3 - entPhysicalChildIndex.1.4 = 4 - entPhysicalChildIndex.1.5 = 5 - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 31] - - - - - -Draft Entity MIB January 22, 1996 - - - entPhysicalChildIndex.1.6 = 6 - - container 1 has a module: - entPhysicalChildIndex.4.7 = 7 - - container 2 has a module - entPhysicalChildIndex.5.12 = 12 - -- container 3 is empty - - module 1 has some ports: - entPhysicalChildIndex.7.8 = 8 - entPhysicalChildIndex.7.9 = 9 - entPhysicalChildIndex.7.10 = 10 - entPhysicalChildIndex.7.11 = 11 - - module 2 has some ports: - entPhysicalChildIndex.12.13 = 13 - entPhysicalChildIndex.12.14 = 14 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 32] - - - - - -Draft Entity MIB January 22, 1996 - - -6. Acknowledgements - -This document was produced by the IETF Entity MIB Working Group. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 33] - - - - - -Draft Entity MIB January 22, 1996 - - -7. References - -[1] Case, J., McCloghrie, K., Rose, M., and S. Waldbusser, "Structure - of Management Information for version 2 of the Simple Network - Management Protocol (SNMPv2)", RFC 1442, SNMP Research,Inc., Hughes - LAN Systems, Dover Beach Consulting, Inc., Carnegie Mellon - University, April 1993. - -[2] McCloghrie, K., and M. Rose, Editors, "Management Information Base - for Network Management of TCP/IP-based internets: MIB-II", STD 17, - RFC 1213, Hughes LAN Systems, Performance Systems International, - March 1991. - -[3] Galvin, J., and K. McCloghrie, "Administrative Model for version 2 - of the Simple Network Management Protocol (SNMPv2)", RFC 1445, - Trusted Information Systems, Hughes LAN Systems, April 1993. - -[4] Case, J., McCloghrie, K., Rose, M., and S. Waldbusser, "Protocol - Operations for version 2 of the Simple Network Management Protocol - (SNMPv2)", RFC 1448, SNMP Research,Inc., Hughes LAN Systems, Dover - Beach Consulting, Inc., Carnegie Mellon University, April 1993. - -[5] McCloghrie, K., and J. Galvin, "Party MIB for Version 2 of the - Simple Network Management Protocol (SNMPv2)", RFC 1447, Hughes LAN - Systems, Trusted Information Systems, April 1993. - -[6] Case, J., M. Fedor, M. Schoffstall, J. Davin, "Simple Network - Management Protocol", RFC 1157, SNMP Research, Performance Systems - International, MIT Laboratory for Computer Science, May 1990. - -[7] McCloghrie, K., and Kastenholtz, F., "Interfaces Group Evolution", - RFC 1573, Hughes LAN Systems, FTP Software, January 1994. - -[8] Case, J., McCloghrie, K., Rose, M., and Waldbusser, S., "Transport - Mappings for version 2 of the Simple Network Management Protocol - (SNMPv2)", RFC 1449, SNMP Research, Inc., Hughes LAN Systems, Dover - Beach Consulting, Inc., Carnegie Mellon University, April 1993. - - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 34] - - - - - -Draft Entity MIB January 22, 1996 - - -8. Security Considerations - -Security issues are not discussed in this memo. - - -9. Authors' Addresses - - Keith McCloghrie - cisco Systems, Inc. - 170 West Tasman Drive - San Jose, CA 95134 - Phone: 408-526-5260 - Email: kzm@cisco.com - - Andy Bierman - Bierman Consulting - 1200 Sagamore Lane - Ventura, CA 93001 - Phone: 805-648-2028 - Email: abierman@west.net - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 35] - - - - - -Draft Entity MIB January 22, 1996 - - -Table of Contents - - -1 Introduction .................................................... 2 -2 The SNMPv1 Network Management Framework ......................... 3 -2.1 Object Definitions ............................................ 3 -3 Overview ........................................................ 4 -3.1 Terms ......................................................... 4 -3.2 Relationship to Community Strings ............................. 6 -3.3 Relationship to Proxy Mechanisms .............................. 6 -3.4 Relationship to a Chassis MIB ................................. 6 -3.5 Relationship to the Interfaces MIB ............................ 7 -3.6 Relationship to the Other MIBs ................................ 7 -3.7 Re-Configuration of Entities .................................. 7 -3.8 MIB Structure ................................................. 7 -3.9 Multiple Agents ............................................... 8 -4 Definitions ..................................................... 9 -5 Usage Examples .................................................. 25 -5.1 Router/Bridge ................................................. 25 -5.2 Repeaters ..................................................... 28 -6 Acknowledgements ................................................ 33 -7 References ...................................................... 34 -8 Security Considerations ......................................... 35 -9 Authors' Addresses .............................................. 35 - - - - - - - - - - - - - - - - - - - - - - - - - - -McCloghrie/Bierman Expires July 22, 1996 [Page 36] - - - diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/mib/em/mib_NSM.em --- a/usr/src/cmd/agents/snmp/mib/em/mib_NSM.em Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,443 +0,0 @@ --- #ident "%Z%%M% %I% %E% SMI" - - APPLICATION-MIB DEFINITIONS ::= BEGIN - - IMPORTS - OBJECT-TYPE, Counter32, Gauge32 - FROM SNMPv2-SMI - mib-2 - FROM RFC1213-MIB - DisplayString, TimeStamp - FROM SNMPv2-TC; - - - -- Textual conventions - - -- DistinguishedName [5] is used to refer to objects in the - -- directory. - --- DistinguishedName ::= TEXTUAL-CONVENTION --- STATUS current --- DESCRIPTION --- "A Distinguished Name represented in accordance with --- RFC1485." --- SYNTAX DisplayString - -DisplayString ::= OCTET STRING -DistinguishedName ::= OCTET STRING -TimeStamp ::= TimeTicks -Gauge32 ::= Gauge -Counter32 ::= Counter - --- application MODULE-IDENTITY --- LAST-UPDATED "9311280000Z" --- ORGANIZATION "IETF Mail and Directory Management Working Group" --- CONTACT-INFO --- " Ned Freed --- --- Postal: Innosoft International, Inc. --- 250 West First Street, Suite 240 --- Claremont, CA 91711 --- US --- --- Tel: +1 909 624 7907 --- Fax: +1 909 621 5319 --- --- E-Mail: ned@innosoft.com" --- DESCRIPTION --- "The MIB module describing network service applications" --- ::= { mib-2 27 } - -iso OBJECT IDENTIFIER ::= { 1 } -org OBJECT IDENTIFIER ::= { iso 3 } -dod OBJECT IDENTIFIER ::= { org 6 } -internet OBJECT IDENTIFIER ::= { dod 1 } -mgmt OBJECT IDENTIFIER ::= { internet 2 } -mib-2 OBJECT IDENTIFIER ::= { mgmt 1 } -application OBJECT IDENTIFIER ::= { mib-2 27 } - - - -- The basic applTable contains a list of the application - -- entities. - - - applTable OBJECT-TYPE - SYNTAX SEQUENCE OF ApplEntry --- MAX-ACCESS not-accessible - ACCESS not-accessible --- STATUS current - STATUS mandatory - DESCRIPTION - "The table holding objects which apply to all different - kinds of applications providing network services." - ::= {application 1} - - applEntry OBJECT-TYPE - SYNTAX ApplEntry --- MAX-ACCESS not-accessible - ACCESS not-accessible --- STATUS current - STATUS mandatory - DESCRIPTION - "An entry associated with a network service application." - INDEX {applIndex} - ::= {applTable 1} - - ApplEntry ::= SEQUENCE { - applIndex - INTEGER, - applName - DisplayString, - applDirectoryName - DistinguishedName, - applVersion - DisplayString, - applUptime - TimeStamp, - applOperStatus - INTEGER, - applLastChange - TimeStamp, - applInboundAssociations - Gauge32, - applOutboundAssociations - Gauge32, - applAccumulatedInboundAssociations - Counter32, - applAccumulatedOutboundAssociations - Counter32, - applLastInboundActivity - TimeStamp, - applLastOutboundActivity - TimeStamp, - applRejectedInboundAssociations - Counter32, - applFailedOutboundAssociations - Counter32 - } - - applIndex OBJECT-TYPE --- SYNTAX INTEGER (1..2147483647) - SYNTAX INTEGER --- MAX-ACCESS not-accessible - ACCESS not-accessible --- STATUS current - STATUS mandatory - DESCRIPTION - "An index to uniquely identify the network service - application." - ::= {applEntry 1} - - applName OBJECT-TYPE - SYNTAX DisplayString --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "The name the network service application chooses to be - known by." - ::= {applEntry 2} - - applDirectoryName OBJECT-TYPE - SYNTAX DistinguishedName --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "The Distinguished Name of the directory entry where - static information about this application is stored. - An empty string indicates that no information about - the application is available in the directory." - ::= {applEntry 3} - - applVersion OBJECT-TYPE - SYNTAX DisplayString --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "The version of network service application software." - ::= {applEntry 4} - - applUptime OBJECT-TYPE - SYNTAX TimeStamp --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "The value of sysUpTime at the time the network service - application was last initialized. If the application was - last initialized prior to the last initialization of the - network management subsystem, then this object contains - a zero value." - ::= {applEntry 5} - - applOperStatus OBJECT-TYPE - SYNTAX INTEGER { - up(1), - down(2), - halted(3), - congested(4), - restarting(5) - } --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "Indicates the operational status of the network service - application. 'down' indicates that the network service is - not available. 'running' indicates that the network service - is operational and available. 'halted' indicates that the - service is operational but not available. 'congested' - indicates that the service is operational but no additional - inbound associations can be accomodated. 'restarting' - indicates that the service is currently unavailable but is - in the process of restarting and will be available soon." - ::= {applEntry 6} - - applLastChange OBJECT-TYPE - SYNTAX TimeStamp --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "The value of sysUpTime at the time the network service - application entered its current operational state. If - the current state was entered prior to the last - initialization of the local network management subsystem, - then this object contains a zero value." - ::= {applEntry 7} - - applInboundAssociations OBJECT-TYPE - SYNTAX Gauge32 --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "The number of current associations to the network service - application, where it is the responder. For dynamic single - threaded processes, this will be the number of application - instances." - ::= {applEntry 8} - - applOutboundAssociations OBJECT-TYPE - SYNTAX Gauge32 --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "The number of current associations to the network service - application, where it is the initiator. For dynamic single - threaded processes, this will be the number of application - instances." - ::= {applEntry 9} - - applAccumulatedInboundAssociations OBJECT-TYPE - SYNTAX Counter32 --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "The total number of associations to the application entity - since application initialization, where it was the responder. - For dynamic single threaded processes, this will be the - number of application instances." - ::= {applEntry 10} - - applAccumulatedOutboundAssociations OBJECT-TYPE - SYNTAX Counter32 --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "The total number of associations to the application entity - since application initialization, where it was the initiator. - For dynamic single threaded processes, this will be the - number of application instances." - ::= {applEntry 11} - - applLastInboundActivity OBJECT-TYPE - SYNTAX TimeStamp --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "The value of sysUpTime at the time this application last - had an inbound association. If the last association - occurred prior to the last initialization of the network - subsystem, then this object contains a zero value." - ::= {applEntry 12} - - applLastOutboundActivity OBJECT-TYPE - SYNTAX TimeStamp --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "The value of sysUpTime at the time this application last - had an outbound association. If the last association - occurred prior to the last initialization of the network - subsystem, then this object contains a zero value." - ::= {applEntry 13} - - applRejectedInboundAssociations OBJECT-TYPE - SYNTAX Counter32 --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "The total number of inbound associations the application - entity has rejected, since application initialization." - ::= {applEntry 14} - - applFailedOutboundAssociations OBJECT-TYPE - SYNTAX Counter32 --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "The total number associations where the application entity - is initiator and association establishment has failed, - since application initialization." - ::= {applEntry 15} - - - -- The assocTable augments the information in the applTable - -- with information about associations. Note that two levels - -- of compliance are specified below, depending on whether - -- association monitoring is mandated. - - assocTable OBJECT-TYPE - SYNTAX SEQUENCE OF AssocEntry --- MAX-ACCESS not-accessible - ACCESS not-accessible --- STATUS current - STATUS mandatory - DESCRIPTION - "The table holding a set of all active application - associations." - ::= {application 2} - - assocEntry OBJECT-TYPE - SYNTAX AssocEntry --- MAX-ACCESS not-accessible - ACCESS not-accessible --- STATUS current - STATUS mandatory - DESCRIPTION - "An entry associated with an association for a network - service application." - INDEX {applIndex, assocIndex} - ::= {assocTable 1} - - AssocEntry ::= SEQUENCE { - assocIndex - INTEGER, - assocRemoteApplication - DisplayString, - assocApplicationProtocol - OBJECT IDENTIFIER, - assocApplicationType - INTEGER, - assocDuration - TimeStamp - } - - assocIndex OBJECT-TYPE - SYNTAX INTEGER (1..2147483647) --- MAX-ACCESS not-accessible - ACCESS not-accessible --- STATUS current - STATUS mandatory - DESCRIPTION - "An index to uniquely identify each association for a network - service application." - ::= {assocEntry 1} - - assocRemoteApplication OBJECT-TYPE - SYNTAX DisplayString --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "The name of the system running remote network service - application. For an IP-based application this should be - either a domain name or IP address. For an OSI application - it should be the string encoded distinguished name of the - managed object. For X.400(84) MTAs which do not have a - Distinguished Name, the RFC1327 [6] syntax - 'mta in globalid' should be used." - ::= {assocEntry 2} - - assocApplicationProtocol OBJECT-TYPE - SYNTAX OBJECT IDENTIFIER --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "An identification of the protocol being used for the - application. For an OSI Application, this will be the - Application Context. For Internet applications, the IANA - maintains a registry of the OIDs which correspond to - well-known applications. If the application protocol is - not listed in the registry, an OID value of the form - {applTCPProtoID port} or {applUDProtoID port} are used for - TCP-based and UDP-based protocols, respectively. In either - case 'port' corresponds to the primary port number being - used by the protocol." - ::= {assocEntry 3} - - assocApplicationType OBJECT-TYPE - SYNTAX INTEGER { - ua-initiator(1), - ua-responder(2), - peer-initiator(3), - peer-responder(4)} --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "This indicates whether the remote application is some type of - client making use of this network service (e.g. a User Agent) - or a server acting as a peer. Also indicated is whether the - remote end initiated an incoming connection to the network - service or responded to an outgoing connection made by the - local application." - ::= {assocEntry 4} - - assocDuration OBJECT-TYPE - SYNTAX TimeStamp --- MAX-ACCESS read-only - ACCESS read-only --- STATUS current - STATUS mandatory - DESCRIPTION - "The value of sysUpTime at the time this association was - started. If this association started prior to the last - initialization of the network subsystem, then this - object contains a zero value." - ::= {assocEntry 5} - - - applTCPProtoID OBJECT IDENTIFIER ::= {application 4} - applUDPProtoID OBJECT IDENTIFIER ::= {application 5} - - END - diff -r 35f707bf8b40 -r 259bb55df8a9 usr/src/cmd/agents/snmp/mib/gdmo/mib_NSM.gdmo --- a/usr/src/cmd/agents/snmp/mib/gdmo/mib_NSM.gdmo Mon Nov 15 20:03:27 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,414 +0,0 @@ --- #ident "%Z%%M% %I% %E% SMI" - -MODULE "IIMCAPPLICATION-MIB" - -application MANAGED OBJECT CLASS - DERIVED FROM "Rec. X.721 | ISO/IEC 10165-2 : 1992":top; - CHARACTERIZED BY - applicationPkg PACKAGE - BEHAVIOUR - applicationPkgBehaviour BEHAVIOUR - DEFINED AS - !This Managed object class maps to the application group - with object id { mib-2 27 } in APPLICATION-MIB. - See APPLICATION-MIB for attribute semantics.!;; - ATTRIBUTES - "iimcManagementDoc 1": internetClassId GET;;; -REGISTERED AS { iimcAutoTrans 1 3 6 1 2 1 27 }; - -application-proxyNB NAME BINDING - SUBORDINATE OBJECT CLASS application - AND SUBCLASSES; - NAMED BY SUPERIOR OBJECT CLASS - "iimcManagementProxyMIB":cmipsnmpProxyAgent - AND SUBCLASSES; - WITH ATTRIBUTE - "iimcManagementDoc 1": internetClassId; - BEHAVIOUR - application-proxyNBBehaviour BEHAVIOUR - DEFINED AS !The portion of - the internetClassId value shall be 0.!;; -REGISTERED AS { iimcManagementNB 1 1 3 6 1 2 1 27 }; - -applTable MANAGED OBJECT CLASS - DERIVED FROM "Rec. X.721 | ISO/IEC 10165-2 : 1992":top; - CHARACTERIZED BY - applTablePkg PACKAGE - BEHAVIOUR - applTablePkgBehaviour BEHAVIOUR - DEFINED AS - !This Managed object class maps to the applTable object - with object id { application 1 } in APPLICATION-MIB - See APPLICATION-MIB for attribute semantics.!;; - ATTRIBUTES - "iimcManagementDoc 1": internetClassId GET;;; -REGISTERED AS { iimcAutoTrans 1 3 6 1 2 1 27 1 }; - -applEntry MANAGED OBJECT CLASS - DERIVED FROM "Rec. X.721 | ISO/IEC 10165-2 : 1992":top; - CHARACTERIZED BY - applEntryPkg PACKAGE - BEHAVIOUR - applEntryPkgBehaviour BEHAVIOUR - DEFINED AS - !PARSE - MULTIPLEINSTANCES - INDEX - applIndex; - CREATEDELETEATT