URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
Compare Revisions
- This comparison shows the changes necessary to convert path
/or1k/trunk/ecos-2.0/packages/net/snmp/agent
- from Rev 1254 to Rev 1765
- ↔ Reverse comparison
Rev 1254 → Rev 1765
/v2_0/utils/mib2c/mib2c.conf
0,0 → 1,469
# |
# Define types of data by mib type, and translate into needed C code. |
# |
|
############################################################################ |
# source variable typing information: |
include: mib2c.vartypes.conf |
|
# Begin code template section |
############################################################################ |
# variable statemnts used in a couple of places below |
############################################################################ |
type: code-varInits |
code: /* variables we may use later */ |
code: static long long_ret; |
code: static unsigned char string[SPRINT_MAX_LEN]; |
code: static oid objid[MAX_OID_LEN]; |
code: static struct counter64 c64; |
|
|
############################################################################ |
# The .h file |
############################################################################ |
type: code-dot-h |
code: //========================================================================== |
code: // |
code: // snmp/snmpagent/current/include/mibgroup/mibII/$outputName.h |
code: // |
code: // |
code: //========================================================================== |
#####ECOSGPLCOPYRIGHTBEGIN#### |
## ------------------------------------------- |
## This file is part of eCos, the Embedded Configurable Operating System. |
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
## |
## eCos is free software; you can redistribute it and/or modify it under |
## the terms of the GNU General Public License as published by the Free |
## Software Foundation; either version 2 or (at your option) any later version. |
## |
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
## WARRANTY; without even the implied warranty of MERCHANTABILITY or |
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
## for more details. |
## |
## You should have received a copy of the GNU General Public License along |
## with eCos; if not, write to the Free Software Foundation, Inc., |
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
## |
## As a special exception, if other files instantiate templates or use macros |
## or inline functions from this file, or you compile this file and link it |
## with other works to produce a work based on this file, this file does not |
## by itself cause the resulting work to be covered by the GNU General Public |
## License. However the source code for this file must still be made available |
## in accordance with section (3) of the GNU General Public License. |
## |
## This exception does not invalidate any other reasons why a work based on |
## this file might be covered by the GNU General Public License. |
## |
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
## at http://sources.redhat.com/ecos/ecos-license/ |
## ------------------------------------------- |
#####ECOSGPLCOPYRIGHTEND#### |
code: //####UCDSNMPCOPYRIGHTBEGIN#### |
code: // |
code: // ------------------------------------------- |
code: // |
code: // Portions of this software may have been derived from the UCD-SNMP |
code: // project, <http://ucd-snmp.ucdavis.edu/> from the University of |
code: // California at Davis, which was originally based on the Carnegie Mellon |
code: // University SNMP implementation. Portions of this software are therefore |
code: // covered by the appropriate copyright disclaimers included herein. |
code: // |
code: // The release used was version 4.1.2 of May 2000. \"ucd-snmp-4.1.2\" |
code: // ------------------------------------------- |
code: // |
code: //####UCDSNMPCOPYRIGHTEND#### |
code: //========================================================================== |
code: //#####DESCRIPTIONBEGIN#### |
code: // |
code: // Author(s): hmt |
code: // Contributors: hmt |
code: // Date: 2000-05-30 |
code: // Purpose: Port of UCD-SNMP distribution to eCos. |
code: // Description: |
code: // |
code: // |
code: //####DESCRIPTIONEND#### |
code: // |
code: //========================================================================== |
code: /******************************************************************** |
code: Copyright 1989, 1991, 1992 by Carnegie Mellon University |
code: \ |
code: Derivative Work - |
code: Copyright 1996, 1998, 1999, 2000 The Regents of the University of California |
code: \ |
code: All Rights Reserved |
code: \ |
code: Permission to use, copy, modify and distribute this software and its |
code: documentation for any purpose and without fee is hereby granted, |
code: provided that the above copyright notice appears in all copies and |
code: that both that copyright notice and this permission notice appear in |
code: supporting documentation, and that the name of CMU and The Regents of |
code: the University of California not be used in advertising or publicity |
code: pertaining to distribution of the software without specific written |
code: permission. |
code: \ |
code: CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL |
code: WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED |
code: WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR |
code: THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL, |
code: INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING |
code: FROM THE LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF |
code: CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
code: CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
code: *********************************************************************/ |
code: /* This file was generated by mib2c and is intended for use as a mib module |
code: for the ucd-snmp snmpd agent. */ |
code: |
code: #ifndef _MIBGROUP_${OUTPUTNAME}_H |
code: #define _MIBGROUP_${OUTPUTNAME}_H |
code: |
code: /* we may use header_generic and header_simple_table from the util_funcs module */ |
code: |
code: config_require(util_funcs) |
code: |
code: /* function prototypes */ |
code: |
code: void init_$outputName(void); |
code: FindVarMethod var_$outputName; |
code: $variables{'code-var_table-decl'}{'processed'} |
code: $variables{'code-write-func-decl'}{'processed'} |
code: |
code: #endif /* _MIBGROUP_${OUTPUTNAME}_H */ |
|
############################################################################ |
# The .c file, top |
############################################################################ |
type: code-main-part |
code: //========================================================================== |
code: // |
code: // snmp/snmpagent/current/src/mibgroup/mibII/$outputName.c |
code: // |
code: // |
code: //========================================================================== |
#####ECOSGPLCOPYRIGHTBEGIN#### |
## ------------------------------------------- |
## This file is part of eCos, the Embedded Configurable Operating System. |
## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
## |
## eCos is free software; you can redistribute it and/or modify it under |
## the terms of the GNU General Public License as published by the Free |
## Software Foundation; either version 2 or (at your option) any later version. |
## |
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY |
## WARRANTY; without even the implied warranty of MERCHANTABILITY or |
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
## for more details. |
## |
## You should have received a copy of the GNU General Public License along |
## with eCos; if not, write to the Free Software Foundation, Inc., |
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
## |
## As a special exception, if other files instantiate templates or use macros |
## or inline functions from this file, or you compile this file and link it |
## with other works to produce a work based on this file, this file does not |
## by itself cause the resulting work to be covered by the GNU General Public |
## License. However the source code for this file must still be made available |
## in accordance with section (3) of the GNU General Public License. |
## |
## This exception does not invalidate any other reasons why a work based on |
## this file might be covered by the GNU General Public License. |
## |
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc. |
## at http://sources.redhat.com/ecos/ecos-license/ |
## ------------------------------------------- |
#####ECOSGPLCOPYRIGHTEND#### |
code: //####UCDSNMPCOPYRIGHTBEGIN#### |
code: // |
code: // ------------------------------------------- |
code: // |
code: // Portions of this software may have been derived from the UCD-SNMP |
code: // project, <http://ucd-snmp.ucdavis.edu/> from the University of |
code: // California at Davis, which was originally based on the Carnegie Mellon |
code: // University SNMP implementation. Portions of this software are therefore |
code: // covered by the appropriate copyright disclaimers included herein. |
code: // |
code: // The release used was version 4.1.2 of May 2000. \"ucd-snmp-4.1.2\" |
code: // ------------------------------------------- |
code: // |
code: //####UCDSNMPCOPYRIGHTEND#### |
code: //========================================================================== |
code: //#####DESCRIPTIONBEGIN#### |
code: // |
code: // Author(s): hmt |
code: // Contributors: hmt |
code: // Date: 2000-05-30 |
code: // Purpose: Port of UCD-SNMP distribution to eCos. |
code: // Description: |
code: // |
code: // |
code: //####DESCRIPTIONEND#### |
code: // |
code: //========================================================================== |
code: /******************************************************************** |
code: Copyright 1989, 1991, 1992 by Carnegie Mellon University |
code: \ |
code: Derivative Work - |
code: Copyright 1996, 1998, 1999, 2000 The Regents of the University of California |
code: \ |
code: All Rights Reserved |
code: \ |
code: Permission to use, copy, modify and distribute this software and its |
code: documentation for any purpose and without fee is hereby granted, |
code: provided that the above copyright notice appears in all copies and |
code: that both that copyright notice and this permission notice appear in |
code: supporting documentation, and that the name of CMU and The Regents of |
code: the University of California not be used in advertising or publicity |
code: pertaining to distribution of the software without specific written |
code: permission. |
code: \ |
code: CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL |
code: WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED |
code: WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR |
code: THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL, |
code: INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING |
code: FROM THE LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF |
code: CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
code: CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
code: *********************************************************************/ |
code: /* This file was generated by mib2c and is intended for use as a mib module |
code: for the ucd-snmp snmpd agent. */ |
code: |
code: /* This should always be included first before anything else */ |
code: #include <config.h> |
code: |
code: /* minimal include directives */ |
code: #include \"mibincl.h\" |
code: #include \"mibgroup/util_funcs.h\" |
code: #include \"mibgroup/mibII/$outputName.h\" |
code: |
code: /* |
code: * ${outputName}_variables_oid: |
code: * this is the top level oid that we want to register under. This |
code: * is essentially a prefix, with the suffix appearing in the |
code: * variable below. |
code: */ |
code: |
code: oid ${outputName}_variables_oid[] = { $commaoid }; |
code: |
code: /* |
code: * variable$varlen ${outputName}_variables: |
code: * this variable defines function callbacks and type return information |
code: * for the $outputName mib section |
code: */ |
code: |
code: struct variable$varlen ${outputName}_variables[] = { |
code: /* magic number , variable type , ro/rw , callback fn , L, oidsuffix */ |
code: $variables{'variable-structure-info'}{'processed'} |
code: }; |
code: /* (L = length of the oidsuffix) */ |
code: |
code: /* |
code: * init_$outputName(): |
code: * Initialization routine. This is called when the agent starts up. |
code: * At a minimum, registration of your variables should take place here. |
code: */ |
code: void init_$outputName(void) { |
code: |
code: /* register ourselves with the agent to handle our mib tree */ |
code: REGISTER_MIB(\"$outputName\", ${outputName}_variables, variable$varlen,\ |
code: ${outputName}_variables_oid); |
code: |
code: /* place any other initialization junk you need here */ |
code: } |
code: |
code: /* |
code: * var_$outputName(): |
code: * This function is called every time the agent gets a request for |
code: * a scalar variable that might be found within your mib section |
code: * registered above. It is up to you to do the right thing and |
code: * return the correct value. |
code: * You should also correct the value of \"var_len\" if necessary. |
code: * |
code: * Please see the documentation for more information about writing |
code: * module extensions, and check out the examples in the examples |
code: * and mibII directories. |
code: */ |
code: unsigned char * |
code: var_$outputName(struct variable *vp, |
code: oid *name, |
code: size_t *length, |
code: int exact, |
code: size_t *var_len, |
code: WriteMethod **write_method) |
code: { |
code: |
code: $variables{'code-varInits'}{'code'} |
code: |
code: if (header_generic(vp,name,length,exact,var_len,write_method) |
code: == MATCH_FAILED ) |
code: return NULL; |
code: |
code: /* |
code: * this is where we do the value assignments for the mib results. |
code: */ |
code: switch(vp->magic) {\n\n |
code: $variables{$outputName}{'code-case-statements'}{'processed'} |
code: default: |
code: ERROR_MSG(\"\"); |
code: } |
code: return NULL; |
code: } |
code: |
code: $variables{'code-var_table'}{'processed'} |
code: |
code: $variables{'code-write-func'}{'processed'} |
|
############################################################################ |
# var_ function for tables, which is handled specially and used above |
# |
# Note: $vtable is set to the table name in the processtable loop. |
############################################################################ |
|
# |
# header file defs first |
# |
type: code-var_table-decl |
processtable: code-var_table-decl |
|
code: FindVarMethod var_$vtable; |
|
# |
# Code code per table |
# |
type: code-var_table |
processtable: code-var_table |
|
code: /* |
code: * var_$vtable(): |
code: * Handle this table separately from the scalar value case. |
code: * The workings of this are basically the same as for var_$outputName above. |
code: */ |
code: unsigned char * |
code: var_$vtable(struct variable *vp, |
code: oid *name, |
code: size_t *length, |
code: int exact, |
code: size_t *var_len, |
code: WriteMethod **write_method) |
code: { |
code: |
code: $variables{'code-varInits'}{'code'} |
code: |
code: /* |
code: * This assumes that the table is a \'simple\' table. |
code: * See the implementation documentation for the meaning of this. |
code: * You will need to provide the correct value for the TABLE_SIZE parameter |
code: * |
code: * If this table does not meet the requirements for a simple table, |
code: * you will need to provide the replacement code yourself. |
code: * Mib2c is not smart enough to write this for you. |
code: * Again, see the implementation documentation for what is required. |
code: */ |
code: if (header_simple_table(vp,name,length,exact,var_len,write_method, TABLE_SIZE) |
code: == MATCH_FAILED ) |
code: return NULL; |
code: |
code: /* |
code: * this is where we do the value assignments for the mib results. |
code: */ |
code: switch(vp->magic) {\n\n |
code: $variables{$vtable}{'code-case-statements'}{'processed'} |
code: default: |
code: ERROR_MSG(\"\"); |
code: } |
code: return NULL; |
code: } |
|
|
############################################################################ |
# case statement sections |
############################################################################ |
type: code-case-statements |
process: code-case-statements |
skipif: $mib->{'access'} =~ /NoAccess/ |
|
code: case $NAME: |
code: " . (($mib->{'access'} =~ /ReadWrite|WriteOnly|Create/) ? "*write_method = write_$mib->{label};" : "") . " |
code: $variables{$mib->{'type'}}{'case'} |
code: |
|
############################################################################ |
# storage structure information |
############################################################################ |
type: variable-structure-info |
process: variable-structure-info |
skipif: $mib->{'access'} =~ /NoAccess/ |
code: " . sprintf("#define %-20s $count", $NAME) . " |
code: " . sprintf(" { %-20s, %-14s, %-6.6s, %s, %d, { %s } },", $NAME, $variables{$mib->{'type'}}{'asnType'}, $accessToUCD{$mib->{'access'}}, "var_$vroutine", $depth-1, $subid) . " |
|
############################################################################ |
# write function defitition, also appended to the end of the .c file. |
############################################################################ |
# |
# Header info: declair write functions for set processing |
# |
process: code-write-func-decl |
type: code-write-func-decl |
skipif: $mib->{'access'} !~ /Write|Create/ |
code: WriteMethod write_$name; |
# |
# C code |
# |
type: code-write-func |
process: code-write-func |
skipif: $mib->{'access'} !~ /Write|Create/ |
code: int |
code: write_$name(int action, |
code: u_char *var_val, |
code: u_char var_val_type, |
code: size_t var_val_len, |
code: u_char *statP, |
code: oid *name, |
code: size_t name_len) |
code: { |
code: $variables{$mib->{'type'}}{writeInit} |
code: int size; |
code: |
code: switch ( action ) { |
code: case RESERVE1: |
code: if (var_val_type != $variables{$mib->{'type'}}{asnType}){ |
code: fprintf(stderr, \"write to $name not $variables{$mib->{'type'}}{asnType}\\n\"); |
code: return SNMP_ERR_WRONGTYPE; |
code: } |
code: if (var_val_len > sizeof($variables{$mib->{'type'}}{variable})){ |
code: fprintf(stderr,\"write to $name: bad length\\n\"); |
code: return SNMP_ERR_WRONGLENGTH; |
code: } |
code: break; |
code: |
code: case RESERVE2: |
code: size = var_val_len; |
code: $variables{$mib->{'type'}}{variable} = ($variables{$mib->{'type'}}{cast}) var_val; |
code: |
code: break; |
code: |
code: case FREE: |
code: /* Release any resources that have been allocated */ |
code: break; |
code: |
code: case ACTION: |
code: /* The variable has been stored in $variables{$mib->{'type'}}{variable} for |
code: you to use, and you have just been asked to do something with |
code: it. Note that anything done here must be reversable in the UNDO case */ |
code: break; |
code: |
code: case UNDO: |
code: /* Back out any changes made in the ACTION case */ |
code: break; |
code: |
code: case COMMIT: |
code: /* Things are working well, so it's now safe to make the change |
code: permanently. Make sure that anything done here can't fail! */ |
code: break; |
code: } |
code: return SNMP_ERR_NOERROR; |
code: } |
code: |
code: |
/v2_0/utils/mib2c/mib2c.storage.conf
0,0 → 1,681
# mib2c.storage.conf: |
# |
# This is a special mib2c.conf file that assumes that you want to do |
# all storage of information locally rather than pulling the |
# information from another source outside the agent (EG, the |
# kernel). To accomplish this, it defines a structure for the |
# storage of tables and assumes you want to use the header_complex |
# functions for retrieving and storing that data in a local data |
# store. It even writes a .conf file parser for you and sets you up |
# for being able to do persistant storage fairly simply. |
# |
# In short: it trys to do almost all of the work for you... Almost... |
|
# |
# Define types of data by mib type, and translate into needed C code. |
# |
|
# We need to get some extra stuff into the variable declarations |
# before sourcing the main mib2c.vartypes.conf file below. |
type: OCTETSTR |
storage: char *${name}; |
storage: size_t ${name}Len; |
varlenname: StorageTmp->${name}Len |
vartest: if (StorageTmp->${name} == NULL) { |
vartest: config_perror(\"invalid specification for ${name}\"); |
vartest: return; |
vartest: } |
vartest: |
action: tmpvar = StorageTmp->$name; |
action: tmplen = StorageTmp->${name}Len; |
action: memdup((u_char **) &StorageTmp->$name, var_val, var_val_len); |
action: StorageTmp->${name}Len = var_val_len; |
undo: SNMP_FREE(StorageTmp->${name}); |
undo: StorageTmp->${name} = tmpvar; |
undo: StorageTmp->${name}Len = tmplen; |
commit: SNMP_FREE(tmpvar); |
sizeofstart: |
sizeofend: Len |
tmpvar: char * |
casttmp: strdup((char *) tmpvar); |
# |
type: INTEGER |
storage: long $name; |
storageret: & |
varlenname: tmpint |
sizeofstart: sizeof( |
sizeofend: ) |
tmpvar: int |
action: tmpvar = StorageTmp->$name; |
action: StorageTmp->${name} = *((long *) var_val); |
undo: StorageTmp->${name} = tmpvar; |
casttmp: tmpvar; |
# |
type: OBJECTID |
storage: oid *$name; |
storage: size_t ${name}Len |
varlenname: StorageTmp->${name}Len |
vartest: if (StorageTmp->${name} == NULL) { |
vartest: config_perror(\"invalid specification for ${name}\"); |
vartest: return; |
vartest: } |
vartest: |
action: tmpvar = StorageTmp->$name; |
action: tmplen = StorageTmp->${name}Len; |
action: memdup((u_char **) &StorageTmp->$name, var_val, var_val_len); |
action: StorageTmp->${name}Len = var_val_len/sizeof(oid); |
undo: SNMP_FREE(StorageTmp->${name}); |
undo: StorageTmp->${name} = tmpvar; |
undo: StorageTmp->${name}Len = tmplen; |
commit: SNMP_FREE(tmpvar); |
sizeofstart: |
sizeofend: Len |
tmpvar: oid * |
casttmp: (oid *) tmpvar; |
freetmp: SNMP_FREE(tmpvar); |
# |
type: COUNTER64 |
storage: struct counter64 $name; |
varlenname: tmpint |
sizeofstart: sizeof( |
sizeofend: ) |
tmpvar: struct counter64 * |
casttmp: (struct counter64 *) tmpvar; |
|
############################################################################ |
# source variable typing information: |
include: mib2c.vartypes.conf |
|
############################################################################ |
# The .h file |
############################################################################ |
type: code-dot-h |
code: /* This file was generated by mib2c and is intended for use as a mib module |
code: for the ucd-snmp snmpd agent. */ |
code: |
code: #ifndef _MIBGROUP_${OUTPUTNAME}_H |
code: #define _MIBGROUP_${OUTPUTNAME}_H |
code: |
code: /* we may use header_complex from the header_complex module */ |
code: |
code: config_require(header_complex) |
code: |
code: /* our storage structure(s) */ |
code: $variables{'code-structure-per-table'}{'processed'} |
code: |
code: /* enum definitions from the covered mib sections */ |
code: |
code: $variables{'code-enums'}{'processed'} |
code: |
code: /* function prototypes */ |
code: |
code: void init_$outputName(void); |
code: $variables{'code-var-table-decl'}{'processed'} |
code: $variables{'code-write-func-decl'}{'processed'} |
code: $variables{'code-write-rowstatus-decl'}{'processed'} |
code: |
code: #endif /* _MIBGROUP_${OUTPUTNAME}_H */ |
|
# |
# Structure definition, one per table |
# |
type: code-structure-per-table |
processtable: code-structure-per-table |
|
code: struct ${vtable}_data { |
code: $variables{$vtable}{'code-structure'}{'processed'} |
code: }; |
|
# |
# Structure storage arrays, one per table |
# |
type: code-structure-storage |
processtable: code-structure-storage |
|
code: static struct header_complex_index *${vtable}Storage = NULL; |
|
# |
# Structure definition line. |
# |
type: code-structure |
process: code-structure |
|
code: " . eval ("\"$variables{$mib->{'type'}}{'storage'}\"") . " |
#$variables{$i}{'code'}\""evalstr( |
# |
# ENUM definitions |
# |
type: code-enums |
process: code-enums |
skipif: $mib->{'textualConvention'} eq "RowStatus" || $mib->{'textualConvention'} eq "StorageType" |
|
code: " . eval{ my ($i, $x); foreach $i (sort {$mib->{'enums'}{$a} <=> $mib->{'enums'}{$b}} keys(%{$mib->{'enums'}})) { $x .= sprintf("#define %-40s %d\n","${NAME}_" . uc($i),$mib->{'enums'}{$i}); } $x; } . " |
|
############################################################################ |
# The .c file, top |
############################################################################ |
type: code-main-part |
code: /* This file was generated by mib2c and is intended for use as |
code: a mib module for the ucd-snmp snmpd agent. */ |
code: |
code: /* This should always be included first before anything else */ |
code: #include <config.h> |
code: #if HAVE_STDLIB_H |
code: #include <stdlib.h> |
code: #endif |
code: #if HAVE_STRING_H |
code: #include <string.h> |
code: #else |
code: #include <strings.h> |
code: #endif |
code: |
code: /* minimal include directives */ |
code: #include \"mibincl.h\" |
code: #include \"header_complex.h\" |
code: #include \"$outputName.h\" |
code: #include \"snmp-tc.h\" |
code: |
code: /* |
code: * ${outputName}_variables_oid: |
code: * this is the top level oid that we want to register under. This |
code: * is essentially a prefix, with the suffix appearing in the |
code: * variable below. |
code: */ |
code: |
code: oid ${outputName}_variables_oid[] = { $commaoid }; |
code: |
code: /* |
code: * variable$varlen ${outputName}_variables: |
code: * this variable defines function callbacks and type return information |
code: * for the $outputName mib section |
code: */ |
code: |
code: struct variable$varlen ${outputName}_variables[] = { |
code: /* magic number , variable type , ro/rw , callback fn , L, oidsuffix */ |
code: $variables{'variable-structure-info'}{'processed'} |
code: }; |
code: /* (L = length of the oidsuffix) */ |
code: |
code: /* global storage of our data, saved in and configured by header_complex() */ |
code: $variables{'code-structure-storage'}{'processed'} |
code: |
code: /* |
code: * init_$outputName(): |
code: * Initialization routine. This is called when the agent starts up. |
code: * At a minimum, registration of your variables should take place here. |
code: */ |
code: void init_$outputName(void) { |
code: DEBUGMSGTL((\"$outputName\", \"initializing... \")); |
code: |
code: /* register ourselves with the agent to handle our mib tree */ |
code: REGISTER_MIB(\"$outputName\", ${outputName}_variables, variable$varlen,\ |
code: ${outputName}_variables_oid); |
code: |
code: /* register our config handler(s) to deal with registrations */ |
code: $variables{'code-parser-registration'}{'processed'} |
code: |
code: /* place any other initialization junk you need here */ |
code: |
code: DEBUGMSGTL((\"$outputName\", \"done.\\n\")); |
code: } |
code: |
code: $variables{'code-parser'}{'processed'} |
code: |
code: $variables{'code-var_table'}{'processed'} |
code: |
code: $variables{'code-write-func'}{'processed'} |
code: |
code: $variables{'code-write-rowstatus'}{'processed'} |
|
############################################################################ |
# var_ function for tables, which is handled specially and used above |
# |
# Note: $vtable is set to the table name in the processtable loop. |
############################################################################ |
|
# |
# header file defs first |
# |
type: code-var-table-decl |
processtable: code-var-table-decl |
|
code: FindVarMethod var_$vtable; |
code: void parse_$vtable(char *, char *); |
|
# |
# .conf Parser Code per table |
# |
type: code-parser-registration |
processtable: code-parser-registration |
code: snmpd_register_config_handler(\"$vtable\", parse_$vtable, NULL, |
code: \"HELP STRING\"); |
|
type: code-varlist-add |
process: code-varlist-add |
skipif: $variables{$vroutine}{$name}{'isanindex'} != 1 |
code: snmp_varlist_add_variable(&vars, NULL, 0, $variables{$mib->{type}}{asnType}, ($variables{$mib->{type}}{'cast'}) thedata->$name, $variables{$mib->{type}}{'sizeofstart'}thedata->$name$variables{$mib->{type}}{'sizeofend'}); /* $name */ |
|
type: code-parser |
processtable: code-parser |
|
code: /* |
code: * ${vtable}_add(): adds a structure node to our data set |
code: */ |
code: int |
code: ${vtable}_add(struct ${vtable}_data *thedata) { |
code: struct variable_list *vars = NULL; |
code: |
code: DEBUGMSGTL((\"$outputName\", \"adding data... \")); |
code: /* add the index variables to the varbind list, which is |
code: used by header_complex to index the data */ |
code: |
code: $variables{$vtable}{'code-varlist-add'}{'processed'} |
code: |
code: header_complex_add_data(&${vtable}Storage, vars, thedata); |
code: DEBUGMSGTL((\"$vtable\",\"registered an entry\\n\")); |
code: |
code: DEBUGMSGTL((\"$outputName\", \"done.\\n\")); |
code: return SNMPERR_SUCCESS; |
code: } |
code: |
code: /* |
code: * parse_$vtable(): |
code: * parses .conf file entries needed to configure the mib. |
code: */ |
code: void |
code: parse_$vtable(char *token, char *line) { |
code: size_t tmpint; |
code: struct ${vtable}_data *StorageTmp = SNMP_MALLOC_STRUCT(${vtable}_data); |
code: struct variable_list *vars = NULL; |
code: |
code: DEBUGMSGTL((\"$outputName\", \"parsing config... \")); |
code: |
code: if (StorageTmp == NULL) { |
code: config_perror(\"malloc failure\"); |
code: return; |
code: } |
code: |
code: $variables{$vtable}{'code-parser-sections'}{'processed'} |
code: |
code: ${vtable}_add(StorageTmp); |
code: |
code: DEBUGMSGTL((\"$outputName\", \"done.\\n\")); |
code: } |
code: |
code: |
code: /* |
code: * store_$vtable(): |
code: * stores .conf file entries needed to configure the mib. |
code: */ |
code: void |
code: store_$vtable(void) { |
code: char line[SNMP_MAXBUF]; |
code: char *cptr; |
code: size_t tmpint; |
code: struct ${vtable}_data *StorageTmp; |
code: struct header_complex_index *hcindex; |
code: |
code: DEBUGMSGTL((\"$outputName\", \"storing data... \")); |
code: |
code: memset(line,0,sizeof(line)); |
code: |
code: strcat(line, \"$vtable\"); |
code: cptr = line + strlen(line); |
code: |
code: for(hcindex=${vtable}Storage; hcindex != NULL; |
code: hcindex = hcindex->next) { |
code: StorageTmp = (struct ${vtable}_data *) hcindex->data; |
code: |
code: $variables{$vtable}{'code-persistent-sections'}{'processed'} |
code: |
code: snmpd_store_config(line); |
code: } |
code: DEBUGMSGTL((\"$outputName\", \"done.\\n\")); |
code: } |
|
# individual sections for the parser |
type: code-parser-sections |
process: code-parser-sections |
skipif: $mib->{'access'} =~ /NoAccess/ |
|
code: line = read_config_read_data($variables{$mib->{type}}{asnType}, line, &StorageTmp->$name, &" . eval ("\"$variables{$mib->{type}}{varlenname}\"") . "); |
code: " . eval ("\"$variables{$mib->{type}}{vartest}\"") . " |
|
# |
# .conf persistent save Code per table |
# |
type: code-persistent-sections |
process: code-persistent-sections |
skipif: $mib->{'access'} =~ /NoAccess/ |
code: cptr = read_config_store_data($variables{$mib->{type}}{asnType}, cptr, &StorageTmp->$name, &" . eval ("\"$variables{$mib->{type}}{varlenname}\"") . "); |
|
# |
# Code code per table |
# |
type: code-var_table |
processtable: code-var_table |
|
code: /* |
code: * var_$vtable(): |
code: * Handle this table separately from the scalar value case. |
code: * The workings of this are basically the same as for var_$outputName above. |
code: */ |
code: unsigned char * |
code: var_$vtable(struct variable *vp, |
code: oid *name, |
code: size_t *length, |
code: int exact, |
code: size_t *var_len, |
code: WriteMethod **write_method) |
code: { |
code: |
code: struct ${vtable}_data *StorageTmp = NULL; |
code: |
code: DEBUGMSGTL((\"$outputName\", \"var_$vtable: Entering... \\n\")); |
code: /* |
code: * this assumes you have registered all your data properly |
cdoe: * with header_complex_add() somewhere before this |
code: */ |
code: if ((StorageTmp = |
code: header_complex(${vtable}Storage, vp,name,length,exact, |
code: var_len,write_method)) == NULL) |
code: return NULL; |
code: |
code: /* |
code: * this is where we do the value assignments for the mib results. |
code: */ |
code: switch(vp->magic) {\n\n |
code: $variables{$vtable}{'code-case-statements'}{'processed'} |
code: default: |
code: ERROR_MSG(\"\"); |
code: } |
code: return NULL; |
code: } |
|
|
############################################################################ |
# case statement sections |
############################################################################ |
type: code-case-statements |
process: code-case-statements |
skipif: $mib->{'access'} =~ /NoAccess/ |
|
code: case $NAME: |
code: " . (($mib->{'access'} =~ /ReadWrite|WriteOnly|Create/) ? "*write_method = write_$mib->{label};" : "") . " |
code: *var_len = $variables{$mib->{'type'}}{'sizeofstart'}StorageTmp->$mib->{label}$variables{$mib->{'type'}}{'sizeofend'}; |
code: return (u_char *) $variables{$mib->{'type'}}{'storageret'}StorageTmp->$mib->{label}; |
code: |
|
############################################################################ |
# storage structure information |
############################################################################ |
type: variable-structure-info |
process: variable-structure-info |
skipif: $mib->{'access'} =~ /NoAccess/ |
code: " . sprintf("#define %-20s $count", $NAME) . " |
code: " . sprintf(" { %-20s, %-14s, %-6.6s, %s, %d, { %s } },", $NAME, $variables{$mib->{'type'}}{'asnType'}, $accessToUCD{$mib->{'access'}}, "var_$vroutine", $depth-1, $subid) . " |
|
############################################################################ |
# write function definition, also appended to the end of the .c file. |
############################################################################ |
# |
# Header info: declair write functions for set processing |
# |
process: code-write-func-decl |
type: code-write-func-decl |
skipif: $mib->{'access'} !~ /Write|Create/ |
code: WriteMethod write_$name; |
# |
# C code |
# |
type: code-write-func |
process: code-write-func |
skipif: $mib->{'textualConvention'} eq "RowStatus" || $mib->{'access'} !~ /Write|Create/ |
code: int |
code: write_$name(int action, |
code: u_char *var_val, |
code: u_char var_val_type, |
code: size_t var_val_len, |
code: u_char *statP, |
code: oid *name, |
code: size_t name_len) |
code: { |
code: static $variables{$mib->{'type'}}{tmpvar} tmpvar; |
code: struct ${vroutine}_data *StorageTmp = NULL; |
code: static size_t tmplen; |
code: size_t newlen=name_len - (sizeof(${outputName}_variables_oid)/sizeof(oid) + $depth - 1); |
code: |
code: DEBUGMSGTL((\"$outputName\", \"write_$name entering action=%d... \\n\", action)); |
code: if ((StorageTmp = |
code: header_complex(${vroutine}Storage, NULL, |
code: &name[sizeof(${outputName}_variables_oid)/sizeof(oid) + $depth - 1], |
code: &newlen, 1, NULL, NULL)) == NULL) |
code: return SNMP_ERR_NOSUCHNAME; /* remove if you support creation here */ |
code: |
code: switch ( action ) { |
code: case RESERVE1: |
code: if (var_val_type != $variables{$mib->{'type'}}{asnType}){ |
code: fprintf(stderr, \"write to $name not $variables{$mib->{'type'}}{asnType}\\n\"); |
code: return SNMP_ERR_WRONGTYPE; |
code: } |
code: break; |
code: |
code: case RESERVE2: |
code: /* memory reseveration, final preparation... */ |
code: break; |
code: |
code: case FREE: |
code: /* Release any resources that have been allocated */ |
code: break; |
code: |
code: case ACTION: |
code: /* The variable has been stored in $variables{$mib->{'type'}}{variable} for |
code: you to use, and you have just been asked to do something with |
code: it. Note that anything done here must be reversable in the UNDO case */ |
code: ".eval ("\"$variables{$mib->{type}}{action}\"")." |
code: break; |
code: |
code: case UNDO: |
code: /* Back out any changes made in the ACTION case */ |
code: ".eval ("\"$variables{$mib->{type}}{undo}\"")." |
code: break; |
code: |
code: case COMMIT: |
code: /* Things are working well, so it's now safe to make the change |
code: permanently. Make sure that anything done here can't fail! */ |
code: ".eval ("\"$variables{$mib->{'type'}}{'commit'}\"")." |
code: break; |
code: } |
code: return SNMP_ERR_NOERROR; |
code: } |
code: |
code: |
############################################################################ |
# copy memory from varlist |
############################################################################ |
type: code-varlist-copy |
process: code-varlist-copy |
skipif: $variables{$vroutine}{$name}{'isanindex'} != 1 |
code: memdup((u_char **) &(StorageNew->$name), |
code: vp->val.$variables{$mib->{'type'}}{variable}, |
code: vp->val_len); |
code: StorageNew->${name}Len = vp->val_len; |
code: vp = vp->next_variable; |
############################################################################ |
# add null pointers to a varlist; value to be parsed later |
############################################################################ |
type: code-varlist-add-null |
process: code-varlist-add-null |
skipif: $variables{$vroutine}{$name}{'isanindex'} != 1 |
code: snmp_varlist_add_variable(&vars, NULL, 0, $variables{$mib->{'type'}}{asnType}, NULL, 0); /* $name */ |
############################################################################ |
# write function definition for a RowStatus object, |
# - allows for creation/deletion. |
############################################################################ |
# |
# Header info: declair write functions for set processing |
# |
process: code-write-rowstatus-decl |
type: code-write-rowstatus-decl |
skipif: $mib->{'textualConvention'} ne "RowStatus" |
code: WriteMethod write_$name; |
# |
# code |
# |
type: code-write-rowstatus |
process: code-write-rowstatus |
skipif: $mib->{'textualConvention'} ne "RowStatus" |
code: int |
code: write_$name(int action, |
code: u_char *var_val, |
code: u_char var_val_type, |
code: size_t var_val_len, |
code: u_char *statP, |
code: oid *name, |
code: size_t name_len) |
code: { |
code: struct ${vroutine}_data *StorageTmp = NULL; |
code: static struct ${vroutine}_data *StorageNew, *StorageDel; |
code: size_t newlen=name_len - (sizeof(${vroutine}_variables_oid)/sizeof(oid) + 3 - 1); |
code: static int old_value; |
code: int set_value; |
code: static struct variable_list *vars, *vp; |
code: struct header_complex_index *hciptr; |
code: char who[MAX_OID_LEN], flagName[MAX_OID_LEN]; |
code: |
code: StorageTmp = |
code: header_complex(${vroutine}Storage, NULL, |
code: &name[sizeof(${vroutine}_variables_oid)/sizeof(oid) + 3 - 1], |
code: &newlen, 1, NULL, NULL); |
code: |
code: |
code: if (var_val_type != ASN_INTEGER || var_val == NULL){ |
code: fprintf(stderr, \"write to $name not ASN_INTEGER\\n\"); |
code: return SNMP_ERR_WRONGTYPE; |
code: } |
code: set_value = *((long *) var_val); |
code: |
code: /* check legal range, and notReady is reserved for us, not a user */ |
code: if (set_value < 1 || set_value > 6 || set_value == RS_NOTREADY) |
code: return SNMP_ERR_INCONSISTENTVALUE; |
code: |
code: switch ( action ) { |
code: case RESERVE1: |
code: /* stage one: test validity */ |
code: if (StorageTmp == NULL) { |
code: /* create the row now? */ |
code: |
code: /* ditch illegal values now */ |
code: if (set_value == RS_ACTIVE || set_value == RS_NOTINSERVICE) |
code: return SNMP_ERR_INCONSISTENTVALUE; |
code: |
code: /* destroying a non-existent row is actually legal */ |
code: if (set_value == RS_DESTROY) { |
code: return SNMP_ERR_NOERROR; |
code: } |
code: |
code: /* illegal creation values */ |
code: if (set_value == RS_ACTIVE || set_value == RS_NOTINSERVICE) { |
code: return SNMP_ERR_INCONSISTENTVALUE; |
code: } |
code: } else { |
code: /* row exists. Check for a valid state change */ |
code: if (set_value == RS_CREATEANDGO || set_value == RS_CREATEANDWAIT) { |
code: /* can't create a row that exists */ |
code: return SNMP_ERR_INCONSISTENTVALUE; |
code: } |
code: /* XXX: interaction with row storage type needed */ |
code: } |
code: break; |
code: |
code: |
code: case RESERVE2: |
code: /* memory reseveration, final preparation... */ |
code: if (StorageTmp == NULL) { |
code: /* creation */ |
code: vars = NULL; |
code: |
code: $variables{'code-varlist-add-null'}{'processed'} |
code: |
code: if (header_complex_parse_oid(&(name[sizeof(${vroutine}_variables_oid)/sizeof(oid)+2]), newlen, |
code: vars) != SNMPERR_SUCCESS) { |
code: /* XXX: free, zero vars */ |
code: return SNMP_ERR_INCONSISTENTNAME; |
code: } |
code: vp = vars; |
code: |
code: StorageNew = SNMP_MALLOC_STRUCT(${vroutine}_data); |
code: $variables{'code-varlist-copy'}{'processed'} |
code: |
code: StorageNew->$name = set_value; |
code: /* XXX: free, zero vars, no longer needed? */ |
code: } |
code: |
code: break; |
code: |
code: |
code: case FREE: |
code: /* XXX: free, zero vars */ |
code: /* Release any resources that have been allocated */ |
code: break; |
code: |
code: |
code: case ACTION: |
code: /* The variable has been stored in set_value for you to |
code: use, and you have just been asked to do something with |
code: it. Note that anything done here must be reversable in |
code: the UNDO case */ |
code: |
code: if (StorageTmp == NULL) { |
code: /* row creation, so add it */ |
code: if (StorageNew != NULL) |
code: ${vroutine}_add(StorageNew); |
code: /* XXX: ack, and if it is NULL? */ |
code: } else if (set_value != RS_DESTROY) { |
code: /* set the flag? */ |
code: old_value = StorageTmp->$name; |
code: StorageTmp->$name = *((long *) var_val); |
code: } else { |
code: /* destroy... extract it for now */ |
code: hciptr = |
code: header_complex_find_entry(${vroutine}Storage, |
code: StorageTmp); |
code: StorageDel = |
code: header_complex_extract_entry(&${vroutine}Storage, |
code: hciptr); |
code: } |
code: break; |
code: |
code: |
code: case UNDO: |
code: /* Back out any changes made in the ACTION case */ |
code: if (StorageTmp == NULL) { |
code: /* row creation, so remove it again */ |
code: hciptr = |
code: header_complex_find_entry(${vroutine}Storage, |
code: StorageTmp); |
code: StorageDel = |
code: header_complex_extract_entry(&${vroutine}Storage, |
code: hciptr); |
code: /* XXX: free it */ |
code: } else if (StorageDel != NULL) { |
code: /* row deletion, so add it again */ |
code: ${vroutine}_add(StorageDel); |
code: } else { |
code: StorageTmp->$name = old_value; |
code: } |
code: break; |
code: |
code: |
code: case COMMIT: |
code: /* Things are working well, so it's now safe to make the change |
code: permanently. Make sure that anything done here can't fail! */ |
code: if (StorageDel != NULL) { |
code: StorageDel == 0; |
code: /* XXX: free it, its dead */ |
code: } |
code: break; |
code: } |
code: return SNMP_ERR_NOERROR; |
code: } |
code: |
/v2_0/utils/mib2c/README-eCos
0,0 → 1,24
To generate the code to allow the agent to understand a MIB: |
|
1) You will need to set the environment variable "MIBS" to "ALL" in your |
environment, e.g.: |
|
setenv MIBS ALL (for csh) |
MIBS=ALL ; export MIBS (for sh/bash) |
|
2) Download the SNMP PERL module |
|
Download the SNMP module from http://www.cpan.org/ |
|
This seems to be at: |
http://cpan.valueclick.com/modules/by-category/05_Networking_Devices_IPC/SNMP/ |
|
3) Place your MIBs in /usr/local/share/snmp/mibs/ |
|
3) Run the mib2c script |
|
perl -I<location of PERL SNMP module> mib2c <mib to generate code for> |
|
e.g. |
|
perl -I~/perl.pl/nsPerl5.005_03/lib/site/i686-linux mib2c interfaces |
/v2_0/utils/mib2c/README.mib2c
0,0 → 1,224
This README describes the ./local/mib2c script. |
|
Author: Derek Simkowiak |
dereks@kd-dev.com |
http://www.kd-dev.com |
(please mail questions to ucd-snmp-coders@ucd-snmp.ucdavis.edu, |
not to the author directly. Thanks!) |
|
Date: Wed Jan 20 02:51:06 PST 1999 |
----------------------------------------------------------------------- |
mib2c |
|
OVERVIEW |
|
mib2c is a Perl script that takes a MIB (such as those files found |
in ./mibs/ ) and converts it into C code. That C code can then be used as a |
"template" to implement your MIB. Then, when you are done editing the C |
code and recompiling, the UCD-SNMP agent (snmpd) will support your MIB. |
mib2c takes the place of "MIB Compilers" that come with commercial SNMP |
agents. |
|
|
REQUIREMENTS/INSTALLATION |
|
mib2c requires the SNMP.pm Perl module. As of this writing the |
latest version of the SNMP.pm module is 1.8. |
|
The SNMP.pm module can be downloaded from CPAN at |
|
http://www.cpan.org/modules/by-module/SNMP/ |
|
...the file that you want is probably SNMP-1.8b5.tar.gz . |
If you didn't know that already, most every Perl module can be downloaded |
from CPAN (www.cpan.org). Follow the installation instructions for the |
module. |
|
NOTE: If you are running Redhat Linux 5.2 (and perhaps other |
versions), you might get the following errors during the "make test" phase |
of the installation of the SNMP.pm module: |
|
[root@olly SNMP-1.8b5]# make test # This is the command... |
PERL_DL_NONLAZY=1 /usr/bin/perl -I./blib/arch -I./blib/lib |
-I/usr/lib/perl5/i386-linux/5.00404 -I/usr/lib/perl5 -e 'use Test::Harness |
qw(&runtests $verbose); $verbose=0; runtests @ARGV;' t/*.t |
t/mib...............ok |
t/session...........FAILED tests 7-8 |
Failed 2/14 tests, 85.71% okay |
t/translate.........ok |
Failed Test Status Wstat Total Fail Failed List of failed |
------------------------------------------------------------------------------- |
t/session.t 14 2 14.29% 7-8 |
Failed 1/3 test scripts, 66.67% okay. 2/24 subtests failed, 91.67% okay. |
make: *** [test_dynamic] Error 9 |
|
|
If the "make" went okay, then you can ignore these test failures. |
These indicate you don't have write access to the portions of the mib |
tree that the test script is trying to use. Please don't email the |
UCD-SNMP list with other errors regarding the SNMP.pm module. |
comp.lang.perl.modules is probably the most appropriate spot to |
discuss problems with the SNMP.pm perl module itself. Interelated |
problems between ucd-snmp and SNMP could be discussed on the ucd-snmp |
mailing lists though. |
|
|
USAGE |
|
mib2c takes one argument: an OID. It then traces down that OID |
and generates the template C code. Here is the documentation, from the |
top of the script: |
|
# This program, given an OID reference as an argument, creates some |
# template mib module files to be used with the ucd-snmp agent. It is |
# far from perfect and will not generate working modules, but it |
# significantly shortens development time by outlining the basic |
# structure. |
# |
# Its up to you to verify what it does and change the default values |
# it returns. |
# |
# You *must* correct the beginning of the var_XXX() function to |
# correctly determine mib ownership of the incoming request. |
|
|
FINDING YOUR MIB |
|
Before you can specify the OID for your enterprise/MIB on the |
command line, the script needs to be able to find your MIB so that it can |
read it in and generate template code. Joe Marzot (gmarzot@nortelnetworks.com) |
tells us: |
-------------------------------------- |
you should read (man mib_api). The defaultm behaviour for mib loading |
from within the perl interface uses the environment variables described |
there. You can also override these and explicitly define mibdirs and |
load modules through the perl/SNMP api. |
|
the easiest thing to do is toss the mibs in /usr/local/share/snmp/mibs |
and set the env. var., MIBS, to 'ALL'. |
-------------------------------------- |
|
I recommend following the last two lines of advice. I simply did |
|
# cp /home/dereks/MY-MIB-FILE.txt /usr/local/share/snmp/mibs/ |
# export MIBS=ALL |
|
...on my Redhat system (with a BASH shell) and it was able to find |
my MIB just fine. |
|
|
EXAMPLES |
|
Here are some examples from Wes Hardaker (wjhardaker@ucdavis.edu). |
He's using a C shell. Wes writes: |
-------------------------------------- |
Ok, in order to run the thing, you actually need to do something like |
this: |
|
setenv MIBS MY-ITEM-MIB # assumes csh |
mib2c itemNode |
|
Where, "itemNode" should be a node in the mib tree that you want to |
generate C code for. Note, pick small pieces not large ones. Yes, it |
will generate code for the entire mibII tree if you ask it to, in one |
very large mib file. |
|
Examples: |
|
% mib2c interfaces |
outputing to interfaces.c and interfaces.h ... |
depth: 3 |
Number of Lines Created: |
178 interfaces.c |
84 interfaces.h |
262 total |
Done. |
|
% mib2c mib-2 # Don't ever do this. |
outputing to mib-2.c and mib-2.h ... |
depth: 5 |
Number of Lines Created: |
2783 mib-2.c |
617 mib-2.h |
3400 total |
Done. |
|
It may have some sorting problems with multiple level mib tree |
branches being generated into one piece of code (reorder the .h file |
structure to be in OID lexical order if needed). |
-------------------------------------- |
|
WHAT TO DO WITH THE CODE THAT GETS GENERATED |
|
You will need to edit your generated code to work with your |
hardware. For instance, if your MIB is for a refridgerator, you will need |
to write the code that talks to the refridgerator (through the serial |
port, maybe?) in Fridge Protocol. |
|
See the files in ./agent/mibgroup/examples/ and |
./agent/mibgroup/dummy/ for heavily-commented example code. Don't ask me |
questions about this stuff--I'm just now figuring it out myself... |
|
[NOTE: If anyone out there has tips about necessary options to |
./configure, or re-compiling snmpd with custom MIB support, please add |
them here...] |
|
WARNING |
|
As of this writing, the mib2c compiler is a bit outdated and needs |
some work. Wes writes: |
-------------------------------------- |
It already needs changing, because the architecture has changed in the |
3.6 line (though its backwards compatible, I'd prefer to generate |
code from newer models than older ones). |
-------------------------------------- |
When I asked him to elaborate on the new 3.6 archictecture, all I |
got was: |
-------------------------------------- |
It hopefully will be in the new documentation about mib module api |
that Dave Shield is putting together (which is also currently wrong, |
for that matter)... |
-------------------------------------- |
...so I don't know what the hell he's talking about. |
|
|
SOME ERRORS AND THEIR MEANING |
|
If you get a large number of errors that look like: |
|
[...] |
unknown type: INTEGER for prIndex |
unknown type: OCTETSTR for prNames |
unknown type: INTEGER for prMin |
[...] |
|
...then you are trying to use an old version of the mib2c script |
that does not support the SNMP.pm module version 1.8. Get the latest |
version of the script. |
|
If you get the error |
|
Couldn't find mib reference: myEnterpriseOID |
|
...when you know that it should be finding your MIB file(s), then |
you forgot to put the word "END" at the very end of your MIB. (Uh...I'm |
not speaking from experience here. Really.) |
|
ACKNOWLEGMENTS |
|
Many thanks to the people on the UCD-SNMP mailing list |
(ucd-snmp@ucd-snmp.ucdavis.edu). In particular, many thanks to |
|
Wes Hardaker <wjhardaker@ucdavis.edu> |
Ken McNamara <conmara@tcon.net> |
Joe Marzot <gmarzot@nortelnetworks.com> |
|
...since about half this document is just cut'n'pasted from emails |
they sent me. |
|
Good luck with your project. |
|
Derek Simkowiak |
dereks@kd-dev.com |
http://www.kd-dev.com |
|
/v2_0/utils/mib2c/mib2c
0,0 → 1,310
#!/usr/bin/perl |
#!/usr/bin/perl -w |
|
# |
# Description: |
# |
# This program, given an OID reference as an argument, creates some |
# template mib module files to be used with the ucd-snmp agent. It is |
# far from perfect and will not generate working modules, but it |
# significantly shortens development time by outlining the basic |
# structure. |
# |
# Its up to you to verify what it does and change the default values |
# it returns. |
# |
|
use SNMP; |
use FileHandle; |
|
#use strict 'vars'; |
$SNMP::save_descriptions=1; |
$SNMP::use_long_names=1; |
$SNMP::use_enums=1; |
SNMP::initMib(); |
|
$configfile="mib2c.conf"; |
$debug=0; |
$nostats = 0; |
|
sub usage { |
print "$0 [-h] [-c configfile] [-f prefix] mibNode\n\n"; |
print " -h\t\tThis message.\n\n"; |
print " -c configfile\tSpecifies the configuration file to use\n\t\tthat dictates what the output of mib2c will look like.\n\n"; |
print " -f prefix\tSpecifies the output prefix to use. All code\n\t\twill be put into prefix.c and prefix.h\n\n"; |
print " mibNode\tThe name of the top level mib node you want to\n\t\tgenerate code for. By default, the code will be stored in\n\t\tmibNode.c and mibNode.h (use the -f flag to change this)\n\n"; |
print " -d\t\tdebugging output (dont do it. trust me.)\n\n"; |
print " -s\t\tDon't display statistics at the end\n\n"; |
1; |
} |
|
while($#ARGV >= 0) { |
$_ = shift; |
$configfile = shift if (/-c/); |
$debug = 1 if (/-d/); |
$nostats = 1 if (/-s/); |
usage && exit(1) if (/-h/); |
$outputName = shift if (/-f/); |
$oid = $_ if (/^[^-]/); |
} |
|
read_config($configfile); |
# |
# internal conversion tables |
# |
|
%accessToUCD = qw(ReadOnly RONLY ReadWrite RWRITE |
WriteOnly RWRITE Create RWRITE); |
|
# The lengths of the defined 'variableN' structures |
@varLengths = (2,4,7,8,13); |
|
if (!defined($oid)) { |
print STDERR "You didn\'t specify a mib oid to convert!\n"; |
usage(); |
exit(1); |
} |
|
$mib = $SNMP::MIB{$oid}; |
$_ = $commaoid = $fulloid = $mib->{'objectID'}; |
if (!defined ($fulloid)) { |
print STDERR "Couldn\'t find mib reference: $oid\n"; |
exit(1); |
} |
s/[^.]//g; |
$commaoid =~ s/\./,/g; |
$commaoid =~ s/^,//g; |
|
$outputName = $mib->{'label'} if (!defined($outputName)); |
$OUTPUTNAME = uc($outputName); |
$vroutine="$outputName"; |
print "outputting to $outputName.c and $outputName.h ...\n"; |
|
#============================================ |
# |
# Walk the MIB tree, and construct strings |
# holding the various fragments of code needed. |
# |
# 'loadMib' returns the length of the longest OID suffix |
# encountered. |
# |
# The variables constructed and used are: |
# |
# (in the header file) |
# functionInfo : A list of definitions for the table-handling functions, |
# and routines for SETtable variables. |
# (The main scalar handling routine is handled implicitly) |
# |
# (in the code file) |
# structinfo : The contents of the variableN structure listing |
# the variables handled, including type, access level, |
# OID suffix and 'magic number' |
# |
# caseStatements: A hash array (indexed by variable routine name) |
# containing the body of the switch statement |
# used for returning the appropriate values. |
# At a minimum, this consists of the various 'case' labels |
# If full type information is available (from mib2c.conf) |
# then this will also include a default initialiser, |
# and setting of a 'write_method' (if appropriate). |
# |
# writeFuncs: A list of function skeletons for setting variables |
# (for variables with suitable access levels). |
# Note that this list will not include functions |
# for variables which don't provide type information |
# in the mib2c.conf file (even if such variables are |
# defined as writeable in the variableN structure). |
# |
#============================================ |
$count = 0; |
$depth = loadMib($mib,0)-1; |
|
# Determine which 'variableN' structure is needed |
for($varlen = 0; $varlen <= $#varLengths; $varlen++) { |
last if ($depth <= $varLengths[$varlen]); |
} |
$varlen = $varLengths[$varlen]; |
|
#============================================ |
# |
# Table-handling routines. |
# |
#============================================ |
foreach $vtable (@table_list) { |
foreach $ptable (@processtable) { |
$variables{$ptable}{'processed'} .= |
(eval "\"$variables{$ptable}{'code'}\"") . "\n\n"; |
} |
$var_routines .= |
(eval "\"$variables{'code-var_table'}{'code'}\"") . "\n\n"; |
} |
|
#============================================ |
# |
# Output the header file |
# |
#============================================ |
open(DOTH,">$outputName.h"); |
print DOTH (eval "\"$variables{'code-dot-h'}{'code'}\"") . "\n"; |
close(DOTH); |
|
#============================================ |
# |
# Output the code file: |
# Initialisation and main variable routine. |
# |
#============================================ |
|
open(DOTC,">$outputName.c"); |
print DOTC (eval "\"$variables{'code-main-part'}{'code'}\"") . "\n\n";; |
close(DOTC); |
|
#============================================ |
# |
# Everyone loves statistics. |
# |
#============================================ |
print " depth: $depth\n"; |
print " Number of Lines Created:\n"; |
system("wc -l $outputName.c $outputName.h"); |
print "Done.\n"; |
|
#============================================ |
# |
# loadMib: |
# Recursive routine to walk the mib, |
# and construct the various code fragment strings. |
# |
#============================================ |
sub loadMib { |
my $mib = shift; |
my $i; |
my $depth = shift; |
$depth = $depth + 1; |
my $name = $mib->{'label'}; |
my $NAME = uc($name); |
print "doing $mib->{label} : $mib->{objectID}\n" if $debug; |
if (defined($mib->{'access'}) && |
$mib->{'access'} =~ /ReadOnly|ReadWrite|WriteOnly|Create|NoAccess/) { |
$count = $count + 1; |
$subid = $mib->{'objectID'}; |
$subid =~ s/$fulloid\.//; |
$subid =~ s/\./,/g; |
if (!defined($variables{$mib->{'type'}}) && !defined($mib->{'indexes'})) { |
print STDERR "unknown type: $mib->{type} for $mib->{label} $mib->{'access'}\n"; |
print STDERR "unknown type: no information generated for $mib->{label}\n"; |
} else { |
foreach $i (@process) { |
next if (defined($variables{$i}{'skipif'}) && |
eval $variables{$i}{'skipif'}); |
my $result = (eval "\"$variables{$i}{'code'}\""); |
$variables{$i}{'processed'} .= "$result\n"; |
$variables{$vroutine}{$i}{'processed'} .= "$result\n"; |
} |
} |
if (defined($mib->{'indexes'})) { |
print "indexes: ", join(", ",@{$mib->{'indexes'}}),"\n" if ($debug); |
$variables{$vroutine}{'indexes'} = $mib->{'indexes'}; |
foreach $i (@{$mib->{'indexes'}}) { |
$variables{$vroutine}{$i}{'isanindex'} = 1; |
} |
} |
} |
my $children = $$mib{'children'}; |
my $i; |
my $newdepth = $depth; |
foreach $i (@{$children}) { |
if ( $name =~ /Table$/ ) { |
$vroutine="$name"; |
push @table_list, $name; |
$newdepth = max(loadMib($i, $depth), $newdepth); |
$vroutine="$outputName"; |
} |
else { |
$newdepth = max(loadMib($i, $depth), $newdepth); |
} |
} |
return $newdepth; |
} |
|
sub max { |
my $x = shift; |
my $y = shift; |
return ($x > $y) ? $x : $y; |
} |
|
|
sub read_config() { |
my $configfile = shift; |
my ($type, $lasttoken); |
my $fh = new FileHandle; |
if ( $fh->open("<$configfile") ) { |
while(<$fh>) { |
next if (/^\s*\#/ || /^\s*$/); |
if (/^\s*type:\s*(.*)/) { |
if (defined($type) && defined($lasttoken) && |
defined ($variables{$type}{$lasttoken})) { |
chomp($variables{$type}{$lasttoken}); |
} |
$type = $1; |
chomp($type); |
} elsif (/include:\s*(.*)/) { |
read_config($1); |
} elsif (/process:\s*(.*)/) { |
push (@process, $1); |
} elsif (/processtable:\s*(.*)/) { |
push (@processtable, $1); |
} elsif (/delete:\s*(.*)/) { |
delete($variables{$type}{$1}); |
} elsif (/copy:\s*(.*)/) { |
my $item; |
chomp($1); |
foreach $item (keys(%{$variables{$1}})) { |
$variables{$type}{$item} = $variables{$1}{$item}; |
} |
} else { |
if (/\s*([^:]*):(\s*.*)/) { |
if (!defined($variables{$type}{$1})) { |
if (defined($type) && defined($lasttoken) && |
defined ($variables{$type}{$lasttoken})) { |
chomp($variables{$type}{$lasttoken}); |
} |
$variables{$type}{$1} = $2; |
$lasttoken = $1; |
$variables{$type}{$1} =~ s/^\t+//; |
} else { |
# duplicate entry: tack it on. |
my ($x, $y) = ($1, $2); |
$y =~ s/^\t+//; |
$variables{$type}{$x} .= "\n" . $y; |
} |
} else { |
# continuation line, it started with spaces or a + |
s/^\s*//; |
s/^\+//; |
$variables{$type}{$lasttoken} .= "\n" . $_; |
chomp($variables{$type}{$lasttoken}); |
} |
} |
} |
$fh->close(); |
} else { |
warn "Config file ($configfile) not found.\n"; |
} |
} |
|
sub evalstr { |
my $str = shift; |
# if ($str !~ /^\"/) { |
$str = "\"$str\""; # surround by quotes. |
# } |
eval ($str); # should return a string, with variables expanded |
} |
|
sub evalrstr { |
my $rstr = shift; |
# if ($str !~ /^\"/) { |
# $$rstr = "\"" . $$rstr . "\""; # surround by quotes. |
# } |
eval ("\"$$rstr\""); # should return a string, with variables expanded |
} |
v2_0/utils/mib2c/mib2c
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: v2_0/utils/mib2c/mib2c.vartypes.conf
===================================================================
--- v2_0/utils/mib2c/mib2c.vartypes.conf (nonexistent)
+++ v2_0/utils/mib2c/mib2c.vartypes.conf (revision 1765)
@@ -0,0 +1,89 @@
+#
+# Define types of data by mib type, and translate into needed C code.
+#
+# type: the label in question extracted from the mib.
+# asnType: the internal type #define we should use for this type.
+# variable: the name of the variable we're going to use.
+# variablePtr: How to get a pointer to the variable above (may be
+# the same, if variable is also a pointer)
+# cast: how to cast from a void * or a char * to a pointer of
+# your type.
+# writeInit: variable declaration
+# case: initialization of the variable to a bogus value.
+#
+# copy: copies the previous definition into the current one,
+# if most of it (or all of it) is the same.
+############################################################################
+type: OCTETSTR
+asnType: ASN_OCTET_STR
+variable: string
+variablePtr: string
+cast: char *
+writeInit: static unsigned char string[SPRINT_MAX_LEN];
+case: *string = 0;
+case: *var_len = strlen(string);
+case: return (unsigned char *) string;
+############################################################################
+type: INTEGER
+asnType: ASN_INTEGER
+variable: long_ret
+variablePtr: &long_ret
+cast: long *
+writeInit: static long *long_ret;
+case: long_ret = 0;
+case: return (unsigned char *) &long_ret;
+############################################################################
+type: OBJECTID
+asnType: ASN_OBJECT_ID
+variable: objid
+variablePtr: objid
+cast: oid *
+writeInit: static oid *objid;
+case: objid[0] = 0;
+case: objid[1] = 0;
+case: *var_len = 2*sizeof(oid);
+case: return (unsigned char *) objid;
+############################################################################
+type: COUNTER64
+asnType: ASN_COUNTER64
+variable: c64
+variablePtr: &c64
+cast: struct counter64 *
+writeInit: struct counter64 *c64;
+case: c64.high = 0;
+case: c64.low = 0;
+case: *var_len = sizeof(c64);
+case: return (unsigned char *) &c64;
+############################################################################
+type: COUNTER
+copy: INTEGER
+delete: asnType
+asnType: ASN_COUNTER
+############################################################################
+type: NETADDR
+copy: ASN_OBJECT_ID
+############################################################################
+type: UINTEGER
+copy: INTEGER
+delete: asnType
+asnType: ASN_UINTEGER
+############################################################################
+type: IPADDR
+copy: OCTETSTR
+delete: asnType
+asnType: ASN_IPADDRESS
+############################################################################
+type: GAUGE
+copy: INTEGER
+delete: asnType
+asnType: ASN_GAUGE
+############################################################################
+type: OPAQUE
+copy: OCTETSTR
+delete: asnType
+asnType: ASN_OPAQUE
+############################################################################
+type: TICKS
+copy: INTEGER
+delete: asnType
+asnType: ASN_TIMETICKS
Index: v2_0/utils/mib2c/mib2c.conf-ORIG
===================================================================
--- v2_0/utils/mib2c/mib2c.conf-ORIG (nonexistent)
+++ v2_0/utils/mib2c/mib2c.conf-ORIG (revision 1765)
@@ -0,0 +1,299 @@
+#
+# Define types of data by mib type, and translate into needed C code.
+#
+
+############################################################################
+# source variable typing information:
+include: mib2c.vartypes.conf
+
+# Begin code template section
+############################################################################
+# variable statemnts used in a couple of places below
+############################################################################
+type: code-varInits
+code: /* variables we may use later */
+code: static long long_ret;
+code: static unsigned char string[SPRINT_MAX_LEN];
+code: static oid objid[MAX_OID_LEN];
+code: static struct counter64 c64;
+
+
+############################################################################
+# The .h file
+############################################################################
+type: code-dot-h
+code: /* This file was generated by mib2c and is intended for use as a mib module
+code: for the ucd-snmp snmpd agent. */
+code:
+code: #ifndef _MIBGROUP_${OUTPUTNAME}_H
+code: #define _MIBGROUP_${OUTPUTNAME}_H
+code:
+code: /* we may use header_generic and header_simple_table from the util_funcs module */
+code:
+code: config_require(util_funcs)
+code:
+code: /* function prototypes */
+code:
+code: void init_$outputName(void);
+code: FindVarMethod var_$outputName;
+code: $variables{'code-var_table-decl'}{'processed'}
+code: $variables{'code-write-func-decl'}{'processed'}
+code:
+code: #endif /* _MIBGROUP_${OUTPUTNAME}_H */
+
+############################################################################
+# The .c file, top
+############################################################################
+type: code-main-part
+code: /* This file was generated by mib2c and is intended for use as a mib module
+code: for the ucd-snmp snmpd agent. */
+code:
+code: #ifdef IN_UCD_SNMP_SOURCE
+code: /* If we're compiling this file inside the ucd-snmp source tree */
+code:
+code: /* This should always be included first before anything else */
+code: #include
+code:
+code: /* minimal include directives */
+code: #include \"mibincl.h\"
+code: #include \"util_funcs.h\"
+code:
+code: #else /* !IN_UCD_SNMP_SOURCE */
+code:
+code: #include
+code: #include
+code: #include
+code:
+code: #endif /* !IN_UCD_SNMP_SOURCE */
+code:
+code: #include \"$outputName.h\"
+code:
+code: /*
+code: * ${outputName}_variables_oid:
+code: * this is the top level oid that we want to register under. This
+code: * is essentially a prefix, with the suffix appearing in the
+code: * variable below.
+code: */
+code:
+code: oid ${outputName}_variables_oid[] = { $commaoid };
+code:
+code: /*
+code: * variable$varlen ${outputName}_variables:
+code: * this variable defines function callbacks and type return information
+code: * for the $outputName mib section
+code: */
+code:
+code: struct variable$varlen ${outputName}_variables[] = {
+code: /* magic number , variable type , ro/rw , callback fn , L, oidsuffix */
+code: $variables{'variable-structure-info'}{'processed'}
+code: };
+code: /* (L = length of the oidsuffix) */
+code:
+code: /*
+code: * init_$outputName():
+code: * Initialization routine. This is called when the agent starts up.
+code: * At a minimum, registration of your variables should take place here.
+code: */
+code: void init_$outputName(void) {
+code:
+code: /* register ourselves with the agent to handle our mib tree */
+code: REGISTER_MIB(\"$outputName\", ${outputName}_variables, variable$varlen,\
+code: ${outputName}_variables_oid);
+code:
+code: /* place any other initialization junk you need here */
+code: }
+code:
+code: /*
+code: * var_$outputName():
+code: * This function is called every time the agent gets a request for
+code: * a scalar variable that might be found within your mib section
+code: * registered above. It is up to you to do the right thing and
+code: * return the correct value.
+code: * You should also correct the value of \"var_len\" if necessary.
+code: *
+code: * Please see the documentation for more information about writing
+code: * module extensions, and check out the examples in the examples
+code: * and mibII directories.
+code: */
+code: unsigned char *
+code: var_$outputName(struct variable *vp,
+code: oid *name,
+code: size_t *length,
+code: int exact,
+code: size_t *var_len,
+code: WriteMethod **write_method)
+code: {
+code:
+code: $variables{'code-varInits'}{'code'}
+code:
+code: if (header_generic(vp,name,length,exact,var_len,write_method)
+code: == MATCH_FAILED )
+code: return NULL;
+code:
+code: /*
+code: * this is where we do the value assignments for the mib results.
+code: */
+code: switch(vp->magic) {\n\n
+code: $variables{$outputName}{'code-case-statements'}{'processed'}
+code: default:
+code: ERROR_MSG(\"\");
+code: }
+code: return NULL;
+code: }
+code:
+code: $variables{'code-var_table'}{'processed'}
+code:
+code: $variables{'code-write-func'}{'processed'}
+
+############################################################################
+# var_ function for tables, which is handled specially and used above
+#
+# Note: $vtable is set to the table name in the processtable loop.
+############################################################################
+
+#
+# header file defs first
+#
+type: code-var_table-decl
+processtable: code-var_table-decl
+
+code: FindVarMethod var_$vtable;
+
+#
+# Code code per table
+#
+type: code-var_table
+processtable: code-var_table
+
+code: /*
+code: * var_$vtable():
+code: * Handle this table separately from the scalar value case.
+code: * The workings of this are basically the same as for var_$outputName above.
+code: */
+code: unsigned char *
+code: var_$vtable(struct variable *vp,
+code: oid *name,
+code: size_t *length,
+code: int exact,
+code: size_t *var_len,
+code: WriteMethod **write_method)
+code: {
+code:
+code: $variables{'code-varInits'}{'code'}
+code:
+code: /*
+code: * This assumes that the table is a \'simple\' table.
+code: * See the implementation documentation for the meaning of this.
+code: * You will need to provide the correct value for the TABLE_SIZE parameter
+code: *
+code: * If this table does not meet the requirements for a simple table,
+code: * you will need to provide the replacement code yourself.
+code: * Mib2c is not smart enough to write this for you.
+code: * Again, see the implementation documentation for what is required.
+code: */
+code: if (header_simple_table(vp,name,length,exact,var_len,write_method, TABLE_SIZE)
+code: == MATCH_FAILED )
+code: return NULL;
+code:
+code: /*
+code: * this is where we do the value assignments for the mib results.
+code: */
+code: switch(vp->magic) {\n\n
+code: $variables{$vtable}{'code-case-statements'}{'processed'}
+code: default:
+code: ERROR_MSG(\"\");
+code: }
+code: return NULL;
+code: }
+
+
+############################################################################
+# case statement sections
+############################################################################
+type: code-case-statements
+process: code-case-statements
+skipif: $mib->{'access'} =~ /NoAccess/
+
+code: case $NAME:
+code: " . (($mib->{'access'} =~ /ReadWrite|WriteOnly|Create/) ? "*write_method = write_$mib->{label};" : "") . "
+code: $variables{$mib->{'type'}}{'case'}
+code:
+
+############################################################################
+# storage structure information
+############################################################################
+type: variable-structure-info
+process: variable-structure-info
+skipif: $mib->{'access'} =~ /NoAccess/
+code: " . sprintf("#define %-20s $count", $NAME) . "
+code: " . sprintf(" { %-20s, %-14s, %-6.6s, %s, %d, { %s } },", $NAME, $variables{$mib->{'type'}}{'asnType'}, $accessToUCD{$mib->{'access'}}, "var_$vroutine", $depth-1, $subid) . "
+
+############################################################################
+# write function defitition, also appended to the end of the .c file.
+############################################################################
+#
+# Header info: declair write functions for set processing
+#
+process: code-write-func-decl
+type: code-write-func-decl
+skipif: $mib->{'access'} !~ /Write|Create/
+code: WriteMethod write_$name;
+#
+# C code
+#
+type: code-write-func
+process: code-write-func
+skipif: $mib->{'access'} !~ /Write|Create/
+code: int
+code: write_$name(int action,
+code: u_char *var_val,
+code: u_char var_val_type,
+code: size_t var_val_len,
+code: u_char *statP,
+code: oid *name,
+code: size_t name_len)
+code: {
+code: $variables{$mib->{'type'}}{writeInit}
+code: int size;
+code:
+code: switch ( action ) {
+code: case RESERVE1:
+code: if (var_val_type != $variables{$mib->{'type'}}{asnType}){
+code: fprintf(stderr, \"write to $name not $variables{$mib->{'type'}}{asnType}\\n\");
+code: return SNMP_ERR_WRONGTYPE;
+code: }
+code: if (var_val_len > sizeof($variables{$mib->{'type'}}{variable})){
+code: fprintf(stderr,\"write to $name: bad length\\n\");
+code: return SNMP_ERR_WRONGLENGTH;
+code: }
+code: break;
+code:
+code: case RESERVE2:
+code: size = var_val_len;
+code: $variables{$mib->{'type'}}{variable} = ($variables{$mib->{'type'}}{cast}) var_val;
+code:
+code: break;
+code:
+code: case FREE:
+code: /* Release any resources that have been allocated */
+code: break;
+code:
+code: case ACTION:
+code: /* The variable has been stored in $variables{$mib->{'type'}}{variable} for
+code: you to use, and you have just been asked to do something with
+code: it. Note that anything done here must be reversable in the UNDO case */
+code: break;
+code:
+code: case UNDO:
+code: /* Back out any changes made in the ACTION case */
+code: break;
+code:
+code: case COMMIT:
+code: /* Things are working well, so it's now safe to make the change
+code: permanently. Make sure that anything done here can't fail! */
+code: break;
+code: }
+code: return SNMP_ERR_NOERROR;
+code: }
+code:
+code:
Index: v2_0/cdl/snmpagent.cdl
===================================================================
--- v2_0/cdl/snmpagent.cdl (nonexistent)
+++ v2_0/cdl/snmpagent.cdl (revision 1765)
@@ -0,0 +1,341 @@
+# ====================================================================
+#
+# snmpagent.cdl
+#
+# SNMP agent configuration data
+#
+# ====================================================================
+#####ECOSGPLCOPYRIGHTBEGIN####
+## -------------------------------------------
+## This file is part of eCos, the Embedded Configurable Operating System.
+## Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+##
+## eCos is free software; you can redistribute it and/or modify it under
+## the terms of the GNU General Public License as published by the Free
+## Software Foundation; either version 2 or (at your option) any later version.
+##
+## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+## WARRANTY; without even the implied warranty of MERCHANTABILITY or
+## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+## for more details.
+##
+## You should have received a copy of the GNU General Public License along
+## with eCos; if not, write to the Free Software Foundation, Inc.,
+## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+##
+## As a special exception, if other files instantiate templates or use macros
+## or inline functions from this file, or you compile this file and link it
+## with other works to produce a work based on this file, this file does not
+## by itself cause the resulting work to be covered by the GNU General Public
+## License. However the source code for this file must still be made available
+## in accordance with section (3) of the GNU General Public License.
+##
+## This exception does not invalidate any other reasons why a work based on
+## this file might be covered by the GNU General Public License.
+##
+## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+## at http://sources.redhat.com/ecos/ecos-license/
+## -------------------------------------------
+#####ECOSGPLCOPYRIGHTEND####
+# ====================================================================
+######DESCRIPTIONBEGIN####
+#
+# Author(s): hmt
+# Original data: hmt, Andrew Lunn
+# Contributors: gthomas
+# Date: 2000-05-30
+#
+#####DESCRIPTIONEND####
+#
+# ====================================================================
+
+cdl_package CYGPKG_SNMPAGENT {
+ display "SNMP agent"
+ parent CYGPKG_NET
+ doc ref/net-snmp-ecos-port.html
+ include_dir ucd-snmp
+ requires CYGPKG_IO
+ requires { 0 != CYGINT_ISO_STRING_STRFUNCS }
+ requires { 0 != CYGINT_ISO_STDLIB_STRCONV }
+ requires { 0 != CYGINT_ISO_STDIO_FORMATTED_IO }
+ requires { 0 != CYGINT_ISO_STRING_STRFUNCS }
+ requires { 0 != CYGINT_ISO_MALLOC }
+ requires { 0 != CYGINT_ISO_ERRNO }
+ requires { 0 != CYGINT_ISO_ERRNO_CODES }
+ requires CYGPKG_NET
+ requires CYGPKG_SNMPLIB
+ description "SNMP agent based on the UCD-SNMP project."
+
+ compile \
+ agent_read_config.c \
+ agent_registry.c \
+ agent_trap.c \
+ kernel.c \
+ mib_modules.c \
+ snmp_agent.c \
+ snmp_vars.c \
+ snmpd.c \
+ snmptask.c \
+ mibgroup/mibII/helpers.c \
+ mibgroup/mibII/system_mib.c \
+ mibgroup/mibII/sysORTable.c \
+ mibgroup/mibII/snmp_mib.c \
+ mibgroup/mibII/icmp.c \
+ mibgroup/mibII/interfaces.c \
+ mibgroup/mibII/ip.c \
+ mibgroup/mibII/tcp.c \
+ mibgroup/mibII/udp.c \
+ mibgroup/util_funcs.c \
+ mibgroup/mibII/dot3.c \
+ mibgroup/snmpv3/usmStats.c \
+ mibgroup/snmpv3/usmUser.c \
+ mibgroup/snmpv3/snmpEngine.c \
+ mibgroup/mibII/vacm_vars.c \
+
+
+
+# Turns out the agent does not need to read the MIBs at all.
+# It is all part of the library startup; I had been misled by
+# debug/error messages. But that part of the lib is not used.
+#
+# rofs/EtherLike-MIB.c \
+# rofs/IANAifType-MIB.c \
+# rofs/IF-MIB.c \
+# rofs/IP-MIB.c \
+# rofs/RFC-1215.c \
+# rofs/SNMPv2-CONF.c \
+# rofs/SNMPv2-MIB.c \
+# rofs/SNMPv2-SMI.c \
+# rofs/SNMPv2-TC.c \
+# rofs/SNMPv2-TM.c \
+# rofs/TCP-MIB.c \
+# rofs/UDP-MIB.c
+
+# compile -library=libextras.a rofs/snmprofs.c
+
+# mibgroup/mibII/interfaces.c \
+# mibgroup/mibII/icmp.c \
+# mibgroup/mibII/ip.c \
+# mibgroup/mibII/snmp_mib.c \
+# mibgroup/mibII/sysORTable.c \
+# mibgroup/mibII/system_mib.c \
+# mibgroup/mibII/tcp.c \
+# mibgroup/mibII/udp.c \
+# mibgroup/util_funcs.c \
+#
+
+# these from MIBII that I think I might need later
+# mibgroup/mibII/ipv6.c \
+# mibgroup/mibII/route_write.c \
+# mibgroup/mibII/var_route.c \
+# AT group is deprecated
+# mibgroup/mibII/at.c \
+# SNMPv3 view access control
+# mibgroup/mibII/vacm_vars.c \
+
+
+# here is the full list
+# compile \
+# dlmods/dlmod_mib.c \
+# dlmods/example.c \
+# mibgroup/agentx/client.c \
+# mibgroup/agentx/master.c \
+# mibgroup/agentx/master_admin.c \
+# mibgroup/agentx/master_request.c \
+# mibgroup/agentx/protocol.c \
+# mibgroup/agentx/subagent.c \
+# mibgroup/examples/example.c \
+# mibgroup/examples/ucdDemoPublic.c \
+# mibgroup/examples/ucdDemoPublic.cmds \
+# mibgroup/examples/ucdDemoPublic.conf \
+# mibgroup/host/hr_device.c \
+# mibgroup/host/hr_disk.c \
+# mibgroup/host/hr_filesys.c \
+# mibgroup/host/hr_network.c \
+# mibgroup/host/hr_other.c \
+# mibgroup/host/hr_partition.c \
+# mibgroup/host/hr_print.c \
+# mibgroup/host/hr_proc.c \
+# mibgroup/host/hr_storage.c \
+# mibgroup/host/hr_swinst.c \
+# mibgroup/host/hr_swrun.c \
+# mibgroup/host/hr_system.c \
+# mibgroup/host/hr_utils.c \
+# mibgroup/mibII/interfaces.c \
+# mibgroup/mibII/at.c \
+# mibgroup/mibII/icmp.c \
+# mibgroup/mibII/ip.c \
+# mibgroup/mibII/ipv6.c \
+# mibgroup/mibII/route_write.c \
+# mibgroup/mibII/snmp_mib.c \
+# mibgroup/mibII/sysORTable.c \
+# mibgroup/mibII/system_mib.c \
+# mibgroup/mibII/tcp.c \
+# mibgroup/mibII/udp.c \
+# mibgroup/mibII/vacm_vars.c \
+# mibgroup/mibII/var_route.c \
+# mibgroup/misc/ipfwacc.c \
+# mibgroup/misc/dlmod.c \
+# mibgroup/smux/snmp_bgp.c \
+# mibgroup/smux/smux.c \
+# mibgroup/smux/snmp_ospf.c \
+# mibgroup/smux/snmp_rip2.c \
+# mibgroup/snmpv3/snmpMPDStats.c \
+# mibgroup/target/snmpTargetAddrEntry.c \
+# mibgroup/target/snmpTargetParamsEntry.c \
+# mibgroup/ucd-snmp/diskio.c \
+# mibgroup/ucd-snmp/disk.c \
+# mibgroup/ucd-snmp/errormib.c \
+# mibgroup/ucd-snmp/extensible.c \
+# mibgroup/ucd-snmp/file.c \
+# mibgroup/ucd-snmp/hpux.c \
+# mibgroup/ucd-snmp/loadave.c \
+# mibgroup/ucd-snmp/memory.c \
+# mibgroup/ucd-snmp/memory_freebsd2.c \
+# mibgroup/ucd-snmp/memory_netbsd1.c \
+# mibgroup/ucd-snmp/memory_solaris2.c \
+# mibgroup/ucd-snmp/pass.c \
+# mibgroup/ucd-snmp/pass_persist.c \
+# mibgroup/ucd-snmp/proc.c \
+# mibgroup/ucd-snmp/registry.c \
+# mibgroup/ucd-snmp/versioninfo.c \
+# mibgroup/ucd-snmp/vmstat.c \
+# mibgroup/ucd-snmp/vmstat_freebsd2.c \
+# mibgroup/ucd-snmp/vmstat_netbsd1.c \
+# mibgroup/ucd-snmp/vmstat_solaris2.c \
+# mibgroup/header_complex.c \
+# mibgroup/kernel_sunos5.c \
+# mibgroup/util_funcs.c \
+
+
+ cdl_component CYGPKG_SNMPAGENT_SYSTEM_MIB {
+ display "System MIB defaults"
+ flavor none
+ no_define
+ description "
+ These options control the default values for items in the
+ system MIB. The symbols are used as initializers for C char
+ arrays; therefore you must include \"double-quotes\" in the
+ defined value to get the correct results."
+
+ cdl_option CYGDAT_NET_SNMPAGENT_SYS_CONTACT {
+ display "Contact address"
+ flavor data
+ default_value { "\"nobody@nowhere.net\"" }
+ description "
+ This specifies the value returned for the sysContact field
+ of the System MIB (via the symbol SYS_CONTACT in the UCD
+ sources)."
+ }
+
+ cdl_option CYGDAT_NET_SNMPAGENT_SYS_LOC {
+ display "System location"
+ flavor data
+ default_value { "\"\"" }
+ description "
+ This specifies the value returned for the sysLocation field
+ of the System MIB (via the symbol SYS_LOC in the UCD
+ sources)"
+ }
+
+ cdl_option CYGDAT_NET_SNMPAGENT_VERS_DESC {
+ display "Version description"
+ flavor data
+ default_value { "\"ucd-snmp-4.1.2/Red Hat eCos\"" }
+ description "
+ This specifies the value returned for the sysDescr field
+ of the System MIB (via the symbol VERS_DESC in the UCD
+ sources)"
+ }
+
+ cdl_option CYGDAT_NET_SNMPAGENT_SYS_NAME {
+ display "System name "
+ flavor data
+ default_value { "\"eCos\"" }
+ description "
+ This specifies the value returned for the sysName field
+ of the System MIB (via the symbol SYS_NAME in the UCD
+ sources)"
+ }
+ }
+
+ cdl_component CYGPKG_SNMPAGENT_OPTIONS {
+ display "SNMP agent build options"
+ flavor none
+ no_define
+
+ cdl_option CYGPKG_SNMPAGENT_CFLAGS_ADD {
+ display "Additional compiler flags"
+ flavor data
+ no_define
+ default_value { "-D_KERNEL -D__ECOS -DIN_UCD_SNMP_SOURCE=1 -I$(PREFIX)/include/ucd-snmp" }
+ description "
+ This option modifies the set of compiler flags for
+ building the SNMP agent package.
+ These flags are used in addition
+ to the set of global flags."
+ }
+
+ cdl_option CYGPKG_SNMPAGENT_CFLAGS_REMOVE {
+ display "Suppressed compiler flags"
+ flavor data
+ no_define
+ default_value { "" }
+ description "
+ This option modifies the set of compiler flags for
+ building the SNMP agent package. These flags are removed from
+ the set of global flags if present."
+ }
+
+ cdl_option CYGPKG_SNMPAGENT_V3_SUPPORT {
+ display "SNMPv3 support package"
+ flavor bool
+ default_value 1
+ description "
+ Enabling this option includes SNMPv3 functionality as per
+ the implementation in UCD-SNMP-4.1.2"
+ }
+
+ cdl_component CYGPKG_SNMPAGENT_TESTS {
+ display "SNMP agent tests"
+ flavor data
+ no_define
+ calculated {
+ "tests/snmpping"
+ }
+ description "
+ This option specifies the set of tests for the eCos SMNP agent."
+
+ cdl_option CYGSEM_SNMPAGENT_TESTS_PROMISCUOUS {
+ display "Run SNMP agent tests in promiscuous mode"
+ flavor bool
+ default_value 0
+ description "
+ This option controls the tests for the eCos SMNP agent.
+ Enabling it will enable promiscuous mode on the hardware
+ interface."
+ }
+
+ cdl_option CYGSEM_SNMPAGENT_TESTS_SNMPv3 {
+ display "SNMP agent test for SNMP version 3"
+ flavor bool
+ active_if CYGPKG_SNMPAGENT_V3_SUPPORT
+ default_value 1
+ description "
+ This option controls the tests for the eCos SMNP agent.
+ Enabling it will include setup and testing of SNMP v3 interfaces."
+ }
+
+ cdl_option CYGNUM_SNMPAGENT_TESTS_ITERATIONS {
+ display "Number of test iterations for SNMP agent test"
+ flavor data
+ default_value 1
+ description "
+ This option controls the number of times the basic test will
+ be run for testing the eCos SMNP agent."
+ }
+ }
+ }
+}
+
+# EOF snmpagent.cdl
Index: v2_0/tests/snmpping.c
===================================================================
--- v2_0/tests/snmpping.c (nonexistent)
+++ v2_0/tests/snmpping.c (revision 1765)
@@ -0,0 +1,668 @@
+//==========================================================================
+//
+// ./agent/current/tests/snmpping.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+//==========================================================================
+//
+// tests/snmpping.c
+//
+// Simple test of PING (ICMP) and networking support
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####BSDCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from OpenBSD or other sources,
+// and are covered by the appropriate copyright disclaimers included herein.
+//
+// -------------------------------------------
+//
+//####BSDCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-01-10
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+
+// -------------------------------------------------------------------------
+// Configuration of the test... now from CDL
+
+// Do we test the interfaces in promiscuous mode?
+//#define CYGSEM_SNMPAGENT_TESTS_PROMISCUOUS
+
+// Do we make the test run forever?
+//#define CYGNUM_SNMPAGENT_TESTS_ITERATIONS 999999
+
+// Do we initialize SNMP v3 MIBs and authentication database?
+//#define CYGSEM_SNMPAGENT_TESTS_SNMPv3
+
+// ------------------------------------------------------------------------
+
+
+// PING test code
+
+#include
+#include
+
+#include
+#include
+#include
+
+#include
+
+#ifdef CYGSEM_SNMPAGENT_TESTS_SNMPv3
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#endif // CYGSEM_SNMPAGENT_TESTS_SNMPv3
+
+#include
+
+#ifdef CYGBLD_DEVS_ETH_DEVICE_H // Get the device config if it exists
+#include CYGBLD_DEVS_ETH_DEVICE_H // May provide CYGTST_DEVS_ETH_TEST_NET_REALTIME
+#endif
+
+#ifdef CYGPKG_NET_TESTS_USE_RT_TEST_HARNESS // do we use the rt test?
+# ifdef CYGTST_DEVS_ETH_TEST_NET_REALTIME // Get the test ancilla if it exists
+# include CYGTST_DEVS_ETH_TEST_NET_REALTIME
+# endif
+#endif
+
+// Fill in the blanks if necessary
+#ifndef TNR_OFF
+# define TNR_OFF()
+#endif
+#ifndef TNR_ON
+# define TNR_ON()
+#endif
+#ifndef TNR_INIT
+# define TNR_INIT()
+#endif
+#ifndef TNR_PRINT_ACTIVITY
+# define TNR_PRINT_ACTIVITY()
+#endif
+
+#define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL + 0x1000)
+static char stack[STACK_SIZE];
+static cyg_thread thread_data;
+static cyg_handle_t thread_handle;
+
+#define NUM_PINGS 16
+#define MAX_PACKET 4096
+#define MIN_PACKET 64
+#define MAX_SEND 4000
+
+#define PACKET_ADD ((MAX_SEND - MIN_PACKET)/NUM_PINGS)
+#define nPACKET_ADD 1
+
+static unsigned char pkt1[MAX_PACKET], pkt2[MAX_PACKET];
+
+#define UNIQUEID 0x1234
+
+// Compute INET checksum
+int
+inet_cksum(u_short *addr, int len)
+{
+ register int nleft = len;
+ register u_short *w = addr;
+ register u_short answer;
+ register u_int sum = 0;
+ u_short odd_byte = 0;
+
+ /*
+ * Our algorithm is simple, using a 32 bit accumulator (sum),
+ * we add sequential 16 bit words to it, and at the end, fold
+ * back all the carry bits from the top 16 bits into the lower
+ * 16 bits.
+ */
+ while( nleft > 1 ) {
+ sum += *w++;
+ nleft -= 2;
+ }
+
+ /* mop up an odd byte, if necessary */
+ if( nleft == 1 ) {
+ *(u_char *)(&odd_byte) = *(u_char *)w;
+ sum += odd_byte;
+ }
+
+ /*
+ * add back carry outs from top 16 bits to low 16 bits
+ */
+ sum = (sum >> 16) + (sum & 0x0000ffff); /* add hi 16 to low 16 */
+ sum += (sum >> 16); /* add carry */
+ answer = ~sum; /* truncate to 16 bits */
+ return (answer);
+}
+
+static int
+show_icmp(unsigned char *pkt, int len,
+ struct sockaddr_in *from, struct sockaddr_in *to)
+{
+ cyg_tick_count_t *tp, tv;
+ struct ip *ip;
+ struct icmp *icmp;
+ tv = cyg_current_time();
+ ip = (struct ip *)pkt;
+ if ((len < sizeof(*ip)) || ip->ip_v != IPVERSION) {
+ diag_printf("%s: Short packet or not IP! - Len: %d, Version: %d\n",
+ inet_ntoa(from->sin_addr), len, ip->ip_v);
+ return 0;
+ }
+ icmp = (struct icmp *)(pkt + sizeof(*ip));
+ len -= (sizeof(*ip) + 8);
+ if ( 0 >= len ) {
+ diag_printf("%s: Completely bogus short packet%s\n",
+ inet_ntoa(from->sin_addr), 0 == len ? "" : " [no ICMP header]");
+ return 0;
+ }
+ tp = (cyg_tick_count_t *)&icmp->icmp_data;
+ if (icmp->icmp_type != ICMP_ECHOREPLY) {
+ diag_printf("%s: Invalid ICMP - type: %d, len (databytes): %d\n",
+ inet_ntoa(from->sin_addr), icmp->icmp_type, len);
+ return 0;
+ }
+ if (icmp->icmp_id != UNIQUEID) {
+ diag_printf("%s: ICMP received for wrong id - sent: %x, recvd: %x\n",
+ inet_ntoa(from->sin_addr), UNIQUEID, icmp->icmp_id);
+ }
+ diag_printf("%d bytes from %s: ", len, inet_ntoa(from->sin_addr));
+ diag_printf("icmp_seq=%d", icmp->icmp_seq);
+ diag_printf(", time=%dms\n", (int)(tv - *tp)*10);
+ return (from->sin_addr.s_addr == to->sin_addr.s_addr);
+}
+
+static void
+ping_host(int s, struct sockaddr_in *host)
+{
+ struct icmp *icmp = (struct icmp *)pkt1;
+ int icmp_len = MIN_PACKET;
+ int seq, ok_recv, bogus_recv;
+ cyg_tick_count_t *tp;
+ long *dp;
+ struct sockaddr_in from;
+ int i, len, fromlen;
+
+ ok_recv = 0;
+ bogus_recv = 0;
+ TNR_OFF();
+ diag_printf("PING server %s\n", inet_ntoa(host->sin_addr));
+ for (seq = 0; seq < NUM_PINGS; seq++, icmp_len += PACKET_ADD ) {
+ TNR_ON();
+ // Build ICMP packet
+ icmp->icmp_type = ICMP_ECHO;
+ icmp->icmp_code = 0;
+ icmp->icmp_cksum = 0;
+ icmp->icmp_seq = seq;
+ icmp->icmp_id = 0x1234;
+ // Set up ping data
+ tp = (cyg_tick_count_t *)&icmp->icmp_data;
+ *tp++ = cyg_current_time();
+ dp = (long *)tp;
+ for (i = sizeof(*tp); i < icmp_len; i += sizeof(*dp)) {
+ *dp++ = i;
+ }
+ // Add checksum
+ icmp->icmp_cksum = inet_cksum( (u_short *)icmp, icmp_len+8);
+ // Send it off
+ if (sendto(s, icmp, icmp_len+8, 0, (struct sockaddr *)host, sizeof(*host)) < 0) {
+ TNR_OFF();
+ perror("sendto");
+ continue;
+ }
+ // Wait for a response
+ fromlen = sizeof(from);
+ len = recvfrom(s, pkt2, sizeof(pkt2), 0, (struct sockaddr *)&from, &fromlen);
+ TNR_OFF();
+ if (len < 0) {
+ perror("recvfrom");
+ icmp_len = MIN_PACKET - PACKET_ADD; // just in case - long routes
+ } else {
+ if (show_icmp(pkt2, len, &from, host)) {
+ ok_recv++;
+ } else {
+ bogus_recv++;
+ }
+ }
+ }
+ TNR_OFF();
+ diag_printf("Sent %d packets, received %d OK, %d bad\n", NUM_PINGS, ok_recv, bogus_recv);
+}
+
+static void
+ping_test(struct bootp *bp)
+{
+ struct protoent *p;
+ struct timeval tv;
+ struct sockaddr_in host;
+ int s;
+
+ if ((p = getprotobyname("icmp")) == (struct protoent *)0) {
+ perror("getprotobyname");
+ return;
+ }
+ s = socket(AF_INET, SOCK_RAW, p->p_proto);
+ if (s < 0) {
+ perror("socket");
+ return;
+ }
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+ setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+ // Set up host address
+ host.sin_family = AF_INET;
+ host.sin_len = sizeof(host);
+ host.sin_addr = bp->bp_siaddr;
+ host.sin_port = 0;
+ ping_host(s, &host);
+ // Now try a bogus host
+ // (also, map 76 <-> 191 so that if a pair runs they ping each other)
+ host.sin_addr = bp->bp_yiaddr; // *my* address.
+// host.sin_addr.s_addr = htonl(ntohl(host.sin_addr.s_addr) ^ 0xf3);
+ host.sin_addr.s_addr = htonl(ntohl(host.sin_addr.s_addr) ^ 2);
+ ping_host(s, &host);
+ close(s);
+}
+
+static void
+ping_test_loopback( int lo )
+{
+ struct protoent *p;
+ struct timeval tv;
+ struct sockaddr_in host;
+ int s;
+
+ if ((p = getprotobyname("icmp")) == (struct protoent *)0) {
+ perror("getprotobyname");
+ return;
+ }
+ s = socket(AF_INET, SOCK_RAW, p->p_proto);
+ if (s < 0) {
+ perror("socket");
+ return;
+ }
+ tv.tv_sec = 1;
+ tv.tv_usec = 0;
+ setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+ // Set up host address
+ host.sin_family = AF_INET;
+ host.sin_len = sizeof(host);
+ host.sin_addr.s_addr = htonl(INADDR_LOOPBACK + (0x100 * lo));
+ host.sin_port = 0;
+ ping_host(s, &host);
+ // Now try a bogus host
+ host.sin_addr.s_addr = htonl(ntohl(host.sin_addr.s_addr) + 32);
+ ping_host(s, &host);
+ close(s);
+}
+
+#ifdef CYGSEM_SNMPAGENT_TESTS_PROMISCUOUS
+static void
+interface_promisc(const char *intf)
+{
+ struct ifreq ifr;
+ int s;
+
+ s = socket(AF_INET, SOCK_DGRAM, 0);
+ if (s < 0) {
+ perror("socket");
+ return;
+ }
+
+ strcpy(ifr.ifr_name, intf);
+ ifr.ifr_flags = IFF_UP | IFF_BROADCAST | IFF_RUNNING | IFF_PROMISC;
+ if (ioctl(s, SIOCSIFFLAGS, &ifr)) {
+ perror("SIOCSIFFLAGS");
+ }
+ close(s);
+}
+#endif // CYGSEM_SNMPAGENT_TESTS_PROMISCUOUS
+
+void snmp_do_reinit( void )
+{
+ diag_printf( "SNMP re-init function\n" );
+#ifdef CYGSEM_SNMPAGENT_TESTS_SNMPv3
+ // Initialisation for USM is now invoked from mib_module_inits.h
+ //init_usmUser(); /* MIBs to support SNMPv3 */
+ //init_usmStats();
+ //init_snmpEngine();
+ usm_parse_create_usmUser(NULL, "root MD5 md5passwd DES DESpasswd");
+#endif // CYGSEM_SNMPAGENT_TESTS_SNMPv3
+}
+
+int create_snmpd_conf (void) {
+#ifdef CYGSEM_SNMPAGENT_TESTS_SNMPv3
+#ifdef CYGPKG_SNMPLIB_FILESYSTEM_SUPPORT
+#ifdef CYGPKG_FS_RAM
+ int c;
+ FILE *fd;
+
+ diag_printf ("\nStarting creation of snmpd.conf\n");
+
+ /* Mount RAM-FS */
+ if (mount ("", "/", "ramfs") != 0) {
+ diag_printf ("File system mount failed; errno=%d \n", errno);
+ return -1;
+ }
+
+ if (mkdir ("/etc", 0) != 0) {
+ diag_printf ("mkdir (etc) failed; errno=%d\n", errno);
+ return -1;
+ }
+
+ if (chdir ("/etc") != 0) {
+ diag_printf ("... Change-dir (etc) failed; errno=%d\n", errno);
+ return -1;
+ } else {
+ diag_printf ("chdir-etc done\n");
+ }
+
+ if (mkdir ("snmp", 0) != 0) {
+ diag_printf ("mkdir failed (snmp); errno=%d\n", errno);
+ return -1;
+ } else {
+ diag_printf ("mkdir-snmp done\n");
+ }
+
+ if (chdir ("snmp") != 0) {
+ diag_printf ("... Change-dir (snmp) failed; errno=%d\n", errno);
+ return -1;
+ } else {
+ diag_printf ("... Change-dir (snmp) done \n");
+ }
+
+ /* Open File & Write to it */
+ if ((fd = fopen( "snmpd.conf", "w" )) == NULL) {
+ diag_printf ("fopen failed\n");
+ return -1;
+ }
+
+ fprintf (fd, "# sec.name source community\n");
+ fprintf (fd, "com2sec public default crux\n");
+ fprintf (fd, "com2sec root default crux\n");
+ fprintf (fd, "# sec.model sec.name\n");
+ fprintf (fd, "group public v1 public\n");
+ fprintf (fd, "group public v2c public\n");
+ fprintf (fd, "group public usm root\n");
+ fprintf (fd, "view all included .1\n");
+ fprintf (fd, "access public \"\" any noauth exact all none none\n");
+ fprintf (fd, "\n\n");
+
+ if (fclose (fd)) {
+ diag_printf ("fclose failed\n");
+ return -1;
+ }
+
+ /* Read Back */
+ fd = fopen( "/etc/snmp/snmpd.conf", "r" );
+ if (fd == NULL) {
+ diag_printf ("fopen failed\n");
+ return -1;
+ }
+
+ while ((c=fgetc (fd)) != EOF) {
+ diag_printf ("%c", c);
+ }
+
+ if (fclose (fd)) {
+ diag_printf ("fclose failed\n");
+ return -1;
+ }
+#endif
+#endif
+#endif
+ return 0;
+}
+
+void
+net_test(cyg_addrword_t p)
+{
+ int i = CYGNUM_SNMPAGENT_TESTS_ITERATIONS;
+ int ieth0_up = 0, ieth1_up = 0;
+ int j;
+
+ diag_printf("Start PING test\n");
+ TNR_INIT();
+ init_all_network_interfaces();
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ ieth0_up = eth0_up;
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ ieth1_up = eth1_up;
+#endif
+#ifdef CYGSEM_SNMPAGENT_TESTS_PROMISCUOUS
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up)
+ interface_promisc("eth0");
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up)
+ interface_promisc("eth1");
+#endif
+#endif // CYGSEM_SNMPAGENT_TESTS_PROMISCUOUS
+ {
+ extern void cyg_net_snmp_init(void);
+ extern void (*snmpd_reinit_function)( void );
+
+ snmpd_reinit_function = snmp_do_reinit;
+
+ if (create_snmpd_conf ()) {
+ CYG_TEST_FAIL_EXIT("create_snmpd_conf() error\n");
+ }
+ cyg_net_snmp_init();
+ }
+ do {
+ TNR_ON();
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ if (eth0_up) {
+ ping_test(ð0_bootp_data);
+ cyg_thread_delay(500);
+ }
+#endif
+#if NLOOP > 0
+ for ( j = 0; j < NLOOP; j++ ) {
+ ping_test_loopback( j );
+ cyg_thread_delay(500);
+ }
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ if (eth1_up) {
+ ping_test(ð1_bootp_data);
+ cyg_thread_delay(500);
+ }
+#endif
+ TNR_OFF();
+ TNR_PRINT_ACTIVITY();
+
+ // If an interface has gone down eg. due to DHCP timing out,
+ // re-initialize everything:
+ if (0
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ || ieth0_up != eth0_up
+#endif
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ || ieth1_up != eth1_up
+#endif
+ ) {
+ diag_printf( "Re-initializing the world: eth0 %d/%d eth1 %d/%d!\n",
+ ieth0_up, 0
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ | eth0_up
+#endif
+ , ieth1_up, 0
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ | eth1_up
+#endif
+ );
+ init_all_network_interfaces();
+ for ( j = 0; j < CYGPKG_NET_NLOOP; j++ )
+ init_loopback_interface( j );
+
+ diag_printf( "Re-initialized the world: eth0 %d/%d eth1 %d/%d!\n",
+ ieth0_up, 0
+#ifdef CYGHWR_NET_DRIVER_ETH0
+ | eth0_up
+#endif
+ , ieth1_up, 0
+#ifdef CYGHWR_NET_DRIVER_ETH1
+ | eth1_up
+#endif
+ );
+ }
+ } while ( i-- > 0 );
+ CYG_TEST_PASS_FINISH( "Done pinging while SNMP looks on" );
+}
+
+void
+cyg_start(void)
+{
+ // Create a main thread, so we can run the scheduler and have time 'pass'
+ cyg_thread_create(10, // Priority - just a number
+ net_test, // entry
+ 0, // entry parameter
+ "Network test", // Name
+ &stack[0], // Stack
+ STACK_SIZE, // Size
+ &thread_handle, // Handle
+ &thread_data // Thread data structure
+ );
+ cyg_thread_resume(thread_handle); // Start it
+ cyg_scheduler_start();
+}
+
+// EOF snmpping.c
Index: v2_0/include/snmp_agent.h
===================================================================
--- v2_0/include/snmp_agent.h (nonexistent)
+++ v2_0/include/snmp_agent.h (revision 1765)
@@ -0,0 +1,129 @@
+//==========================================================================
+//
+// ./agent/current/include/snmp_agent.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * snmp_agent.h
+ *
+ * External definitions for functions in snmp_agent.c.
+ */
+
+#ifndef SNMP_AGENT_H
+#define SNMP_AGENT_H
+
+#define SNMP_MAX_PDU_SIZE 64000 /* local constraint on PDU size sent by agent
+ (see also SNMP_MAX_MSG_SIZE in snmp_api.h) */
+
+struct agent_snmp_session {
+ int mode;
+ struct variable_list *start, *end;
+ struct snmp_session *session;
+ struct snmp_pdu *pdu;
+ int rw;
+ int exact;
+ int status;
+
+ struct request_list *outstanding_requests;
+ struct agent_snmp_session *next;
+};
+
+/* config file parsing routines */
+int handle_snmp_packet(int, struct snmp_session *, int, struct snmp_pdu *, void *);
+int handle_next_pass( struct agent_snmp_session *);
+int handle_var_list( struct agent_snmp_session *);
+void snmp_agent_parse_config (char *, char *);
+struct agent_snmp_session *init_agent_snmp_session( struct snmp_session *, struct snmp_pdu *);
+int getNextSessID(void);
+int init_master_agent(int dest_port,
+ int (*pre_parse) (struct snmp_session *, snmp_ipaddr),
+ int (*post_parse) (struct snmp_session *, struct snmp_pdu *,int));
+int agent_check_and_process(int block);
+
+#endif
Index: v2_0/include/m2m.h
===================================================================
--- v2_0/include/m2m.h (nonexistent)
+++ v2_0/include/m2m.h (revision 1765)
@@ -0,0 +1,140 @@
+//==========================================================================
+//
+// ./agent/current/include/m2m.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * m2m.h
+ */
+
+struct get_req_state {
+ int type;
+ void *info;
+};
+
+/* values for type field in get_req_state */
+#define ALARM_GET_REQ 1
+#define EVENT_GET_REQ 2
+
+/* the following define is used to document a routine or variable which
+** is not static to a module.
+*/
+#define Export
+
+/* values for EntryStatus */
+#define ENTRY_ACTIVE 1
+#define ENTRY_NOTINSERVICE 2
+#define ENTRY_NOTREADY 3
+#define ENTRY_CREATEANDGO 4
+#define ENTRY_CREATEANDWAIT 5
+#define ENTRY_DESTROY 6
+
+/* maximum length for an OwnerString variable */
+#define MAX_OWNER_STR_LEN 128
+
+/* maximum length for a description field */
+#define MAX_DESCRIPTION_LEN 128
+
+/* defines for noting whether the incoming packet is unicast, broadcast,
+** or multicast
+*/
+#define PKT_UNICAST 0
+#define PKT_BROADCAST 1
+#define PKT_MULTICAST 2
+
+/* macro to compare two ethernet addresses. addr1 is a pointer to a
+** struct ether_addr; addr2 is just a struct ether_addr.
+*/
+#define sameEtherAddr(addr1, addr2) \
+ ((*((short *)((addr1)->ether_addr_octet)) == \
+ *((short *)((addr2).ether_addr_octet))) &&\
+ (*((short *)(((addr1)->ether_addr_octet) + 2)) == \
+ *((short *)((((addr2).ether_addr_octet) + 2)))) &&\
+ (*((short *)(((addr1)->ether_addr_octet) + 4)) == \
+ *((short *)((((addr2).ether_addr_octet) + 4)))))
Index: v2_0/include/var_struct.h
===================================================================
--- v2_0/include/var_struct.h (nonexistent)
+++ v2_0/include/var_struct.h (revision 1765)
@@ -0,0 +1,173 @@
+//==========================================================================
+//
+// ./agent/current/include/var_struct.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+#ifndef VAR_STRUCT_H
+#define VAR_STRUCT_H
+/*
+ * The subtree structure contains a subtree prefix which applies to
+ * all variables in the associated variable list.
+ *
+ * By converting to a tree of subtree structures, entries can
+ * now be subtrees of another subtree in the structure. i.e:
+ * 1.2
+ * 1.2.0
+ */
+struct subtree {
+ oid name[16]; /* objid prefix of registered subtree */
+ u_char namelen; /* number of subid's in name above */
+ oid start[16]; /* objid of start of covered range */
+ u_char start_len; /* number of subid's in start name */
+ oid end[16]; /* objid of end of covered range */
+ u_char end_len; /* number of subid's in end name */
+ struct variable *variables; /* pointer to variables array */
+ int variables_len; /* number of entries in above array */
+ int variables_width; /* sizeof each variable entry */
+ char label[256]; /* calling module's label */
+ struct snmp_session *session;
+ u_char flags;
+ u_char priority;
+ struct subtree *next; /* List of 'sibling' subtrees */
+ struct subtree *prev; /* Make siblings a doubly-linked list */
+ struct subtree *children; /* List of 'child' subtrees */
+};
+
+/*
+ * This is a new variable structure that doesn't have as much memory
+ * tied up in the object identifier. It's elements have also been re-arranged
+ * so that the name field can be variable length. Any number of these
+ * structures can be created with lengths tailor made to a particular
+ * application. The first 5 elements of the structure must remain constant.
+ */
+struct variable2 {
+ u_char magic; /* passed to function as a hint */
+ u_char type; /* type of variable */
+ u_short acl; /* access control list for variable */
+ FindVarMethod *findVar; /* function that finds variable */
+ u_char namelen; /* length of name below */
+ oid name[2]; /* object identifier of variable */
+};
+
+struct variable4 {
+ u_char magic; /* passed to function as a hint */
+ u_char type; /* type of variable */
+ u_short acl; /* access control list for variable */
+ FindVarMethod *findVar; /* function that finds variable */
+ u_char namelen; /* length of name below */
+ oid name[4]; /* object identifier of variable */
+};
+
+struct variable7 {
+ u_char magic; /* passed to function as a hint */
+ u_char type; /* type of variable */
+ u_short acl; /* access control list for variable */
+ FindVarMethod *findVar; /* function that finds variable */
+ u_char namelen; /* length of name below */
+ oid name[7]; /* object identifier of variable */
+};
+
+struct variable8 {
+ u_char magic; /* passed to function as a hint */
+ u_char type; /* type of variable */
+ u_short acl; /* access control list for variable */
+ FindVarMethod *findVar; /* function that finds variable */
+ u_char namelen; /* length of name below */
+ oid name[8]; /* object identifier of variable */
+};
+
+struct variable13 {
+ u_char magic; /* passed to function as a hint */
+ u_char type; /* type of variable */
+ u_short acl; /* access control list for variable */
+ FindVarMethod *findVar; /* function that finds variable */
+ u_char namelen; /* length of name below */
+ oid name[13]; /* object identifier of variable */
+};
+#endif /* VAR_STRUCT_H */
Index: v2_0/include/agent_callbacks.h
===================================================================
--- v2_0/include/agent_callbacks.h (nonexistent)
+++ v2_0/include/agent_callbacks.h (revision 1765)
@@ -0,0 +1,102 @@
+//==========================================================================
+//
+// ./agent/current/include/agent_callbacks.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+#ifndef AGENT_CALLBACKS_H
+#define AGENT_CALLBACKS_H
+
+#define SNMPD_CALLBACK_ACM_CHECK 0
+#define SNMPD_CALLBACK_REGISTER_OID 1
+#define SNMPD_CALLBACK_UNREGISTER_OID 2
+#define SNMPD_CALLBACK_REG_SYSOR 3
+#define SNMPD_CALLBACK_UNREG_SYSOR 4
+#define SNMPD_CALLBACK_ACM_CHECK_INITIAL 5
+
+#endif /* AGENT_CALLBACKS_H */
Index: v2_0/include/mibgroup/util_funcs.h
===================================================================
--- v2_0/include/mibgroup/util_funcs.h (nonexistent)
+++ v2_0/include/mibgroup/util_funcs.h (revision 1765)
@@ -0,0 +1,122 @@
+//==========================================================================
+//
+// ./agent/current/include/mibgroup/util_funcs.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * util_funcs.h: utilitiy functions for extensible groups.
+ */
+#ifndef _MIBGROUP_UTIL_FUNCS_H
+#define _MIBGROUP_UTIL_FUNCS_H
+
+#ifdef IN_UCD_SNMP_SOURCE
+#include "mibgroup/struct.h"
+#else
+#include
+#endif
+
+void Exit (int);
+int shell_command (struct extensible *);
+int exec_command (struct extensible *);
+int get_exec_output (struct extensible *);
+int get_exec_pipes (char *cmd, int *fdIn, int *fdOut, int *pid);
+WriteMethod clear_cache;
+RETSIGTYPE restart_doit (int);
+WriteMethod restart_hook;
+void print_mib_oid (oid *, size_t);
+void sprint_mib_oid (char *, oid *, size_t);
+int header_simple_table (struct variable *, oid *, size_t *, int, size_t *, WriteMethod **write_method, int);
+int header_generic (struct variable *,oid *, size_t *, int, size_t *, WriteMethod **);
+int checkmib (struct variable *, oid *, size_t *, int, size_t *, WriteMethod **write_method, int);
+char *find_field (char *, int);
+int parse_miboid (const char *, oid *);
+void string_append_int (char *, int);
+void wait_on_exec (struct extensible *);
+
+#endif /* _MIBGROUP_UTIL_FUNCS_H */
Index: v2_0/include/mibgroup/mibII/dot3.h
===================================================================
--- v2_0/include/mibgroup/mibII/dot3.h (nonexistent)
+++ v2_0/include/mibgroup/mibII/dot3.h (revision 1765)
@@ -0,0 +1,123 @@
+//==========================================================================
+//
+// snmp/snmpagent/current/include/mibgroup/mibII/dot3.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* This file was generated by mib2c and is intended for use as a mib module
+ for the ucd-snmp snmpd agent. */
+
+
+#ifndef _MIBGROUP_DOT3_H
+#define _MIBGROUP_DOT3_H
+
+
+/* we may use header_generic and header_simple_table from the util_funcs module */
+
+
+config_require(util_funcs)
+
+
+/* function prototypes */
+void init_dot3(void);
+FindVarMethod var_dot3;
+FindVarMethod var_dot3PauseTable;
+WriteMethod write_dot3PauseAdminMode;
+
+FindVarMethod var_dot3StatsTable;
+FindVarMethod var_dot3StatsTable;
+
+FindVarMethod var_dot3ControlTable;
+FindVarMethod var_dot3ControlTable;
+
+FindVarMethod var_dot3PauseTable;
+FindVarMethod var_dot3PauseTable;
+
+WriteMethod write_dot3PauseAdminMode;
+
+#endif /* _MIBGROUP_DOT3_H */
Index: v2_0/include/mibgroup/mibII/system_mib.h
===================================================================
--- v2_0/include/mibgroup/mibII/system_mib.h (nonexistent)
+++ v2_0/include/mibgroup/mibII/system_mib.h (revision 1765)
@@ -0,0 +1,119 @@
+//==========================================================================
+//
+// ./agent/current/include/mibgroup/mibII/system_mib.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * System MIB group interface - system.h
+ *
+ */
+#ifndef _MIBGROUP_SYSTEM_MIB_H
+#define _MIBGROUP_SYSTEM_MIB_H
+
+config_require(util_funcs)
+
+extern char version_descr[];
+
+void init_system_mib (void);
+extern FindVarMethod var_system;
+
+/* config file parsing routines */
+void system_parse_config_sysloc (const char *, char *);
+void system_parse_config_syscon (const char *, char *);
+
+#define VERSION_DESCR 1
+#define VERSIONID 2
+#define UPTIME 3
+#define SYSCONTACT 4
+#define SYSTEMNAME 5
+#define SYSLOCATION 6
+#define SYSSERVICES 7
+#define SYSORLASTCHANGE 8
+
+#endif /* _MIBGROUP_SYSTEM_MIB_H */
Index: v2_0/include/mibgroup/mibII/ifr_helper.h
===================================================================
--- v2_0/include/mibgroup/mibII/ifr_helper.h (nonexistent)
+++ v2_0/include/mibgroup/mibII/ifr_helper.h (revision 1765)
@@ -0,0 +1,56 @@
+#ifndef CYGONCE_NET_SNMP_AGENT_IFR_HELPER_H
+#define CYGONCE_NET_SNMP_AGENT_IFR_HELPER_H
+//=============================================================================
+//
+// ifr_helper.h
+//
+// Helper functions to deal with getting interface structures.
+//
+//=============================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2003 Andrew Lunn
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//=============================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): andrew.lunn
+// Contributors:
+// Date: 2003-02-22
+//
+//####DESCRIPTIONEND####
+//
+//=============================================================================
+
+long cyg_snmp_num_interfaces(void);
+struct ifnet *cyg_snmp_get_if(int if_num);
+
+#endif //CYGONCE_NET_SNMP_AGENT_IFR_HELPER_H
Index: v2_0/include/mibgroup/mibII/interfaces.h
===================================================================
--- v2_0/include/mibgroup/mibII/interfaces.h (nonexistent)
+++ v2_0/include/mibgroup/mibII/interfaces.h (revision 1765)
@@ -0,0 +1,118 @@
+//==========================================================================
+//
+// snmp/snmpagent/current/include/mibgroup/mibII/interfaces.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* This file was generated by mib2c and is intended for use as a mib module
+ for the ucd-snmp snmpd agent. */
+
+
+#ifndef _MIBGROUP_INTERFACES_H
+#define _MIBGROUP_INTERFACES_H
+
+
+/* we may use header_generic and header_simple_table from the util_funcs module */
+
+
+config_require(util_funcs)
+
+
+/* function prototypes */
+
+
+void init_interfaces(void);
+FindVarMethod var_interfaces;
+FindVarMethod var_ifTable;
+
+
+WriteMethod write_ifAdminStatus;
+
+
+
+#endif /* _MIBGROUP_INTERFACES_H */
Index: v2_0/include/mibgroup/mibII/snmp_mib.h
===================================================================
--- v2_0/include/mibgroup/mibII/snmp_mib.h (nonexistent)
+++ v2_0/include/mibgroup/mibII/snmp_mib.h (revision 1765)
@@ -0,0 +1,174 @@
+//==========================================================================
+//
+// ./agent/current/include/mibgroup/mibII/snmp_mib.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * SNMP MIB group interface - snmp.h
+ *
+ */
+#ifndef _MIBGROUP_SNMP_H
+#define _MIBGROUP_SNMP_H
+
+struct variable;
+
+extern FindVarMethod var_snmp;
+extern WriteMethod write_snmp;
+
+void init_snmp_mib(void);
+
+extern int snmp_inpkts; /* 1 - current */
+extern int snmp_outpkts; /* 2 - obsolete */
+extern int snmp_inbadversions; /* 3 - current */
+extern int snmp_inbadcommunitynames; /* 4 - current */
+extern int snmp_inbadcommunityuses; /* 5 - current */
+extern int snmp_inasnparseerrors; /* 6 - current */
+extern int snmp_intoobigs; /* 8 - obsolete */
+extern int snmp_innosuchnames; /* 9 - obsolete */
+extern int snmp_inbadvalues; /* 10 - obsolete */
+extern int snmp_inreadonlys; /* 11 - obsolete */
+extern int snmp_ingenerrs; /* 12 - obsolete */
+extern int snmp_intotalreqvars; /* 13 - obsolete */
+extern int snmp_intotalsetvars; /* 14 - obsolete */
+extern int snmp_ingetrequests; /* 15 - obsolete */
+extern int snmp_ingetnexts; /* 16 - obsolete */
+extern int snmp_insetrequests; /* 17 - obsolete */
+extern int snmp_ingetresponses; /* 18 - obsolete */
+extern int snmp_intraps; /* 19 - obsolete */
+extern int snmp_outtoobigs; /* 20 - obsolete */
+extern int snmp_outnosuchnames; /* 21 - obsolete */
+extern int snmp_outbadvalues; /* 22 - obsolete */
+extern int snmp_outgenerrs; /* 24 - obsolete */
+extern int snmp_outgetrequests; /* 25 - obsolete */
+extern int snmp_outgetnexts; /* 26 - obsolete */
+extern int snmp_outsetrequests; /* 27 - obsolete */
+extern int snmp_outgetresponses; /* 28 - obsolete */
+extern int snmp_outtraps; /* 29 - obsolete */
+extern int snmp_enableauthentraps; /* 30 - current */
+extern int snmp_silentdrops; /* 31 - current */
+extern int snmp_proxydrops; /* 32 - current */
+
+extern char *snmp_trapsink;
+extern char *snmp_trapcommunity;
+
+
+#define SNMPINPKTS 1
+#define SNMPOUTPKTS 2
+#define SNMPINBADVERSIONS 3
+#define SNMPINBADCOMMUNITYNAMES 4
+#define SNMPINBADCOMMUNITYUSES 5
+#define SNMPINASNPARSEERRORS 6
+#define SNMPINBADTYPES 7
+#define SNMPINTOOBIGS 8
+#define SNMPINNOSUCHNAMES 9
+#define SNMPINBADVALUES 10
+#define SNMPINREADONLYS 11
+#define SNMPINGENERRS 12
+#define SNMPINTOTALREQVARS 13
+#define SNMPINTOTALSETVARS 14
+#define SNMPINGETREQUESTS 15
+#define SNMPINGETNEXTS 16
+#define SNMPINSETREQUESTS 17
+#define SNMPINGETRESPONSES 18
+#define SNMPINTRAPS 19
+#define SNMPOUTTOOBIGS 20
+#define SNMPOUTNOSUCHNAMES 21
+#define SNMPOUTBADVALUES 22
+#define SNMPOUTREADONLYS 23
+#define SNMPOUTGENERRS 24
+#define SNMPOUTGETREQUESTS 25
+#define SNMPOUTGETNEXTS 26
+#define SNMPOUTSETREQUESTS 27
+#define SNMPOUTGETRESPONSES 28
+#define SNMPOUTTRAPS 29
+#define SNMPENABLEAUTHENTRAPS 30
+#define SNMPSILENTDROPS 31
+#define SNMPPROXYDROPS 32
+
+#endif /* _MIBGROUP_SNMP_H */
Index: v2_0/include/mibgroup/mibII/tcp.h
===================================================================
--- v2_0/include/mibgroup/mibII/tcp.h (nonexistent)
+++ v2_0/include/mibgroup/mibII/tcp.h (revision 1765)
@@ -0,0 +1,120 @@
+//==========================================================================
+//
+// snmp/snmpagent/current/include/mibgroup/mibII/tcp.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* This file was generated by mib2c and is intended for use as a mib module
+ for the ucd-snmp snmpd agent. */
+
+
+#ifndef _MIBGROUP_TCP_H
+#define _MIBGROUP_TCP_H
+
+
+/* we may use header_generic and header_simple_table from the util_funcs module */
+
+
+config_require(util_funcs)
+
+
+/* function prototypes */
+
+
+void init_tcp(void);
+FindVarMethod var_tcp;
+FindVarMethod var_tcpConnTable;
+FindVarMethod var_ipv6TcpConnTable;
+
+
+WriteMethod write_tcpConnState;
+WriteMethod write_ipv6TcpConnState;
+
+
+
+#endif /* _MIBGROUP_TCP_H */
Index: v2_0/include/mibgroup/mibII/sysORTable.h
===================================================================
--- v2_0/include/mibgroup/mibII/sysORTable.h (nonexistent)
+++ v2_0/include/mibgroup/mibII/sysORTable.h (revision 1765)
@@ -0,0 +1,145 @@
+//==========================================================================
+//
+// ./agent/current/include/mibgroup/mibII/sysORTable.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * Template MIB group interface - sysORTable.h
+ *
+ */
+#ifndef _MIBGROUP_SYSORTABLE_H
+#define _MIBGROUP_SYSORTABLE_H
+
+config_require(util_funcs)
+
+struct sysORTable {
+ char *OR_descr;
+ oid *OR_oid;
+ size_t OR_oidlen;
+ struct timeval OR_uptime;
+ struct snmp_session *OR_sess;
+ struct sysORTable *next;
+};
+
+struct register_sysOR_parameters {
+ oid *name;
+ int namelen;
+ const char *descr;
+};
+
+extern void init_sysORTable (void);
+extern FindVarMethod var_sysORTable;
+extern FindVarMethod var_sysORLastChange;
+extern int register_sysORTable (oid *, size_t, const char *);
+extern int unregister_sysORTable (oid *, size_t);
+extern int register_sysORTable_sess (oid *, size_t, const char *, struct snmp_session *);
+extern int unregister_sysORTable_sess (oid *, size_t, struct snmp_session *);
+extern void unregister_sysORTable_by_session (struct snmp_session *);
+
+#define SYSORTABLEINDEX 1
+#define SYSORTABLEID 2
+#define SYSORTABLEDESCR 3
+#define SYSORTABLEUPTIME 4
+
+#define SYS_ORTABLE_REGISTERED_OK 0
+#define SYS_ORTABLE_REGISTRATION_FAILED -1
+#define SYS_ORTABLE_UNREGISTERED_OK 0
+#define SYS_ORTABLE_NO_SUCH_REGISTRATION -1
+
+#ifdef USING_MIBII_SYSORTABLE_MODULE
+#define REGISTER_SYSOR_ENTRY(theoid, descr) \
+ (void)register_sysORTable(theoid, sizeof(theoid)/sizeof(oid), descr);
+#define REGISTER_SYSOR_TABLE(theoid, len, descr) \
+ (void)register_sysORTable(theoid, len, descr);
+
+#else
+#define REGISTER_SYSOR_ENTRY
+#define REGISTER_SYSOR_TABLE
+#endif /* USING_MIBII_SYSORTABLE_MODULE */
+#endif /* _MIBGROUP_SYSORTABLE_H */
Index: v2_0/include/mibgroup/mibII/icmp.h
===================================================================
--- v2_0/include/mibgroup/mibII/icmp.h (nonexistent)
+++ v2_0/include/mibgroup/mibII/icmp.h (revision 1765)
@@ -0,0 +1,115 @@
+//==========================================================================
+//
+// snmp/snmpagent/current/include/mibgroup/mibII/icmp.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* This file was generated by mib2c and is intended for use as a mib module
+ for the ucd-snmp snmpd agent. */
+
+
+#ifndef _MIBGROUP_ICMP_H
+#define _MIBGROUP_ICMP_H
+
+
+/* we may use header_generic and header_simple_table from the util_funcs module */
+
+
+config_require(util_funcs)
+
+
+/* function prototypes */
+
+
+void init_icmp(void);
+FindVarMethod var_icmp;
+
+
+
+
+#endif /* _MIBGROUP_ICMP_H */
Index: v2_0/include/mibgroup/mibII/ip.h
===================================================================
--- v2_0/include/mibgroup/mibII/ip.h (nonexistent)
+++ v2_0/include/mibgroup/mibII/ip.h (revision 1765)
@@ -0,0 +1,135 @@
+//==========================================================================
+//
+// snmp/snmpagent/current/include/mibgroup/mibII/ip.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* This file was generated by mib2c and is intended for use as a mib module
+ for the ucd-snmp snmpd agent. */
+
+
+#ifndef _MIBGROUP_IP_H
+#define _MIBGROUP_IP_H
+
+
+/* we may use header_generic and header_simple_table from the util_funcs module */
+
+
+config_require(util_funcs)
+
+
+/* function prototypes */
+
+
+void init_ip(void);
+FindVarMethod var_ip;
+FindVarMethod var_ipAddrTable;
+FindVarMethod var_ipNetToMediaTable;
+
+
+WriteMethod write_ipForwarding;
+WriteMethod write_ipDefaultTTL;
+WriteMethod write_ipRouteDest;
+WriteMethod write_ipRouteIfIndex;
+WriteMethod write_ipRouteMetric1;
+WriteMethod write_ipRouteMetric2;
+WriteMethod write_ipRouteMetric3;
+WriteMethod write_ipRouteMetric4;
+WriteMethod write_ipRouteNextHop;
+WriteMethod write_ipRouteType;
+WriteMethod write_ipRouteAge;
+WriteMethod write_ipRouteMask;
+WriteMethod write_ipRouteMetric5;
+WriteMethod write_ipNetToMediaIfIndex;
+WriteMethod write_ipNetToMediaPhysAddress;
+WriteMethod write_ipNetToMediaNetAddress;
+WriteMethod write_ipNetToMediaType;
+
+
+
+#endif /* _MIBGROUP_IP_H */
Index: v2_0/include/mibgroup/mibII/udp.h
===================================================================
--- v2_0/include/mibgroup/mibII/udp.h (nonexistent)
+++ v2_0/include/mibgroup/mibII/udp.h (revision 1765)
@@ -0,0 +1,118 @@
+//==========================================================================
+//
+// snmp/snmpagent/current/include/mibgroup/mibII/udp.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* This file was generated by mib2c and is intended for use as a mib module
+ for the ucd-snmp snmpd agent. */
+
+
+#ifndef _MIBGROUP_UDP_H
+#define _MIBGROUP_UDP_H
+
+
+/* we may use header_generic and header_simple_table from the util_funcs module */
+
+
+config_require(util_funcs)
+
+
+/* function prototypes */
+
+
+void init_udp(void);
+FindVarMethod var_udp;
+FindVarMethod var_udpTable;
+FindVarMethod var_ipv6UdpTable;
+
+
+
+
+
+#endif /* _MIBGROUP_UDP_H */
Index: v2_0/include/mibgroup/struct.h
===================================================================
--- v2_0/include/mibgroup/struct.h (nonexistent)
+++ v2_0/include/mibgroup/struct.h (revision 1765)
@@ -0,0 +1,135 @@
+//==========================================================================
+//
+// ./agent/current/include/mibgroup/struct.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+#ifndef UCD_SNMP_STRUCT
+#define UCD_SNMP_STRUCT
+
+#define STRMAX 1024
+#define SHPROC 1
+#define EXECPROC 2
+#define PASSTHRU 3
+#define PASSTHRU_PERSIST 4
+#define MIBMAX 30
+
+struct extensible
+{
+ char name[STRMAX];
+ char command[STRMAX];
+ char fixcmd[STRMAX];
+ int type;
+ int result;
+ char output[STRMAX];
+ struct extensible *next;
+ unsigned long miboid[MIBMAX];
+ size_t miblen;
+ int pid;
+};
+
+struct myproc
+{
+ char name[STRMAX];
+ char fixcmd[STRMAX];
+ int min;
+ int max;
+ struct myproc *next;
+};
+
+/*
+struct mibinfo
+{
+ int numid;
+ unsigned long mibid[10];
+ char *name;
+ void (*handle) ();
+};
+*/
+
+#endif
Index: v2_0/include/mib_modules.h
===================================================================
--- v2_0/include/mib_modules.h (nonexistent)
+++ v2_0/include/mib_modules.h (revision 1765)
@@ -0,0 +1,93 @@
+//==========================================================================
+//
+// ./agent/current/include/mib_modules.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+void init_mib_modules(void);
+
Index: v2_0/include/mib_module_config.h
===================================================================
--- v2_0/include/mib_module_config.h (nonexistent)
+++ v2_0/include/mib_module_config.h (revision 1765)
@@ -0,0 +1,194 @@
+//==========================================================================
+//
+// ./agent/current/include/mib_module_config.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* This file is automatically generated by configure. Do not modify by hand. */
+/* Define if compiling with the mibII module files. */
+#define USING_MIBII_MODULE 1
+
+/* Define if compiling with the ucd_snmp module files. */
+#define USING_UCD_SNMP_MODULE 1
+
+/* Define if compiling with the snmpv3mibs module files. */
+//#define USING_SNMPV3MIBS_MODULE 1
+
+/* Define if compiling with the mibII/system_mib module files. */
+#define USING_MIBII_SYSTEM_MIB_MODULE 1
+
+/* Define if compiling with the mibII/sysORTable module files. */
+#define USING_MIBII_SYSORTABLE_MODULE 1
+
+/* Define if compiling with the mibII/at module files. */
+//#define USING_MIBII_AT_MODULE 1
+
+/* Define if compiling with the mibII/interfaces module files. */
+#define USING_MIBII_INTERFACES_MODULE 1
+
+/* Define if compiling with the mibII/snmp_mib module files. */
+#define USING_MIBII_SNMP_MIB_MODULE 1
+
+/* Define if compiling with the mibII/tcp module files. */
+#define USING_MIBII_TCP_MODULE 1
+
+/* Define if compiling with the mibII/icmp module files. */
+#define USING_MIBII_ICMP_MODULE 1
+
+/* Define if compiling with the mibII/ip module files. */
+#define USING_MIBII_IP_MODULE 1
+
+/* Define if compiling with the mibII/udp module files. */
+#define USING_MIBII_UDP_MODULE 1
+
+/* Define if compiling with the mibII/vacm_vars module files. */
+#ifdef CYGPKG_SNMPAGENT_V3_SUPPORT
+#ifdef CYGPKG_SNMPLIB_FILESYSTEM_SUPPORT
+#define USING_MIBII_VACM_VARS_MODULE 1
+#endif
+#endif
+
+/* Define if compiling with the ucd-snmp/memory module files. */
+//#define USING_UCD_SNMP_MEMORY_MODULE 1
+
+/* Define if compiling with the ucd-snmp/vmstat module files. */
+//#define USING_UCD_SNMP_VMSTAT_MODULE 1
+
+/* Define if compiling with the ucd-snmp/proc module files. */
+//#define USING_UCD_SNMP_PROC_MODULE 1
+
+/* Define if compiling with the ucd-snmp/versioninfo module files. */
+//#define USING_UCD_SNMP_VERSIONINFO_MODULE 1
+
+/* Define if compiling with the ucd-snmp/pass module files. */
+//#define USING_UCD_SNMP_PASS_MODULE 1
+
+/* Define if compiling with the ucd-snmp/pass_persist module files. */
+//#define USING_UCD_SNMP_PASS_PERSIST_MODULE 1
+
+/* Define if compiling with the ucd-snmp/disk module files. */
+//#define USING_UCD_SNMP_DISK_MODULE 1
+
+/* Define if compiling with the ucd-snmp/loadave module files. */
+//#define USING_UCD_SNMP_LOADAVE_MODULE 1
+
+/* Define if compiling with the ucd-snmp/extensible module files. */
+//#define USING_UCD_SNMP_EXTENSIBLE_MODULE 1
+
+/* Define if compiling with the ucd-snmp/errormib module files. */
+//#define USING_UCD_SNMP_ERRORMIB_MODULE 1
+
+/* Define if compiling with the ucd-snmp/registry module files. */
+//#define USING_UCD_SNMP_REGISTRY_MODULE 1
+
+/* Define if compiling with the ucd-snmp/file module files. */
+//#define USING_UCD_SNMP_FILE_MODULE 1
+
+#ifdef CYGPKG_SNMPAGENT_V3_SUPPORT
+/* Define if compiling with the snmpv3/snmpEngine module files. */
+#define USING_SNMPV3_SNMPENGINE_MODULE 1
+
+/* Define if compiling with the snmpv3/snmpMPDStats module files. */
+//#define USING_SNMPV3_SNMPMPDSTATS_MODULE 1
+
+/* Define if compiling with the snmpv3/usmStats module files. */
+#define USING_SNMPV3_USMSTATS_MODULE 1
+
+/* Define if compiling with the snmpv3/usmUser module files. */
+#define USING_SNMPV3_USMUSER_MODULE 1
+#endif
+
+/* Define if compiling with the util_funcs module files. */
+#define USING_UTIL_FUNCS_MODULE 1
+
+/* Define if compiling with the mibII/var_route module files. */
+//#define USING_MIBII_VAR_ROUTE_MODULE 1
+
+/* Define if compiling with the mibII/route_write module files. */
+//#define USING_MIBII_ROUTE_WRITE_MODULE 1
+
Index: v2_0/include/mib_module_includes.h
===================================================================
--- v2_0/include/mib_module_includes.h (nonexistent)
+++ v2_0/include/mib_module_includes.h (revision 1765)
@@ -0,0 +1,125 @@
+//==========================================================================
+//
+// ./agent/current/include/mib_module_includes.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* This file is automatically generated by configure. Do not modify by hand. */
+//#include "mibgroup/mibII.h" // no content
+//#include "mibgroup/ucd_snmp.h"
+//#include "mibgroup/snmpv3mibs.h"
+#include "mibgroup/mibII/system_mib.h" // { mib2 1 }
+#include "mibgroup/mibII/sysORTable.h" // { mib2 1.9.1 } == { system 9.1 }
+#include "mibgroup/mibII/interfaces.h" // { mib2 2 }
+//#include "mibgroup/mibII/at.h" // #3 is deprecated
+#include "mibgroup/mibII/ip.h" // { mib2 4 }
+#include "mibgroup/mibII/icmp.h" // { mib2 5 }
+#include "mibgroup/mibII/tcp.h" // { mib2 6 }
+#include "mibgroup/mibII/udp.h" // { mib2 7 }
+#include "mibgroup/mibII/dot3.h" // { mib2 10.7 } == { transmission 7 }
+#include "mibgroup/mibII/snmp_mib.h" // { mib2 11 }
+//#include "mibgroup/mibII/vacm_vars.h"
+//#include "mibgroup/ucd-snmp/memory.h"
+//#include "mibgroup/ucd-snmp/vmstat.h"
+//#include "mibgroup/ucd-snmp/proc.h"
+//#include "mibgroup/ucd-snmp/versioninfo.h"
+//#include "mibgroup/ucd-snmp/pass.h"
+//#include "mibgroup/ucd-snmp/pass_persist.h"
+//#include "mibgroup/ucd-snmp/disk.h"
+//#include "mibgroup/ucd-snmp/loadave.h"
+//#include "mibgroup/ucd-snmp/extensible.h"
+//#include "mibgroup/ucd-snmp/errormib.h"
+//#include "mibgroup/ucd-snmp/registry.h"
+//#include "mibgroup/ucd-snmp/file.h"
+//#include "mibgroup/snmpv3/snmpEngine.h"
+//#include "mibgroup/snmpv3/snmpMPDStats.h"
+//#include "mibgroup/snmpv3/usmStats.h"
+//#include "mibgroup/snmpv3/usmUser.h"
+//#include "mibgroup/util_funcs.h"
+//#include "mibgroup/mibII/var_route.h"
+//#include "mibgroup/mibII/route_write.h"
Index: v2_0/include/usmUser.h
===================================================================
--- v2_0/include/usmUser.h (nonexistent)
+++ v2_0/include/usmUser.h (revision 1765)
@@ -0,0 +1,154 @@
+//==========================================================================
+//
+// ./agent/current/include/usmUser.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): Andrew.Lunn@ascom.ch, Manu.Sharma@ascom.com
+// Contributors: hmt
+// Date: 2001-05-29
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * usmUser.h
+ *
+ */
+
+#ifndef _MIBGROUP_USMUSER_H
+#define _MIBGROUP_USMUSER_H
+
+#ifdef CYGPKG_SNMPAGENT_V3_SUPPORT
+
+#include "callback.h"
+#include "snmpusm.h"
+
+/* <...prefix>....
+ = 1 + 32 + 1 + 32 */
+#define USM_LENGTH_OID_MAX 66
+
+/* we use header_generic and checkmib from the util_funcs module */
+
+config_require(util_funcs)
+config_add_mib(SNMP-USER-BASED-SM-MIB)
+
+/* Magic number definitions: */
+
+#define USMUSERSPINLOCK 1
+#define USMUSERSECURITYNAME 2
+#define USMUSERCLONEFROM 3
+#define USMUSERAUTHPROTOCOL 4
+#define USMUSERAUTHKEYCHANGE 5
+#define USMUSEROWNAUTHKEYCHANGE 6
+#define USMUSERPRIVPROTOCOL 7
+#define USMUSERPRIVKEYCHANGE 8
+#define USMUSEROWNPRIVKEYCHANGE 9
+#define USMUSERPUBLIC 10
+#define USMUSERSTORAGETYPE 11
+#define USMUSERSTATUS 12
+
+/* function definitions */
+
+extern void init_usmUser(void);
+extern FindVarMethod var_usmUser;
+
+void shutdown_usmUser(void);
+int store_usmUser(int majorID, int minorID, void *serverarg, void *clientarg);
+oid *usm_generate_OID(oid *prefix, size_t prefixLen, struct usmUser *uptr,
+ size_t *length);
+int usm_parse_oid(oid *oidIndex, size_t oidLen,
+ unsigned char **engineID, size_t *engineIDLen,
+ unsigned char **name, size_t *nameLen);
+
+WriteMethod write_usmUserSpinLock;
+WriteMethod write_usmUserCloneFrom;
+WriteMethod write_usmUserAuthProtocol;
+WriteMethod write_usmUserAuthKeyChange;
+WriteMethod write_usmUserPrivProtocol;
+WriteMethod write_usmUserPrivKeyChange;
+WriteMethod write_usmUserPublic;
+WriteMethod write_usmUserStorageType;
+WriteMethod write_usmUserStatus;
+
+#endif /* CYGPKG_SNMPAGENT_V3_SUPPORT */
+
+#endif /* _MIBGROUP_USMUSER_H */
Index: v2_0/include/snmpEngine.h
===================================================================
--- v2_0/include/snmpEngine.h (nonexistent)
+++ v2_0/include/snmpEngine.h (revision 1765)
@@ -0,0 +1,125 @@
+//==========================================================================
+//
+// ./agent/current/include/snmpEngine.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): Andrew.Lunn@ascom.ch, Manu.Sharma@ascom.com
+// Contributors: hmt
+// Date: 2001-05-29
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * snmpEngine.h
+ *
+ * This file was generated by mib2c and is intended for use as a mib module
+ * for the ucd-snmp snmpd agent.
+ */
+
+
+#ifndef _MIBGROUP_SNMPENGINE_H
+#define _MIBGROUP_SNMPENGINE_H
+
+#ifdef CYGPKG_SNMPAGENT_V3_SUPPORT
+
+/* we use header_generic and checkmib from the util_funcs module */
+
+config_require(util_funcs)
+config_add_mib(SNMP-FRAMEWORK-MIB)
+
+/* Magic number definitions: */
+
+#define SNMPENGINEID 1
+#define SNMPENGINEBOOTS 2
+#define SNMPENGINETIME 3
+#define SNMPENGINEMAXMESSAGESIZE 4
+
+/* function definitions */
+
+extern void init_snmpEngine (void);
+extern FindVarMethod var_snmpEngine;
+
+#endif /* CYGPKG_SNMPAGENT_V3_SUPPORT */
+
+#endif /* _MIBGROUP_SNMPENGINE_H */
+
Index: v2_0/include/mib_module_shutdown.h
===================================================================
--- v2_0/include/mib_module_shutdown.h (nonexistent)
+++ v2_0/include/mib_module_shutdown.h (revision 1765)
@@ -0,0 +1,91 @@
+//==========================================================================
+//
+// ./agent/current/include/mib_module_shutdown.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
Index: v2_0/include/snmp_vars.h
===================================================================
--- v2_0/include/snmp_vars.h (nonexistent)
+++ v2_0/include/snmp_vars.h (revision 1765)
@@ -0,0 +1,179 @@
+//==========================================================================
+//
+// ./agent/current/include/snmp_vars.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * Definitions for SNMP (RFC 1067) agent variable finder.
+ *
+ */
+
+#ifndef _SNMP_VARS_H_
+#define _SNMP_VARS_H_
+
+/***********************************************************
+ Copyright 1988, 1989 by Carnegie Mellon University
+ Copyright 1989 TGV, Incorporated
+
+ 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 and TGV not be used
+in advertising or publicity pertaining to distribution of the software
+without specific, written prior permission.
+
+CMU AND TGV DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL CMU OR TGV 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.
+******************************************************************/
+
+struct variable;
+
+/* Function pointer called by the master agent for writes. */
+typedef int (WriteMethod)(int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t length);
+
+/* Function pointer called by the master agent for mib information retrieval */
+typedef u_char *(FindVarMethod)(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method);
+
+/* Function pointer called by the master agent for setting up subagent requests */
+struct agent_snmp_session;
+typedef int (AddVarMethod)(struct agent_snmp_session *asp,
+ struct variable_list *vbp);
+
+struct nlist;
+
+extern long long_return;
+extern u_char return_buf[];
+
+extern oid nullOid[];
+extern int nullOidLen;
+
+#define INST 0xFFFFFFFF /* used to fill out the instance field of the variables table */
+
+struct variable {
+ u_char magic; /* passed to function as a hint */
+ char type; /* type of variable */
+/* See important comment in snmp_vars.c relating to acl */
+ u_short acl; /* access control list for variable */
+ FindVarMethod *findVar; /* function that finds variable */
+ u_char namelen; /* length of above */
+ oid name[MAX_OID_LEN]; /* object identifier of variable */
+};
+
+void init_agent(const char *);
+int subtree_old_size (void);
+void sort_tree (void);
+
+#ifndef _AGENT_REGISTRY_H
+#include "agent_registry.h"
+#endif
+
+/* fail overloads non-negative integer value. it must be -1 ! */
+#define MATCH_FAILED (-1)
+#define MATCH_SUCCEEDED 0
+
+#endif /* _SNMP_VARS_H_ */
Index: v2_0/include/mibdefs.h
===================================================================
--- v2_0/include/mibdefs.h (nonexistent)
+++ v2_0/include/mibdefs.h (revision 1765)
@@ -0,0 +1,103 @@
+//==========================================================================
+//
+// ./agent/current/include/mibdefs.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* 2 global mib defs:
+ ERRORFLAG: A binary flag to signal an error condition.
+ Also used as exit code.
+ ERRORMSG: A text message describing what caused the above condition,
+ Also used as the single line return message from programs */
+
+#define MIBINDEX 1
+#define ERRORNAME 2
+#define ERRORFLAG 100
+#define ERRORMSG 101
+#define ERRORFIX 102
+#define ERRORFIXCMD 103
Index: v2_0/include/mibincl.h
===================================================================
--- v2_0/include/mibincl.h (nonexistent)
+++ v2_0/include/mibincl.h (revision 1765)
@@ -0,0 +1,147 @@
+//==========================================================================
+//
+// ./agent/current/include/mibincl.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * mibincl.h
+ */
+
+#include
+#include
+
+#if HAVE_STDLIB_H
+#include
+#endif
+#if HAVE_MALLOC_H
+#include
+#endif
+#if TIME_WITH_SYS_TIME
+# ifdef WIN32
+# include
+# else
+# include
+# endif
+# include
+#else
+# if HAVE_SYS_TIME_H
+# include
+# else
+# include
+# endif
+#endif
+#if HAVE_NETINET_IN_H
+#include
+#endif
+#if HAVE_SYS_SOCKET_H
+#include
+#endif
+
+#include "mib_module_config.h"
+
+#include "asn1.h"
+#include "snmp_api.h"
+#include "snmp_impl.h"
+
+#include "snmp_vars.h"
+#include "agent_read_config.h"
+#include "var_struct.h"
+
+#include "snmp.h"
+#include "mib.h"
+#include "snmp_debug.h"
+#include "snmp_logging.h"
+#include "read_config.h"
+#include "tools.h"
+#include "agent_trap.h"
+#include "callback.h"
+#define u_char unsigned char
+#define u_short unsigned short
+
+
Index: v2_0/include/agent_read_config.h
===================================================================
--- v2_0/include/agent_read_config.h (nonexistent)
+++ v2_0/include/agent_read_config.h (revision 1765)
@@ -0,0 +1,108 @@
+//==========================================================================
+//
+// ./agent/current/include/agent_read_config.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * agent_read_config.h: reads configuration files for extensible sections.
+ *
+ */
+#ifndef _AGENT_READ_CONFIG_H
+#define _AGENT_READ_CONFIG_H
+
+void init_agent_read_config (const char *);
+void update_config (void);
+void snmpd_register_config_handler (const char *,
+ void (*parser)(const char *, char *),
+ void (*releaser) (void),
+ const char *);
+void snmpd_unregister_config_handler (const char *);
+void snmpd_store_config (const char *);
+
+#endif /* _AGENT_READ_CONFIG_H */
Index: v2_0/include/kernel.h
===================================================================
--- v2_0/include/kernel.h (nonexistent)
+++ v2_0/include/kernel.h (revision 1765)
@@ -0,0 +1,101 @@
+//==========================================================================
+//
+// ./agent/current/include/kernel.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+
+#ifndef linux
+extern void init_kmem (const char *);
+extern int klookup (unsigned long, char *, int);
+#endif
+
+#if HAVE_KVM_H
+#include
+extern kvm_t *kd;
+#endif
Index: v2_0/include/vacm_vars.h
===================================================================
--- v2_0/include/vacm_vars.h (nonexistent)
+++ v2_0/include/vacm_vars.h (revision 1765)
@@ -0,0 +1,144 @@
+//==========================================================================
+//
+// ./agent/current/include/vacm_vars.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): Manu Sharma
+// Contributors:
+// Date: 2002-11-01
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * SNMPv3 View-based Access Control Model
+ */
+
+#ifndef _MIBGROUP_VACM_H
+#define _MIBGROUP_VACM_H
+
+#ifdef CYGPKG_SNMPAGENT_V3_SUPPORT
+#ifdef CYGPKG_SNMPLIB_FILESYSTEM_SUPPORT
+
+config_require(util_funcs)
+config_add_mib(SNMP-VIEW-BASED-ACM-MIB)
+config_add_mib(SNMP-COMMUNITY-MIB)
+
+void init_vacm_vars (void);
+void vacm_free_security (void);
+void vacm_free_group (void);
+void vacm_free_access (void);
+void vacm_free_view (void);
+void vacm_parse_security (const char *, char *);
+void vacm_parse_group (const char *, char *);
+void vacm_parse_access (const char *, char *);
+void vacm_parse_view (const char *, char *);
+void vacm_parse_simple (const char *, char *);
+
+SNMPCallback vacm_in_view_callback;
+
+int vacm_in_view (struct snmp_pdu *, oid *, size_t);
+
+extern FindVarMethod var_vacm_sec2group;
+extern FindVarMethod var_vacm_access;
+extern FindVarMethod var_vacm_view;
+
+#define OID_SNMPVACMMIB SNMP_OID_SNMPMODULES, 16
+#define OID_VACMMIBOBJECTS OID_SNMPVACMMIB, 1
+
+#define OID_VACMCONTEXTTABLE OID_VACMMIBOBJECTS, 1
+#define OID_VACMCONTEXTENTRY OID_VACMCONTEXTTABLE, 1
+
+#define OID_VACMGROUPTABLE OID_VACMMIBOBJECTS, 2
+#define OID_VACMGROUPENTRY OID_VACMGROUPTABLE, 1
+
+#define OID_VACMACCESSTABLE OID_VACMMIBOBJECTS, 4
+#define OID_VACMACCESSENTRY OID_VACMACCESSTABLE, 1
+
+#define OID_VACMMIBVIEWS OID_VACMMIBOBJECTS, 5
+#define OID_VACMVIEWTABLE OID_VACMMIBVIEWS, 2
+#define OID_VACMVIEWENTRY OID_VACMVIEWTABLE, 1
+
+#endif /* CYGPKG_SNMPLIB_FILESYSTEM_SUPPORT */
+#endif /* CYGPKG_SNMPAGENT_V3_SUPPORT */
+
+#endif /* _MIBGROUP_VACM_H */
Index: v2_0/include/snmpd.h
===================================================================
--- v2_0/include/snmpd.h (nonexistent)
+++ v2_0/include/snmpd.h (revision 1765)
@@ -0,0 +1,110 @@
+//==========================================================================
+//
+// ./agent/current/include/snmpd.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * snmpd.h
+ */
+
+#define MASTER_AGENT 0
+#define SUB_AGENT 1
+extern int agent_role;
+
+extern int snmp_dump_packet;
+extern int verbose;
+extern int (*sd_handlers[])(int);
+extern int smux_listen_sd;
+
+extern int snmp_read_packet (int);
+extern u_char *getStatPtr (oid *, size_t *, u_char *, size_t *,
+ u_short *, int, WriteMethod **write_method, struct snmp_pdu *, int *);
+
+/* config file parsing routines */
+void agentBoots_conf (char *, char *);
Index: v2_0/include/mib_module_inits.h
===================================================================
--- v2_0/include/mib_module_inits.h (nonexistent)
+++ v2_0/include/mib_module_inits.h (revision 1765)
@@ -0,0 +1,145 @@
+//==========================================================================
+//
+// ./agent/current/include/mib_module_inits.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* This file is automatically generated by configure. Do not modify by hand. */
+
+
+init_system_mib(); // { mib2 1 }
+init_sysORTable(); // { mib2 1.9.1 } == { system 9.1 }
+init_interfaces(); // { mib2 2 }
+//init_at(); // #3 is deprecated
+init_ip(); // { mib2 4 }
+init_icmp(); // { mib2 5 }
+init_tcp(); // { mib2 6 }
+init_udp(); // { mib2 7 }
+init_dot3(); // { mib2 10.7 } == { transmission 7 }
+init_snmp_mib(); // { mib2 11 }
+
+
+
+
+
+// init_system_mib();
+// init_sysORTable();
+// init_interfaces();
+// init_snmp_mib();
+// init_tcp();
+// init_icmp();
+// init_ip();
+// init_udp();
+
+
+// init_at(); // #3 is deprecated
+
+#ifdef CYGPKG_SNMPAGENT_V3_SUPPORT
+init_snmpEngine();
+init_usmStats();
+init_usmUser();
+#ifdef CYGPKG_SNMPLIB_FILESYSTEM_SUPPORT
+init_vacm_vars();
+#endif
+#endif
+
+// init_memory();
+// init_vmstat();
+// init_proc();
+// init_versioninfo();
+// init_pass();
+// init_pass_persist();
+// init_disk();
+// init_loadave();
+// init_extensible();
+// init_errormib();
+// init_registry();
+// init_file();
+// init_snmpMPDStats();
+// init_var_route();
+
Index: v2_0/include/usmStats.h
===================================================================
--- v2_0/include/usmStats.h (nonexistent)
+++ v2_0/include/usmStats.h (revision 1765)
@@ -0,0 +1,125 @@
+//==========================================================================
+//
+// ./agent/current/include/usmStats.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): Andrew.Lunn@ascom.ch, Manu.Sharma@ascom.com
+// Contributors: hmt
+// Date: 2001-05-29
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * usmStats.h
+ *
+ * This file was generated by mib2c and is intended for use as a mib module
+ * for the ucd-snmp snmpd agent.
+ */
+
+#ifndef _MIBGROUP_USMSTATS_H
+#define _MIBGROUP_USMSTATS_H
+
+#ifdef CYGPKG_SNMPAGENT_V3_SUPPORT
+
+/* we use header_generic and checkmib from the util_funcs module */
+
+config_require(util_funcs)
+config_add_mib(SNMP-USER-BASED-SM-MIB)
+
+/* Magic number definitions: */
+
+#define USMSTATSUNSUPPORTEDSECLEVELS 0
+#define USMSTATSNOTINTIMEWINDOWS 1
+#define USMSTATSUNKNOWNUSERNAMES 2
+#define USMSTATSUNKNOWNENGINEIDS 3
+#define USMSTATSWRONGDIGESTS 4
+#define USMSTATSDECRYPTIONERRORS 5
+
+/* function definitions */
+
+extern void init_usmStats(void);
+extern FindVarMethod var_usmStats;
+
+#endif /* CYGPKG_SNMPAGENT_V3_SUPPORT */
+
+#endif /* _MIBGROUP_USMSTATS_H */
Index: v2_0/include/agent_trap.h
===================================================================
--- v2_0/include/agent_trap.h (nonexistent)
+++ v2_0/include/agent_trap.h (revision 1765)
@@ -0,0 +1,111 @@
+//==========================================================================
+//
+// ./agent/current/include/agent_trap.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+#ifndef AGENT_TRAP_H
+#define AGENT_TRAP_H
+
+void send_easy_trap (int, int);
+void send_trap_pdu(struct snmp_pdu *);
+void send_v2trap ( struct variable_list *);
+void send_trap_vars (int, int, struct variable_list *);
+
+void snmpd_parse_config_authtrap (const char *, char *);
+void snmpd_parse_config_trapsink (const char *, char *);
+void snmpd_parse_config_trap2sink (const char *, char *);
+void snmpd_parse_config_informsink (const char *, char *);
+void snmpd_free_trapsinks (void);
+void snmpd_parse_config_trapcommunity (const char *, char *);
+void snmpd_free_trapcommunity (void);
+
+int create_trap_session (char *, u_short, char *, int, int);
+int add_trap_session( struct snmp_session *, int, int);
+
+#endif /* AGENT_TRAP_H */
Index: v2_0/include/ds_agent.h
===================================================================
--- v2_0/include/ds_agent.h (nonexistent)
+++ v2_0/include/ds_agent.h (revision 1765)
@@ -0,0 +1,108 @@
+//==========================================================================
+//
+// ./agent/current/include/ds_agent.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+#ifndef DS_AGENT_H
+#define DS_AGENT_H
+/* defines agent's default store registrations */
+
+/* booleans */
+#define DS_AGENT_VERBOSE 0 /* 1 if verbose output desired */
+#define DS_AGENT_ROLE 1 /* 0 if master, 1 if client */
+#define DS_AGENT_NO_ROOT_ACCESS 2 /* 1 if we can't get root access */
+
+/* strings */
+#define DS_AGENT_PROGNAME 0 /* argv[0] */
+#define DS_AGENT_X_SOCKET 1 /* AF_UNIX or ip:port socket addr */
+
+/* integers */
+#define DS_AGENT_FLAGS 0 /* session.flags */
+
+#endif
Index: v2_0/include/version.h
===================================================================
--- v2_0/include/version.h (nonexistent)
+++ v2_0/include/version.h (revision 1765)
@@ -0,0 +1,92 @@
+//==========================================================================
+//
+// ./agent/current/include/version.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+static const char *VersionInfo="4.1.2";
v2_0/include/version.h
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: v2_0/include/agent_registry.h
===================================================================
--- v2_0/include/agent_registry.h (nonexistent)
+++ v2_0/include/agent_registry.h (revision 1765)
@@ -0,0 +1,181 @@
+//==========================================================================
+//
+// ./agent/current/include/agent_registry.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+#ifndef AGENT_REGISTRY_H
+#define AGENT_REGISTRY_H
+
+/* the structure of parameters passed to registered ACM modules */
+struct view_parameters {
+ struct snmp_pdu *pdu;
+ oid *name;
+ size_t namelen;
+ int errorcode; /* do not change unless you're
+ specifying an error,
+ as it starts in a success state. */
+};
+
+struct register_parameters {
+ oid *name;
+ size_t namelen;
+ int priority;
+ int range_subid;
+ oid range_ubound;
+};
+
+#define MIB_REGISTERED_OK 0
+#define MIB_DUPLICATE_REGISTRATION -1
+#define MIB_REGISTRATION_FAILED -2
+
+#define MIB_UNREGISTERED_OK 0
+#define MIB_NO_SUCH_REGISTRATION -1
+#define MIB_UNREGISTRATION_FAILED -2
+
+#define DEFAULT_MIB_PRIORITY 127
+
+#define ALLOCATE_THIS_INDEX 0x0
+#define ALLOCATE_ANY_INDEX 0x1
+#define ALLOCATE_NEW_INDEX 0x3
+ /* N.B: it's deliberate that NEW_INDEX & ANY_INDEX == ANY_INDEX */
+
+#define ANY_INTEGER_INDEX -1
+#define ANY_STRING_INDEX NULL
+#define ANY_OID_INDEX NULL
+
+#define INDEX_ERR_GENERR -1
+#define INDEX_ERR_WRONG_TYPE -2
+#define INDEX_ERR_NOT_ALLOCATED -3
+#define INDEX_ERR_WRONG_SESSION -4
+
+char* register_string_index( oid *, size_t, char *);
+int register_int_index( oid *, size_t, int);
+struct variable_list* register_oid_index( oid *, size_t, oid *, size_t);
+struct variable_list* register_index( struct variable_list *, int, struct snmp_session*);
+
+int release_index( struct variable_list *);
+int remove_index( struct variable_list *, struct snmp_session*);
+void unregister_index_by_session(struct snmp_session *);
+int unregister_index(struct variable_list *, int, struct snmp_session *);
+
+void setup_tree (void);
+struct subtree *find_subtree (oid *, size_t, struct subtree *);
+struct subtree *find_subtree_next (oid *, size_t, struct subtree *);
+struct subtree *find_subtree_previous (oid *, size_t, struct subtree *);
+struct snmp_session *get_session_for_oid( oid *, size_t);
+
+int register_mib(const char *, struct variable *, size_t, size_t, oid *, size_t);
+int register_mib_priority(const char *, struct variable *, size_t, size_t, oid *, size_t, int);
+int register_mib_range(const char *, struct variable *, size_t , size_t , oid *, size_t, int, int, oid, struct snmp_session *);
+
+int unregister_mib (oid *, size_t);
+int unregister_mib_priority (oid *, size_t, int);
+int unregister_mib_range (oid *, size_t, int, int, oid);
+void unregister_mibs_by_session (struct snmp_session *);
+
+struct subtree *free_subtree (struct subtree *);
+int compare_tree (const oid *, size_t, const oid *, size_t);
+int in_a_view(oid *, size_t *, struct snmp_pdu *, int);
+int check_access(struct snmp_pdu *pdu);
+
+/* REGISTER_MIB(): This macro simply loads register_mib with less pain:
+
+ descr: A short description of the mib group being loaded.
+ var: The variable structure to load.
+ vartype: The variable structure used to define it (variable2, variable4, ...)
+ theoid: A *initialized* *exact length* oid pointer.
+ (sizeof(theoid) *must* return the number of elements!)
+*/
+#define REGISTER_MIB(descr, var, vartype, theoid) \
+ if (register_mib(descr, (struct variable *) var, sizeof(struct vartype), \
+ sizeof(var)/sizeof(struct vartype), \
+ theoid, sizeof(theoid)/sizeof(oid)) != MIB_REGISTERED_OK ) \
+ DEBUGMSGTL(("register_mib", "%s registration failed\n", descr));
+
+#endif /* AGENT_REGISTRY_H */
Index: v2_0/include/mib_module_dot_conf.h
===================================================================
--- v2_0/include/mib_module_dot_conf.h (nonexistent)
+++ v2_0/include/mib_module_dot_conf.h (revision 1765)
@@ -0,0 +1,91 @@
+//==========================================================================
+//
+// ./agent/current/include/mib_module_dot_conf.h
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
Index: v2_0/doc/prepare-manpages.sh
===================================================================
--- v2_0/doc/prepare-manpages.sh (nonexistent)
+++ v2_0/doc/prepare-manpages.sh (revision 1765)
@@ -0,0 +1,68 @@
+#! /bin/sh
+
+echo 'dude, assuming you are running this script from the packages/net/snmp/agent/current/doc/ directory'
+
+MANPAGE_LIST=`find manpages -type f -name '*.?'`
+
+echo "MANPAGE_LIST is $MANPAGE_LIST"
+
+echo 'removing the previous file snmp-manpages.sgml'
+/bin/rm -f snmp-manpages.sgml
+touch snmp-manpages.sgml
+echo '' >> snmp-manpages.sgml
+echo '' >> snmp-manpages.sgml
+echo '' >> snmp-manpages.sgml
+echo '' >> snmp-manpages.sgml
+echo >> snmp-manpages.sgml
+echo >> snmp-manpages.sgml
+
+for manpage in $MANPAGE_LIST
+do
+ echo "processing $manpage"
+ # get the title for this section
+ manpage_title=`egrep '^\.TH' $manpage | awk '{print $2}' | tr 'A-Z' 'a-z'`
+ # note that _ is illegal in an id, so we canonicalize it to -
+ docbook_section_id=`echo $manpage_title | sed 's/_/-/g'`
+ # now prepare out a section and title
+ echo " " >> snmp-manpages.sgml
+ echo " $manpage_title " >> snmp-manpages.sgml
+ # we make it so that it is a monospaced font
+ echo " " >> snmp-manpages.sgml
+
+ # now put the contents into this section
+ cat $manpage | groff -Tascii -mandoc | sed 's/\_\(.\)/\1/g' \
+ | sed 's/\(.\)\(.\)/\1/g' \
+ | sed 's/\&/\&/g' \
+ | sed 's/\</g' \
+ | sed 's/+o/o/g' >> snmp-manpages.sgml
+
+ # now close out the section
+ echo " " >> snmp-manpages.sgml
+ echo " " >> snmp-manpages.sgml
+ echo >> snmp-manpages.sgml
+done
+
+cat <> snmp-manpages.sgml
+
+
+
+EOF
+
+
v2_0/doc/prepare-manpages.sh
Property changes :
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: v2_0/doc/snmp-manpages.sgml
===================================================================
--- v2_0/doc/snmp-manpages.sgml (nonexistent)
+++ v2_0/doc/snmp-manpages.sgml (revision 1765)
@@ -0,0 +1,488 @@
+
+
+
+
+
+
+
+ snmpd.conf
+
+SNMPD.CONF(5) SNMPD.CONF(5)
+
+
+
+NAME
+ share/snmp/snmpd.conf - configuration file for the ucd-
+ snmp SNMP agent.
+
+DESCRIPTION
+ snmpd.conf is the configuration file which defines how the
+ ucd-smnp SNMP agent operates. These files may contain any
+ of the directives found in the DIRECTIVES section below.
+ This file is not required for the agent to operate and
+ report mib entries.
+
+PLEASE READ FIRST
+ First, make sure you have read the snmp_config(5) manual
+ page that describes how the ucd-snmp configuration files
+ operate, where they are located and how they all work
+ together.
+
+EXTENSIBLE-MIB
+ The ucd-snmp SNMP agent reports much of its information
+ through queries to the 1.3.6.1.4.1.2021 section of the mib
+ tree. Every mib in this section has the following table
+ entries in it.
+
+ .1 -- index
+ This is the table's index numbers for each of the
+ DIRECTIVES listed below.
+
+ .2 -- name
+ The name of the given table entry. This should be
+ unique, but is not required to be.
+
+ .100 -- errorFlag
+ This is a flag returning either the integer value 1
+ or 0 if an error is detected for this table entry.
+
+ .101 -- errorMsg
+ This is a DISPLAY-STRING describing any error trig-
+ gering the errorFlag above.
+
+ .102 -- errorFix
+ If this entry is SNMPset to the integer value of 1
+ AND the errorFlag defined above is indeed a 1, a
+ program or script will get executed with the table
+ entry name from above as the argument. The program
+ to be executed is configured in the config.h file
+ at compile time.
+
+ Directives
+ proc NAME
+
+ proc NAME MAX
+
+ proc NAME MAX MIN
+
+ Checks to see if the NAME'd processes are running
+ on the agent's machine. An error flag (1) and a
+ description message are then passed to the
+ 1.3.6.1.4.1.2021.2.100 and 1.3.6.1.4.1.2021.2.101
+ mib tables (respectively) if the NAME'd program is
+ not found in the process table as reported by
+ "/bin/ps -e".
+
+ If MAX and MIN are not specified, MAX is assumed to
+ be infinity and MIN is assumed to be 1.
+
+ If MAX is specified but MIN is not specified, MIN
+ is assumed to be 0.
+
+ procfix NAME PROG ARGS
+ This registers a command that knows how to fix
+ errors with the given process NAME. When
+ 1.3.6.1.4.1.2021.2.102 for a given NAMEd program is
+ set to the integer value of 1, this command will be
+ called. It defaults to a compiled value set using
+ the PROCFIXCMD definition in the config.h file.
+
+ exec NAME PROG ARGS
+
+ exec MIBNUM NAME PROG ARGS
+
+ If MIBNUM is not specified, the agent executes the
+ named PROG with arguments of ARGS and returns the
+ exit status and the first line of the STDOUT output
+ of the PROG program to queries of the
+ 1.3.6.1.4.1.2021.8.100 and 1.3.6.1.4.1.2021.8.101
+ mib tables (respectively). All STDOUT output
+ beyond the first line is silently truncated.
+
+ If MIBNUM is specified, it acts as above but
+ returns the exit status to MIBNUM.100.0 and the
+ entire STDOUT output to the table MIBNUM.101 in a
+ mib table. In this case, the MIBNUM.101 mib con-
+ tains the entire STDOUT output, one mib table entry
+ per line of output (ie, the first line is output as
+ MIBNUM.101.1, the second at MIBNUM.101.2, etc...).
+
+ Note: The MIBNUM must be specified in dotted-inte-
+ ger notation and can not be specified as
+ ".iso.org.dod.internet..." (should instead
+ be
+
+ Note: The agent caches the exit status and STDOUT
+ of the executed program for 30 seconds after
+ the initial query. This is to increase
+ speed and maintain consistency of informa-
+ tion for consecutive table queries. The
+ cache can be flushed by a snmp-set request
+ of integer(1) to 1.3.6.1.4.1.2021.100.VER-
+ CLEARCACHE.
+
+ execfix NAME PROG ARGS
+ This registers a command that knows how to fix
+ errors with the given exec or sh NAME. When
+ 1.3.6.1.4.1.2021.8.102 for a given NAMEd entry is
+ set to the integer value of 1, this command will be
+ called. It defaults to a compiled value set using
+ the EXECFIXCMD definition in the config.h file.
+
+ disk PATH
+
+ disk PATH [ MINSPACE | MINPERCENT% ]
+
+ Checks the named disks mounted at PATH for avail-
+ able disk space. If the disk space is less than
+ MINSPACE (kB) if specified or less than MINPERCENT
+ (%) if a % sign is specified, or DEFDISKMINI-
+ MUMSPACE (kB) if not specified, the associated
+ entry in the 1.3.6.1.4.1.2021.9.100 mib table will
+ be set to (1) and a descriptive error message will
+ be returned to queries of 1.3.6.1.4.1.2021.9.101.
+
+ load MAX1
+
+ load MAX1 MAX5
+
+ load MAX1 MAX5 MAX15
+
+ Checks the load average of the machine and returns
+ an error flag (1), and an text-string error message
+ to queries of 1.3.6.1.4.1.2021.10.100 and
+ 1.3.6.1.4.1.2021.10.101 (respectively) when the
+ 1-minute, 5-minute, or 15-minute averages exceed
+ the associated maximum values. If any of the MAX1,
+ MAX5, or MAX15 values are unspecified, they default
+ to a value of DEFMAXLOADAVE.
+
+ file FILE [MAXSIZE]
+ Monitors file sizes and makes sure they don't grow
+ beyond a certain size. MAXSIZE defaults to infi-
+ nite if not specified, and only monitors the size
+ without reporting errors about it.
+
+ Errors
+ Any errors in obtaining the above information are reported
+ via the 1.3.6.1.4.1.2021.101.100 flag and the
+ 1.3.6.1.4.1.2021.101.101 text-string description.
+
+SMUX SUB-AGENTS
+ To enable and SMUX based sub-agent, such as gated, use the
+ smuxpeer configuration entry
+
+ smuxpeer OID PASS
+ For gated a sensible entry might be
+
+ .1.3.6.1.4.1.4.1.3 secret
+
+ACCESS CONTROL
+ snmpd supports the View-Based Access Control Model (vacm)
+ as defined in RFC 2275. To this end, it recognizes the
+ following keywords in the configuration file: com2sec,
+ group, access, and view as well as some easier-to-use
+ wrapper directives: rocommunity, rwcommunity, rouser,
+ rwuser.
+
+ rocommunity COMMUNITY [SOURCE] [OID]
+
+ rwcommunity COMMUNITY [SOURCE] [OID]
+ These create read-only and read-write communities
+ that can be used to access the agent. They are a
+ quick method of using the following com2sec, group,
+ access, and view directive lines. They are not as
+ efficient either, as groups aren't created so the
+ tables are possibly larger. In other words: don't
+ use these if you have complex situations to set up.
+
+ The format of the SOURCE is token is described in
+ the com2sec directive section below. The OID token
+ restricts access for that community to everything
+ below that given OID.
+
+ rouser USER [noauth|auth|priv] [OID]
+
+ rwuser USER [noauth|auth|priv] [OID]
+ Creates a SNMPv3 USM user in the VACM access
+ configuration tables. Again, its more efficient
+ (and powerful) to use the combined com2sec, group,
+ access, and view directives instead.
+
+ The minimum level of authentication and privacy the
+ user must use is specified by the first token
+ (which defaults to "auth"). The OID parameter
+ restricts access for that user to everything below
+ the given OID.
+
+ com2sec NAME SOURCE COMMUNITY
+ This directive specifies the mapping from a
+ source/community pair to a security name. SOURCE
+ can be a hostname, a subnet, or the word "default".
+ A subnet can be specified as IP/MASK or IP/BITS.
+ The first source/community combination that matches
+ the incoming packet is selected.
+
+ group NAME MODEL SECURITY
+ This directive defines the mapping from security-
+ model/securityname to group. MODEL is one of v1,
+ v2c, or usm.
+
+ access NAME CONTEXT MODEL LEVEL PREFX READ WRITE NOTIFY
+ The access directive maps from group/security
+ model/security level to a view. MODEL is one of
+ any, v1, v2c, or usm. LEVEL is one of noauth,
+ auth, or priv. PREFX specifies how CONTEXT should
+ be matched against the context of the incoming pdu,
+ either exact or prefix. READ, WRITE and NOTIFY
+ specifies the view to be used for the corresponding
+ access. For v1 or v2c access, LEVEL will be
+ noauth, and CONTEXT will be empty.
+
+ view NAME TYPE SUBTREE [MASK]
+ The defines the named view. TYPE is either included
+ or excluded. MASK is a list of hex octets, sepa-
+ rated by '.' or ':'. The MASK defaults to "ff" if
+ not specified.
+
+ The reason for the mask is, that it allows you to
+ control access to one row in a table, in a rela-
+ tively simple way. As an example, as an ISP you
+ might consider giving each customer access to his
+ or her own interface:
+
+ view cust1 included interfaces.ifTable.ifEntry.ifIndex.1 ff.a0
+ view cust2 included interfaces.ifTable.ifEntry.ifIndex.2 ff.a0
+
+ (interfaces.ifTable.ifEntry.ifIndex.1 == .1.3.6.1.2.1.2.2.1.1.1,
+ ff.a0 == 11111111.10100000. which nicely covers up and including
+ the row index, but lets the user vary the field of the row)
+
+ VACM Examples:
+ # sec.name source community
+ com2sec local localhost private
+ com2sec mynet 10.10.10.0/24 public
+ com2sec public default public
+
+ # sec.model sec.name
+ group mygroup v1 mynet
+ group mygroup v2c mynet
+ group mygroup usm mynet
+ group local v1 local
+ group local v2c local
+ group local usm local
+ group public v1 public
+ group public v2c public
+ group public usm public
+
+ # incl/excl subtree mask
+ view all included .1 80
+ view system included system fe
+ view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
+
+ # context sec.model sec.level prefix read write notify
+ access mygroup "" any noauth exact mib2 none none
+ access public "" any noauth exact system none none
+ access local "" any noauth exact all all all
+
+ Default VACM model
+ The default configuration of the agent, as shipped, is functionally
+ equivalent to the following entries:
+ com2sec public default public
+ group public v1 public
+ group public v2c public
+ group public usm public
+ view all included .1
+ access public "" any noauth exact all none none
+
+SNMPv3 CONFIGURATION
+ engineID STRING
+ The snmpd agent needs to be configured with an
+ engineID to be able to respond to SNMPv3 messages.
+ With this configuration file line, the engineID
+ will be configured from STRING. The default value
+ of the engineID is configured with the first IP
+ address found for the hostname of the machine.
+
+ createUser username (MD5|SHA) authpassphrase [DES] [priv-
+ passphrase]
+ This directive should be placed into the "/var/ucd-
+ snmp"/snmpd.conf file instead of the other normal
+ locations. The reason is that the information is
+ read from the file and then the line is removed
+ (eliminating the storage of the master password for
+ that user) and replaced with the key that is
+ derived from it. This key is a localized key, so
+ that if it is stolen it can not be used to access
+ other agents. If the password is stolen, however,
+ it can be.
+
+ MD5 and SHA are the authentication types to use,
+ but you must have built the package with openssl
+ installed in order to use SHA. The only privacy
+ protocol currently supported is DES. If the pri-
+ vacy passphrase is not specified, it is assumed to
+ be the same as the authentication passphrase. Note
+ that the users created will be useless unless they
+ are also added to the VACM access control tables
+ described above.
+
+ Warning: the minimum pass phrase length is 8 char-
+ acters.
+
+ SNMPv3 users can be created at runtime using the
+ snmpusm command.
+
+
+SETTING SYSTEM INFORMATION
+ syslocation STRING
+
+ syscontact STRING
+
+ Sets the system location and the system contact for
+ the agent. This information is reported by the
+ 'system' table in the mibII tree.
+
+ authtrapenable NUMBER
+ Setting authtrapenable to 1 enables generation of
+ authentication failure traps. The default value is
+ 2 (disable).
+
+ trapcommunity STRING
+ This defines the default community string to be
+ used when sending traps. Note that this command
+ must be used prior to any of the following three
+ commands that are intended use this community
+ string.
+
+ trapsink HOST [COMMUNITY [PORT]]
+
+ trap2sink HOST [COMMUNITY [PORT]]
+
+ informsink HOST [COMMUNITY [PORT]]
+ These commands define the hosts to receive traps
+ (and/or inform notifications). The daemon sends a
+ Cold Start trap when it starts up. If enabled, it
+ also sends traps on authentication failures. Mul-
+ tiple trapsink, trap2sink and informsink lines may
+ be specified to specify multiple destinations. Use
+ trap2sink to send SNMPv2 traps and informsink to
+ send inform notifications. If COMMUNITY is not
+ specified, the string from a preceding trapcommu-
+ nity directive will be used. If PORT is not speci-
+ fied, the well known SNMP trap port (162) will be
+ used.
+
+PASS-THROUGH CONTROL
+ pass MIBOID EXEC
+ Passes entire control of MIBOID to the EXEC pro-
+ gram. The EXEC program is called in one of the
+ following three ways:
+
+ EXEC -g MIBOID
+
+ EXEC -n MIBOID
+
+ These call lines match to SNMP get and get-
+ next requests. It is expected that the EXEC
+ program will take the arguments passed to it
+ and return the appropriate response through
+ it's stdout.
+
+ The first line of stdout should be the mib
+ OID of the returning value. The second line
+ should be the TYPE of value returned, where
+ TYPE is one of the text strings: string,
+ integer, unsigned, objectid, timeticks,
+ ipaddress, counter, or gauge. The third
+ line of stdout should be the VALUE corre-
+ sponding with the returned TYPE.
+
+ For instance, if a script was to return the
+ value integer value "42" when a request for
+ .1.3.6.1.4.100 was requested, the script
+ should return the following 3 lines:
+ .1.3.6.1.4.100
+ integer
+ 42
+
+ To indicate that the script is unable to
+ comply with the request due to an end-of-mib
+ condition or an invalid request, simple exit
+ and return no output to stdout at all. A
+ snmp error will be generated corresponding
+ to the SNMP NO-SUCH-NAME response.
+
+ EXEC -s MIBOID TYPE VALUE
+
+ For SNMP set requests, the above call method
+ is used. The TYPE passed to the EXEC pro-
+ gram is one of the text strings: integer,
+ counter, gauge, timeticks, ipaddress, objid,
+ or string, indicating the type of value
+ passed in the next argument.
+
+ Return nothing to stdout, and the set will
+ assumed to have been successful. Otherwise,
+ return one of the following error strings to
+ signal an error: not-writable, or wrong-type
+ and the appropriate error response will be
+ generated instead.
+
+ Note: By default, the only community
+ allowed to write (ie snmpset) to
+ your script will be the "private"
+ community,or community #2 if defined
+ differently by the "community" token
+ discussed above. Which communities
+ are allowed write access are con-
+ trolled by the RWRITE definition in
+ the snmplib/snmp_impl.h source file.
+
+EXAMPLE
+ See the EXAMPLE.CONF file in the top level source direc-
+ tory for a more detailed example of how the above informa-
+ tion is used in real examples.
+
+RE-READING snmpd.conf and snmpd.local.conf
+ The ucd-snmp agent can be forced to re-read its configura-
+ tion files. It can be told to do so by one of two ways:
+
+ 1. An snmpset of integer(1) to
+ 1.3.6.1.4.1.2021.100.VERUPDATECONFIG.
+
+ 2. A "kill -HUP" signal sent to the snmpd agent pro-
+ cess.
+
+FILES
+ share/snmp/snmpd.conf
+
+SEE ALSO
+ snmp_config(5), snmpd(1), EXAMPLE.conf, read_config(3).
+
+
+
+ 27 Jan 2000 SNMPD.CONF(5)
+
+
+
+
+
+
Index: v2_0/doc/manpages/snmpd.conf.5
===================================================================
--- v2_0/doc/manpages/snmpd.conf.5 (nonexistent)
+++ v2_0/doc/manpages/snmpd.conf.5 (revision 1765)
@@ -0,0 +1,373 @@
+.TH SNMPD.CONF 5 "27 Jan 2000"
+.ds )H U.C. Davis, ECE Dept.
+.ds ]W V4.1.2
+.UC 4
+.SH NAME
+share/snmp/snmpd.conf - configuration file for the ucd-snmp SNMP agent.
+.SH DESCRIPTION
+.B snmpd.conf
+is the configuration file which defines how the ucd-smnp SNMP agent
+operates. These files may contain any of the directives found in the
+DIRECTIVES section below. This file is not required for the agent to
+operate and report mib entries.
+.SH PLEASE READ FIRST
+First, make sure you have read the snmp_config(5) manual page that
+describes how the ucd-snmp configuration files operate, where they
+are located and how they all work together.
+.SH EXTENSIBLE-MIB
+.PP
+The ucd-snmp SNMP agent reports much of its information through
+queries to the 1.3.6.1.4.1.2021 section of the mib tree. Every mib in
+this section has the following table entries in it.
+.IP ".1 -- index"
+This is the table's index numbers for each of the DIRECTIVES listed below.
+.IP ".2 -- name"
+The name of the given table entry. This should be unique, but is not
+required to be.
+.IP ".100 -- errorFlag"
+This is a flag returning either the integer value 1 or 0 if an error
+is detected for this table entry.
+.IP ".101 -- errorMsg"
+This is a DISPLAY-STRING describing any error triggering the errorFlag above.
+.IP ".102 -- errorFix"
+If this entry is SNMPset to the integer value of 1 AND the errorFlag
+defined above is indeed a 1, a program or script will get executed
+with the table entry name from above as the argument. The program to
+be executed is configured in the config.h file at compile time.
+.SS Directives
+.IP "proc NAME"
+.IP "proc NAME MAX"
+.IP "proc NAME MAX MIN"
+.IP
+Checks to see if the NAME'd processes are running on the agent's
+machine. An error flag (1) and a description message are then passed
+to the 1.3.6.1.4.1.2021.2.100 and
+1.3.6.1.4.1.2021.2.101 mib tables (respectively) if the
+NAME'd program is not found in the process table as reported by "/bin/ps -e".
+.IP
+If MAX and MIN are not specified, MAX is assumed to be
+.B infinity
+and MIN is assumed to be 1.
+.IP
+If MAX is specified but MIN is not specified, MIN is assumed to be 0.
+.IP "procfix NAME PROG ARGS"
+This registers a command that knows how to fix errors with the given
+process NAME. When 1.3.6.1.4.1.2021.2.102 for a given
+NAMEd program is set to the integer value of 1, this command will be
+called. It defaults to a compiled value set using the PROCFIXCMD
+definition in the config.h file.
+.IP "exec NAME PROG ARGS"
+.IP "exec MIBNUM NAME PROG ARGS"
+.IP
+If MIBNUM is not specified, the agent executes the named PROG with
+arguments of ARGS and returns the exit status and the first line of
+the STDOUT output of the PROG program to queries of the
+1.3.6.1.4.1.2021.8.100 and
+1.3.6.1.4.1.2021.8.101 mib tables (respectively). All
+STDOUT output beyond the first line is silently truncated.
+.IP
+If MIBNUM is specified, it acts as above but returns the exit status
+to MIBNUM.100.0 and the entire STDOUT output to the table
+MIBNUM.101 in a mib table. In this case, the MIBNUM.101 mib
+contains the entire STDOUT output, one mib table entry per line of
+output (ie, the first line is output as MIBNUM.101.1, the second
+at MIBNUM.101.2, etc...).
+.RS
+.IP Note:
+The MIBNUM must be specified in dotted-integer notation and can
+not be specified as ".iso.org.dod.internet..." (should instead be
+.1.3.6.1...).
+.IP Note:
+The agent caches the exit status and STDOUT of the executed program
+for 30 seconds after the initial query. This is to increase speed and
+maintain consistency of information for consecutive table queries.
+The cache can be flushed by a snmp-set request of integer(1) to
+1.3.6.1.4.1.2021.100.VERCLEARCACHE.
+.RE
+.IP "execfix NAME PROG ARGS"
+This registers a command that knows how to fix errors with the given
+exec or sh NAME. When 1.3.6.1.4.1.2021.8.102 for a
+given NAMEd entry is set to the integer value of 1, this command will
+be called. It defaults to a compiled value set using the EXECFIXCMD
+definition in the config.h file.
+.IP "disk PATH"
+.IP "disk PATH [ MINSPACE | MINPERCENT% ]"
+.IP
+Checks the named disks mounted at PATH for available disk space. If
+the disk space is less than MINSPACE (kB) if specified or less than
+MINPERCENT (%) if a % sign is specified, or DEFDISKMINIMUMSPACE (kB)
+if not specified, the associated entry in the
+1.3.6.1.4.1.2021.9.100 mib table will be set to (1) and
+a descriptive error message will be returned to queries of
+1.3.6.1.4.1.2021.9.101.
+.IP "load MAX1"
+.IP "load MAX1 MAX5"
+.IP "load MAX1 MAX5 MAX15"
+.IP
+Checks the load average of the machine and returns an error flag (1),
+and an text-string error message
+to queries of 1.3.6.1.4.1.2021.10.100 and
+1.3.6.1.4.1.2021.10.101 (respectively) when the
+1-minute, 5-minute, or 15-minute averages exceed the associated
+maximum values. If any of the MAX1, MAX5, or MAX15 values are
+unspecified, they default to a value of DEFMAXLOADAVE.
+.IP "file FILE [MAXSIZE]"
+Monitors file sizes and makes sure they don't grow beyond a certain
+size. MAXSIZE defaults to infinite if not specified, and only
+monitors the size without reporting errors about it.
+.SS "Errors"
+.PP
+Any errors in obtaining the above information are reported via the
+1.3.6.1.4.1.2021.101.100 flag and the
+1.3.6.1.4.1.2021.101.101 text-string description.
+.SH SMUX SUB-AGENTS
+To enable and SMUX based sub-agent, such as
+.IR gated ,
+use the
+.I smuxpeer
+configuration entry
+.IP "smuxpeer OID PASS"
+For
+.I gated
+a sensible entry might be
+.IP ".1.3.6.1.4.1.4.1.3 secret"
+.SH ACCESS CONTROL
+snmpd supports the View-Based Access Control Model (vacm)
+as defined in RFC 2275.
+To this end, it recognizes the following keywords in the configuration
+file: \fIcom2sec\fR, \fIgroup\fR, \fIaccess\fR, and \fIview\fR as well
+as some easier-to-use wrapper directives: \fIrocommunity\fR,
+\fIrwcommunity\fR, \fIrouser\fR, \fIrwuser\fR.
+.IP "rocommunity COMMUNITY [SOURCE] [OID]"
+.IP "rwcommunity COMMUNITY [SOURCE] [OID]"
+These create read-only and read-write communities that can be used to
+access the agent. They are a quick method of using the following
+\fIcom2sec\fR, \fIgroup\fR, \fIaccess\fR, and \fIview\fR directive lines. They are
+not as efficient either, as groups aren't created so the tables are
+possibly larger. In other words: don't use these if you have complex
+situations to set up.
+.IP
+The format of the SOURCE is token is described in the \fIcom2sec\fR
+directive section below. The OID token restricts access for that
+community to everything below that given OID.
+.IP "rouser USER [noauth|auth|priv] [OID]"
+.IP "rwuser USER [noauth|auth|priv] [OID]"
+Creates a SNMPv3 USM user in the VACM access configuration tables.
+Again, its more efficient (and powerful) to use the combined
+\fIcom2sec\fR, \fIgroup\fR, \fIaccess\fR, and \fIview\fR directives instead.
+.IP
+The minimum level of authentication and privacy the user must use is
+specified by the first token (which defaults to "auth"). The OID
+parameter restricts access for that user to everything below the given
+OID.
+.IP "com2sec NAME SOURCE COMMUNITY"
+This directive specifies the mapping from a source/community pair to
+a security name. SOURCE can be a hostname, a subnet, or the word
+\fI"default"\fR.
+A subnet can be specified as IP/MASK or IP/BITS.
+The first source/community combination that matches the incoming packet
+is selected.
+.IP "group NAME MODEL SECURITY"
+This directive defines the mapping from securitymodel/securityname to group.
+MODEL is one of \fIv1\fR, \fIv2c\fR, or \fIusm\fR.
+.IP "access NAME CONTEXT MODEL LEVEL PREFX READ WRITE NOTIFY"
+The access directive maps from group/security model/security level to
+a view.
+MODEL is one of \fIany\fR, \fIv1\fR, \fIv2c\fR, or \fIusm\fR.
+LEVEL is one of \fInoauth\fR, \fIauth\fR, or \fIpriv\fR.
+PREFX specifies how CONTEXT should be matched against the context of
+the incoming pdu, either \fIexact\fR or \fIprefix\fR.
+READ, WRITE and NOTIFY specifies the view to be used for the corresponding
+access.
+For v1 or v2c access, LEVEL will be noauth, and CONTEXT will be empty.
+.IP "view NAME TYPE SUBTREE [MASK]"
+The defines the named view. TYPE is either \fIincluded\fR or \fIexcluded\fR.
+MASK is a list of hex octets, separated by '.' or ':'. The MASK
+defaults to "ff" if not specified.
+.IP
+The reason for the mask is, that it allows you to control access to
+one row in a table, in a relatively simple way. As an example, as an ISP
+you might consider giving each customer access to his or her own interface:
+.IP
+.nf
+view cust1 included interfaces.ifTable.ifEntry.ifIndex.1 ff.a0
+view cust2 included interfaces.ifTable.ifEntry.ifIndex.2 ff.a0
+.IP
+(interfaces.ifTable.ifEntry.ifIndex.1 == .1.3.6.1.2.1.2.2.1.1.1,
+ff.a0 == 11111111.10100000. which nicely covers up and including
+the row index, but lets the user vary the field of the row)
+.IP "VACM Examples:"
+.nf
+# sec.name source community
+com2sec local localhost private
+com2sec mynet 10.10.10.0/24 public
+com2sec public default public
+
+# sec.model sec.name
+group mygroup v1 mynet
+group mygroup v2c mynet
+group mygroup usm mynet
+group local v1 local
+group local v2c local
+group local usm local
+group public v1 public
+group public v2c public
+group public usm public
+
+# incl/excl subtree mask
+view all included .1 80
+view system included system fe
+view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
+
+# context sec.model sec.level prefix read write notify
+access mygroup "" any noauth exact mib2 none none
+access public "" any noauth exact system none none
+access local "" any noauth exact all all all
+.IP "Default VACM model"
+The default configuration of the agent, as shipped, is functionally
+equivalent to the following entries:
+.nf
+com2sec public default public
+group public v1 public
+group public v2c public
+group public usm public
+view all included .1
+access public "" any noauth exact all none none
+.SH SNMPv3 CONFIGURATION
+.PP
+.IP "engineID STRING"
+The snmpd agent needs to be configured with an engineID to be able to
+respond to SNMPv3 messages. With this configuration file line, the
+engineID will be configured from STRING. The default value of the
+engineID is configured with the first IP address found for the
+hostname of the machine.
+.IP "createUser username (MD5|SHA) authpassphrase [DES] [privpassphrase]"
+This directive should be placed into the
+"/var/ucd-snmp"/snmpd.conf file instead of the other normal
+locations. The reason is that the information is read from the file
+and then the line is removed (eliminating the storage of the master
+password for that user) and replaced with the key that is derived from
+it. This key is a localized key, so that if it is stolen it can not
+be used to access other agents. If the password is stolen, however,
+it can be.
+.IP
+MD5 and SHA are the authentication types to use, but you must have
+built the package with openssl installed in order to use SHA. The
+only privacy protocol currently supported is DES. If the privacy
+passphrase is not specified, it is assumed to be the same as the
+authentication passphrase. Note that the users created will be
+useless unless they are also added to the VACM access control tables
+described above.
+.IP
+Warning: the minimum pass phrase length is 8 characters.
+.IP
+SNMPv3 users can be created at runtime using the
+.I snmpusm
+command.
+.IP
+.SH SETTING SYSTEM INFORMATION
+.IP "syslocation STRING"
+.IP "syscontact STRING"
+.IP
+Sets the system location and the system contact for the agent. This
+information is reported by the 'system' table in the mibII tree.
+.IP "authtrapenable NUMBER"
+Setting authtrapenable to 1 enables generation of authentication failure
+traps. The default value is 2 (disable).
+.IP "trapcommunity STRING"
+This defines the default community string to be used when sending traps.
+Note that this command must be used prior to any of the following three
+commands that are intended use this community string.
+.IP "trapsink HOST [COMMUNITY [PORT]]"
+.IP "trap2sink HOST [COMMUNITY [PORT]]"
+.IP "informsink HOST [COMMUNITY [PORT]]"
+These commands define
+the hosts to receive traps (and/or inform notifications). The
+daemon sends a Cold Start trap when it starts up. If enabled, it also sends
+traps on authentication failures. Multiple \fItrapsink\fR, \fItrap2sink\fR
+and \fIinformsink\fR lines may be specified to specify multiple destinations.
+Use \fItrap2sink\fR to send SNMPv2 traps and \fIinformsink\fR to send
+inform notifications.
+If COMMUNITY is not specified, the string from a preceding \fItrapcommunity\fR
+directive will be used. If PORT is not specified, the well known SNMP trap
+port (162) will be used.
+.SH "PASS-THROUGH CONTROL"
+.IP "pass MIBOID EXEC"
+Passes entire control of MIBOID to the EXEC program. The EXEC program
+is called in one of the following three ways:
+.RS
+.IP "EXEC -g MIBOID"
+.IP "EXEC -n MIBOID"
+.IP
+These call lines match to SNMP get and getnext requests. It is
+expected that the EXEC program will take the arguments passed to it
+and return the appropriate response through it's stdout.
+.IP
+The first line of stdout should be the mib OID of the returning value.
+The second line should be the TYPE of value returned, where TYPE is
+one of the text strings:
+.B string, integer, unsigned, objectid, timeticks, ipaddress, counter,
+or
+.B gauge.
+The third line of stdout should be the VALUE corresponding with the
+returned TYPE.
+.IP
+For instance, if a script was to return the value integer value "42"
+when a request for .1.3.6.1.4.100 was requested, the script should
+return the following 3 lines:
+.br
+.RS
+ .1.3.6.1.4.100
+.br
+ integer
+.br
+ 42
+.RE
+.IP
+To indicate that the script is unable to comply with the request due
+to an end-of-mib condition or an invalid request, simple exit and
+return no output to stdout at all. A snmp error will be generated
+corresponding to the SNMP NO-SUCH-NAME response.
+.IP "EXEC -s MIBOID TYPE VALUE"
+.IP
+For SNMP set requests, the above call method is used. The TYPE passed
+to the EXEC program is one of the text strings:
+.B integer, counter, gauge, timeticks, ipaddress, objid,
+or
+.B string,
+indicating the type of value passed in the next argument.
+.IP
+Return nothing to stdout, and the set will assumed to have been
+successful. Otherwise, return one of the following error strings to
+signal an error:
+.B not-writable,
+or
+.B wrong-type
+and the appropriate error response will be generated instead.
+.RS
+.IP Note:
+By default, the only community allowed to write (ie snmpset) to your
+script will be the "private" community,or community #2 if defined
+differently by the "community" token discussed above. Which
+communities are allowed write access are controlled by the RWRITE
+definition in the snmplib/snmp_impl.h source file.
+.RE
+.RE
+.SH "EXAMPLE"
+See the EXAMPLE.CONF file in the top level source directory for a more
+detailed example of how the above information is used in real
+examples.
+.SH "RE-READING snmpd.conf and snmpd.local.conf"
+The ucd-snmp agent can be forced to re-read its configuration files.
+It can be told to do so by one of two ways:
+.IP 1.
+An snmpset of integer(1) to 1.3.6.1.4.1.2021.100.VERUPDATECONFIG.
+.IP 2.
+A "kill -HUP" signal sent to the snmpd agent process.
+.SH "FILES"
+share/snmp/snmpd.conf
+.SH "SEE ALSO"
+snmp_config(5), snmpd(1), EXAMPLE.conf, read_config(3).
+.\" Local Variables:
+.\" mode: nroff
+.\" End:
Index: v2_0/doc/snmp.sgml
===================================================================
--- v2_0/doc/snmp.sgml (nonexistent)
+++ v2_0/doc/snmp.sgml (revision 1765)
@@ -0,0 +1,600 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+SNMP
+
+SNMP for eCos
+
+Version
+
+This is a port of UCD-SNMP-4.1.2
+
+Originally this document said: See
+http://ucd-snmp.ucdavis.edu/
+for details. And send them a postcard.
+
+
+The project has since been renamed “net-snmp” and re-homed at
+
+ http://net-snmp.sourceforge.net/
+where various new releases (of the original, not eCos
+ports) are available.
+
+
+The original source base from which we worked to create the
+eCos port is available from various archive sites such
+as
+
+ ftp://ftp.freesnmp.com/mirrors/net-snmp/
+or
+
+ ftp://sunsite.cnlab-switch.ch/mirror/ucd-snmp/
+generally with this filename and details:
+
+
+ucd-snmp-4.1.2.tar.gz. . . . . . Nov 2 2000 1164k
+
+
+
+
+SNMP packages in the eCos source repository
+
+The SNMP/eCos package consists of two eCos packages;
+the SNMP library and the SNMP agent.
+
+
+The sources are arranged this way partly for consistency with
+the original release from UCD, and so as to accommodate possible
+future use of the SNMP library without having an agent present.
+That could be used to build an eCos-based SNMP client application.
+
+
+The library contains support code for talking SNMP over the
+net - the SNMP protocol itself - and a MIB file parser (ASN-1) which
+is not used in the agent case.
+
+
+The agent contains the application specific handler files
+to get information about the system into the SNMP world, together
+with the SNMP agent thread
+(snmpd in UNIX terms).
+
+
+
+MIBs supported
+
+The standard set in MIB-II, together with the Ether-Like MIB, are supported
+by default. The MIB files used to compile the handlers in the agent and to
+“drive” the testing (snmpwalk et
+al under LINUX )
+are those acquired from that same UCD distribution.
+
+
+These are the supported MIBs; all are below mib2 == 1.3.6.1.2.1:
+
+
+system { mib2 1 }
+interfaces { mib2 2 }
+ [ address-translation “at” { mib2 3 } is deprecated ]
+ip { mib2 4 }
+icmp { mib2 5 }
+tcp { mib2 6 }
+udp { mib2 7 }
+ [ exterior gateway protocol “egp” { mib2 8 } not supported ]
+ [ cmot { mib2 9 } is “historic”, just a placeholder ]
+dot3 { mib2 10 7 } == { transmission 7 } “EtherLike MIB”
+snmp { mib2 11 }
+
+
+On inclusion of SNMPv3 support packages, the following MIBs are added to the
+default set of MIBs enumerated above :
+
+
+snmpEngine { snmpFrameworkMIBObjects 1 } SNMP-FRAMEWORK-MIB, as described in
+ RFC-2571 for support of SNMPv3
+ framework.
+
+usmStats { usmMIBObjects 1 } SNMP-USER-BASED-SM-MIB, as
+usmUser { usmMIBObjects 2 } specified in RFC-2574 for support
+ of user based security model in
+ SNMPv3 management domains.
+
+
+
+Changes to eCos sources
+
+Small changes have been made in three areas:
+
+
+Various hardware-specific ethernet drivers.
+The generic ethernet device driver.
+The OpenBSD TCP/IP networking package.
+
+
+These changes were made in order to export information about the driver and
+the network that the SNMP agent must report. The changes were trivial in
+the case of the network stack, since it was already SNMP-friendly. The
+generic ethernet device driver was re-organized to have an extensive header
+file and to add a couple of APIs to extract statistics that the
+hardware-specific device drivers keep within themselves.
+
+
+There may be a performance hit for recording that data; disabling
+a config option named something like
+CYGDBG_DEVS_ETH_xxxx_xxxx_KEEP_STATISTICS
+depending on the specific device driver will prevent that.
+
+
+Not all platform ethernet device drivers export complete SNMP statistical
+information; if the exported information is missing, SNMP will report zero
+values for such data (in the dot3 MIB).
+
+
+The interface chipset has an ID which is an OID; not all the latest greatest
+devices are listed in the abailable database, so new chipsets may need to
+be added to the client MIB, if not defined in those from UCD.
+
+
+
+Starting the SNMP Agent
+
+A routine to instantiate and start the SNMP agent thread in the default
+configuration is provided in
+PACKAGES/net/snmp/agent/VERSION/src/snmptask.c
+
+
+It starts the snmpd thread at priority
+CYGPKG_NET_THREAD_PRIORITY+1
+by default, ie. one step less important than the TCP/IP stack service
+thread.
+It also statically creates and uses a very large stack of around 100
+KiloBytes.
+To use that convenience function, this code fragment may be copied (in
+plain C).
+
+
+#ifdef CYGPKG_SNMPAGENT
+{
+ extern void cyg_net_snmp_init(void);
+ cyg_net_snmp_init();
+
+}
+#endif
+
+
+In case you need to perform initialization, for example setting up SNMPv3
+security features, when the snmp agent starts and every time it restarts,
+you can register a callback function by simply writing the global variable:
+
+externC void (*snmpd_reinit_function )( void );
+
+with a suitable function pointer.
+
+
+The entry point to the SNMP agent is
+
+externC void snmpd ( void (*initfunc )( void ) );
+
+so you can of course easily start it in a thread of your choice at another
+priority instead if required, after performing whatever other
+initialization your SNMP MIBs need. A larger than default stacksize is
+required. The initfunc parameter is the callback
+function mentioned above — a NULL parameter there is safe and
+obviously means no callback is registered.
+
+
+Note that if you call snmpd(); yourself and do
+not call cyg_net_snmp_init(); then
+that routine, global variable, and the default large stack will not be
+used. This is the recommended way control such features from your
+application; create and start the thread yourself at the appropriate
+moment.
+
+
+Other APIs from the snmpd module are available,
+specifically:
+
+void SnmpdShutDown (int a );
+
+which causes the snmpd to restart itself —
+including the callback to your init function — as soon as possible.
+
+
+The parameter a is ignored. It is there because in
+snmpd 's “natural environment” this routine
+is a UNIX signal handler.
+
+
+The helper functions in the network stack for managing
+DHCP
+leases will call SnmpdShutDown()
+when necessary, for example if network interfaces go down and/or come up
+again.
+
+
+
+Configuring eCos
+
+To use the SNMP agent, the SNMP library and agent packages must be
+included in your configuration. To incorporate the stack into your
+configuration select the SNMP library and SNMP agent packages in the
+eCos Configuration Tool, or at the command line type:
+
+$ ecosconfig add snmplib snmpagent
+
+
+
+After adding the networking, common ethernet device drivers,
+snmp library and snmp agent packages, there is no configuration
+required. However there are a number of configuration options
+that can be set such as some details for the System MIB, and
+disabling SNMPv3 support (see below).
+
+
+Starting the SNMP agent is not integrated into network
+tests other than snmpping below, nor is it
+started automatically in normal eCos startup -
+it is up to the application to start the agent when it is ready,
+at least after the network interfaces are both ‘up’.
+
+
+Version usage (v1, v2 or v3)
+
+The default build supports all three versions of the SNMP protocol, but without
+any dispatcher functionality (rfc 2571, section 3.1.1.2). This has the
+following implications :
+
+ 1. There is no community authentication for v1 and v2c.
+2. Security provided by v3 can be bypassed by using v1/v2c protocol.
+
+To provide the dispatcher with rfc 2571 type functionality, it is required to
+set up security models and access profiles. This can be provided in the normal
+Unix style by writing the required configurations in snmpd.conf
+file. Application code may setup profiles in snmpd.conf and
+optionally set the environment variable SNMPCONFPATH to
+point to the file if it is not in the usual location. The whole concept works
+in the usual way as with the standard UCD-SNMP distribution.
+
+
+
+Traps
+
+The support of the trapsink command in the
+snmpd.conf file is not tested
+and there may be problems for it working as expected. Moreover, in systems that do not
+have filesystem support, there is no way to configure a trap-session in the
+conventional way.
+
+
+For reasons mentioned above, applications need to initialize their own trap
+sessions and pass it the details of trap-sink. The following is a small sample
+for initializing a v1 trap session :
+
+
+typedef struct trap {
+ unsigned char ip [4];
+ unsigned int port;
+ unsigned char community [256];
+}
+
+trap trapsink;
+unsinged char sink [16];
+
+...
+...
+
+if (trapsink.ip != 0) {
+ sprintf (sink, "%d.%d.%d.%d",
+ trapsink[0], trapsink[1], trapsink[2], trapsink[3]);
+ if (create_trap_session (sink,
+ trapsink.port,
+ (char *)trapsink.community,
+ SNMP_VERSION_1,
+ SNMP_MSG_TRAP) == 0) {
+ log_error ("Creation of trap session failed \n");
+ }
+}
+
+
+
+snmpd.conf file
+
+Using snmpd.conf requires the inclusion of one of the file-system packages
+(eg. CYGPKG_RAMFS) and CYGPKG_FILEIO. With these two packages included, the
+SNMP sub-system will read the snmpd.conf file from the location specified in
+SNMPCONFPATH , or the standard builtin locations, and use
+these profiles. Only the profiles specified in the ACCESS-CONTROL
+section of snmpd.conf file have
+been tested and shown to work. Other profiles which have been implemented in
+UCD-SNMP-4.1.2 's snmpd.conf may not work
+because the sole purpose of adding support for the snmpd.conf file has been to
+set up ACCESS-CONTROL models.
+
+
+At startup, the SNMP module tries to look for file snmp.conf .
+If this file is not available, the module successively looks for files
+snmpd.conf , snmp.local.conf and
+snmpd.local.conf at the locations pointed to by
+SNMPCONFPATH environment variable. In case SNMPCONFPATH
+ is not defined, the search sequence is carried out in default directories.
+The default directories are :/usr/share/snmp ,
+/usr/local/share/snmp and $(HOME)/.snmp .
+The configurations read from these files are used to control both, SNMP
+applications and the SNMP agent; in the usual UNIX fashion.
+
+
+The inclusion of snmpd.conf support is enabled by default when suitable
+filesystems and FILEIO packages are active.
+
+
+
+
+Test cases
+
+Currently only one test program is provided which uses SNMP.
+
+
+"snmpping" in the SNMP agent package runs the ping test from
+the TCPIP package, with the snmpd running also. This allows you
+to interrogate it using host tools of your choice. It supports MIBs
+as documented above, so eg. snmpwalk
+<hostname> public dot3 under
+Linux/UNIX should have the desired effect.
+
+
+For serious testing, you should increase the length of time
+the test runs by setting CYGNUM_SNMPAGENT_TESTS_ITERATIONS
+to something big (e.g., 999999). Build the test
+(make -C net/snmp/agent/current tests )
+and run it on the target.
+
+
+Then start several jobs, some for pinging the board (to make
+the stats change) and some for interrogating the snmpd. Set $IP
+to whatever IP address the board has:
+
+
+# in a root shell, for flood ping
+while(1)
+date
+ping -f -c 3001 $IP
+sleep 5
+ping -c 32 -s 2345 $IP
+end
+
+# have more than one of these going at once
+setenv MIBS all
+while (1)
+snmpwalk -OS $IP public
+date
+end
+
+Leave to run for a couple of days or so to test stability.
+
+
+The test program can also test snmpd.conf support. It tries to build a minimal
+snmpd.conf file on a RAM filesystem and passes it to the snmp sub-system. With
+this profile on target, the following snmp[cmd] (cmd=walk, get, set) should
+work :
+
+
+snmp[cmd] -v1 $IP crux $OID
+snmp[cmd] -v2 $IP crux $OID
+snmp[cmd] -v3 $IP -u root -L noAuthNoPriv $OID
+snmp[cmd] -v3 $IP -u root -L authNoPriv -A MD5 -a md5passwd $OID
+
+
+The following commands would however fail since they violate the access model :
+
+
+snmp[cmd] $IP public $OID
+snmp[cmd] -v1 $IP public $OID
+snmp[cmd] -v2c $IP public $OID
+snmp[cmd] -v3 $IP -u no_user -L noAuthNoPriv $OID
+snmp[cmd] -v3 $IP -u root -L authNoPriv -A MD5 -a badpasswd $OID
+
+
+
+SNMP clients and package use
+
+SNMP clients may use these packages, but this usage is currently
+untested: the reason why this port to eCos exists is to acquire
+the SNMP agent. The fact that that the SNMP API (for clients) exists
+is a side-effect. See the standard man page SNMP_API(3)
+for details. There are further caveats below about client-side
+use of the SNMP library.
+
+
+All of the SNMP header files are installed beneath .../include/ucd-snmp
+in the install tree. The SNMP code itself assumes that directory
+is on its include path, so we recommend that client code does the
+same. Further, like the TCP/IP stack, compiling SNMP code
+requires definition of _KERNEL and __ECOS,
+and additionally IN_UCD_SNMP_SOURCE.
+
+
+Therefore, add all of these to your compile lines if you wish
+to include SNMP header files:
+
+-D_KERNEL
+-D__ECOS
+-DIN_UCD_SNMP_SOURCE=1
+-I$(PREFIX)/include/ucd-snmp
+
+
+Unimplemented features
+
+Currently, the filesystem and persistent storage areas are
+left undone, to be implemented by the application.
+
+
+The SNMP library package is intended to support client and
+agent code alike. It therefore contains lots of assumptions about
+the presence of persistent storage ie. a filesystem. Currently,
+by default, eCos has no such thing, so those areas have been simply
+commented out and made to return empty lists or say “no
+data here.”
+
+
+Specifically the following files have omitted/unimplemented code :
+
+
+PACKAGES/net/snmp/lib/VERSION/src/parse.c
+
+
+contains code to enumerate MIB files discovered in the system
+MIB directories (“/usr/share/snmp/mibs ”),
+and read them all in, building data structures that are used by
+client programs to interrogate an agent. This is not required in
+an agent, so the routine which enumerates the directories returns
+an empty list.
+
+
+PACKAGES/net/snmp/lib/VERSION/src/read_config.c
+contains two systems:
+
+
+The first tries to read the configuration file as described in the
+snmpd.conf file section and
+the second system contains code to record persistent data as files in a
+directory (typically /var/ucd-snmp ) thus preserving the
+state permanently.
+
+
+The first part is partially implemented to support multiple profiles and enables
+dispatcher functionality as discussed in .
+The second part is not supported at all in the default implementation. As required,
+a cleaner interface to permit application code to manage persistent data will be
+developed in consultation with customers.
+
+
+
+MIB Compiler
+In the directory
+ /snmp/agent/VERSION/utils/mib2c ,
+there are the following files:
+
+README-eCos notes about running with a nonstandard
+ perl path.
+README.mib2c the README from UCD; full instructions on
+ using mib2c
+mib2c the perl program
+mib2c.conf a configuration file altered to include the
+ eCos/UCD
+mib2c.conf-ORIG copyright and better #include paths; and
+ the ORIGinal.
+mib2c.storage.conf other config files, not modified.
+mib2c.vartypes.conf
+
+
+mib2c is provided BUT it requires the SNMP perl package SNMP-3.1.0,
+and that in turn requires perl nsPerl5.005_03 (part of
+Red Hat Linux from 6.0, April 1999).
+These are available from the CPAN (“the Comprehensive
+Perl Archive Network”) as usual;
+http://www.cpan.org/
+and links from there. Specifically:
+
+
+
+PERL itself:
+
+http://people.netscape.com/kristian/nsPerl/
+
+
+
+http://people.netscape.com/richm/nsPerl/nsPerl5.005_03-11-i686-linux.tar.gz
+
+
+SNMP.pl
+
+http://www.cpan.org/modules/01modules.index.html
+
+
+
+http://cpan.valueclick.com/modules/by-category/05_Networking_Devices_IPC/SNMP/
+
+
+
+http://www.cpan.org/authors/id/G/GS/GSM/SNMP.tar.gz
+
+
+(note that the .tar.gz files are not browsable)
+
+For documentation on the files produced, see the documentation
+available at
+http://ucd-snmp.ucdavis.edu/
+
+in general, and file AGENT.txt in particular.
+
+
+It is likely that the output of mib2c will be further customized
+depending on eCos customer needs; it’s easy to do this
+by editing the mib2c.conf file to add or remove whatever you need
+with the resulting C sources.
+
+
+The UCD autoconf-style configuration does not apply to eCos.
+ So if you add a completely new MIB to the agent, and support it
+using mib2c so that the my_new_mib.c file contains
+a init_my_new_mib() routine to register
+the MIB handler, you will also need to edit a couple of control
+files; these claim to be auto-generated, but in the eCos release,
+they’re not, don’t worry.
+
+PACKAGES/net/snmp/agent/VERSION/include/mib_module_includes.h
+
+contains a number of lines like
+
+#include “mibgroup/mibII/interfaces.h”
+
+so add your new MIB thus:
+
+#include “mibgroup/mibII/my_new_mib.h”
+PACKAGES/net/snmp/agent/VERSION/include/mib_module_inits.h
+
+contains a number of lines like
+
+init_interfaces();
+init_dot3();
+
+and so on; add your new MIB as follows:
+
+init_my_new_mib();
+
+and this should work correctly.
+
+
+
+&net-snmp-agent-snmp-manpages-sgml
+
+
Index: v2_0/ChangeLog
===================================================================
--- v2_0/ChangeLog (nonexistent)
+++ v2_0/ChangeLog (revision 1765)
@@ -0,0 +1,554 @@
+2003-03-25 Andrew Lunn
+
+ Imported from trunk into 2.0 branch:
+ * include/mibgroup/mibII/itf_helpers.h:
+ * src/mibgroup/mibII/helpers.c: (New) Functions for finding the
+ interface structure for Free and open BSD.
+ * src/mibgroup/mibII/interfaces.c: Use the helper functions and
+ other changes needed for the FreeBSD stack.
+ * src/mibgroup/mibII/ip.c: Ditto
+ * src/mibgroup/mibII/udp.c: Ditto
+ * src/mibgroup/mibII/tcp.c: Ditto
+ * src/mibgroup/mibII/dot3.c: Ditto
+ * cdl/snmpagent.cdl: Removed the requirement for the OpenBSD stack.
+ * doc/snmp.sgml: Removed the documented requirement for the OpenBSD
+ stack.
+
+2003-02-24 Jonathan Larmour
+
+ * cdl/snmpagent.cdl: Add doc link.
+
+ * doc/prepare-manpages.sh: Generate namespaced IDs, without shouting.
+ * doc/snmp-manpages.sgml: Regenerated.
+
+2003-02-14 Jonathan Larmour
+
+ * cdl/snmpagent.cdl: Explicitly require OpenBSD stack since we don't
+ work with the FreeBSD stack yet.
+
+ * doc/snmp.sgml: Document configuring packages better, and only use
+ of OpenBSD stack.
+
+2003-02-05 Jonathan Larmour
+
+ * doc/snmp.sgml: Fix a doc build failure, and tweak some duff links and
+ a few typos.
+
+2003-02-03 Andrew Lunn
+
+ * doc/prepare-manpages.sh: New file. Convert from man to sgml.
+ * doc/manpages/snmpd.conf.5: New file: Manual page for snmpd.conf.
+ * doc/snmp-manpages.sgml: New file. The converted man page
+ * doc/snmp.sgml: Updated documentation which includes the man page.
+
+2003-02-03 Manu Sharma
+
+ * cdl/snmpagent.cdl,
+ * include/mib_module_config.h,
+ * include/mib_module_dot_conf.h,
+ * include/mib_module_inits.h,
+ * include/mib_module_shutdown.h,
+ * include/snmpEngine.h,
+ * include/usmStats.h,
+ * include/usmUser.h,
+ * include/vacm_vars.h,
+ * src/agent_registry.c,:
+ * src/mib_modules.c,
+ * src/snmp_vars.c,
+ * src/snmpd.c,
+ * src/mibgroup/mibII/vacm_vars.c,
+ * src/mibgroup/snmpv3/snmpEngine.c,
+ * src/mibgroup/snmpv3/usmStats.c,
+ * src/mibgroup/snmpv3/usmUser.c,
+ * tests/snmpping.c : Support to conditionally implement SNMPv3
+ features, based on definition of CYGPKG_SNMPAGENT_V3_SUPPORT.
+
+2002-11-11 Manu Sharma
+
+ * src/mibgroup/mibII/vacm_vars.c:
+ * include/vacm_vars.h: Imported from the UCD-SNMP-4.1.2. These
+ are required to support VACM features, based on a snmpd.conf file.
+
+ * cdl/snmpagent.cdl : Compile vacm_vars.c
+
+ * include/mib_module_inits.h : Initialization of vacm and usm related
+ functions. The usm related functionality are no longer required to
+ be initialized by application code.
+
+ * tests/snmpping.c : Code to create a basic snmpd.conf file and
+ enable its usage. This conditional on
+ CYGPKG_SNMPLIB_FILESYSTEM_SUPPORT and require the ramfs package
+
+ * doc/snmp.sgml: Documentation for above changes.
+
+2002-08-14 David Smith
+
+ * src/agent_trap.c (send_enterprise_trap_vars):
+ * src/snmp_agent.c (handle_var_list): Memory leak fixes from
+ ucd-snmp-4.2.2.
+
+2002-06-03 Gary Thomas (on behalf of)
+2002-06-03 Roland Caßebohm
+
+ * src/agent_trap.c (send_enterprise_trap_vars):
+ * src/snmp_agent.c (handle_snmp_packet): Fix memory leaks.
+
+2002-03-19 Hugo Tyson
+
+ * doc/snmp.sgml: Fix the URLs for "where is SNMP now".
+
+2002-02-14 Hugo Tyson
+
+ * doc/snmp.sgml: NEW FILE: Clarified and brought up to date
+ somewhat. Still rather vague - but then it's a port of UCD's
+ work, we should not second-guess their expertise in the matter.
+
+ Release notes section from when SNMP was distributed as a separate
+ .EPK file removed - it was full of version- and platform-specific
+ references, and rehashes of general repository management advice.
+
+2002-02-05 Hugo Tyson
+
+ * src/snmptask.c: Pass a function pointer into dhcpd() for for
+ SNMP reinitialization when its state cycles up-down-up; for
+ example setting up v3 security, extra MIBs and the like.
+
+ * src/snmpd.c (dhcpd): Handle re-init pointer. Namespace tidied
+ up a little too; state flags can be static no problem.
+
+ * tests/snmpping.c (snmp_do_reinit): New function to test hook for
+ SNMP reinitialization. Also commit some stuff I've had around for
+ ages to make this test very robust against eg. DHCP going away.
+ It re-does the init_all_network_interfaces() and so on if any
+ interface "up"ness changes, thus testing all that stuff too.
+ Also looks at the correct symbol for SNMPv3 testing now.
+
+2002-02-01 Gary Thomas
+
+ * tests/snmpping.c (ping_test):
+ * src/agent_trap.c (send_enterprise_trap_vars):
+ Need valid value for sin_len.
+
+2001-11-21 Hugo Tyson
+
+ * src/snmpd.c (snmpd): Explicit execution-time initialization of
+ "running" variable, so that we can restart snmpd without it
+ immediately exiting again.
+
+ * src/snmptask.c (snmpdloop): Make the snmpd thread loop forever,
+ so that we can restart it when the state of all the interfaces
+ changes.
+
+2001-08-14 Gary Thomas
+
+ * tests/snmpping.c:
+ * cdl/snmpagent.cdl: Add CDL options to configure tests.
+
+2001-07-31 Hugo Tyson
+2001-07-31 Ron Kundla
+
+ * utils/mib2c/mib2c (Table-handling): Concatenate rather than
+ replace subsequent processed variables. The symptom was that in
+ the generated header file you only get the last table in the MIB.
+ This fixes it. Thanks Ron!
+
+2001-06-07 Jesper Skov
+
+ * src/mibgroup/mibII/ip.c (var_ipNetToMediaTable): Only handle
+ IPNETTOMEDIAPHYSADDRESS for devices with associated hardware.
+
+2001-05-29 Hugo Tyson
+
+ * tests/snmpping.c (net_test): Committed the improved version of
+ this that I've been using for a while - with new improved SNMPv3
+ testing. This requires (in the current setup) explicit init of
+ the SNMPv3 MIBs and a "user" for authentication purposes. The
+ test can also be set to run the interfaces in promiscuous mode,
+ and/or to run forever, and it has lots better diagnostics if you
+ see mangled ping packets. And the ping size varies too, to test
+ ICMP defragmentation.
+
+2001-05-29 Hugo Tyson
+2001-05-28 Manu Sharma
+2001-05-28 Andrew Lunn
+
+ * src/mibgroup/mibII/interfaces.c (var_ifTable): Support a direct
+ call into a customer's device ioctl() for devices of type
+ IFT_CUSTOMER_SPECIAL - if they have defined it. This is to make
+ it easier to add a custom interface type and have SNMP deal with
+ it properly without editting the SNMP sources.
+
+ * include/snmpEngine.h, include/usmState.h, include/usmUser.h:
+ * src/mibgroup/snmpv3/snmpEngine.c, src/mibgroup/snmpv3/usmStats.c:
+ * src/mibgroup/snmpv3/usmUser.c: NEW FILES: Added support of
+ SNMPv3 User based Security Module (USM). This adds
+ authentification and encryption to snmp requests and replies.
+
+ * cdl/snmpagent.cdl: Build the new files above.
+
+2001-05-08 Jonathan Larmour
+
+ * utils/mib2c/README-eCos: Clarify usage of mib2c a bit.
+
+2001-01-17 Jonathan Larmour
+
+ * src/mibgroup/util_funcs.c (restart_hook): Don't use alarm() in eCos
+ (wait_on_exec): Don't use waitpid() in eCos
+ The above prevent link errors.
+
+2001-01-10 Jonathan Larmour
+
+ * cdl/snmpagent.cdl: Clarify ISO C requirements
+
+2000-11-29 Hugo Tyson
+2000-11-29 Andrew Lunn
+ * src/mibgroup/mibII/dot3.c (var_dot3StatsTable):
+ * src/mibgroup/mibII/interfaces.c (var_ifTable):
+ Undo Hugo's fix; it fails if there are holes in the if_index space
+ (not something I expected). Use this fix instead, from Andrew.
+ [CASE 104939]
+
+ * src/mibgroups/mibII/ip.c: IPADENTIFINDEX should return the
+ interface index as seen in the interface group. This is not the
+ if_index but merely acquired by counting.
+
+2000-11-17 Hugo Tyson
+
+ * src/mibgroup/mibII/dot3.c (var_dot3StatsTable):
+ * src/mibgroup/mibII/interfaces.c (var_ifTable): Use the
+ last component of the OID to select the matching interface rather
+ than merely counting through them. Thus this MIB matches eg. the
+ IP MIB in terms of ip.ipAddrTable.ipAddrEntry.ipAdEntIfIndex.
+ [CASE 104939 "snmp interface and IP group don't correspond"]
+
+2000-08-31 Hugo Tyson
+
+ * tests/snmpping.c (net_test): Add use of network realtime test
+ harness - if available. One example is provided for the EBSA285
+ in "devs/eth/arm/ebsa285/VERSION/tests/test_net_realtime.h"
+
+2000-08-25 Hugo Tyson
+
+ * src/mibgroup/mibII/dot3.c (var_dot3StatsTable): A little further
+ diddling; have a bool to say whether the dot3 info is filled in.
+
+2000-08-24 Hugo Tyson
+
+ * src/mibgroup/mibII/dot3.c (var_dot3StatsTable):
+ * src/mibgroup/mibII/interfaces.c (var_ifTable): Use new ioctl()
+ interface to get information out of ethernet devices. If the
+ ioctl call is not supported, we just get default values.
+
+2000-08-16 Hugo Tyson
+
+ * src/snmpd.c (snmpd): Remove call to
+ init_all_network_interfaces(); it's a bad idea for the situations
+ when initialization has been done externally to our helper
+ functions. This adds the constraint that you must initialize the
+ network interfaces first, by whatever means. Starting snmpd
+ before the network is up may cause confusion.
+ [CASE 104330]
+
+ Also tidied some warnings.
+
+2000-07-25 Hugo Tyson
+
+ * tests/snmpping.c (net_test): Make it ping the loopback
+ interfaces so as to do some valid testing in the absence of any
+ real interfaces on the platform. Also make it run less time or no
+ doubt the farm will report many non-failures.
+
+2000-07-13 Hugo Tyson
+
+ * tests/snmpping.c: Up the stack size to cope with full DHCP
+ initialization in init_all_network_interfaces().
+
+2000-06-27 Hugo Tyson
+
+ * src/mibgroup/mibII/dot3.c (var_dot3StatsTable): Forgot the
+ DOT3STATSINDEX for loopback, so it claimed index 0. Fixed.
+
+2000-06-26 Hugo Tyson
+
+ * src/snmptask.c (cyg_net_snmp_init): Change the priority of the
+ SNMP thread; make it one less important than the network thread of
+ which it is a client.
+
+2000-06-19 Hugo Tyson
+
+ * src/mibgroup/mibII/dot3.c (var_dot3StatsTable): Don't trip over
+ loopback interface; it doesn't support the same enquiries as an
+ eth device.
+
+ * src/mibgroup/mibII/interfaces.c (var_ifTable): Don't trip over
+ loopback interface; it doesn't support the same enquiries as an
+ eth device.
+
+2000-06-14 Hugo Tyson
+
+ * cdl/snmpagent.cdl: Add options for the default values for system
+ MIB vals that describe the machine.
+
+ * src/mibgroup/mibII/system_mib.c (init_system_mib): Pick up
+ values from configury (this goes via config.h in the library).
+
+2000-06-14 John Dallaway
+
+ * cdl/snmpagent.cdl: Tidy display strings.
+
+2000-06-14 Hugo Tyson
+
+ * cdl/snmpagent.cdl: Install all the header files below
+ include/ucd-snmp/ as is the normal host-side standard; this avoids
+ some rather terrible filenamespace pollution too. That location
+ is also added to the include path, using a mechanism that's rather
+ build-method-specific; it may need revisiting.
+
+2000-06-14 Hugo Tyson
+
+ * cdl/snmpagent.cdl: parent this below CYGPKG_NET.
+
+2000-06-13 Hugo Tyson
+
+ * cdl/snmpagent.cdl: Add mibgroup/mibII/dot3.c to compile list.
+
+ * src/mibgroup/mibII/dot3.c (var_dot3StatsTable): Done that - and
+ it required changes to the EBSA ether device driver. Of course,
+ if those info-macros are not present, the SNMP agent module uses
+ zeros, so it should "work" half-heartedly with other platforms
+ too.
+
+ * include/mibgroup/mibII/dot3.h: Completed handler function list.
+
+ * src/mibgroup/mibII/interfaces.c (var_ifTable): This now makes
+ use of info-macros exported from the ethernet dd.
+
+ * include/mib_module_inits.h: Call init_dot3() in the bootup.
+
+ * src/mibgroup/mibII/system_mib.c (init_system_mib): Fill in
+ default system type description.
+
+2000-06-09 Hugo Tyson
+
+ * src/mibgroup/mibII/tcp.c (var_tcpConnTable): Done that.
+
+2000-06-09 Hugo Tyson
+
+ * src/mibgroup/mibII/udp.c (var_udpTable): Done that.
+
+2000-06-08 Hugo Tyson
+
+ * src/mibgroup/mibII/icmp.c (var_icmp): Fleshed this out with a
+ copy from the UCD version - BSD stack nosing-in-kernel memory arm
+ of the code is the same, unsurprisingly.
+
+2000-06-08 Hugo Tyson
+
+ * src/mibgroup/mibII/ip.c (var_ip): Flesh this out; it's mostly
+ there now.
+
+ * src/mibgroup/mibII/interfaces.c (var_ifTable): Make this more
+ consistent, particularly the use of FIXMEs for the bits I have not
+ completed yet.
+
+2000-06-06 Hugo Tyson
+
+ * src/mibgroup/mibII/interfaces.c (var_ifTable): Flesh this out
+ with lots of snooping into the ifnet structures and a little info
+ from the device driver. The info is there now.
+
+ * src/mibgroup/mibII/tcp.c (var_tcpConnTable,var_ipv6TcpConnTable):
+ * src/mibgroup/mibII/udp.c (var_udpTable,var_ipv6UdpTable):
+ * src/mibgroup/mibII/ip.c (var_ipAddrTable,var_ipNetToMediaTable):
+ Fix these (by commenting out) parts for complex tables that made
+ the snmpwalk tool crash out; ie. it acts as if all such complex
+ tables are empty, rather than returning badly indexed entries.
+
+2000-06-02 Hugo Tyson
+
+ * utils/mib2c/README-eCos:
+ * utils/mib2c/README.mib2c:
+ * utils/mib2c/mib2c:
+ * utils/mib2c/mib2c.conf:
+ * utils/mib2c/mib2c.conf-ORIG:
+ * utils/mib2c/mib2c.storage.conf:
+ * utils/mib2c/mib2c.vartypes.conf:
+ New files, just to keep my variant of mib2c.conf under source
+ controlled; it includes our copyright (and attribution to UCD et
+ al, of course) the different include paths as required by eCos'
+ package layout and a couple of other nits sorted out.
+
+2000-06-02 Hugo Tyson
+
+ * cdl/snmpagent.cdl (compile): Omit the read-only file-system
+ part; the library will cheerfully use it, but it's not at all
+ necessary. Waste of time - unless someone is liable to use the
+ snmplib for tool rather than agent purposes.
+
+ * include/mib_module_includes.h: Include the full set of includes
+ for the MIBs we will implement. Ie.
+ mibgroup/mibII/system_mib.h // { mib2 1 }
+ mibgroup/mibII/sysORTable.h // { mib2 1.9.1 } == { system 9.1 }
+ mibgroup/mibII/interfaces.h // { mib2 2 }
+ (NOT mibgroup/mibII/at.h) // #3 is deprecated
+ mibgroup/mibII/ip.h // { mib2 4 }
+ mibgroup/mibII/icmp.h // { mib2 5 }
+ mibgroup/mibII/tcp.h // { mib2 6 }
+ mibgroup/mibII/udp.h // { mib2 7 }
+ mibgroup/mibII/dot3.h // { mib2 10.7 } == { transmission 7 }
+ mibgroup/mibII/snmp_mib.h // { mib2 11 }
+
+ * include/mib_module_inits.h: Same thing really; but dot3 is not
+ yet in there at all, it'll be added later.
+ init_system_mib(); // { mib2 1 }
+ init_sysORTable(); // { mib2 1.9.1 } == { system 9.1 }
+ init_interfaces(); // { mib2 2 }
+ //init_at(); // #3 is deprecated
+ init_ip(); // { mib2 4 }
+ init_icmp(); // { mib2 5 }
+ init_tcp(); // { mib2 6 }
+ init_udp(); // { mib2 7 }
+ //init_dot3(); // { mib2 10.7 } == { transmission 7 } FIXME
+ init_snmp_mib(); // { mib2 11 }
+
+ * include/mibgroup/mibII/icmp.h:
+ * include/mibgroup/mibII/interfaces.h:
+ * include/mibgroup/mibII/ip.h:
+ * include/mibgroup/mibII/tcp.h:
+ * include/mibgroup/mibII/udp.h:
+ These files have all been replaced by versions direct from mib2c,
+ without any of the UNIX/LINUX/Win32-specific gubbins from the
+ original versions.
+
+ * include/mibgroup/mibII/dot3.h: New file direct from mib2c.
+
+ * include/mibgroup/mibII/route_write.h: DELETED
+ * include/mibgroup/mibII/at.h: DELETED
+ * include/mibgroup/mibII/var_route.h: DELETED
+ Removed, not necessary for the vanilla headers; they were there
+ before to satisfy include needs of the originals.
+
+ * src/mibgroup/mibII/dot3.c:
+ * src/mibgroup/mibII/icmp.c:
+ * src/mibgroup/mibII/interfaces.c:
+ * src/mibgroup/mibII/ip.c:
+ * src/mibgroup/mibII/tcp.c:
+ * src/mibgroup/mibII/udp.c:
+ These are new files, direct from mib2c, again without all the
+ UNIX/LINUX/Win32-specific gubbins from the original versions.
+
+ * src/rofs/EtherLike-MIB.c: DELETED
+ * src/rofs/IANAifType-MIB.c: DELETED
+ * src/rofs/IF-MIB.c: DELETED
+ * src/rofs/IP-MIB.c: DELETED
+ * src/rofs/RFC-1215.c: DELETED
+ * src/rofs/SNMPv2-CONF.c: DELETED
+ * src/rofs/SNMPv2-MIB.c: DELETED
+ * src/rofs/SNMPv2-SMI.c: DELETED
+ * src/rofs/SNMPv2-TC.c: DELETED
+ * src/rofs/SNMPv2-TM.c: DELETED
+ * src/rofs/TCP-MIB.c: DELETED
+ * src/rofs/UDP-MIB.c: DELETED
+ * src/rofs/snmprofs.c: DELETED
+ Turns out that I don't need a read-only FS with all the MIBs in in
+ the agent - reading them in (and complaining of their absence) is
+ part of the snmplib startup, but it's not needed by an agent.
+ This also means that if reinstated they should live in the lib
+ component rather than the agent one; oh well.
+
+
+2000-05-31 Hugo Tyson
+
+ * Initial commit of port of UCD-SNMP version 4.1.2 to eCos.
+
+//==========================================================================
+//
+// ./agent/current/ChangeLog
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
Index: v2_0/src/agent_read_config.c
===================================================================
--- v2_0/src/agent_read_config.c (nonexistent)
+++ v2_0/src/agent_read_config.c (revision 1765)
@@ -0,0 +1,252 @@
+//==========================================================================
+//
+// ./agent/current/src/agent_read_config.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * agent_read_config.c
+ */
+
+#include
+
+#include
+#if HAVE_STDLIB_H
+#include
+#endif
+#if HAVE_STRING_H
+#include
+#else
+#include
+#endif
+#include
+#include
+#include
+
+#if TIME_WITH_SYS_TIME
+# ifdef WIN32
+# include
+# else
+# include
+# endif
+# include
+#else
+# if HAVE_SYS_TIME_H
+# include
+# else
+# include
+# endif
+#endif
+#if HAVE_NETINET_IN_H
+#include
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+#include
+#endif
+#if HAVE_NETINET_IP_H
+#include
+#endif
+#ifdef INET6
+#if HAVE_NETINET_IP6_H
+#include
+#endif
+#endif
+#if HAVE_SYS_QUEUE_H
+#include
+#endif
+#if HAVE_SYS_SOCKET_H
+#include
+#elif HAVE_WINSOCK_H
+#include
+#endif
+#if HAVE_SYS_STREAM_H
+#include
+#endif
+#if HAVE_NET_ROUTE_H
+#include
+#endif
+#if HAVE_NETINET_IP_VAR_H
+#include
+#endif
+#ifdef INET6
+#if HAVE_NETINET6_IP6_VAR_H
+#include
+#endif
+#endif
+#if HAVE_NETINET_IN_PCB_H
+#include
+#endif
+#if HAVE_INET_MIB2_H
+#include
+#endif
+
+#if HAVE_DMALLOC_H
+#include
+#endif
+
+#include "mibincl.h"
+#include "snmpusm.h"
+
+#include "mibgroup/struct.h"
+#include "read_config.h"
+#include "agent_read_config.h"
+#include "callback.h"
+#include "snmp_agent.h"
+#include "agent_trap.h"
+#include "snmpd.h"
+#include "system.h"
+#include "snmp_debug.h"
+#include "snmp_alarm.h"
+#include "default_store.h"
+#include "ds_agent.h"
+#include "mib_module_includes.h"
+
+char dontReadConfigFiles;
+char *optconfigfile;
+
+void init_agent_read_config (const char *app)
+{
+ if ( app != NULL )
+ ds_set_string(DS_LIBRARY_ID, DS_LIB_APPTYPE, app);
+
+ register_app_config_handler("authtrapenable",
+ snmpd_parse_config_authtrap, NULL,
+ "1 | 2\t\t(1 = enable, 2 = disable)");
+
+ if ( ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_ROLE) == MASTER_AGENT ) {
+ register_app_config_handler("trapsink",
+ snmpd_parse_config_trapsink, snmpd_free_trapsinks,
+ "host [community]");
+ register_app_config_handler("trap2sink",
+ snmpd_parse_config_trap2sink, NULL,
+ "host [community]");
+ register_app_config_handler("informsink",
+ snmpd_parse_config_informsink, NULL,
+ "host [community]");
+ }
+ register_app_config_handler("trapcommunity",
+ snmpd_parse_config_trapcommunity,
+ snmpd_free_trapcommunity,
+ "community-string");
+#include "mib_module_dot_conf.h"
+#ifdef TESTING
+ print_config_handlers();
+#endif
+}
+
+void update_config(void)
+{
+ free_config();
+ read_configs();
+}
+
+
+void
+snmpd_register_config_handler(const char *token,
+ void (*parser) (const char *, char *),
+ void (*releaser) (void),
+ const char *help)
+{
+ DEBUGMSGTL(("snmpd_register_app_config_handler",
+ "registering .conf token for \"%s\"\n", token));
+ register_app_config_handler(token, parser, releaser, help);
+}
+
+void
+snmpd_unregister_config_handler(const char *token)
+{
+ unregister_app_config_handler(token);
+}
+
+/* this function is intended for use by mib-modules to store permenant
+ configuration information generated by sets or persistent counters */
+void
+snmpd_store_config(const char *line)
+{
+ read_app_config_store(line);
+}
Index: v2_0/src/mib_modules.c
===================================================================
--- v2_0/src/mib_modules.c (nonexistent)
+++ v2_0/src/mib_modules.c (revision 1765)
@@ -0,0 +1,142 @@
+//==========================================================================
+//
+// ./agent/current/src/mib_modules.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* wrapper to call all the mib module initialization functions */
+
+#include "mib_module_config.h"
+#include
+#if HAVE_STRING_H
+#include
+#else
+#include
+#endif
+#if HAVE_STDLIB_H
+#include
+#endif
+#if HAVE_UNISTD_H
+#include
+#endif
+#if HAVE_NETINET_IN_H
+#include
+#endif
+#if HAVE_WINSOCK_H
+#include
+#endif
+
+#include "asn1.h"
+#include "snmp_api.h"
+#include "snmp_impl.h"
+#include "system.h"
+#include "read_config.h"
+#include "snmp.h"
+#include "mib.h"
+#include "m2m.h"
+#include "snmp_vars.h"
+#include "agent_read_config.h"
+#ifdef CYGPKG_SNMPAGENT_V3_SUPPORT
+#include "snmpv3.h"
+#endif
+#include "callback.h"
+#include "snmp_alarm.h"
+#include "default_store.h"
+#include "tools.h"
+
+#include "mibgroup/struct.h"
+#include "mib_modules.h"
+#include "mib_module_includes.h"
+#ifdef USING_AGENTX_SUBAGENT_MODULE
+#include "mibgroup/agentx/subagent.h"
+#endif
+
+void
+init_mib_modules(void) {
+# include "mib_module_inits.h"
+}
Index: v2_0/src/kernel.c
===================================================================
--- v2_0/src/kernel.c (nonexistent)
+++ v2_0/src/kernel.c (revision 1765)
@@ -0,0 +1,288 @@
+//==========================================================================
+//
+// ./agent/current/src/kernel.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+
+/*
+ * 13 Jun 91 wsak (wk0x@andrew) added mips support
+ */
+
+#include
+
+#ifdef CAN_USE_NLIST
+
+#include
+#if HAVE_UNISTD_H
+#include
+#endif
+#include
+#include
+#if HAVE_STRING_H
+#include
+#endif
+#if HAVE_FCNTL_H
+#include
+#endif
+#if HAVE_NETINET_IN_H
+#include
+#endif
+#if HAVE_KVM_H
+#include
+#endif
+
+#include "asn1.h"
+#include "snmp_api.h"
+#include "snmp_impl.h"
+#include "snmp_logging.h"
+#include "default_store.h"
+
+#include "kernel.h"
+#include "ds_agent.h"
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+
+#if HAVE_KVM_H
+kvm_t *kd;
+
+void
+init_kmem(const char *file)
+{
+#if HAVE_KVM_OPENFILES
+ char err[4096];
+ kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, err);
+ if (kd == NULL && !ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_NO_ROOT_ACCESS)) {
+ snmp_log(LOG_CRIT, "init_kmem: kvm_openfiles failed: %s\n", err);
+ exit(1);
+ }
+#else
+ kd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL);
+ if (!kd && !ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_NO_ROOT_ACCESS)) {
+ snmp_log(LOG_CRIT, "init_kmem: kvm_open failed: %s\n", strerror(errno));
+ exit(1);
+ }
+#endif /* HAVE_KVM_OPENFILES */
+}
+
+
+/*
+ * klookup:
+ *
+ * It seeks to the location off in kmem
+ * It does a read into target of siz bytes.
+ *
+ * Return 0 on failure and 1 on sucess.
+ *
+ */
+
+
+int
+klookup(unsigned long off,
+ char *target,
+ int siz)
+{
+ int result;
+ if (kd == NULL) return 0;
+ result = kvm_read(kd, off, target, siz);
+ if (result != siz) {
+#if HAVE_KVM_OPENFILES
+ snmp_log(LOG_ERR,"kvm_read(*, %lx, %p, %d) = %d: %s\n", off, target, siz,
+ result, kvm_geterr(kd));
+#else
+ snmp_log(LOG_ERR,"kvm_read(*, %lx, %p, %d) = %d: ", off, target, siz,
+ result);
+ snmp_log_perror("klookup");
+#endif
+ return 0;
+ }
+ return 1;
+}
+
+#else /* HAVE_KVM_H */
+
+static off_t klseek (off_t);
+static int klread (char *, int);
+int swap, mem, kmem;
+
+void
+init_kmem(const char *file)
+{
+ kmem = open(file, O_RDONLY);
+ if (kmem < 0 && !ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_NO_ROOT_ACCESS)){
+ snmp_log_perror(file);
+ exit(1);
+ }
+ fcntl(kmem,F_SETFD,1);
+ mem = open("/dev/mem",O_RDONLY);
+ if (mem < 0 && !ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_NO_ROOT_ACCESS)){
+ snmp_log_perror("/dev/mem");
+ exit(1);
+ }
+ fcntl(mem,F_SETFD,1);
+#ifdef DMEM_LOC
+ swap = open(DMEM_LOC,O_RDONLY);
+ if (swap < 0 && !ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_NO_ROOT_ACCESS)){
+ snmp_log_perror(DMEM_LOC);
+ exit(1);
+ }
+ fcntl(swap,F_SETFD,1);
+#endif
+}
+
+
+/*
+ * Seek into the kernel for a value.
+ */
+static off_t
+klseek(off_t base)
+{
+ return (lseek(kmem, (off_t)base, SEEK_SET));
+}
+
+
+/*
+ * Read from the kernel
+ */
+static int
+klread(char *buf,
+ int buflen)
+{
+ return (read(kmem, buf, buflen));
+}
+
+
+/*
+ * klookup:
+ *
+ * It seeks to the location off in kmem
+ * It does a read into target of siz bytes.
+ *
+ * Return 0 on failure and 1 on sucess.
+ *
+ */
+
+
+int
+klookup(unsigned long off,
+ char *target,
+ int siz)
+{
+ long retsiz;
+
+ if (kmem < 0) return 0;
+
+ if ((retsiz = klseek((off_t) off)) != off) {
+ snmp_log(LOG_ERR, "klookup(%lx, %p, %d): ", off, target, siz);
+ snmp_log_perror("klseek");
+#ifdef EXIT_ON_BAD_KLREAD
+ exit(1);
+#endif
+ return (0);
+ }
+ if ((retsiz = klread(target, siz)) != siz ) {
+ if (snmp_get_do_debugging()) {
+ /* these happen too often on too many architectures to print them
+ unless we're in debugging mode. People get very full log files. */
+ snmp_log(LOG_ERR, "klookup(%lx, %p, %d): ", off, target, siz);
+ snmp_log_perror("klread");
+ }
+#ifdef EXIT_ON_BAD_KLREAD
+ exit(1);
+#endif
+ return(0);
+ }
+ return (1);
+}
+
+#endif /* HAVE_KVM_H */
+
+#endif /* CAN_USE_NLIST */
Index: v2_0/src/snmptask.c
===================================================================
--- v2_0/src/snmptask.c (nonexistent)
+++ v2_0/src/snmptask.c (revision 1765)
@@ -0,0 +1,205 @@
+//==========================================================================
+//
+// ./agent/current/src/snmptask.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+//==========================================================================
+//
+// snmptask.c
+//
+// eCos wrapper for the SNMP daemon
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####BSDCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from OpenBSD or other sources,
+// and are covered by the appropriate copyright disclaimers included herein.
+//
+// -------------------------------------------
+//
+//####BSDCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): gthomas
+// Contributors: gthomas
+// Date: 2000-01-10
+// Purpose:
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+
+#include
+#include
+
+#include
+#include CYGDAT_NET_STACK_CFG
+
+#define STACK_SIZE CYGNUM_HAL_STACK_SIZE_TYPICAL + 102400
+static char netsnmp_stack[STACK_SIZE];
+static cyg_thread netsnmp_thread_data;
+static cyg_handle_t netsnmp_thread_handle;
+
+
+
+
+externC void (*snmpd_reinit_function)( void );
+
+void (*snmpd_reinit_function)( void ) = NULL;
+
+
+externC void snmpd( void (*initfunc)( void ) );
+
+static void
+snmpdloop( cyg_addrword_t data )
+{
+ while ( 1 )
+ snmpd(snmpd_reinit_function);
+}
+
+// Network initialization
+// This function is called during system initialization to setup the whole
+// networking environment.
+//
+
+void
+cyg_net_snmp_init(void)
+{
+
+ // Create network background thread
+ cyg_thread_create(CYGPKG_NET_THREAD_PRIORITY+1, // Priority, just lower than the net
+ snmpdloop, // entry
+ 0, // entry parameter
+ "snmpd", // Name
+ &netsnmp_stack[0], // Stack
+ STACK_SIZE, // Size
+ &netsnmp_thread_handle, // Handle
+ &netsnmp_thread_data // Thread data structure
+ );
+ cyg_thread_resume(netsnmp_thread_handle); // Start it
+ // Done
+
+}
Index: v2_0/src/snmpd.c
===================================================================
--- v2_0/src/snmpd.c (nonexistent)
+++ v2_0/src/snmpd.c (revision 1765)
@@ -0,0 +1,1038 @@
+//==========================================================================
+//
+// ./agent/current/src/snmpd.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * snmpd.c - rrespond to SNMP queries from management stations
+ *
+ */
+/***********************************************************
+ Copyright 1988, 1989 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.
+******************************************************************/
+#include
+
+#include
+#include
+#if HAVE_STRING_H
+#include
+#else
+#include
+#endif
+#if HAVE_STDLIB_H
+#include
+#endif
+#if HAVE_UNISTD_H
+#include
+#endif
+#include
+#if HAVE_NETINET_IN_H
+#include
+#endif
+#if HAVE_ARPA_INET_H
+#include
+#endif
+#if TIME_WITH_SYS_TIME
+# ifdef WIN32
+# include
+# else
+# include
+# endif
+# include
+#else
+# if HAVE_SYS_TIME_H
+# include
+# else
+# include
+# endif
+#endif
+#if HAVE_SYS_SELECT_H
+#include
+#endif
+#if HAVE_SYS_SOCKET_H
+#include
+#elif HAVE_WINSOCK_H
+#include
+#endif
+#if HAVE_NET_IF_H
+#include
+#endif
+#if HAVE_INET_MIB2_H
+#include
+#endif
+#if HAVE_SYS_IOCTL_H
+#include
+#endif
+#if HAVE_SYS_FILE_H
+#include
+#endif
+#if HAVE_FCNTL_H
+#include
+#endif
+#if HAVE_SYS_WAIT_H
+#include
+#endif
+#include
+#ifdef HAVE_SYS_PARAM_H
+#include
+#endif
+
+#ifndef FD_SET
+typedef long fd_mask;
+#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
+#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
+#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
+#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
+#define FD_ZERO(p) memset((p), 0, sizeof(*(p)))
+#endif
+
+#if HAVE_DMALLOC_H
+#include
+#endif
+
+#include "asn1.h"
+#include "snmp_api.h"
+#include "snmp_impl.h"
+#include "system.h"
+#include "read_config.h"
+#include "snmp.h"
+#include "mib.h"
+#include "m2m.h"
+#include "snmp_vars.h"
+#include "agent_read_config.h"
+#ifdef CYGPKG_SNMPAGENT_V3_SUPPORT
+#include "snmpv3.h"
+#endif
+#include "callback.h"
+#include "snmp_alarm.h"
+#include "default_store.h"
+#include "mib_module_config.h"
+
+#include "snmp_client.h"
+#include "snmpd.h"
+#include "var_struct.h"
+#include "mibgroup/struct.h"
+#include "mibgroup/util_funcs.h"
+#include "snmp_debug.h"
+#include "mib_modules.h"
+
+#ifdef CYGPKG_SNMPAGENT_V3_SUPPORT
+#include "snmpusm.h"
+#endif
+#include "tools.h"
+#include "lcd_time.h"
+
+#include "transform_oids.h"
+
+#include "snmp_agent.h"
+#include "agent_trap.h"
+#include "ds_agent.h"
+#include "agent_read_config.h"
+#include "snmp_logging.h"
+
+#include "version.h"
+
+#include "mib_module_includes.h"
+
+/*
+ * Globals.
+ */
+#ifdef USE_LIBWRAP
+#include
+
+int allow_severity = LOG_INFO;
+int deny_severity = LOG_WARNING;
+#endif /* USE_LIBWRAP */
+
+#define TIMETICK 500000L
+#define ONE_SEC 1000000L
+
+static int log_addresses = 0;
+int snmp_dump_packet;
+static int running = 1;
+static int reconfig = 0;
+
+struct addrCache {
+ in_addr_t addr;
+ int status;
+#define UNUSED 0
+#define USED 1
+#define OLD 2
+};
+
+#define ADDRCACHE 10
+
+static struct addrCache addrCache[ADDRCACHE];
+static int lastAddrAge = 0;
+
+extern char **argvrestartp;
+extern char *argvrestart;
+extern char *argvrestartname;
+
+#define NUM_SOCKETS 32
+
+#ifdef USING_SMUX_MODULE
+static int sdlist[NUM_SOCKETS], sdlen = 0;
+int smux_listen_sd;
+#endif /* USING_SMUX_MODULE */
+
+/*
+ * Prototypes.
+ */
+int snmp_read_packet (int);
+int snmp_input (int, struct snmp_session *, int, struct snmp_pdu *, void *);
+int main (int, char **);
+static void SnmpTrapNodeDown (void);
+static int receive(void);
+int snmp_check_packet(struct snmp_session*, snmp_ipaddr);
+int snmp_check_parse(struct snmp_session*, struct snmp_pdu*, int);
+
+#if !defined(__ECOS)
+static void usage(char *prog)
+{
+ printf("\nUsage: %s [-h] [-v] [-f] [-a] [-d] [-V] [-P PIDFILE] [-q] [-D] [-p NUM] [-L] [-l LOGFILE] [-r]",prog);
+#if HAVE_UNISTD_H
+ printf(" [-u uid] [-g gid]");
+#endif
+ printf("\n");
+ printf("\n\tVersion: %s\n",VersionInfo);
+ printf("\tAuthor: Wes Hardaker\n");
+ printf("\tEmail: ucd-snmp-coders@ucd-snmp.ucdavis.edu\n");
+ printf("\n-h\t\tThis usage message.\n");
+ printf("-H\t\tDisplay configuration file directives understood.\n");
+ printf("-v\t\tVersion information.\n");
+ printf("-f\t\tDon't fork from the shell.\n");
+ printf("-a\t\tLog addresses.\n");
+ printf("-d\t\tDump sent and received UDP SNMP packets\n");
+ printf("-V\t\tVerbose display\n");
+ printf("-P PIDFILE\tUse PIDFILE to store process id\n");
+ printf("-q\t\tPrint information in a more parsable format (quick-print)\n");
+ printf("-D\t\tTurn on debugging output\n");
+ printf("-p NUM\t\tRun on port NUM instead of the default: 161\n");
+ printf("-x SOCKADDR\tBind AgentX to this address\n");
+ printf("-c CONFFILE\tRead CONFFILE as a configuration file.\n");
+ printf("-C\t\tDon't read the default configuration files.\n");
+ printf("-L\t\tPrint warnings/messages to stdout/err\n");
+ printf("-s\t\tLog warnings/messages to syslog\n");
+ printf("-A\t\tAppend to the logfile rather than truncating it.\n");
+ printf("-r Don't exit if root only accessible files can't be opened\n");
+ printf("-l LOGFILE\tPrint warnings/messages to LOGFILE\n");
+ printf("\t\t(By default LOGFILE=%s)\n",
+#ifdef LOGFILE
+ LOGFILE
+#else
+ "none"
+#endif
+ );
+#if HAVE_UNISTD_H
+ printf("-g \t\tChange to this gid after opening port\n");
+ printf("-u \t\tChange to this uid after opening port\n");
+#endif
+ printf("\n");
+ exit(1);
+}
+#endif // !defined(__ECOS)
+
+ RETSIGTYPE
+SnmpdShutDown(int a)
+{
+ running = 0;
+}
+
+#ifdef SIGHUP
+ RETSIGTYPE
+SnmpdReconfig(int a)
+{
+ reconfig = 1;
+ signal(SIGHUP, SnmpdReconfig);
+}
+#endif
+
+#ifdef SIGUSR1
+extern void dump_registry( void );
+ RETSIGTYPE
+SnmpdDump(int a)
+{
+ dump_registry();
+ signal(SIGUSR1, SnmpdDump);
+}
+#endif
+
+
+ static void
+SnmpTrapNodeDown(void)
+{
+ send_easy_trap (SNMP_TRAP_ENTERPRISESPECIFIC, 2);
+ /* XXX 2 - Node Down #define it as NODE_DOWN_TRAP */
+}
+
+/*******************************************************************-o-******
+ * main
+ *
+ * Parameters:
+ * argc
+ * *argv[]
+ *
+ * Returns:
+ * 0 Always succeeds. (?)
+ *
+ *
+ * Setup and start the agent daemon.
+ *
+ * Also successfully EXITs with zero for some options.
+ */
+#if !defined(__ECOS)
+
+ int
+main(int argc, char *argv[])
+{
+ int arg, i;
+ int ret;
+ u_short dest_port = SNMP_PORT;
+ int dont_fork = 0;
+ char logfile[SNMP_MAXBUF_SMALL];
+ char *cptr, **argvptr;
+ char *pid_file = NULL;
+#if HAVE_GETPID
+ FILE *PID;
+#endif
+ int dont_zero_log = 0;
+ int stderr_log=0, syslog_log=0;
+ int uid=0, gid=0;
+
+ logfile[0] = 0;
+
+#ifdef LOGFILE
+ strcpy(logfile, LOGFILE);
+#endif
+
+
+ /*
+ * usage: snmpd
+ */
+ for (arg = 1; arg < argc; arg++)
+ {
+ if (argv[arg][0] == '-') {
+ switch (argv[arg][1]) {
+
+ case 'c':
+ if (++arg == argc)
+ usage(argv[0]);
+ ds_set_string(DS_LIBRARY_ID, DS_LIB_OPTIONALCONFIG,
+ argv[arg]);
+ break;
+
+ case 'C':
+ ds_set_boolean(DS_LIBRARY_ID, DS_LIB_DONT_READ_CONFIGS, 1);
+ break;
+
+ case 'd':
+ snmp_set_dump_packet(++snmp_dump_packet);
+ ds_set_boolean(DS_APPLICATION_ID, DS_AGENT_VERBOSE, 1);
+ break;
+
+ case 'q':
+ snmp_set_quick_print(1);
+ break;
+
+ case 'T':
+ if (argv[arg][2] != '\0')
+ cptr = &argv[arg][2];
+ else if (++arg>argc) {
+ fprintf(stderr,"Need UDP or TCP after -T flag.\n");
+ usage(argv[0]);
+ exit(1);
+ } else {
+ cptr = argv[arg];
+ }
+ if (strcasecmp(cptr,"TCP") == 0) {
+ ds_set_int(DS_APPLICATION_ID, DS_AGENT_FLAGS,
+ ds_get_int(DS_APPLICATION_ID, DS_AGENT_FLAGS)
+ | SNMP_FLAGS_STREAM_SOCKET);
+ } else if (strcasecmp(cptr,"UDP") == 0) {
+ /* default, do nothing */
+ } else {
+ fprintf(stderr,
+ "Unknown transport \"%s\" after -T flag.\n",
+ cptr);
+ usage(argv[0]);
+ exit(1);
+ }
+ break;
+
+ case 'D':
+ debug_register_tokens(&argv[arg][2]);
+ snmp_set_do_debugging(1);
+ break;
+
+ case 'p':
+ if (++arg == argc)
+ usage(argv[0]);
+ dest_port = atoi(argv[arg]);
+ if (dest_port <= 0)
+ usage(argv[0]);
+ break;
+
+ case 'x':
+ if (++arg == argc)
+ usage(argv[0]);
+ ds_set_string(DS_APPLICATION_ID, DS_AGENT_X_SOCKET, argv[arg]);
+ break;
+
+ case 'r':
+ ds_set_boolean(DS_APPLICATION_ID,
+ DS_AGENT_NO_ROOT_ACCESS, 1);
+ break;
+
+ case 'P':
+ if (++arg == argc)
+ usage(argv[0]);
+ pid_file = argv[arg];
+
+ case 'a':
+ log_addresses++;
+ break;
+
+ case 'V':
+ ds_set_boolean(DS_APPLICATION_ID, DS_AGENT_VERBOSE, 1);
+ break;
+
+ case 'f':
+ dont_fork = 1;
+ break;
+
+ case 'l':
+ if (++arg == argc)
+ usage(argv[0]);
+ strcpy(logfile, argv[arg]);
+ break;
+
+ case 'L':
+ stderr_log=1;
+ break;
+
+ case 's':
+ syslog_log=1;
+ break;
+
+ case 'A':
+ dont_zero_log = 1;
+ break;
+#if HAVE_UNISTD_H
+ case 'u':
+ if (++arg == argc) usage(argv[0]);
+ uid = atoi(argv[arg]);
+ break;
+ case 'g':
+ if (++arg == argc) usage(argv[0]);
+ gid = atoi(argv[arg]);
+ break;
+#endif
+ case 'h':
+ usage(argv[0]);
+ break;
+ case 'H':
+ init_agent("snmpd"); /* register our .conf handlers */
+ init_mib_modules();
+ init_snmp("snmpd");
+ fprintf(stderr, "Configuration directives understood:\n");
+ read_config_print_usage(" ");
+ exit(0);
+ case 'v':
+ printf("\nUCD-snmp version: %s\n",VersionInfo);
+ printf("Author: Wes Hardaker\n");
+ printf("Email: ucd-snmp-coders@ucd-snmp.ucdavis.edu\n\n");
+ exit (0);
+ case '-':
+ switch(argv[arg][2]){
+ case 'v':
+ printf("\nUCD-snmp version: %s\n",VersionInfo);
+ printf("Author: Wes Hardaker\n");
+ printf("Email: ucd-snmp-coders@ucd-snmp.ucdavis.edu\n\n");
+ exit (0);
+ case 'h':
+ usage(argv[0]);
+ exit(0);
+ }
+
+ default:
+ printf("invalid option: %s\n", argv[arg]);
+ usage(argv[0]);
+ break;
+ }
+ continue;
+ }
+ } /* end-for */
+
+ /*
+ * Initialize a argv set to the current for restarting the agent.
+ */
+ argvrestartp = (char **) malloc((argc + 2) * sizeof(char *));
+ argvptr = argvrestartp;
+ for (i = 0, ret = 1; i < argc; i++) {
+ ret += strlen(argv[i]) + 1;
+ }
+ argvrestart = (char *) malloc(ret);
+ argvrestartname = (char *) malloc(strlen(argv[0]) + 1);
+ strcpy(argvrestartname, argv[0]);
+ if ( strstr(argvrestartname, "agentxd") != NULL)
+ ds_set_boolean(DS_APPLICATION_ID, DS_AGENT_ROLE, SUB_AGENT);
+ else
+ ds_set_boolean(DS_APPLICATION_ID, DS_AGENT_ROLE, MASTER_AGENT);
+ for (cptr = argvrestart, i = 0; i < argc; i++) {
+ strcpy(cptr, argv[i]);
+ *(argvptr++) = cptr;
+ cptr += strlen(argv[i]) + 1;
+ }
+ *cptr = 0;
+ *argvptr = NULL;
+
+
+ /*
+ * Open the logfile if necessary.
+ */
+
+ /* Should open logfile and/or syslog based on arguments */
+ if (logfile[0])
+ snmp_enable_filelog(logfile, dont_zero_log);
+ if (syslog_log)
+ snmp_enable_syslog();
+#ifdef BUFSIZ
+ setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
+#endif
+ /*
+ * Initialize the world. Detach from the shell.
+ * Create initial user.
+ */
+#if HAVE_FORK
+ if (!dont_fork && fork() != 0) {
+ exit(0);
+ }
+#endif
+
+#if HAVE_GETPID
+ if (pid_file != NULL) {
+ if ((PID = fopen(pid_file, "w")) == NULL) {
+ snmp_log_perror("fopen");
+ if (!ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_NO_ROOT_ACCESS))
+ exit(1);
+ }
+ else {
+ fprintf(PID, "%d\n", (int)getpid());
+ fclose(PID);
+ }
+ }
+#endif
+
+#else /* __ECOS environment: */
+void snmpd( void *initfunc( void ) ) {
+ int ret;
+ u_short dest_port = SNMP_PORT;
+#define stderr_log 1
+#endif
+
+ // ---------
+ // En-bloc reinitialization of statics.
+ running = 1;
+ // ---------
+
+ SOCK_STARTUP;
+ init_agent("snmpd"); /* do what we need to do first. */
+ init_mib_modules();
+
+
+ /* start library */
+ init_snmp("snmpd");
+
+ ret = init_master_agent( dest_port,
+ snmp_check_packet,
+ snmp_check_parse );
+ if( ret != 0 )
+ Exit(1); /* Exit logs exit val for us */
+
+#ifdef SIGTERM
+ signal(SIGTERM, SnmpdShutDown);
+#endif
+#ifdef SIGINT
+ signal(SIGINT, SnmpdShutDown);
+#endif
+#ifdef SIGHUP
+ signal(SIGHUP, SnmpdReconfig);
+#endif
+#ifdef SIGUSR1
+ signal(SIGUSR1, SnmpdDump);
+#endif
+
+ /* send coldstart trap via snmptrap(1) if possible */
+ send_easy_trap (0, 0);
+
+#if HAVE_UNISTD_H
+ if (gid) {
+ DEBUGMSGTL(("snmpd", "Changing gid to %d.\n", gid));
+ if (setgid(gid)==-1) {
+ snmp_log_perror("setgid failed");
+ if (!ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_NO_ROOT_ACCESS))
+ exit(1);
+ }
+ }
+ if (uid) {
+ DEBUGMSGTL(("snmpd", "Changing uid to %d.\n", uid));
+ if(setuid(uid)==-1) {
+ snmp_log_perror("setuid failed");
+ if (!ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_NO_ROOT_ACCESS))
+ exit(1);
+ }
+ }
+#endif
+
+ /* honor selection of standard error output */
+ if (!stderr_log)
+ snmp_disable_stderrlog();
+
+ /* we're up, log our version number */
+ snmp_log(LOG_INFO, "UCD-SNMP version %s\n", VersionInfo);
+
+ memset(addrCache, 0, sizeof(addrCache));
+
+ /*
+ * Call initialization function if necessary
+ */
+ DEBUGMSGTL(("snmpd", "Calling initfunc().\n"));
+ if ( initfunc )
+ (initfunc)();
+
+ /*
+ * Forever monitor the dest_port for incoming PDUs.
+ */
+ DEBUGMSGTL(("snmpd", "We're up. Starting to process data.\n"));
+ receive();
+#include "mib_module_shutdown.h"
+ DEBUGMSGTL(("snmpd", "sending shutdown trap\n"));
+ SnmpTrapNodeDown();
+ DEBUGMSGTL(("snmpd", "Bye...\n"));
+ snmp_shutdown("snmpd");
+
+} /* End main() -- snmpd */
+
+/*******************************************************************-o-******
+ * receive
+ *
+ * Parameters:
+ *
+ * Returns:
+ * 0 On success.
+ * -1 System error.
+ *
+ * Infinite while-loop which monitors incoming messges for the agent.
+ * Invoke the established message handlers for incoming messages on a per
+ * port basis. Handle timeouts.
+ */
+ static int
+receive(void)
+{
+ int numfds;
+ fd_set fdset;
+ struct timeval timeout, *tvp = &timeout;
+ struct timeval sched, *svp = &sched,
+ now, *nvp = &now;
+ int count, block;
+#ifdef USING_SMUX_MODULE
+ int i, sd;
+#endif /* USING_SMUX_MODULE */
+
+
+ /*
+ * Set the 'sched'uled timeout to the current time + one TIMETICK.
+ */
+ gettimeofday(nvp, (struct timezone *) NULL);
+ svp->tv_usec = nvp->tv_usec + TIMETICK;
+ svp->tv_sec = nvp->tv_sec;
+
+ while (svp->tv_usec >= ONE_SEC){
+ svp->tv_usec -= ONE_SEC;
+ svp->tv_sec++;
+ }
+
+ /*
+ * Loop-forever: execute message handlers for sockets with data,
+ * reset the 'sched'uler.
+ */
+ while (running) {
+ if (reconfig) {
+ reconfig = 0;
+ snmp_log(LOG_INFO, "Reconfiguring daemon\n");
+ update_config();
+ }
+ tvp = &timeout;
+ tvp->tv_sec = 0;
+ tvp->tv_usec = TIMETICK;
+
+ numfds = 0;
+ FD_ZERO(&fdset);
+ block = 0;
+ snmp_select_info(&numfds, &fdset, tvp, &block);
+ if (block == 1)
+ tvp = NULL; /* block without timeout */
+
+#ifdef USING_SMUX_MODULE
+ if (smux_listen_sd >= 0) {
+ FD_SET(smux_listen_sd, &fdset);
+ numfds = smux_listen_sd >= numfds ? smux_listen_sd + 1 : numfds;
+ for (i = 0; i < sdlen; i++) {
+ FD_SET(sdlist[i], &fdset);
+ numfds = sdlist[i] >= numfds ? sdlist[i] + 1 : numfds;
+ }
+ }
+#endif /* USING_SMUX_MODULE */
+
+ count = select(numfds, &fdset, 0, 0, tvp);
+
+ if (count > 0){
+ snmp_read(&fdset);
+ } else switch(count){
+ case 0:
+ snmp_timeout();
+ break;
+ case -1:
+ if (errno == EINTR){
+ continue;
+ } else {
+ snmp_log_perror("select");
+ }
+ return -1;
+ default:
+ snmp_log(LOG_ERR, "select returned %d\n", count);
+ return -1;
+ } /* endif -- count>0 */
+
+#ifdef USING_SMUX_MODULE
+ /* handle the SMUX sd's */
+ if (smux_listen_sd >= 0) {
+ for (i = 0; i < sdlen; i++) {
+ if (FD_ISSET(sdlist[i], &fdset)) {
+ if (smux_process(sdlist[i]) < 0) {
+ for (; i < (sdlen - 1); i++) {
+ sdlist[i] = sdlist[i+1];
+ }
+ sdlen--;
+ }
+ }
+ }
+ /* new connection */
+ if (FD_ISSET(smux_listen_sd, &fdset)) {
+ if ((sd = smux_accept(smux_listen_sd)) >= 0) {
+ sdlist[sdlen++] = sd;
+ }
+ }
+ }
+#endif /* USING_SMUX_MODULE */
+
+
+
+ /*
+ * If the time 'now' is greater than the 'sched'uled time, then:
+ *
+ * Check alarm and event timers.
+ * Reset the 'sched'uled time to current time + one TIMETICK.
+ * Age the cache network addresses (from whom messges have
+ * been received).
+ */
+ gettimeofday(nvp, (struct timezone *) NULL);
+
+ if (nvp->tv_sec > svp->tv_sec
+ || (nvp->tv_sec == svp->tv_sec && nvp->tv_usec > svp->tv_usec)){
+ svp->tv_usec = nvp->tv_usec + TIMETICK;
+ svp->tv_sec = nvp->tv_sec;
+
+ while (svp->tv_usec >= ONE_SEC){
+ svp->tv_usec -= ONE_SEC;
+ svp->tv_sec++;
+ }
+ if (log_addresses && lastAddrAge++ > 600){
+
+ lastAddrAge = 0;
+ for(count = 0; count < ADDRCACHE; count++){
+ if (addrCache[count].status == OLD)
+ addrCache[count].status = UNUSED;
+ if (addrCache[count].status == USED)
+ addrCache[count].status = OLD;
+ }
+ }
+ } /* endif -- now>sched */
+
+ /* run requested alarms */
+ run_alarms();
+
+ } /* endwhile */
+
+ snmp_log(LOG_INFO, "Received TERM or STOP signal... shutting down...\n");
+ return 0;
+
+} /* end receive() */
+
+
+
+
+/*******************************************************************-o-******
+ * snmp_check_packet
+ *
+ * Parameters:
+ * session, from
+ *
+ * Returns:
+ * 1 On success.
+ * 0 On error.
+ *
+ * Handler for all incoming messages (a.k.a. packets) for the agent. If using
+ * the libwrap utility, log the connection and deny/allow the access. Print
+ * output when appropriate, and increment the incoming counter.
+ *
+ */
+int
+snmp_check_packet(struct snmp_session *session,
+ snmp_ipaddr from)
+{
+ struct sockaddr_in *fromIp = (struct sockaddr_in *)&from;
+
+#ifdef USE_LIBWRAP
+ const char *addr_string;
+ /*
+ * Log the message and/or dump the message.
+ * Optionally cache the network address of the sender.
+ */
+ addr_string = inet_ntoa(fromIp->sin_addr);
+
+ if(!addr_string) {
+ addr_string = STRING_UNKNOWN;
+ }
+ if(hosts_ctl("snmpd", addr_string, addr_string, STRING_UNKNOWN)) {
+ snmp_log(allow_severity, "Connection from %s\n", addr_string);
+ } else {
+ snmp_log(deny_severity, "Connection from %s REFUSED\n", addr_string);
+ return(0);
+ }
+#endif /* USE_LIBWRAP */
+
+ snmp_increment_statistic(STAT_SNMPINPKTS);
+
+ if (log_addresses || ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_VERBOSE)){
+ int count;
+
+ for(count = 0; count < ADDRCACHE; count++){
+ if (addrCache[count].status > UNUSED /* used or old */
+ && fromIp->sin_addr.s_addr == addrCache[count].addr)
+ break;
+ }
+
+ if (count >= ADDRCACHE ||
+ ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_VERBOSE)){
+ snmp_log(LOG_INFO, "Received SNMP packet(s) from %s\n",
+ inet_ntoa(fromIp->sin_addr));
+ for(count = 0; count < ADDRCACHE; count++){
+ if (addrCache[count].status == UNUSED){
+ addrCache[count].addr = fromIp->sin_addr.s_addr;
+ addrCache[count].status = USED;
+ break;
+ }
+ }
+ } else {
+ addrCache[count].status = USED;
+ }
+ }
+
+ return ( 1 );
+}
+
+
+int
+snmp_check_parse( struct snmp_session *session,
+ struct snmp_pdu *pdu,
+ int result)
+{
+ if ( result == 0 ) {
+ if ( ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_VERBOSE) &&
+ snmp_get_do_logging() ) {
+ char c_oid [SPRINT_MAX_LEN];
+ struct variable_list *var_ptr;
+
+ switch (pdu->command) {
+ case SNMP_MSG_GET:
+ snmp_log(LOG_DEBUG, " GET message\n"); break;
+ case SNMP_MSG_GETNEXT:
+ snmp_log(LOG_DEBUG, " GETNEXT message\n"); break;
+ case SNMP_MSG_RESPONSE:
+ snmp_log(LOG_DEBUG, " RESPONSE message\n"); break;
+ case SNMP_MSG_SET:
+ snmp_log(LOG_DEBUG, " SET message\n"); break;
+ case SNMP_MSG_TRAP:
+ snmp_log(LOG_DEBUG, " TRAP message\n"); break;
+ case SNMP_MSG_GETBULK:
+ snmp_log(LOG_DEBUG, " GETBULK message, non-rep=%d, max_rep=%d\n",
+ pdu->errstat, pdu->errindex); break;
+ case SNMP_MSG_INFORM:
+ snmp_log(LOG_DEBUG, " INFORM message\n"); break;
+ case SNMP_MSG_TRAP2:
+ snmp_log(LOG_DEBUG, " TRAP2 message\n"); break;
+ case SNMP_MSG_REPORT:
+ snmp_log(LOG_DEBUG, " REPORT message\n"); break;
+ }
+
+ for ( var_ptr = pdu->variables ;
+ var_ptr != NULL ; var_ptr=var_ptr->next_variable )
+ {
+ sprint_objid (c_oid, var_ptr->name, var_ptr->name_length);
+ snmp_log(LOG_DEBUG, " -- %s\n", c_oid);
+ }
+ }
+ return 1;
+ }
+ return 0; /* XXX: does it matter what the return value is? */
+}
+
+/*******************************************************************-o-******
+ * snmp_input
+ *
+ * Parameters:
+ * op
+ * *session
+ * requid
+ * *pdu
+ * *magic
+ *
+ * Returns:
+ * 1 On success -OR-
+ * Passes through Return from alarmGetResponse() when
+ * USING_V2PARTY_ALARM_MODULE is defined.
+ *
+ * Call-back function to manage responses to traps (informs) and alarms.
+ * Not used by the agent to process other Response PDUs.
+ */
+int
+snmp_input(int op,
+ struct snmp_session *session,
+ int reqid,
+ struct snmp_pdu *pdu,
+ void *magic)
+{
+ struct get_req_state *state = (struct get_req_state *)magic;
+
+ if (op == RECEIVED_MESSAGE) {
+ if (pdu->command == SNMP_MSG_GET) {
+ if (state->type == EVENT_GET_REQ) {
+ /* this is just the ack to our inform pdu */
+ return 1;
+ }
+ }
+ }
+ else if (op == TIMED_OUT) {
+ if (state->type == ALARM_GET_REQ) {
+ /* Need a mechanism to replace obsolete SNMPv2p alarm */
+ }
+ }
+ return 1;
+
+} /* end snmp_input() */
Index: v2_0/src/mibgroup/snmpv3/snmpEngine.c
===================================================================
--- v2_0/src/mibgroup/snmpv3/snmpEngine.c (nonexistent)
+++ v2_0/src/mibgroup/snmpv3/snmpEngine.c (revision 1765)
@@ -0,0 +1,282 @@
+//==========================================================================
+//
+// ./agent/current/src/mibgroup/snmpv3/snmpEngine.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): Andrew.Lunn@ascom.ch, Manu.Sharma@ascom.ch
+// Contributors: hmt
+// Date: 2001-05-29
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* snmpEngine.c: implements the SNMP-FRAMEWORK-MIB. */
+
+#include
+
+#ifdef CYGPKG_SNMPAGENT_V3_SUPPORT
+#if HAVE_WINSOCK_H
+#include
+#endif
+
+#include "mibincl.h"
+#include "snmpv3.h"
+//#include "util_funcs.h"
+#include "lcd_time.h"
+#include "mibgroup/mibII/sysORTable.h"
+#include "snmpEngine.h"
+
+struct variable2 snmpEngine_variables[] = {
+ { SNMPENGINEID , ASN_OCTET_STR , RONLY , var_snmpEngine, 1, { 1 } },
+#ifdef SNMP_TESTING_CODE
+ { SNMPENGINEBOOTS , ASN_INTEGER , RWRITE, var_snmpEngine, 1, { 2 } },
+ { SNMPENGINETIME , ASN_INTEGER , RWRITE, var_snmpEngine, 1, { 3 } },
+#else /* !SNMP_TESTING_CODE */
+ { SNMPENGINEBOOTS , ASN_INTEGER , RONLY , var_snmpEngine, 1, { 2 } },
+ { SNMPENGINETIME , ASN_INTEGER , RONLY , var_snmpEngine, 1, { 3 } },
+#endif /* SNMP_TESTING_CODE */
+ { SNMPENGINEMAXMESSAGESIZE, ASN_INTEGER, RONLY , var_snmpEngine, 1, { 4 } },
+};
+
+/* now load this mib into the agents mib table */
+oid snmpEngine_variables_oid[] = {1,3,6,1,6,3,10,2,1};
+
+void init_snmpEngine (void) {
+#ifdef USING_MIBII_SYSORTABLE_MODULE
+ static oid reg[] = {1,3,6,1,6,3,10,3,1,1};
+ register_sysORTable(reg,10,"The SNMP Management Architecture MIB.");
+#endif
+
+ REGISTER_MIB("snmpv3/snmpEngine", snmpEngine_variables, variable2,
+ snmpEngine_variables_oid);
+
+/* place any initialization routines needed here */
+}
+
+extern struct timeval starttime;
+
+#ifdef SNMP_TESTING_CODE
+int write_engineBoots(int, u_char *,u_char, size_t, u_char *,oid*, size_t);
+int write_engineTime(int, u_char *,u_char, size_t, u_char *,oid*, size_t);
+#endif /* SNMP_TESTING_CODE */
+
+u_char *
+var_snmpEngine(
+ struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+
+ /* variables we may use later */
+ static long long_ret;
+ static unsigned char engineID[SNMP_MAXBUF];
+
+ *write_method = 0; /* assume it isnt writable for the time being */
+ *var_len = sizeof(long_ret); /* assume an integer and change later if not */
+
+ if (header_generic(vp,name,length,exact,var_len,write_method))
+ return 0;
+
+ /* this is where we do the value assignments for the mib results. */
+ switch(vp->magic) {
+
+ case SNMPENGINEID:
+ *var_len = snmpv3_get_engineID(engineID, SNMP_MAXBUF);
+ /* XXX Set ERROR_MSG() upon error? */
+ return (unsigned char *) engineID;
+
+ case SNMPENGINEBOOTS:
+#ifdef SNMP_TESTING_CODE
+ *write_method = write_engineBoots;
+#endif /* SNMP_TESTING_CODE */
+ long_ret = snmpv3_local_snmpEngineBoots();
+ return (unsigned char *) &long_ret;
+
+ case SNMPENGINETIME:
+#ifdef SNMP_TESTING_CODE
+ *write_method = write_engineTime;
+#endif /* SNMP_TESTING_CODE */
+ long_ret = snmpv3_local_snmpEngineTime();
+ return (unsigned char *) &long_ret;
+
+ case SNMPENGINEMAXMESSAGESIZE:
+ long_ret = 1500;
+ return (unsigned char *) &long_ret;
+
+ default:
+ DEBUGMSGTL(("snmpd", "unknown sub-id %d in var_snmpEngine\n", vp->magic));
+ }
+ return 0;
+}
+
+#ifdef SNMP_TESTING_CODE
+/* write_engineBoots():
+
+ This is technically not writable a writable mib object, but we
+ allow it so we can run some time synchronization tests.
+*/
+int
+write_engineBoots(
+ int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ /* variables we may use later */
+ static long long_ret;
+ size_t size;
+ int bigsize=SNMP_MAXBUF_MEDIUM;
+ u_char engineIDBuf[SNMP_MAXBUF_MEDIUM];
+ int engineIDBufLen = 0;
+
+ if (var_val_type != ASN_INTEGER){
+ DEBUGMSGTL(("snmpEngine","write to engineBoots not ASN_INTEGER\n"));
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(long_ret)){
+ DEBUGMSGTL(("snmpEngine","write to engineBoots: bad length\n"));
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ long_ret = *((long *) var_val);
+ if (action == COMMIT) {
+ engineIDBufLen = snmpv3_get_engineID(engineIDBuf, SNMP_MAXBUF_MEDIUM);
+ /* set our local engineTime in the LCD timing cache */
+ snmpv3_set_engineBootsAndTime(long_ret, snmpv3_local_snmpEngineTime());
+ set_enginetime(engineIDBuf, engineIDBufLen,
+ snmpv3_local_snmpEngineBoots(),
+ snmpv3_local_snmpEngineTime(),
+ TRUE);
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+/* write_engineTime():
+
+ This is technically not writable a writable mib object, but we
+ allow it so we can run some time synchronization tests.
+*/
+int
+write_engineTime(
+ int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ /* variables we may use later */
+ static long long_ret;
+ size_t size;
+ int bigsize=SNMP_MAXBUF_MEDIUM;
+ u_char engineIDBuf[SNMP_MAXBUF_MEDIUM];
+ int engineIDBufLen = 0;
+
+ if (var_val_type != ASN_INTEGER){
+ DEBUGMSGTL(("snmpEngine","write to engineTime not ASN_INTEGER\n"));
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(long_ret)){
+ DEBUGMSGTL(("snmpEngine","write to engineTime: bad length\n"));
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ long_ret = *((long *) var_val);
+ if (action == COMMIT) {
+ engineIDBufLen = snmpv3_get_engineID(engineIDBuf, SNMP_MAXBUF_MEDIUM);
+ /* set our local engineTime in the LCD timing cache */
+ snmpv3_set_engineBootsAndTime(snmpv3_local_snmpEngineBoots(), long_ret);
+ set_enginetime(engineIDBuf, engineIDBufLen,
+ snmpv3_local_snmpEngineBoots(),
+ snmpv3_local_snmpEngineTime(),
+ TRUE);
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+#endif /* CYGPKG_SNMPAGENT_V3_SUPPORT */
+#endif /* SNMP_TESTING_CODE */
Index: v2_0/src/mibgroup/snmpv3/usmStats.c
===================================================================
--- v2_0/src/mibgroup/snmpv3/usmStats.c (nonexistent)
+++ v2_0/src/mibgroup/snmpv3/usmStats.c (revision 1765)
@@ -0,0 +1,161 @@
+//==========================================================================
+//
+// ./agent/current/src/mibgroup/snmpv3/usmStats.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): Andrew.Lunn@ascom.ch, Manu.Sharma@ascom.com
+// Contributors: hmt
+// Date: 2001-05-29
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+
+/* usmStats.c: implements the usmStats portion of the SNMP-USER-BASED-SM-MIB */
+
+#include
+
+#ifdef CYGPKG_SNMPAGENT_V3_SUPPORT
+#if HAVE_WINSOCK_H
+#include
+#endif
+
+#include "mibincl.h"
+//#include "util_funcs.h"
+#include "mibgroup/mibII/sysORTable.h"
+#include "usmStats.h"
+
+struct variable2 usmStats_variables[] = {
+ { USMSTATSUNSUPPORTEDSECLEVELS, ASN_COUNTER, RONLY, var_usmStats, 1, { 1 } },
+ { USMSTATSNOTINTIMEWINDOWS, ASN_COUNTER, RONLY, var_usmStats, 1, { 2 } },
+ { USMSTATSUNKNOWNUSERNAMES, ASN_COUNTER, RONLY, var_usmStats, 1, { 3 } },
+ { USMSTATSUNKNOWNENGINEIDS, ASN_COUNTER, RONLY, var_usmStats, 1, { 4 } },
+ { USMSTATSWRONGDIGESTS, ASN_COUNTER, RONLY, var_usmStats, 1, { 5 } },
+ { USMSTATSDECRYPTIONERRORS, ASN_COUNTER, RONLY, var_usmStats, 1, { 6 } },
+};
+
+/* now load this mib into the agents mib table */
+oid usmStats_variables_oid[] = {1,3,6,1,6,3,15,1,1};
+
+
+void init_usmStats (void) {
+#ifdef USING_MIBII_SYSORTABLE_MODULE
+ static oid reg[] = {1,3,6,1,6,3,15,2,1,1};
+ register_sysORTable(reg,10,"The management information definitions for the SNMP User-based Security Model.");
+#endif
+
+ REGISTER_MIB("snmpv3/usmStats", usmStats_variables, variable2,
+ usmStats_variables_oid );
+}
+
+u_char *
+var_usmStats(
+ struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+
+ /* variables we may use later */
+ static long long_ret;
+ int tmagic;
+
+ *write_method = 0; /* assume it isnt writable for the time being */
+ *var_len = sizeof(long_ret); /* assume an integer and change later if not */
+
+ if (header_generic(vp,name,length,exact,var_len,write_method))
+ return 0;
+
+ /* this is where we do the value assignments for the mib results. */
+ tmagic = vp->magic;
+ if ( (tmagic >= 0)
+ && (tmagic <= (STAT_USM_STATS_END - STAT_USM_STATS_START)) )
+ {
+ long_ret = snmp_get_statistic(tmagic + STAT_USM_STATS_START);
+ return (unsigned char *) &long_ret;
+ }
+ return 0;
+}
+
+#endif /* CYGPKG_SNMPAGENT_V3_SUPPORT */
Index: v2_0/src/mibgroup/snmpv3/usmUser.c
===================================================================
--- v2_0/src/mibgroup/snmpv3/usmUser.c (nonexistent)
+++ v2_0/src/mibgroup/snmpv3/usmUser.c (revision 1765)
@@ -0,0 +1,1177 @@
+//==========================================================================
+//
+// ./agent/current/src/mibgroup/snmpv3/usmUser.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): Andrew.Lunn@ascom.ch, Manu.Sharma@ascom.com
+// Contributors: hmt
+// Date: 2001-05-29
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * usmUser.c
+ */
+
+#include
+
+#ifdef CYGPKG_SNMPAGENT_V3_SUPPORT
+#include
+
+#if HAVE_STRING_H
+#include
+#else
+#include
+#endif
+
+#if HAVE_WINSOCK_H
+#include
+#endif
+
+#include "mibincl.h"
+#include "snmpusm.h"
+#include "snmpv3.h"
+#include "snmp-tc.h"
+#include "read_config.h"
+#include "agent_read_config.h"
+//#include "util_funcs.h"
+#include "keytools.h"
+#include "tools.h"
+#include "scapi.h"
+
+#include "usmUser.h"
+#include "transform_oids.h"
+
+struct variable4 usmUser_variables[] = {
+ { USMUSERSPINLOCK , ASN_INTEGER , RWRITE, var_usmUser, 1, { 1 } },
+ { USMUSERSECURITYNAME , ASN_OCTET_STR , RONLY , var_usmUser, 3, { 2,1,3 } },
+ { USMUSERCLONEFROM , ASN_OBJECT_ID , RWRITE, var_usmUser, 3, { 2,1,4 } },
+ { USMUSERAUTHPROTOCOL , ASN_OBJECT_ID , RWRITE, var_usmUser, 3, { 2,1,5 } },
+ { USMUSERAUTHKEYCHANGE, ASN_OCTET_STR , RWRITE, var_usmUser, 3, { 2,1,6 } },
+ { USMUSEROWNAUTHKEYCHANGE, ASN_OCTET_STR , RWRITE, var_usmUser, 3, { 2,1,7 } },
+ { USMUSERPRIVPROTOCOL , ASN_OBJECT_ID , RWRITE, var_usmUser, 3, { 2,1,8 } },
+ { USMUSERPRIVKEYCHANGE, ASN_OCTET_STR , RWRITE, var_usmUser, 3, { 2,1,9 } },
+ { USMUSEROWNPRIVKEYCHANGE, ASN_OCTET_STR , RWRITE, var_usmUser, 3, { 2,1,10 } },
+ { USMUSERPUBLIC , ASN_OCTET_STR , RWRITE, var_usmUser, 3, { 2,1,11 } },
+ { USMUSERSTORAGETYPE , ASN_INTEGER , RWRITE, var_usmUser, 3, { 2,1,12 } },
+ { USMUSERSTATUS , ASN_INTEGER , RWRITE, var_usmUser, 3, { 2,1,13 } },
+
+};
+
+oid usmUser_variables_oid[] = {1,3,6,1,6,3,15,1,2};
+
+
+/* needed for the write_ functions to find the start of the index */
+#define USM_MIB_LENGTH 12
+
+static unsigned int usmUserSpinLock=0;
+
+void
+init_usmUser(void)
+{
+ snmpd_register_config_handler("usmUser",
+ usm_parse_config_usmUser, NULL, NULL);
+ snmpd_register_config_handler("createUser",
+ usm_parse_create_usmUser, NULL,
+ "username (MD5|SHA) passphrase [DES] [passphrase]");
+
+ /* we need to be called back later */
+ snmp_register_callback(SNMP_CALLBACK_LIBRARY, SNMP_CALLBACK_STORE_DATA,
+ usm_store_users, NULL);
+
+ REGISTER_MIB("snmpv3/usmUser", usmUser_variables, variable4,
+ usmUser_variables_oid);
+
+}
+
+/*******************************************************************-o-******
+ * usm_generate_OID
+ *
+ * Parameters:
+ * *prefix (I) OID prefix to the usmUser table entry.
+ * prefixLen (I)
+ * *uptr (I) Pointer to a user in the user list.
+ * *length (O) Length of generated index OID.
+ *
+ * Returns:
+ * Pointer to the OID index for the user (uptr) -OR-
+ * NULL on failure.
+ *
+ *
+ * Generate the index OID for a given usmUser name. 'length' is set to
+ * the length of the index OID.
+ *
+ * Index OID format is:
+ *
+ * <...prefix>....
+ */
+oid *
+usm_generate_OID(oid *prefix, size_t prefixLen, struct usmUser *uptr,
+ size_t *length)
+{
+ oid *indexOid;
+ int i;
+
+ *length = 2 + uptr->engineIDLen + strlen(uptr->name) + prefixLen;
+ indexOid = (oid *) malloc(*length * sizeof(oid));
+ if (indexOid) {
+ memmove(indexOid, prefix, prefixLen * sizeof (oid));
+
+ indexOid[prefixLen] = uptr->engineIDLen;
+ for(i = 0; i < (int)uptr->engineIDLen; i++)
+ indexOid[prefixLen+1+i] = (oid) uptr->engineID[i];
+
+ indexOid[prefixLen + uptr->engineIDLen + 1] = strlen(uptr->name);
+ for(i = 0; i < (int)strlen(uptr->name); i++)
+ indexOid[prefixLen + uptr->engineIDLen + 2 + i] = (oid) uptr->name[i];
+ }
+ return indexOid;
+
+} /* end usm_generate_OID() */
+
+/* usm_parse_oid(): parses an index to the usmTable to break it down into
+ a engineID component and a name component. The results are stored in:
+
+ **engineID: a newly malloced string.
+ *engineIDLen: The length of the malloced engineID string above.
+ **name: a newly malloced string.
+ *nameLen: The length of the malloced name string above.
+
+ returns 1 if an error is encountered, or 0 if successful.
+*/
+int
+usm_parse_oid(oid *oidIndex, size_t oidLen,
+ unsigned char **engineID, size_t *engineIDLen,
+ unsigned char **name, size_t *nameLen)
+{
+ int nameL;
+ int engineIDL;
+ int i;
+
+ /* first check the validity of the oid */
+ if ((oidLen <= 0) || (!oidIndex)) {
+ DEBUGMSGTL(("usmUser","parse_oid: null oid or zero length oid passed in\n"));
+ return 1;
+ }
+ engineIDL = *oidIndex; /* initial engineID length */
+ if ((int)oidLen < engineIDL + 2) {
+ DEBUGMSGTL(("usmUser","parse_oid: invalid oid length: less than the engineIDLen\n"));
+ return 1;
+ }
+ nameL = oidIndex[engineIDL+1]; /* the initial name length */
+ if ((int)oidLen != engineIDL + nameL + 2) {
+ DEBUGMSGTL(("usmUser","parse_oid: invalid oid length: length is not exact\n"));
+ return 1;
+ }
+
+ /* its valid, malloc the space and store the results */
+ if (engineID == NULL || name == NULL) {
+ DEBUGMSGTL(("usmUser","parse_oid: null storage pointer passed in.\n"));
+ return 1;
+ }
+
+ *engineID = (unsigned char *) malloc(engineIDL);
+ if (*engineID == NULL) {
+ DEBUGMSGTL(("usmUser","parse_oid: malloc of the engineID failed\n"));
+ return 1;
+ }
+ *engineIDLen = engineIDL;
+
+ *name = (unsigned char *) malloc(nameL+1);
+ if (*name == NULL) {
+ DEBUGMSGTL(("usmUser","parse_oid: malloc of the name failed\n"));
+ free(*engineID);
+ return 1;
+ }
+ *nameLen = nameL;
+
+ for(i = 0; i < engineIDL; i++) {
+ if (oidIndex[i+1] > 255) {
+ goto UPO_parse_error;
+ }
+ engineID[0][i] = (unsigned char) oidIndex[i+1];
+ }
+
+ for(i = 0; i < nameL; i++) {
+ if (oidIndex[i+2+engineIDL] > 255) {
+ UPO_parse_error:
+ free(*engineID);
+ free(*name);
+ return 1;
+ }
+ name[0][i] = (unsigned char) oidIndex[i+2+engineIDL];
+ }
+ name[0][nameL] = 0;
+
+ return 0;
+
+} /* end usm_parse_oid() */
+
+/*******************************************************************-o-******
+ * usm_parse_user
+ *
+ * Parameters:
+ * *name Complete OID indexing a given usmUser entry.
+ * name_length
+ *
+ * Returns:
+ * Pointer to a usmUser -OR-
+ * NULL if name does not convert to a usmUser.
+ *
+ * Convert an (full) OID and return a pointer to a matching user in the
+ * user list if one exists.
+ */
+struct usmUser *
+usm_parse_user(oid *name, size_t name_len)
+{
+ struct usmUser *uptr;
+
+ char *newName;
+ u_char *engineID;
+ size_t nameLen, engineIDLen;
+
+ /* get the name and engineID out of the incoming oid */
+ if (usm_parse_oid(&name[USM_MIB_LENGTH], name_len-USM_MIB_LENGTH,
+ &engineID, &engineIDLen, (u_char **)&newName, &nameLen))
+ return NULL;
+
+ /* Now see if a user exists with these index values */
+ uptr = usm_get_user(engineID, engineIDLen, newName);
+ free(engineID);
+ free(newName);
+
+ return uptr;
+
+} /* end usm_parse_user() */
+
+/*******************************************************************-o-******
+ * var_usmUser
+ *
+ * Parameters:
+ * *vp (I) Variable-binding associated with this action.
+ * *name (I/O) Input name requested, output name found.
+ * *length (I/O) Length of input and output oid's.
+ * exact (I) TRUE if an exact match was requested.
+ * *var_len (O) Length of variable or 0 if function returned.
+ * (**write_method) Hook to name a write method (UNUSED).
+ *
+ * Returns:
+ * Pointer to (char *) containing related data of length 'length'
+ * (May be NULL.)
+ *
+ *
+ * Call-back function passed to the agent in order to return information
+ * for the USM MIB tree.
+ *
+ *
+ * If this invocation is not for USMUSERSPINLOCK, lookup user name
+ * in the usmUser list.
+ *
+ * If the name does not match any user and the request
+ * is for an exact match, -or- if the usmUser list is empty, create a
+ * new list entry.
+ *
+ * Finally, service the given USMUSER* var-bind. A NULL user generally
+ * results in a NULL return value.
+ */
+u_char *
+var_usmUser(
+ struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ struct usmUser *uptr=NULL, *nptr, *pptr;
+ int i, rtest, result;
+ oid *indexOid;
+ size_t len;
+
+ /* variables we may use later */
+ static long long_ret;
+ static u_char string[1];
+ static oid objid[2]; /* for .0.0 */
+
+ *write_method = 0; /* assume it isnt writable for the time being */
+ *var_len = sizeof(long_ret); /* assume an integer and change later if not */
+
+ if (vp->magic != USMUSERSPINLOCK) {
+ oid newname[MAX_OID_LEN];
+ len = (*length < vp->namelen) ? *length : vp->namelen;
+ rtest = snmp_oid_compare(name, len, vp->name, len);
+ if (rtest > 0 ||
+/* (rtest == 0 && !exact && (int) vp->namelen+1 < (int) *length) || */
+ (exact == 1 && rtest != 0)) {
+ if (var_len)
+ *var_len = 0;
+ return 0;
+ }
+ memset(newname, 0, sizeof(newname));
+ if (((int) *length) <= (int) vp->namelen || rtest == -1) {
+ /* oid is not within our range yet */
+ /* need to fail if not exact */
+ uptr = usm_get_userList();
+
+ } else {
+ for(nptr = usm_get_userList(), pptr = NULL, uptr = NULL; nptr != NULL;
+ pptr = nptr, nptr = nptr->next) {
+ indexOid = usm_generate_OID(vp->name, vp->namelen, nptr, &len);
+ result = snmp_oid_compare(name, *length, indexOid, len);
+ DEBUGMSGTL(("usmUser", "Checking user: %s - ", nptr->name));
+ for(i = 0; i < (int)nptr->engineIDLen; i++) {
+ DEBUGMSG(("usmUser", " %x",nptr->engineID[i]));
+ }
+ DEBUGMSG(("usmUser"," - %d \n -> OID: ", result));
+ DEBUGMSGOID(("usmUser", indexOid, len));
+ DEBUGMSG(("usmUser","\n"));
+
+ free(indexOid);
+
+ if (exact) {
+ if (result == 0) {
+ uptr = nptr;
+ }
+ } else {
+ if (result == 0) {
+ /* found an exact match. Need the next one for !exact */
+ uptr = nptr->next;
+ } else if (result == 1) {
+ uptr = nptr;
+ }
+ }
+ }
+ } /* endif -- name <= vp->name */
+
+ /* if uptr is NULL and exact we need to continue for creates */
+ if (uptr == NULL && !exact)
+ return(NULL);
+
+ if (uptr) {
+ indexOid = usm_generate_OID(vp->name, vp->namelen, uptr, &len);
+ *length = len;
+ memmove(name, indexOid, len*sizeof(oid));
+ DEBUGMSGTL(("usmUser", "Found user: %s - ", uptr->name));
+ for(i = 0; i < (int)uptr->engineIDLen; i++) {
+ DEBUGMSG(("usmUser", " %x",uptr->engineID[i]));
+ }
+ DEBUGMSG(("usmUser","\n -> OID: "));
+ DEBUGMSGOID(("usmUser", indexOid, len));
+ DEBUGMSG(("usmUser","\n"));
+
+ free(indexOid);
+ }
+ } else {
+ if (header_generic(vp,name,length,exact,var_len,write_method))
+ return 0;
+ } /* endif -- vp->magic != USMUSERSPINLOCK */
+
+ switch(vp->magic) {
+ case USMUSERSPINLOCK:
+ *write_method = write_usmUserSpinLock;
+ long_ret = usmUserSpinLock;
+ return (unsigned char *) &long_ret;
+
+ case USMUSERSECURITYNAME:
+ if (uptr) {
+ *var_len = strlen(uptr->secName);
+ return (unsigned char *) uptr->secName;
+ }
+ return NULL;
+
+ case USMUSERCLONEFROM:
+ *write_method = write_usmUserCloneFrom;
+ if (uptr) {
+ objid[0] = 0; /* "When this object is read, the ZeroDotZero OID */
+ objid[1] = 0; /* is returned." */
+ *var_len = sizeof(oid)*2;
+ return (unsigned char *) objid;
+ }
+ return NULL;
+
+ case USMUSERAUTHPROTOCOL:
+ *write_method = write_usmUserAuthProtocol;
+ if (uptr) {
+ *var_len = uptr->authProtocolLen*sizeof(oid);
+ return (u_char *)uptr->authProtocol;
+ }
+ return NULL;
+
+ case USMUSERAUTHKEYCHANGE:
+ case USMUSEROWNAUTHKEYCHANGE:
+
+ /* we treat these the same, and let the calling module
+ distinguish between them */
+ *write_method = write_usmUserAuthKeyChange;
+ if (uptr) {
+ *string = 0; /* always return a NULL string */
+ *var_len = 0;
+ return string;
+ }
+ return NULL;
+
+ case USMUSERPRIVPROTOCOL:
+ *write_method = write_usmUserPrivProtocol;
+ if (uptr) {
+ *var_len = uptr->privProtocolLen*sizeof(oid);
+ return (u_char *)uptr->privProtocol;
+ }
+ return NULL;
+
+ case USMUSERPRIVKEYCHANGE:
+ case USMUSEROWNPRIVKEYCHANGE:
+ /* we treat these the same, and let the calling module
+ distinguish between them */
+ *write_method = write_usmUserPrivKeyChange;
+ if (uptr) {
+ *string = 0; /* always return a NULL string */
+ *var_len = 0;
+ return string;
+ }
+ return NULL;
+
+ case USMUSERPUBLIC:
+ *write_method = write_usmUserPublic;
+ if (uptr) {
+ if (uptr->userPublicString) {
+ *var_len = strlen((char *)uptr->userPublicString);
+ return uptr->userPublicString;
+ }
+ *string = 0;
+ *var_len = 0; /* return an empty string if the public
+ string hasn't been defined yet */
+ return string;
+ }
+ return NULL;
+
+ case USMUSERSTORAGETYPE:
+ *write_method = write_usmUserStorageType;
+ if (uptr) {
+ long_ret = uptr->userStorageType;
+ return (unsigned char *) &long_ret;
+ }
+ return NULL;
+
+ case USMUSERSTATUS:
+ *write_method = write_usmUserStatus;
+ if (uptr) {
+ long_ret = uptr->userStatus;
+ return (unsigned char *) &long_ret;
+ }
+ return NULL;
+
+ default:
+ DEBUGMSGTL(("snmpd", "unknown sub-id %d in var_usmUser\n", vp->magic));
+ }
+ return 0;
+
+} /* end var_usmUser() */
+
+/* write_usmUserSpinLock(): called when a set is performed on the
+ usmUserSpinLock object */
+int
+write_usmUserSpinLock(
+ int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ /* variables we may use later */
+ static long long_ret;
+
+ if (var_val_type != ASN_INTEGER){
+ DEBUGMSGTL(("usmUser","write to usmUserSpinLock not ASN_INTEGER\n"));
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(long_ret)){
+ DEBUGMSGTL(("usmUser","write to usmUserSpinLock: bad length\n"));
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ long_ret = *((long *) var_val);
+
+ if (long_ret != (long)usmUserSpinLock)
+ return SNMP_ERR_INCONSISTENTVALUE;
+
+ if (action == COMMIT) {
+ if (usmUserSpinLock == 2147483647) {
+ usmUserSpinLock = 0;
+ } else {
+ usmUserSpinLock++;
+ }
+ }
+ return SNMP_ERR_NOERROR;
+} /* end write_usmUserSpinLock() */
+
+/*******************************************************************-o-******
+ * write_usmUserCloneFrom
+ *
+ * Parameters:
+ * action
+ * *var_val
+ * var_val_type
+ * var_val_len
+ * *statP (UNUSED)
+ * *name OID of user to clone from.
+ * name_len
+ *
+ * Returns:
+ * SNMP_ERR_NOERROR On success -OR- If user exists
+ * and has already been cloned.
+ * SNMP_ERR_GENERR Local function call failures.
+ * SNMP_ERR_INCONSISTENTNAME 'name' does not exist in user list
+ * -OR- user to clone from != RS_ACTIVE.
+ * SNMP_ERR_WRONGLENGTH OID length > than local buffer size.
+ * SNMP_ERR_WRONGTYPE ASN_OBJECT_ID is wrong.
+ *
+ *
+ * XXX: should handle action=UNDO's.
+ */
+int
+write_usmUserCloneFrom(
+ int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ /* variables we may use later */
+ static oid objid[USM_LENGTH_OID_MAX], *oidptr;
+ struct usmUser *uptr, *cloneFrom;
+ size_t size;
+
+ if (var_val_type != ASN_OBJECT_ID){
+ DEBUGMSGTL(("usmUser","write to usmUserCloneFrom not ASN_OBJECT_ID\n"));
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(objid)){
+ DEBUGMSGTL(("usmUser","write to usmUserCloneFrom: bad length\n"));
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ if (action == COMMIT){
+ /* parse the clonefrom objid */
+ size = var_val_len/sizeof(oid);
+ memcpy(objid, var_val, var_val_len);
+
+ if ((uptr = usm_parse_user(name, name_len)) == NULL)
+ /* We don't allow creations here */
+ return SNMP_ERR_INCONSISTENTNAME;
+
+ /* have the user already been cloned? If so, second cloning is
+ not allowed, but does not generate an error */
+ if (uptr->cloneFrom)
+ return SNMP_ERR_NOERROR;
+
+ /* does the cloneFrom user exist? */
+ if ((cloneFrom = usm_parse_user(objid, size)) == NULL)
+ /* We don't allow creations here */
+ return SNMP_ERR_INCONSISTENTNAME;
+
+ /* is it active */
+ if (cloneFrom->userStatus != RS_ACTIVE)
+ return SNMP_ERR_INCONSISTENTNAME;
+
+ /* set the cloneFrom OID */
+ if ((oidptr = snmp_duplicate_objid(objid, size/sizeof(oid))) == NULL)
+ return SNMP_ERR_GENERR;
+
+ /* do the actual cloning */
+
+ if (uptr->cloneFrom)
+ free(uptr->cloneFrom);
+ uptr->cloneFrom = oidptr;
+
+ usm_cloneFrom_user(cloneFrom, uptr);
+
+ } /* endif: action == COMMIT */
+
+ return SNMP_ERR_NOERROR;
+
+
+} /* end write_usmUserCloneFrom() */
+
+/*******************************************************************-o-******
+ * write_usmUserAuthProtocol
+ *
+ * Parameters:
+ * action
+ * *var_val OID of auth transform to set.
+ * var_val_type
+ * var_val_len
+ * *statP
+ * *name OID of user upon which to perform set operation.
+ * name_len
+ *
+ * Returns:
+ * SNMP_ERR_NOERROR On success.
+ * SNMP_ERR_GENERR
+ * SNMP_ERR_INCONSISTENTVALUE
+ * SNMP_ERR_NOSUCHNAME
+ * SNMP_ERR_WRONGLENGTH
+ * SNMP_ERR_WRONGTYPE
+ */
+int
+write_usmUserAuthProtocol(
+ int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ /* variables we may use later */
+ static oid objid[USM_LENGTH_OID_MAX];
+ static oid *optr;
+ struct usmUser *uptr;
+ size_t size;
+
+ if (var_val_type != ASN_OBJECT_ID){
+ DEBUGMSGTL(("usmUser","write to usmUserAuthProtocol not ASN_OBJECT_ID\n"));
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(objid)){
+ DEBUGMSGTL(("usmUser","write to usmUserAuthProtocol: bad length\n"));
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ if (action == COMMIT){
+ size = var_val_len/sizeof(oid);
+ memcpy(objid, var_val, var_val_len);
+
+ /* don't allow creations here */
+ if ((uptr = usm_parse_user(name, name_len)) == NULL)
+ return SNMP_ERR_NOSUCHNAME;
+
+ /* check the objid for validity */
+ /* only allow sets to perform a change to usmNoAuthProtocol */
+ if (snmp_oid_compare(objid, size, usmNoAuthProtocol,
+ sizeof(usmNoAuthProtocol)/sizeof(oid)) != 0)
+ return SNMP_ERR_INCONSISTENTVALUE;
+
+ /* if the priv protocol is not usmNoPrivProtocol, we can't change */
+ if (snmp_oid_compare(uptr->privProtocol, uptr->privProtocolLen, usmNoPrivProtocol,
+ sizeof(usmNoPrivProtocol)/sizeof(oid)) != 0)
+ return SNMP_ERR_INCONSISTENTVALUE;
+
+ /* finally, we can do it */
+ optr = uptr->authProtocol;
+ if ((uptr->authProtocol = snmp_duplicate_objid(objid, size))
+ == NULL) {
+ uptr->authProtocol = optr;
+ return SNMP_ERR_GENERR;
+ }
+ free(optr);
+ uptr->authProtocolLen = size;
+ }
+ return SNMP_ERR_NOERROR;
+} /* end write_usmUserAuthProtocol() */
+
+/*******************************************************************-o-******
+ * write_usmUserAuthKeyChange
+ *
+ * Parameters:
+ * action
+ * *var_val Octet string representing new KeyChange value.
+ * var_val_type
+ * var_val_len
+ * *statP (UNUSED)
+ * *name OID of user upon which to perform set operation.
+ * name_len
+ *
+ * Returns:
+ * SNMP_ERR_NOERR Success.
+ * SNMP_ERR_WRONGTYPE
+ * SNMP_ERR_WRONGLENGTH
+ * SNMP_ERR_NOSUCHNAME
+ * SNMP_ERR_GENERR
+ *
+ * Note: This function handles both the usmUserAuthKeyChange and
+ * usmUserOwnAuthKeyChange objects. We are not passed the name
+ * of the user requseting the keychange, so we leave this to the
+ * calling module to verify when and if we should be called. To
+ * change this would require a change in the mib module API to
+ * pass in the securityName requesting the change.
+ *
+ * XXX: should handle action=UNDO's.
+ */
+int
+write_usmUserAuthKeyChange(
+ int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ static unsigned char string[SNMP_MAXBUF_SMALL];
+ struct usmUser *uptr;
+ unsigned char buf[SNMP_MAXBUF_SMALL];
+ size_t buflen = SNMP_MAXBUF_SMALL;
+
+ char fnAuthKey[] = "write_usmUserAuthKeyChange",
+ fnOwnAuthKey[] = "write_usmUserOwnAuthKeyChange",
+ *fname;
+
+ if (name[USM_MIB_LENGTH-1] == 6)
+ fname = fnAuthKey;
+ else
+ fname = fnOwnAuthKey;
+
+ if (var_val_type != ASN_OCTET_STR) {
+ DEBUGMSGTL(("usmUser","write to %s not ASN_OCTET_STR\n", fname));
+ return SNMP_ERR_WRONGTYPE;
+ }
+
+ if (var_val_len > sizeof(string)) {
+ DEBUGMSGTL(("usmUser","write to %s: bad length\n", fname));
+ return SNMP_ERR_WRONGLENGTH;
+ }
+
+ if (action == COMMIT) {
+ /* don't allow creations here */
+ if ((uptr = usm_parse_user(name, name_len)) == NULL) {
+ return SNMP_ERR_NOSUCHNAME;
+ }
+
+ /* Change the key. */
+ DEBUGMSGTL(("usmUser","%s: changing auth key for user %s\n", fname, uptr->secName));
+
+ if (decode_keychange(uptr->authProtocol, uptr->authProtocolLen,
+ uptr->authKey, uptr->authKeyLen,
+ var_val, var_val_len,
+ buf, &buflen) != SNMPERR_SUCCESS) {
+ DEBUGMSGTL(("usmUser","%s: ... failed\n", fname));
+ return SNMP_ERR_GENERR;
+ }
+ DEBUGMSGTL(("usmUser","%s: ... succeeded\n", fname));
+ SNMP_FREE(uptr->authKey);
+ memdup(&uptr->authKey, buf, buflen);
+ uptr->authKeyLen = buflen;
+ }
+
+ return SNMP_ERR_NOERROR;
+} /* end write_usmUserAuthKeyChange() */
+
+int
+write_usmUserPrivProtocol(
+ int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ /* variables we may use later */
+ static oid objid[USM_LENGTH_OID_MAX];
+ static oid *optr;
+ struct usmUser *uptr;
+ size_t size;
+
+ if (var_val_type != ASN_OBJECT_ID){
+ DEBUGMSGTL(("usmUser","write to usmUserPrivProtocol not ASN_OBJECT_ID\n"));
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(objid)){
+ DEBUGMSGTL(("usmUser","write to usmUserPrivProtocol: bad length\n"));
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ if (action == COMMIT){
+ size = var_val_len/sizeof(oid);
+ memcpy(objid, var_val, var_val_len);
+
+ /* don't allow creations here */
+ if ((uptr = usm_parse_user(name, name_len)) == NULL)
+ return SNMP_ERR_NOSUCHNAME;
+
+ /* check the objid for validity */
+ /* only allow sets to perform a change to usmNoPrivProtocol */
+ if (snmp_oid_compare(objid, size, usmNoPrivProtocol,
+ sizeof(usmNoPrivProtocol)/sizeof(oid)) != 0)
+ return SNMP_ERR_INCONSISTENTVALUE;
+
+ /* finally, we can do it */
+ optr = uptr->privProtocol;
+ if ((uptr->privProtocol = snmp_duplicate_objid(objid, size))
+ == NULL) {
+ uptr->privProtocol = optr;
+ return SNMP_ERR_GENERR;
+ }
+ free(optr);
+ uptr->privProtocolLen = size;
+ }
+ return SNMP_ERR_NOERROR;
+} /* end write_usmUserPrivProtocol() */
+
+/*
+ * Note: This function handles both the usmUserPrivKeyChange and
+ * usmUserOwnPrivKeyChange objects. We are not passed the name
+ * of the user requseting the keychange, so we leave this to the
+ * calling module to verify when and if we should be called. To
+ * change this would require a change in the mib module API to
+ * pass in the securityName requesting the change.
+ *
+ */
+int
+write_usmUserPrivKeyChange(
+ int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ static unsigned char string[SNMP_MAXBUF_SMALL];
+ struct usmUser *uptr;
+ unsigned char buf[SNMP_MAXBUF_SMALL];
+ size_t buflen = SNMP_MAXBUF_SMALL;
+
+ char fnPrivKey[] = "write_usmUserPrivKeyChange",
+ fnOwnPrivKey[] = "write_usmUserOwnPrivKeyChange",
+ *fname;
+
+ if (name[USM_MIB_LENGTH-1] == 9)
+ fname = fnPrivKey;
+ else
+ fname = fnOwnPrivKey;
+
+ if (var_val_type != ASN_OCTET_STR) {
+ DEBUGMSGTL(("usmUser","write to %s not ASN_OCTET_STR\n", fname));
+ return SNMP_ERR_WRONGTYPE;
+ }
+
+ if (var_val_len > sizeof(string)) {
+ DEBUGMSGTL(("usmUser","write to %s: bad length\n", fname));
+ return SNMP_ERR_WRONGLENGTH;
+ }
+
+ if (action == COMMIT) {
+ /* don't allow creations here */
+ if ((uptr = usm_parse_user(name, name_len)) == NULL) {
+ return SNMP_ERR_NOSUCHNAME;
+ }
+
+ /* Change the key. */
+ DEBUGMSGTL(("usmUser","%s: changing priv key for user %s\n", fname, uptr->secName));
+
+ if (decode_keychange(uptr->authProtocol, uptr->authProtocolLen,
+ uptr->privKey, uptr->privKeyLen,
+ var_val, var_val_len,
+ buf, &buflen) != SNMPERR_SUCCESS) {
+ DEBUGMSGTL(("usmUser","%s: ... failed\n", fname));
+ return SNMP_ERR_GENERR;
+ }
+ DEBUGMSGTL(("usmUser","%s: ... succeeded\n", fname));
+ SNMP_FREE(uptr->privKey);
+ memdup(&uptr->privKey, buf, buflen);
+ uptr->privKeyLen = buflen;
+ }
+
+ return SNMP_ERR_NOERROR;
+} /* end write_usmUserPrivKeyChange() */
+
+int
+write_usmUserPublic(
+ int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ /* variables we may use later */
+ static unsigned char string[SNMP_MAXBUF];
+
+ struct usmUser *uptr;
+
+ if (var_val_type != ASN_OCTET_STR){
+ DEBUGMSGTL(("usmUser","write to usmUserPublic not ASN_OCTET_STR\n"));
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(string)){
+ DEBUGMSGTL(("usmUser","write to usmUserPublic: bad length\n"));
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ if (action == COMMIT) {
+ /* don't allow creations here */
+ if ((uptr = usm_parse_user(name, name_len)) == NULL) {
+ return SNMP_ERR_NOSUCHNAME;
+ }
+ if (uptr->userPublicString)
+ free(uptr->userPublicString);
+ uptr->userPublicString = (u_char *) malloc(var_val_len+1);
+ if (uptr->userPublicString == NULL) {
+ return SNMP_ERR_GENERR;
+ }
+ memcpy(uptr->userPublicString, var_val, var_val_len);
+ uptr->userPublicString[var_val_len] = 0;
+ DEBUGMSG(("usmUser", "setting public string: %d - %s\n", var_val_len,
+ uptr->userPublicString));
+ }
+ return SNMP_ERR_NOERROR;
+} /* end write_usmUserPublic() */
+
+int
+write_usmUserStorageType(
+ int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ /* variables we may use later */
+ static long long_ret;
+ struct usmUser *uptr;
+
+ if (var_val_type != ASN_INTEGER){
+ DEBUGMSGTL(("usmUser","write to usmUserStorageType not ASN_INTEGER\n"));
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(long_ret)){
+ DEBUGMSGTL(("usmUser","write to usmUserStorageType: bad length\n"));
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ if (action == COMMIT){
+ /* don't allow creations here */
+ if ((uptr = usm_parse_user(name, name_len)) == NULL) {
+ return SNMP_ERR_NOSUCHNAME;
+ }
+ long_ret = *((long *) var_val);
+ if ((long_ret == ST_VOLATILE || long_ret == ST_NONVOLATILE) &&
+ (uptr->userStorageType == ST_VOLATILE ||
+ uptr->userStorageType == ST_NONVOLATILE))
+ uptr->userStorageType = long_ret;
+ else
+ return SNMP_ERR_INCONSISTENTVALUE;
+ }
+ return SNMP_ERR_NOERROR;
+} /* end write_usmUserStorageType() */
+
+/*******************************************************************-o-******
+ * write_usmUserStatus
+ *
+ * Parameters:
+ * action
+ * *var_val
+ * var_val_type
+ * var_val_len
+ * *statP
+ * *name
+ * name_len
+ *
+ * Returns:
+ * SNMP_ERR_NOERROR On success.
+ * SNMP_ERR_GENERR
+ * SNMP_ERR_INCONSISTENTNAME
+ * SNMP_ERR_INCONSISTENTVALUE
+ * SNMP_ERR_WRONGLENGTH
+ * SNMP_ERR_WRONGTYPE
+ */
+int
+write_usmUserStatus(
+ int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ /* variables we may use later */
+ static long long_ret;
+ unsigned char *engineID;
+ size_t engineIDLen;
+ char *newName;
+ size_t nameLen;
+ struct usmUser *uptr;
+
+ if (var_val_type != ASN_INTEGER){
+ DEBUGMSGTL(("usmUser","write to usmUserStatus not ASN_INTEGER\n"));
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(long_ret)){
+ DEBUGMSGTL(("usmUser","write to usmUserStatus: bad length\n"));
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ if (action == COMMIT){
+ long_ret = *((long *) var_val);
+
+ /* ditch illegal values now */
+ /* notReady can not be used, but the return error code is not mentioned */
+ if (long_ret == RS_NOTREADY || long_ret < 1 || long_ret > 6)
+ return SNMP_ERR_INCONSISTENTVALUE;
+
+ /* see if we can parse the oid for engineID/name first */
+ if (usm_parse_oid(&name[USM_MIB_LENGTH], name_len-USM_MIB_LENGTH,
+ &engineID, &engineIDLen, (u_char **)&newName, &nameLen))
+ return SNMP_ERR_INCONSISTENTNAME;
+
+ /* Now see if a user already exists with these index values */
+ uptr = usm_get_user(engineID, engineIDLen, newName);
+
+
+ if (uptr) { /* If so, we set the appropriate value... */
+ free(engineID);
+ free(newName);
+ if (long_ret == RS_CREATEANDGO || long_ret == RS_CREATEANDWAIT) {
+ return SNMP_ERR_INCONSISTENTVALUE;
+ }
+ if (long_ret == RS_DESTROY) {
+ usm_remove_user(uptr);
+ usm_free_user(uptr);
+ } else {
+ uptr->userStatus = long_ret;
+ }
+
+ } else { /* ...else we create a new user */
+ /* check for a valid status column set */
+ if (long_ret == RS_ACTIVE || long_ret == RS_NOTINSERVICE) {
+ free(engineID);
+ free(newName);
+ return SNMP_ERR_INCONSISTENTVALUE;
+ }
+ if (long_ret == RS_DESTROY) {
+ /* destroying a non-existent row is actually legal */
+ free(engineID);
+ free(newName);
+ return SNMP_ERR_NOERROR;
+ }
+
+ /* generate a new user */
+ if ((uptr = usm_create_user()) == NULL) {
+ free(engineID);
+ free(newName);
+ return SNMP_ERR_GENERR;
+ }
+
+ /* copy in the engineID */
+ uptr->engineID =
+ (unsigned char *) malloc(engineIDLen);
+ if (uptr->engineID == NULL) {
+ free(engineID);
+ free(newName);
+ usm_free_user(uptr);
+ return SNMP_ERR_GENERR;
+ }
+ uptr->engineIDLen = engineIDLen;
+ memcpy(uptr->engineID, engineID, engineIDLen);
+ free(engineID);
+
+ /* copy in the name and secname */
+ if ((uptr->name = strdup(newName)) == NULL) {
+ free(newName);
+ usm_free_user(uptr);
+ return SNMP_ERR_GENERR;
+ }
+ free(newName);
+ if ((uptr->secName = strdup(uptr->name)) == NULL) {
+ usm_free_user(uptr);
+ return SNMP_ERR_GENERR;
+ }
+
+ /* set the status of the row based on the request */
+ if (long_ret == RS_CREATEANDGO)
+ uptr->userStatus = RS_ACTIVE;
+ else if (long_ret == RS_CREATEANDWAIT)
+ uptr->userStatus = RS_NOTINSERVICE;
+
+ /* finally, add it to our list of users */
+ usm_add_user(uptr);
+
+ } /* endif -- uptr */
+ } /* endif -- action==COMMIT */
+
+ return SNMP_ERR_NOERROR;
+
+} /* end write_usmUserStatus() */
+
+#endif /* CYGPKG_SNMPAGENT_V3_SUPPORT */
Index: v2_0/src/mibgroup/mibII/vacm_vars.c
===================================================================
--- v2_0/src/mibgroup/mibII/vacm_vars.c (nonexistent)
+++ v2_0/src/mibgroup/mibII/vacm_vars.c (revision 1765)
@@ -0,0 +1,1194 @@
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): Manu Sharma
+// Contributors:
+// Date: 2002-11-01
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * vacm_vars.c
+ *
+ * SNMPv3 View-based Access Control Model
+ */
+/***********************************************************
+ Copyright 1988, 1989 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.
+******************************************************************/
+
+#include
+
+#ifdef CYGPKG_SNMPAGENT_V3_SUPPORT
+#ifdef CYGPKG_SNMPLIB_FILESYSTEM_SUPPORT
+
+#if HAVE_STDLIB_H
+#include
+#endif
+#if HAVE_UNISTD_H
+#include
+#endif
+#if HAVE_STRING_H
+#include
+#else
+#include
+#endif
+#if HAVE_MALLOC_H
+#include
+#endif
+#include
+#include
+#if HAVE_NETINET_IN_H
+#include
+#endif
+#if HAVE_ARPA_INET_H
+#include
+#endif
+
+#if HAVE_DMALLOC_H
+#include
+#endif
+
+#if HAVE_NETDB_H
+#include
+#endif
+#if HAVE_WINSOCK_H
+#include
+#endif
+
+#include "mibincl.h"
+#include "read_config.h"
+#include "agent_read_config.h"
+#include "system.h"
+#include "vacm.h"
+#include "callback.h"
+#include "agent_registry.h"
+#include "agent_callbacks.h"
+#include "vacm_vars.h"
+
+#ifdef USING_MIBII_SYSORTABLE_MODULE
+#if TIME_WITH_SYS_TIME
+# ifdef WIN32
+# include
+# else
+# include
+# endif
+# include
+#else
+# if HAVE_SYS_TIME_H
+# include
+# else
+# include
+# endif
+#endif
+#include
+#endif
+
+void
+init_vacm_vars (void)
+{
+
+#ifdef USING_MIBII_SYSORTABLE_MODULE
+ static oid reg[] = {SNMP_OID_SNMPMODULES,16,2,2,1};
+#endif
+
+#define PRIVRW (SNMPV2ANY | 0x5000)
+
+ struct variable2 vacm_sec2group[] = {
+ {SECURITYGROUP, ASN_OCTET_STR, PRIVRW, var_vacm_sec2group, 1, {3}},
+ {SECURITYSTORAGE, ASN_INTEGER, PRIVRW, var_vacm_sec2group, 1, {4}},
+ {SECURITYSTATUS, ASN_INTEGER, PRIVRW, var_vacm_sec2group, 1, {5}},
+ };
+
+ struct variable2 vacm_access[] = {
+ {ACCESSMATCH, ASN_INTEGER, PRIVRW, var_vacm_access, 1, {4}},
+ {ACCESSREAD, ASN_OCTET_STR, PRIVRW, var_vacm_access, 1, {5}},
+ {ACCESSWRITE, ASN_OCTET_STR, PRIVRW, var_vacm_access, 1, {6}},
+ {ACCESSNOTIFY, ASN_OCTET_STR, PRIVRW, var_vacm_access, 1, {7}},
+ {ACCESSSTORAGE, ASN_INTEGER, PRIVRW, var_vacm_access, 1, {8}},
+ {ACCESSSTATUS, ASN_INTEGER, PRIVRW, var_vacm_access, 1, {9}},
+ };
+
+ struct variable2 vacm_view[] = {
+ {VIEWMASK, ASN_OCTET_STR, PRIVRW, var_vacm_view, 1, {3}},
+ {VIEWTYPE, ASN_INTEGER, PRIVRW, var_vacm_view, 1, {4}},
+ {VIEWSTORAGE, ASN_INTEGER, PRIVRW, var_vacm_view, 1, {5}},
+ {VIEWSTATUS, ASN_INTEGER, PRIVRW, var_vacm_view, 1, {6}},
+ };
+
+/* Define the OID pointer to the top of the mib tree that we're
+ registering underneath */
+ oid vacm_sec2group_oid[] = { OID_VACMGROUPENTRY };
+ oid vacm_access_oid[] = { OID_VACMACCESSENTRY};
+ oid vacm_view_oid[] = { OID_VACMVIEWENTRY };
+
+ /* register ourselves with the agent to handle our mib tree */
+ REGISTER_MIB("mibII/vacm:sec2group", vacm_sec2group, variable2, \
+ vacm_sec2group_oid);
+ REGISTER_MIB("mibII/vacm:access", vacm_access, variable2, vacm_access_oid);
+ REGISTER_MIB("mibII/vacm:view", vacm_view, variable2, vacm_view_oid);
+
+ snmpd_register_config_handler("com2sec", vacm_parse_security,
+ vacm_free_security,"name source community");
+ snmpd_register_config_handler("group", vacm_parse_group, vacm_free_group,
+ "name v1|v2c|usm security");
+ snmpd_register_config_handler("access", vacm_parse_access, vacm_free_access,
+ "name context model level prefx read write notify");
+ snmpd_register_config_handler("view", vacm_parse_view, vacm_free_view,
+ "name type subtree [mask]");
+ snmpd_register_config_handler("rwcommunity", vacm_parse_simple,
+ NULL,"community [default|hostname|network/bits] [oid]");
+ snmpd_register_config_handler("rocommunity", vacm_parse_simple,
+ NULL,"community [default|hostname|network/bits] [oid]");
+ snmpd_register_config_handler("rwuser", vacm_parse_simple,
+ NULL,"user [noauth|auth|priv] [oid]");
+ snmpd_register_config_handler("rouser", vacm_parse_simple,
+ NULL,"user [noauth|auth|priv] [oid]");
+
+#ifdef USING_MIBII_SYSORTABLE_MODULE
+ register_sysORTable(reg,10,"View-based Access Control Model for SNMP.");
+#endif
+
+ /* register ourselves to handle access control */
+ snmp_register_callback(SNMP_CALLBACK_APPLICATION, SNMPD_CALLBACK_ACM_CHECK,
+ vacm_in_view_callback, NULL);
+ snmp_register_callback(SNMP_CALLBACK_APPLICATION,
+ SNMPD_CALLBACK_ACM_CHECK_INITIAL,
+ vacm_in_view_callback, NULL);
+}
+
+static struct vacm_securityEntry *securityFirst =0, *securityLast =0;
+
+#define EXAMPLE_NETWORK "NETWORK"
+#define EXAMPLE_COMMUNITY "COMMUNITY"
+
+void vacm_parse_security (const char *token,
+ char *param)
+{
+ char *name, *source, *community;
+ const char *mask;
+ char *cp;
+ struct vacm_securityEntry *sp, se;
+ int maskLength, maskBit;
+ struct sockaddr_in *srcIp, *srcMask;
+ char null[] = "";
+
+ memset (&se, 0 , sizeof se);
+ name = strtok(param, "\t\n ");
+ if (!name) {
+ config_perror("missing NAME parameter");
+ return;
+ }
+ source = strtok(NULL, "\t\n ");
+ if (!source) {
+ config_perror("missing SOURCE parameter");
+ return;
+ }
+ if ( !strncmp( source, EXAMPLE_NETWORK, strlen(EXAMPLE_NETWORK)) ) {
+ config_perror("Example config NETWORK not properly configured");
+ return; /* or exit(1); */
+ }
+ community = strtok(NULL, "\t\n ");
+ if (!community) {
+ config_perror("missing COMMUNITY parameter");
+ return;
+ }
+ if ( !strncmp( community, EXAMPLE_COMMUNITY, strlen(EXAMPLE_COMMUNITY)) ) {
+ config_perror("Example config COMMUNITY not properly configured");
+ return; /* or exit(1); */
+ }
+ srcIp = (struct sockaddr_in*)&(se.sourceIp);
+ srcMask = (struct sockaddr_in*)&(se.sourceMask);
+ cp = strchr(source, '/');
+ if (cp == NULL) cp = null;
+ else *cp++ = 0;
+ mask = cp;
+ if (strcmp("default", source) == 0 || strcmp("0.0.0.0", source) == 0) {
+ memset(&(srcIp->sin_addr), 0, sizeof(struct in_addr));
+ mask = "0.0.0.0";
+ }
+ else if ((srcIp->sin_addr.s_addr = inet_addr (source)) == (unsigned) -1) {
+ struct hostent *hp = gethostbyname(source);
+ if (hp != NULL) {
+ memcpy(&(srcIp->sin_addr), hp->h_addr, 4);
+ }
+ else {
+ config_perror ("bad source address");
+ return;
+ }
+ }
+ if (*mask == 0) memset (&(srcMask->sin_addr), 0xff, sizeof(struct in_addr));
+ else {
+ if (strchr(mask, '.')) {
+ if ((srcMask->sin_addr.s_addr = inet_addr(mask)) == (unsigned)-1) {
+ config_perror("bad mask");
+ return;
+ }
+ }
+ else {
+ maskLength = atoi(mask);
+ if (maskLength <= 0 || maskLength > 32) {
+ config_perror("bad mask length");
+ return;
+ }
+ maskBit = 0x80000000L;
+ srcMask->sin_addr.s_addr = 0;
+ while (maskLength--) {
+ srcMask->sin_addr.s_addr |= maskBit;
+ maskBit >>= 1;
+ }
+ srcMask->sin_addr.s_addr = htonl(srcMask->sin_addr.s_addr);
+ }
+ }
+ if ((srcIp->sin_addr.s_addr & ~srcMask->sin_addr.s_addr) != 0) {
+ config_perror("source/mask mismatch");
+ return;
+ }
+ if (strlen(name)+1 > sizeof(se.securityName)) {
+ config_perror("security name too long");
+ return;
+ }
+ if (strlen(community)+1 > sizeof(se.community)) {
+ config_perror("community name too long");
+ return;
+ }
+ strcpy(se.securityName, name);
+ strcpy(se.community, community);
+ sp = (struct vacm_securityEntry *)malloc (sizeof *sp);
+ if (sp == NULL) {
+ config_perror("memory error");
+ return;
+ }
+ *sp = se;
+ if (securityFirst != NULL) {
+ securityLast->next = sp;
+ securityLast = sp;
+ }
+ else {
+ securityFirst = securityLast = sp;
+ }
+}
+
+void vacm_free_security (void)
+{
+ struct vacm_securityEntry *sp;
+ while ((sp = securityFirst)) {
+ securityFirst = sp->next;
+ free(sp);
+ }
+}
+
+void vacm_parse_group (const char *token,
+ char *param)
+{
+ char *group, *model, *security;
+ int imodel;
+ struct vacm_groupEntry *gp = NULL;
+
+ group = strtok (param, " \t\n");
+ model = strtok (NULL, " \t\n");
+ security = strtok (NULL, " \t\n");
+
+ if (group == NULL || *group == 0) {
+ config_perror("missing GROUP parameter");
+ return;
+ }
+ if (model == NULL || *model == 0) {
+ config_perror("missing MODEL parameter");
+ return;
+ }
+ if (security == NULL || *security == 0) {
+ config_perror("missing SECURITY parameter");
+ return;
+ }
+ if (strcasecmp(model, "v1") == 0) imodel = SNMP_SEC_MODEL_SNMPv1;
+ else if (strcasecmp(model, "v2c") == 0) imodel = SNMP_SEC_MODEL_SNMPv2c;
+ else if (strcasecmp(model, "usm") == 0) imodel = SNMP_SEC_MODEL_USM;
+ else if (strcasecmp(model, "any") == 0) {
+ config_perror("bad security model \"any\" should be: v1, v2c or usm - installing anyway");
+ imodel = SNMP_SEC_MODEL_ANY;
+ }
+ else {
+ config_perror("bad security model, should be: v1, v2c or usm");
+ return;
+ }
+ if (strlen(security)+1 > sizeof(gp->groupName)) {
+ config_perror("security name too long");
+ return;
+ }
+ gp = vacm_createGroupEntry(imodel, security);
+ if (!gp) {
+ config_perror("failed to create group entry");
+ return;
+ }
+ strcpy (gp->groupName, group);
+ gp->storageType = SNMP_STORAGE_PERMANENT;
+ gp->status = SNMP_ROW_ACTIVE;
+ free (gp->reserved);
+ gp->reserved = NULL;
+}
+
+void vacm_free_group (void)
+{
+ vacm_destroyAllGroupEntries();
+}
+
+void vacm_parse_access (const char *token, char *param)
+{
+ char *name, *context, *model, *level, *prefix, *readView, *writeView, *notify;
+ int imodel, ilevel, iprefix;
+ struct vacm_accessEntry *ap;
+
+ name = strtok(param, " \t\n");
+ if (!name) {
+ config_perror("missing NAME parameter");
+ return;
+ }
+ context = strtok(NULL, " \t\n");
+ if (!context) {
+ config_perror("missing CONTEXT parameter");
+ return;
+ }
+ model = strtok(NULL, " \t\n");
+ if (!model) {
+ config_perror("missing MODEL parameter");
+ return;
+ }
+ level = strtok(NULL, " \t\n");
+ if (!level) {
+ config_perror("missing LEVEL parameter");
+ return;
+ }
+ prefix = strtok(NULL, " \t\n");
+ if (!prefix) {
+ config_perror("missing PREFIX parameter");
+ return;
+ }
+ readView = strtok(NULL, " \t\n");
+ if (!readView) {
+ config_perror("missing readView parameter");
+ return;
+ }
+ writeView = strtok(NULL, " \t\n");
+ if (!writeView) {
+ config_perror("missing writeView parameter");
+ return;
+ }
+ notify = strtok(NULL, " \t\n");
+ if (!notify) {
+ config_perror("missing notifyView parameter");
+ return;
+ }
+ if (strcmp(context, "\"\"") == 0) *context = 0;
+ if (strcasecmp(model, "any") == 0) imodel = SNMP_SEC_MODEL_ANY;
+ else if (strcasecmp(model, "v1") == 0) imodel = SNMP_SEC_MODEL_SNMPv1;
+ else if (strcasecmp(model, "v2c") == 0) imodel = SNMP_SEC_MODEL_SNMPv2c;
+ else if (strcasecmp(model, "usm") == 0) imodel = SNMP_SEC_MODEL_USM;
+ else {
+ config_perror("bad security model (any, v1, v2c, usm)");
+ return;
+ }
+ if (strcasecmp(level, "noauth") == 0) ilevel = SNMP_SEC_LEVEL_NOAUTH;
+ else if (strcasecmp(level, "noauthnopriv") == 0) ilevel = SNMP_SEC_LEVEL_NOAUTH;
+ else if (strcasecmp(level, "auth") == 0) ilevel = SNMP_SEC_LEVEL_AUTHNOPRIV;
+ else if (strcasecmp(level, "authnopriv") == 0) ilevel = SNMP_SEC_LEVEL_AUTHNOPRIV;
+ else if (strcasecmp(level, "priv") == 0) ilevel = SNMP_SEC_LEVEL_AUTHPRIV;
+ else if (strcasecmp(level, "authpriv") == 0) ilevel = SNMP_SEC_LEVEL_AUTHPRIV;
+ else {
+ config_perror("bad security level (noauthnopriv, authnopriv, authpriv)");
+ return;
+ }
+ if (strcmp(prefix,"exact") == 0) iprefix = 1;
+ else if (strcmp(prefix,"prefix") == 0) iprefix = 2;
+ else if (strcmp(prefix,"0") == 0) {
+ config_perror("bad prefix match parameter \"0\", should be: exact or prefix - installing anyway");
+ iprefix = 1;
+ }
+ else {
+ config_perror("bad prefix match parameter, should be: exact or prefix");
+ return;
+ }
+ if (strlen(readView)+1 > sizeof(ap->readView)) {
+ config_perror("readView too long");
+ return;
+ }
+ if (strlen(writeView)+1 > sizeof(ap->writeView)) {
+ config_perror("writeView too long");
+ return;
+ }
+ if (strlen(notify)+1 > sizeof(ap->notifyView)) {
+ config_perror("notifyView too long");
+ return;
+ }
+ ap = vacm_createAccessEntry (name, context, imodel, ilevel);
+ if (!ap) {
+ config_perror("failed to create access entry");
+ return;
+ }
+ strcpy(ap->readView, readView);
+ strcpy(ap->writeView, writeView);
+ strcpy(ap->notifyView, notify);
+ ap->contextMatch = iprefix;
+ ap->storageType = SNMP_STORAGE_PERMANENT;
+ ap->status = SNMP_ROW_ACTIVE;
+ free (ap->reserved);
+ ap->reserved = NULL;
+}
+
+void vacm_free_access (void)
+{
+ vacm_destroyAllAccessEntries();
+}
+
+void vacm_parse_view (const char *token,
+ char *param)
+{
+ char *name, *type, *subtree, *mask;
+ int inclexcl;
+ struct vacm_viewEntry *vp;
+ oid suboid[MAX_OID_LEN];
+ size_t suboid_len = 0;
+ u_char viewMask[sizeof (vp->viewMask)];
+ int i;
+
+ name = strtok (param, " \t\n");
+ if (!name) {
+ config_perror("missing NAME parameter");
+ return;
+ }
+ type = strtok (NULL, " \n\t");
+ if (!type) {
+ config_perror("missing TYPE parameter");
+ return;
+ }
+ subtree = strtok(NULL, " \t\n");
+ if (!subtree) {
+ config_perror("missing SUBTREE parameter");
+ return;
+ }
+ mask = strtok(NULL, " \t\n");
+
+ if (strcmp(type, "included") == 0) inclexcl = SNMP_VIEW_INCLUDED;
+ else if (strcmp(type, "excluded") == 0) inclexcl = SNMP_VIEW_EXCLUDED;
+ else {
+ config_perror("TYPE must be included/excluded?");
+ return;
+ }
+ suboid_len = MAX_OID_LEN;
+ if (!read_objid(subtree, suboid, &suboid_len)) {
+ config_perror("bad SUBTREE object id");
+ return;
+ }
+ if (mask) {
+ int val;
+ i = 0;
+ for (mask = strtok(mask, ".:"); mask; mask = strtok(NULL, ".:")) {
+ if (i >= sizeof(viewMask)) {
+ config_perror("MASK too long");
+ return;
+ }
+ if (sscanf(mask, "%x", &val) == 0) {
+ config_perror("invalid MASK");
+ return;
+ }
+ viewMask[i] = val;
+ i++;
+ }
+ }
+ else {
+ for (i = 0; i < sizeof(viewMask); i++)
+ viewMask[i] = 0xff;
+ }
+ vp = vacm_createViewEntry(name, suboid, suboid_len);
+ if (!vp) {
+ config_perror("failed to create view entry");
+ return;
+ }
+ memcpy(vp->viewMask, viewMask, sizeof(viewMask));
+ vp->viewType = inclexcl;
+ vp->viewStorageType = SNMP_STORAGE_PERMANENT;
+ vp->viewStatus = SNMP_ROW_ACTIVE;
+ free (vp->reserved);
+ vp->reserved = NULL;
+}
+
+void vacm_free_view (void)
+{
+ vacm_destroyAllViewEntries();
+}
+
+void vacm_parse_simple(const char *token, char *confline) {
+ char line[SPRINT_MAX_LEN];
+ char community[COMMUNITY_MAX_LEN];
+ char theoid[SPRINT_MAX_LEN];
+ char viewname[SPRINT_MAX_LEN];
+ char addressname[SPRINT_MAX_LEN];
+ const char *rw = "none";
+ const char *model = "any";
+ char *cp;
+ static int num = 0;
+ char secname[SPRINT_MAX_LEN];
+ char authtype[SPRINT_MAX_LEN];
+
+ /* community name or user name */
+ cp = copy_word(confline, community);
+
+ if (strcmp(token,"rouser") == 0 || strcmp(token,"rwuser") == 0) {
+ /* authentication type */
+ if (cp && *cp)
+ cp = copy_word(cp, authtype);
+ else
+ strcpy(authtype, "auth");
+ DEBUGMSGTL((token, "setting auth type: \"%s\"\n",authtype));
+ model = "usm";
+ } else {
+ /* source address */
+ if (cp && *cp) {
+ cp = copy_word(cp, addressname);
+ } else {
+ strcpy(addressname, "default");
+ }
+ /* authtype has to be noauth */
+ strcpy(authtype, "noauth");
+ }
+
+ /* oid they can touch */
+ if (cp && *cp) {
+ cp = copy_word(cp, theoid);
+ } else {
+ strcpy(theoid, ".1");
+ }
+
+ if (strcmp(token,"rwcommunity") == 0 || strcmp(token,"rwuser") == 0)
+ rw = viewname;
+
+ if (strcmp(token,"rwcommunity") == 0 || strcmp(token,"rocommunity") == 0) {
+ /* com2sec mapping */
+ /* com2sec anonymousSecNameNUM ADDRESS COMMUNITY */
+ sprintf(secname, "anonymousSecName%03d", num);
+ sprintf(line,"%s %s %s", secname, addressname, community);
+ DEBUGMSGTL((token,"passing: %s %s\n", "com2sec", line));
+ vacm_parse_security("com2sec",line);
+
+ /* sec->group mapping */
+ /* group anonymousGroupNameNUM any anonymousSecNameNUM */
+ sprintf(line,"anonymousGroupName%03d v1 %s", num, secname);
+ DEBUGMSGTL((token,"passing: %s %s\n", "group", line));
+ vacm_parse_group("group",line);
+ sprintf(line,"anonymousGroupName%03d v2c %s", num, secname);
+ DEBUGMSGTL((token,"passing: %s %s\n", "group", line));
+ vacm_parse_group("group",line);
+ } else {
+ strcpy(secname, community);
+
+ /* sec->group mapping */
+ /* group anonymousGroupNameNUM any anonymousSecNameNUM */
+ sprintf(line,"anonymousGroupName%03d usm %s", num, secname);
+ DEBUGMSGTL((token,"passing: %s %s\n", "group", line));
+ vacm_parse_group("group",line);
+ }
+
+
+ /* view definition */
+ /* view anonymousViewNUM included OID */
+ sprintf(viewname,"anonymousView%03d",num);
+ sprintf(line,"%s included %s", viewname, theoid);
+ DEBUGMSGTL((token,"passing: %s %s\n", "view", line));
+ vacm_parse_view("view",line);
+
+ /* map everything together */
+ /* access anonymousGroupNameNUM "" MODEL AUTHTYPE exact anonymousViewNUM [none/anonymousViewNUM] [none/anonymousViewNUM] */
+ sprintf(line, "anonymousGroupName%03d \"\" %s %s exact %s %s %s", num,
+ model, authtype, viewname, rw, rw);
+ DEBUGMSGTL((token,"passing: %s %s\n", "access", line));
+ vacm_parse_access("access",line);
+ num++;
+}
+
+int
+vacm_in_view_callback(int majorID, int minorID, void *serverarg,
+ void *clientarg) {
+ struct view_parameters *view_parms = (struct view_parameters *) serverarg;
+ int retval;
+
+ if (view_parms == NULL)
+ return 1;
+ retval = vacm_in_view(view_parms->pdu, view_parms->name,
+ view_parms->namelen);
+ if (retval != 0)
+ view_parms->errorcode = retval;
+ return retval;
+}
+
+
+/*******************************************************************-o-******
+ * vacm_in_view
+ *
+ * Parameters:
+ * *pdu
+ * *name
+ * namelen
+ *
+ * Returns:
+ * 0 On success.
+ * 1 Missing security name.
+ * 2 Missing group
+ * 3 Missing access
+ * 4 Missing view
+ * 5 Not in view
+ *
+ * Debug output listed as follows:
+ *
+ */
+int vacm_in_view (struct snmp_pdu *pdu,
+ oid *name,
+ size_t namelen)
+{
+ struct vacm_securityEntry *sp = securityFirst;
+ struct vacm_accessEntry *ap;
+ struct vacm_groupEntry *gp;
+ struct vacm_viewEntry *vp;
+ struct sockaddr_in *pduIp = (struct sockaddr_in*)&(pdu->address);
+ struct sockaddr_in *srcIp, *srcMask;
+ char *vn;
+ char *sn;
+
+ if (pdu->version == SNMP_VERSION_1 || pdu->version == SNMP_VERSION_2c) {
+ if (snmp_get_do_debugging()) {
+ char *buf;
+ if (pdu->community) {
+ buf = malloc(1+ pdu->community_len);
+ memcpy(buf, pdu->community, pdu->community_len);
+ buf[pdu->community_len] = '\0';
+ } else {
+ DEBUGMSGTL(("mibII/vacm_vars", "NULL community"));
+ buf = strdup("NULL");
+ }
+
+ DEBUGMSGTL(("mibII/vacm_vars", "vacm_in_view: ver=%d, source=%.8x, community=%s\n", pdu->version, pduIp->sin_addr.s_addr, buf));
+ free (buf);
+ }
+
+ /* allow running without snmpd.conf */
+ if (sp == NULL && !vacm_is_configured()) {
+ DEBUGMSGTL(("mibII/vacm_vars", "vacm_in_view: accepted with no com2sec entries\n"));
+ switch (pdu->command) {
+ case SNMP_MSG_GET:
+ case SNMP_MSG_GETNEXT:
+ case SNMP_MSG_GETBULK:
+ return 0;
+ default:
+ return 1;
+ }
+ }
+ while (sp) {
+ srcIp = (struct sockaddr_in *)&(sp->sourceIp);
+ srcMask = (struct sockaddr_in *)&(sp->sourceMask);
+ if ((pduIp->sin_addr.s_addr & srcMask->sin_addr.s_addr)
+ == srcIp->sin_addr.s_addr
+ && strlen(sp->community) == pdu->community_len
+ && !strncmp(sp->community, (char *)pdu->community, pdu->community_len))
+ break;
+ sp = sp->next;
+ }
+ if (sp == NULL) return 1;
+ sn = sp->securityName;
+ } else if (pdu->securityModel == SNMP_SEC_MODEL_USM) {
+ DEBUGMSG (("mibII/vacm_vars",
+ "vacm_in_view: ver=%d, model=%d, secName=%s\n",
+ pdu->version, pdu->securityModel, pdu->securityName));
+ sn = pdu->securityName;
+ } else {
+ sn = NULL;
+ }
+
+ if (sn == NULL) return 1;
+ DEBUGMSGTL(("mibII/vacm_vars", "vacm_in_view: sn=%s", sn));
+
+ gp = vacm_getGroupEntry(pdu->securityModel, sn);
+ if (gp == NULL) { DEBUGMSG(("mibII/vacm_vars", "\n")); return 2; }
+ DEBUGMSG (("mibII/vacm_vars", ", gn=%s", gp->groupName));
+
+ ap = vacm_getAccessEntry(gp->groupName, "", pdu->securityModel,
+ pdu->securityLevel);
+ if (ap == NULL) { DEBUGMSG(("mibII/vacm_vars", "\n")); return 3; }
+
+ if (name == 0) { /* only check the setup of the vacm for the request */
+ DEBUGMSG(("mibII/vacm_vars", ", Done checking setup\n"));
+ return 0;
+ }
+
+ switch (pdu->command) {
+ case SNMP_MSG_GET:
+ case SNMP_MSG_GETNEXT:
+ case SNMP_MSG_GETBULK:
+ vn = ap->readView;
+ break;
+ case SNMP_MSG_SET:
+ vn = ap->writeView;
+ break;
+ case SNMP_MSG_TRAP:
+ case SNMP_MSG_TRAP2:
+ case SNMP_MSG_INFORM:
+ vn = ap->notifyView;
+ break;
+ default:
+ snmp_log(LOG_ERR, "bad msg type in vacm_in_view: %d\n", pdu->command);
+ vn = ap->readView;
+ }
+ DEBUGMSG (("mibII/vacm_vars", ", vn=%s", vn));
+
+ vp = vacm_getViewEntry (vn, name, namelen);
+ if (vp == NULL) { DEBUGMSG(("mibII/vacm_vars", "\n")); return 4; }
+ DEBUGMSG(("mibII/vacm_vars", ", vt=%d\n", vp->viewType));
+ if (vp->viewType == SNMP_VIEW_EXCLUDED) return 5;
+
+ return 0;
+
+} /* end vacm_in_view() */
+
+
+u_char *var_vacm_sec2group(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ struct vacm_groupEntry *gp;
+ oid *groupSubtree;
+ int groupSubtreeLen;
+ int secmodel;
+ char secname[32], *cp;
+
+ write_method = NULL;
+ if (memcmp(name, vp->name, sizeof(oid)*vp->namelen) != 0) {
+ memcpy(name, vp->name, sizeof(oid)*vp->namelen);
+ *length = vp->namelen;
+ }
+ if (exact) {
+ if (*length < 13) return NULL;
+
+ secmodel = name[11];
+ groupSubtree = name+13;
+ groupSubtreeLen = *length - 13;
+ cp = secname;
+ while (groupSubtreeLen-- > 0) {
+ if (*groupSubtree > 255)
+ return 0; /* illegal value */
+ *cp++ = (char) *groupSubtree++;
+ }
+ *cp = 0;
+
+ gp = vacm_getGroupEntry(secmodel, secname);
+ }
+ else {
+ secmodel = *length > 11 ? name[11] : 0;
+ groupSubtree = name+12;
+ groupSubtreeLen = *length - 12;
+ cp = secname;
+ while (groupSubtreeLen-- > 0) {
+ if (*groupSubtree > 255)
+ return 0; /* illegal value */
+ *cp++ = (char) *groupSubtree++;
+ }
+ *cp = 0;
+ vacm_scanGroupInit();
+ while ((gp = vacm_scanGroupNext()) != NULL) {
+ if (gp->securityModel > secmodel ||
+ (gp->securityModel == secmodel && strcmp(gp->securityName, secname) > 0))
+ break;
+ }
+ if (gp) {
+ name[11] = gp->securityModel;
+ *length = 12;
+ cp = gp->securityName;
+ while (*cp) {
+ name[(*length)++] = *cp++;
+ }
+ }
+ }
+
+ if (!gp) return NULL;
+
+ *var_len =sizeof(long_return);
+ switch (vp->magic) {
+ case SECURITYMODEL:
+ long_return = gp->securityModel;
+ return (u_char *)&long_return;
+ case SECURITYNAME:
+ *var_len = gp->securityName[0];
+ return (u_char *)&gp->securityName[1];
+ case SECURITYGROUP:
+ *var_len = strlen(gp->groupName);
+ return (u_char *)gp->groupName;
+ case SECURITYSTORAGE:
+ long_return = gp->storageType;
+ return (u_char *)&long_return;
+ case SECURITYSTATUS:
+ long_return = gp->status;
+ return (u_char *)&long_return;
+ }
+ return NULL;
+}
+
+u_char *var_vacm_access(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ struct vacm_accessEntry *gp;
+ int secmodel;
+ int seclevel;
+ char groupName[32];
+ char contextPrefix[32];
+ oid *op;
+ int len;
+ char *cp;
+ int cmp;
+
+ write_method = NULL;
+ if (memcmp(name, vp->name, sizeof(oid)*vp->namelen) != 0) {
+ memcpy(name, vp->name, sizeof(oid)*vp->namelen);
+ *length = vp->namelen;
+ }
+ if (exact) {
+ if (*length < 15) return NULL;
+
+ op = name+11;
+ len = *op++;
+ cp = groupName;
+ while (len-- > 0) {
+ if (*op > 255)
+ return 0; /* illegal value */
+ *cp++ = (char) *op++;
+ }
+ *cp = 0;
+ len = *op++;
+ cp = contextPrefix;
+ while (len-- > 0) {
+ if (*op > 255)
+ return 0; /* illegal value */
+ *cp++ = (char) *op++;
+ }
+ *cp = 0;
+ secmodel = *op++;
+ seclevel = *op++;
+ if (op != name + *length) {
+ return NULL;
+ }
+
+ gp = vacm_getAccessEntry(groupName, contextPrefix, secmodel, seclevel);
+ }
+ else {
+ secmodel = seclevel = 0;
+ groupName[0] = 0;
+ contextPrefix[0] = 0;
+ op = name+11;
+ if (op >= name + *length) {
+ }
+ else {
+ len = *op;
+ cp = groupName;
+ while (len-- >= 0) {
+ if (*op > 255)
+ return 0; /* illegal value */
+ *cp++ = (char) *op++;
+ }
+ *cp = 0;
+ }
+ if (op >= name + *length) {
+ }
+ else {
+ len = *op;
+ cp = contextPrefix;
+ while (len-- >= 0) {
+ if (*op > 255)
+ return 0; /* illegal value */
+ *cp++ = (char) *op++;
+ }
+ *cp = 0;
+ }
+ if (op >= name + *length) {
+ }
+ else {
+ secmodel = *op++;
+ }
+ if (op >= name + *length) {
+ }
+ else {
+ seclevel = *op++;
+ }
+ vacm_scanAccessInit();
+ while ((gp = vacm_scanAccessNext()) != NULL) {
+ cmp = strcmp(gp->groupName, groupName);
+ if (cmp > 0) break;
+ if (cmp < 0) continue;
+ cmp = strcmp(gp->contextPrefix, contextPrefix);
+ if (cmp > 0) break;
+ if (cmp < 0) continue;
+ if (gp->securityModel > secmodel) break;
+ if (gp->securityModel < secmodel) continue;
+ if (gp->securityLevel > seclevel) break;
+ }
+ if (gp) {
+ *length = 11;
+ cp = gp->groupName;
+ do {
+ name[(*length)++] = *cp++;
+ } while (*cp);
+ cp = gp->contextPrefix;
+ do {
+ name[(*length)++] = *cp++;
+ } while (*cp);
+ name[(*length)++] = gp->securityModel;
+ name[(*length)++] = gp->securityLevel;
+ }
+ }
+
+ if (!gp) return NULL;
+
+ *var_len =sizeof(long_return);
+ switch (vp->magic) {
+ case ACCESSMATCH:
+ long_return = gp->contextMatch;
+ return (u_char *)&long_return;
+ case ACCESSLEVEL:
+ long_return = gp->securityLevel;
+ return (u_char *)&long_return;
+ case ACCESSMODEL:
+ long_return = gp->securityModel;
+ return (u_char *)&long_return;
+ case ACCESSPREFIX:
+ *var_len = *gp->contextPrefix;
+ return (u_char *)&gp->contextPrefix[1];
+ case ACCESSREAD:
+ *var_len = strlen(gp->readView);
+ return (u_char *)gp->readView;
+ case ACCESSWRITE:
+ *var_len = strlen(gp->writeView);
+ return (u_char *)gp->writeView;
+ case ACCESSNOTIFY:
+ *var_len = strlen(gp->notifyView);
+ return (u_char *)gp->notifyView;
+ case ACCESSSTORAGE:
+ long_return = gp->storageType;
+ return (u_char *)&long_return;
+ case ACCESSSTATUS:
+ long_return = gp->status;
+ return (u_char *)&long_return;
+ }
+ return NULL;
+}
+
+u_char *var_vacm_view(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ struct vacm_viewEntry *gp;
+ char viewName[32];
+ oid subtree[MAX_OID_LEN];
+ size_t subtreeLen = 0;
+ oid *op, *op1;
+ int len;
+ char *cp;
+ int cmp;
+
+ write_method = NULL;
+ if (memcmp(name, vp->name, sizeof(oid)*vp->namelen) != 0) {
+ memcpy(name, vp->name, sizeof(oid)*vp->namelen);
+ *length = vp->namelen;
+ }
+ if (exact) {
+ if (*length < 15) return NULL;
+
+ op = name+12;
+ len = *op++;
+ cp = viewName;
+ while (len-- > 0) {
+ if (*op > 255)
+ return 0; /* illegal value */
+ *cp++ = (char) *op++;
+ }
+ *cp = 0;
+ len = *length - (op - name);
+ op1 = subtree;
+ while (len-- > 0) {
+ *op1++ = *op++;
+ subtreeLen++;
+ }
+ if (op != name + *length) {
+ return NULL;
+ }
+
+ gp = vacm_getViewEntry(viewName, subtree, subtreeLen);
+ }
+ else {
+ viewName[0] = 0;
+ op = name+12;
+ if (op >= name + *length) {
+ }
+ else {
+ len = *op;
+ cp = viewName;
+ while (len-- >= 0) {
+ if (*op > 255)
+ return 0; /* illegal value */
+ *cp++ = (char) *op++;
+ }
+ *cp = 0;
+ }
+ if (op >= name + *length) {
+ }
+ else {
+ len = *length - (op - name);
+ op1 = subtree;
+ while (len-- >= 0) {
+ *op1++ = *op++;
+ subtreeLen++;
+ }
+ }
+ vacm_scanViewInit();
+ while ((gp = vacm_scanViewNext()) != NULL) {
+ cmp = strcmp(gp->viewName, viewName);
+ if (cmp > 0) break;
+ if (cmp < 0) continue;
+ }
+ if (gp) {
+ *length = 12;
+ cp = gp->viewName;
+ do {
+ name[(*length)++] = *cp++;
+ } while (*cp);
+ op1 = gp->viewSubtree;
+ len = gp->viewSubtreeLen;
+ do {
+ name[(*length)++] = *op1++;
+ } while (len-- > 0);
+ }
+ }
+
+ if (!gp) return NULL;
+
+ *var_len =sizeof(long_return);
+ switch (vp->magic) {
+ case VIEWNAME:
+ *var_len = gp->viewName[0];
+ return (u_char *)&gp->viewName[1];
+ case VIEWSUBTREE:
+ *var_len = gp->viewSubtreeLen*sizeof(oid);
+ return (u_char *)gp->viewSubtree;
+ case VIEWMASK:
+ *var_len = (gp->viewSubtreeLen + 7) / 8;
+ return (u_char *)gp->viewMask;
+ case VIEWTYPE:
+ long_return = gp->viewType;
+ return (u_char *)&long_return;
+ case VIEWSTORAGE:
+ long_return = gp->viewStorageType;
+ return (u_char *)&long_return;
+ case VIEWSTATUS:
+ long_return = gp->viewStatus;
+ return (u_char *)&long_return;
+ }
+ return NULL;
+}
+
+#endif /* CYGPKG_SNMPLIB_FILESYSTEM_SUPPORT */
+#endif /* CYGPKG_SNMPAGENT_V3_SUPPORT */
Index: v2_0/src/mibgroup/mibII/helpers.c
===================================================================
--- v2_0/src/mibgroup/mibII/helpers.c (nonexistent)
+++ v2_0/src/mibgroup/mibII/helpers.c (revision 1765)
@@ -0,0 +1,116 @@
+//=============================================================================
+//
+// sntp.c
+//
+// Helper functions to access the interface information
+//
+//=============================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 2003 Andrew Lunn
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//=============================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): andrew.lunn
+// Contributors:
+// Date: 2003-02-22
+// Description: Provides helper functions to access the network interface
+// information.
+//####DESCRIPTIONEND####
+//
+//=============================================================================
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+
+/* How many interfaces are there? */
+
+#ifdef CYGPKG_NET_FREEBSD_STACK
+struct ifaddr **ifnet_addrs;
+
+long cyg_snmp_num_interfaces(void) {
+ long long_ret=0;
+ int cnt = if_index;
+
+ while (cnt > 0) {
+ if (ifnet_addrs[cnt] != 0) {
+ long_ret++;
+ }
+ cnt--;
+ }
+ return long_ret;
+}
+
+struct ifnet *cyg_snmp_get_if(int if_num) {
+ int index = 0;
+ struct ifnet *ifp;
+ do {
+ while(0 == ifnet_addrs[index])
+ index++;
+
+ ifp = ifnet_addrs[index]->ifa_ifp;
+ if_num--;
+ } while (if_num);
+
+ return ifp;
+}
+#endif
+
+#ifdef CYGPKG_NET_OPENBSD_STACK
+long cyg_snmp_num_interfaces(void) {
+ register struct ifnet *ifp;
+ long long_ret = 0;
+
+ for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next)
+ long_ret++;
+
+ return long_ret;
+}
+
+struct ifnet *cyg_snmp_get_if(int if_num) {
+ struct ifnet *ifp;
+
+ for ( ifp = ifnet.tqh_first;
+ if_num > 1 && ifp != 0;
+ if_num-- )
+ ifp = ifp->if_list.tqe_next;
+
+ return ifp;
+}
+#endif
+
+
Index: v2_0/src/mibgroup/mibII/interfaces.c
===================================================================
--- v2_0/src/mibgroup/mibII/interfaces.c (nonexistent)
+++ v2_0/src/mibgroup/mibII/interfaces.c (revision 1765)
@@ -0,0 +1,545 @@
+//==========================================================================
+//
+// snmp/snmpagent/current/src/mibgroup/mibII/interfaces.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt, Andrew Lunn
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* This file was generated by mib2c and is intended for use as a mib module
+ for the ucd-snmp snmpd agent. */
+
+#include
+
+#include
+#include
+#include
+#include
+#ifdef CYGPKG_NET_FREEBSD_STACK
+#include
+#endif
+#include
+#include
+#include
+// These two to acquire all the statistics.
+
+#include
+#include
+
+/* This should always be included first before anything else */
+#include
+
+
+/* minimal include directives */
+#include "mibincl.h"
+#include "mibgroup/util_funcs.h"
+#include "mibgroup/mibII/interfaces.h"
+#include "mibgroup/mibII/ifr_helper.h"
+#include
+
+/*
+ * interfaces_variables_oid:
+ * this is the top level oid that we want to register under. This
+ * is essentially a prefix, with the suffix appearing in the
+ * variable below.
+ */
+oid interfaces_variables_oid[] = { 1,3,6,1,2,1,2 };
+
+
+/*
+ * variable4 interfaces_variables:
+ * this variable defines function callbacks and type return information
+ * for the interfaces mib section
+ */
+
+
+struct variable4 interfaces_variables[] = {
+/* magic number , variable type , ro/rw , callback fn , L, oidsuffix */
+#define IFNUMBER 1
+ { IFNUMBER , ASN_INTEGER , RONLY , var_interfaces, 1, { 1 } },
+#define IFINDEX 4
+ { IFINDEX , ASN_INTEGER , RONLY , var_ifTable, 3, { 2,1,1 } },
+#define IFDESCR 5
+ { IFDESCR , ASN_OCTET_STR , RONLY , var_ifTable, 3, { 2,1,2 } },
+#define IFTYPE 6
+ { IFTYPE , ASN_INTEGER , RONLY , var_ifTable, 3, { 2,1,3 } },
+#define IFMTU 7
+ { IFMTU , ASN_INTEGER , RONLY , var_ifTable, 3, { 2,1,4 } },
+#define IFSPEED 8
+ { IFSPEED , ASN_GAUGE , RONLY , var_ifTable, 3, { 2,1,5 } },
+#define IFPHYSADDRESS 9
+ { IFPHYSADDRESS , ASN_OCTET_STR , RONLY , var_ifTable, 3, { 2,1,6 } },
+#define IFADMINSTATUS 10
+ { IFADMINSTATUS , ASN_INTEGER , RWRITE, var_ifTable, 3, { 2,1,7 } },
+#define IFOPERSTATUS 11
+ { IFOPERSTATUS , ASN_INTEGER , RONLY , var_ifTable, 3, { 2,1,8 } },
+#define IFLASTCHANGE 12
+ { IFLASTCHANGE , ASN_TIMETICKS , RONLY , var_ifTable, 3, { 2,1,9 } },
+#define IFINOCTETS 13
+ { IFINOCTETS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,10 } },
+#define IFINUCASTPKTS 14
+ { IFINUCASTPKTS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,11 } },
+#define IFINNUCASTPKTS 15
+ { IFINNUCASTPKTS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,12 } },
+#define IFINDISCARDS 16
+ { IFINDISCARDS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,13 } },
+#define IFINERRORS 17
+ { IFINERRORS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,14 } },
+#define IFINUNKNOWNPROTOS 18
+ { IFINUNKNOWNPROTOS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,15 } },
+#define IFOUTOCTETS 19
+ { IFOUTOCTETS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,16 } },
+#define IFOUTUCASTPKTS 20
+ { IFOUTUCASTPKTS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,17 } },
+#define IFOUTNUCASTPKTS 21
+ { IFOUTNUCASTPKTS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,18 } },
+#define IFOUTDISCARDS 22
+ { IFOUTDISCARDS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,19 } },
+#define IFOUTERRORS 23
+ { IFOUTERRORS , ASN_COUNTER , RONLY , var_ifTable, 3, { 2,1,20 } },
+#define IFOUTQLEN 24
+ { IFOUTQLEN , ASN_GAUGE , RONLY , var_ifTable, 3, { 2,1,21 } },
+#define IFSPECIFIC 25
+ { IFSPECIFIC , ASN_OBJECT_ID , RONLY , var_ifTable, 3, { 2,1,22 } },
+
+};
+/* (L = length of the oidsuffix) */
+
+
+/*
+ * init_interfaces():
+ * Initialization routine. This is called when the agent starts up.
+ * At a minimum, registration of your variables should take place here.
+ */
+void init_interfaces(void) {
+
+
+ /* register ourselves with the agent to handle our mib tree */
+ REGISTER_MIB("interfaces", interfaces_variables, variable4,
+ interfaces_variables_oid);
+
+
+ /* place any other initialization junk you need here */
+}
+
+/*
+ * var_interfaces():
+ * This function is called every time the agent gets a request for
+ * a scalar variable that might be found within your mib section
+ * registered above. It is up to you to do the right thing and
+ * return the correct value.
+ * You should also correct the value of "var_len" if necessary.
+ *
+ * Please see the documentation for more information about writing
+ * module extensions, and check out the examples in the examples
+ * and mibII directories.
+ */
+unsigned char *
+var_interfaces(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+
+
+ static long long_ret;
+
+ if ( MATCH_FAILED ==
+ header_generic(vp,name,length,exact,var_len,write_method) )
+ return NULL;
+
+ /*
+ * this is where we do the value assignments for the mib results.
+ */
+ switch(vp->magic) {
+ case IFNUMBER: {
+ long_ret = cyg_snmp_num_interfaces();
+ return (unsigned char *) &long_ret;
+ }
+ default:
+ ERROR_MSG("");
+ }
+ return NULL;
+}
+
+
+/*
+ * var_ifTable():
+ * Handle this table separately from the scalar value case.
+ * The workings of this are basically the same as for var_interfaces above.
+ */
+unsigned char *
+var_ifTable(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+
+
+ /* variables we may use later */
+ static long long_ret;
+ static unsigned char string[SPRINT_MAX_LEN];
+ static oid objid[MAX_OID_LEN];
+ struct ifnet *ifp;
+ int if_num;
+
+ int interface_count = cyg_snmp_num_interfaces();
+
+ /*
+ * This assumes that the table is a 'simple' table.
+ * See the implementation documentation for the meaning of this.
+ * You will need to provide the correct value for the TABLE_SIZE parameter
+ *
+ * If this table does not meet the requirements for a simple table,
+ * you will need to provide the replacement code yourself.
+ * Mib2c is not smart enough to write this for you.
+ * Again, see the implementation documentation for what is required.
+ */
+ if ( header_simple_table( vp,name,length,exact,var_len,write_method,
+ interface_count)
+ == MATCH_FAILED )
+ return NULL;
+
+ if_num = name[ (*length)-1 ];
+
+ ifp = cyg_snmp_get_if(if_num);
+ if (!ifp)
+ return NULL;
+
+// This is to assist customers with their own special interfaces; if they
+// define IFT_CUSTOMER_SPECIAL to whatever their own device is, then its
+// ioctl() will be called to handle these enquiries.
+#ifdef IFT_CUSTOMER_SPECIAL
+ if ( (ifp->if_type == IFT_CUSTOMER_SPECIAL) && (NULL != ifp->if_ioctl) )
+ {
+ if( (vp->magic == IFDESCR) || (vp->magic == IFPHYSADDRESS) )
+ {
+ (*ifp->if_ioctl)(ifp, vp->magic, (caddr_t)string);
+ *var_len = strlen(string);
+ return (unsigned char *) string;
+ }
+ else
+ {
+ (*ifp->if_ioctl)(ifp, vp->magic, (caddr_t)&long_ret);
+ return (unsigned char *) &long_ret;
+ }
+ }
+#endif // IFT_CUSTOMER_SPECIAL
+
+ if ( IFT_ETHER == ifp->if_type &&
+ ((IFDESCR == vp->magic) ||
+ (IFSPEED == vp->magic) ||
+ (IFOUTDISCARDS == vp->magic) ||
+ (IFOUTQLEN == vp->magic) )
+ ) {
+ // then acquire up to date information and deal with the relevent
+ // keys (only):
+ int i = -1;
+ struct ether_drv_stats x;
+ bzero( &x, sizeof( x ) );
+
+ // Call the ioctl to get all the info.
+ // (We KNOW it's an ether dev here, it should have an ioctl())
+ if ( NULL != ifp->if_ioctl )
+ i = (*ifp->if_ioctl)(ifp, SIOCGIFSTATSUD, (caddr_t)&x);
+
+ switch(vp->magic) {
+ case IFDESCR:
+ if ( i || 0 == x.description[0] )
+ strcpy( string, "" );
+ else
+ strcpy( string, x.description );
+ *var_len = strlen(string);
+ return (unsigned char *) string;
+
+ case IFSPEED:
+ long_ret = x.speed;
+ return (unsigned char *) &long_ret;
+
+ case IFOUTDISCARDS:
+ long_ret = x.tx_dropped;
+ return (unsigned char *) &long_ret;
+
+ case IFOUTQLEN:
+ long_ret = x.tx_queue_len;
+ return (unsigned char *) &long_ret;
+
+ default:
+ CYG_FAIL( "Bad magic; shouldn't be in here" );
+ break;
+ }
+ }
+
+ switch(vp->magic) {
+
+ case IFINDEX:
+ long_ret = name[(*length)-1];
+ return (unsigned char *) &long_ret;
+
+ case IFDESCR:
+ switch ( ifp->if_type ) {
+ case IFT_LOOP:
+ strcpy( string, "(Loopback device)" );
+ break;
+ case IFT_PROPVIRTUAL:
+ strcpy( string, "(Proprietary Virtual/Internal)" );
+ break;
+ default:
+ strcpy( string, "Some shy network adaptor" );
+ break;
+ }
+ *var_len = strlen(string);
+ return (unsigned char *) string;
+
+ case IFTYPE:
+ long_ret = ifp->if_type;
+ return (unsigned char *) &long_ret;
+
+ case IFMTU:
+ long_ret = ifp->if_mtu;
+ return (unsigned char *) &long_ret;
+
+ case IFSPEED:
+ if ( IFT_LOOP == ifp->if_type )
+ long_ret = 0;
+ else
+ long_ret = ifp->if_baudrate;
+ return (unsigned char *) &long_ret;
+
+ case IFPHYSADDRESS: {
+ if ( IFT_ETHER == ifp->if_type ) {
+ struct arpcom *ac = (struct arpcom *)ifp;
+ bcopy(&ac->ac_enaddr, string, ETHER_ADDR_LEN);
+ }
+ else {
+ bzero( string, ETHER_ADDR_LEN );
+ }
+ *var_len = ETHER_ADDR_LEN;
+ return (unsigned char *) string;
+ }
+ case IFADMINSTATUS:
+ //NOTSUPPORTED: *write_method = write_ifAdminStatus;
+ long_ret = (ifp->if_flags & IFF_RUNNING) ? 1 : 2;
+ return (unsigned char *) &long_ret;
+
+ case IFOPERSTATUS:
+ long_ret = (ifp->if_flags & IFF_UP) ? 1 : 2;
+ return (unsigned char *) &long_ret;
+
+ case IFLASTCHANGE:
+ long_ret = 0; //FIXME: ifp->if_lastchange;
+ return (unsigned char *) &long_ret;
+
+ case IFINOCTETS:
+ long_ret = ifp->if_ibytes;
+ return (unsigned char *) &long_ret;
+
+ case IFINUCASTPKTS:
+ long_ret = ifp->if_ipackets - ifp->if_imcasts;
+ return (unsigned char *) &long_ret;
+
+ case IFINNUCASTPKTS:
+ long_ret = ifp->if_imcasts;
+ return (unsigned char *) &long_ret;
+
+ case IFINDISCARDS:
+ long_ret = ifp->if_iqdrops;
+ return (unsigned char *) &long_ret;
+
+ case IFINERRORS:
+ long_ret = ifp->if_ierrors;
+ return (unsigned char *) &long_ret;
+
+ case IFINUNKNOWNPROTOS:
+ long_ret = ifp->if_noproto;
+ return (unsigned char *) &long_ret;
+
+ case IFOUTOCTETS:
+ long_ret = ifp->if_obytes;
+ return (unsigned char *) &long_ret;
+
+ case IFOUTUCASTPKTS:
+ long_ret = ifp->if_opackets - ifp->if_omcasts;
+ return (unsigned char *) &long_ret;
+
+ case IFOUTNUCASTPKTS:
+ long_ret = ifp->if_omcasts;
+ return (unsigned char *) &long_ret;
+
+ case IFOUTDISCARDS:
+ long_ret = 0; // ETHER case dealt with above
+ return (unsigned char *) &long_ret;
+
+ case IFOUTERRORS:
+ long_ret = ifp->if_oerrors;
+ return (unsigned char *) &long_ret;
+
+ case IFOUTQLEN:
+ long_ret = 0; // ETHER case dealt with above
+ return (unsigned char *) &long_ret;
+
+ case IFSPECIFIC:
+ objid[0] = 0;
+ objid[1] = 0;
+ *var_len = 2*sizeof(oid);
+ return (unsigned char *) objid;
+
+ default:
+ ERROR_MSG("");
+ }
+ return NULL;
+}
+
+
+
+//NOTSUPPORTED:
+#if 0
+int
+write_ifAdminStatus(int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ static long *long_ret;
+ int size;
+
+
+ switch ( action ) {
+ case RESERVE1:
+ if (var_val_type != ASN_INTEGER){
+ fprintf(stderr, "write to ifAdminStatus not ASN_INTEGER\n");
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(long_ret)){
+ fprintf(stderr,"write to ifAdminStatus: bad length\n");
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ break;
+
+
+ case RESERVE2:
+ size = var_val_len;
+ long_ret = (long *) var_val;
+
+
+ break;
+
+
+ case FREE:
+ /* Release any resources that have been allocated */
+ break;
+
+
+ case ACTION:
+ /* The variable has been stored in long_ret for you to use,
+ and you have just been asked to do something with it. Note
+ that anything done here must be reversable in the UNDO case */
+ break;
+
+
+ case UNDO:
+ /* Back out any changes made in the ACTION case */
+ break;
+
+
+ case COMMIT:
+ /* Things are working well, so it's now safe to make the change
+ permanently. Make sure that anything done here can't fail! */
+ break;
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+#endif
+
+// EOF interfaces.c
Index: v2_0/src/mibgroup/mibII/snmp_mib.c
===================================================================
--- v2_0/src/mibgroup/mibII/snmp_mib.c (nonexistent)
+++ v2_0/src/mibgroup/mibII/snmp_mib.c (revision 1765)
@@ -0,0 +1,302 @@
+//==========================================================================
+//
+// ./agent/current/src/mibgroup/mibII/snmp_mib.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * SNMPv1 MIB group implementation - snmp.c
+ *
+ */
+
+#include
+#include
+#if HAVE_STRING_H
+#include
+#else
+#include
+#endif
+#if HAVE_NETINET_IN_H
+#include
+#endif
+
+#if HAVE_WINSOCK_H
+#include
+#endif
+
+#include "mibincl.h"
+#include "system.h"
+#include "mibgroup/util_funcs.h"
+
+#include "mibgroup/mibII/snmp_mib.h"
+#include "mibgroup/mibII/sysORTable.h"
+
+
+ /*********************
+ *
+ * Kernel & interface information,
+ * and internal forward declarations
+ *
+ *********************/
+
+extern int snmp_enableauthentraps;
+ int old_snmp_enableauthentraps;
+
+/*********************
+ *
+ * Initialisation & common implementation functions
+ *
+ *********************/
+
+/* define the structure we're going to ask the agent to register our
+ information at */
+struct variable2 snmp_variables[] = {
+ {SNMPINPKTS, ASN_COUNTER, RONLY, var_snmp, 1, {1}},
+ {SNMPOUTPKTS, ASN_COUNTER, RONLY, var_snmp, 1, {2}},
+ {SNMPINBADVERSIONS, ASN_COUNTER, RONLY, var_snmp, 1, {3}},
+ {SNMPINBADCOMMUNITYNAMES, ASN_COUNTER, RONLY, var_snmp, 1, {4}},
+ {SNMPINBADCOMMUNITYUSES, ASN_COUNTER, RONLY, var_snmp, 1, {5}},
+ {SNMPINASNPARSEERRORS, ASN_COUNTER, RONLY, var_snmp, 1, {6}},
+ {SNMPINTOOBIGS, ASN_COUNTER, RONLY, var_snmp, 1, {8}},
+ {SNMPINNOSUCHNAMES, ASN_COUNTER, RONLY, var_snmp, 1, {9}},
+ {SNMPINBADVALUES, ASN_COUNTER, RONLY, var_snmp, 1, {10}},
+ {SNMPINREADONLYS, ASN_COUNTER, RONLY, var_snmp, 1, {11}},
+ {SNMPINGENERRS, ASN_COUNTER, RONLY, var_snmp, 1, {12}},
+ {SNMPINTOTALREQVARS, ASN_COUNTER, RONLY, var_snmp, 1, {13}},
+ {SNMPINTOTALSETVARS, ASN_COUNTER, RONLY, var_snmp, 1, {14}},
+ {SNMPINGETREQUESTS, ASN_COUNTER, RONLY, var_snmp, 1, {15}},
+ {SNMPINGETNEXTS, ASN_COUNTER, RONLY, var_snmp, 1, {16}},
+ {SNMPINSETREQUESTS, ASN_COUNTER, RONLY, var_snmp, 1, {17}},
+ {SNMPINGETRESPONSES, ASN_COUNTER, RONLY, var_snmp, 1, {18}},
+ {SNMPINTRAPS, ASN_COUNTER, RONLY, var_snmp, 1, {19}},
+ {SNMPOUTTOOBIGS, ASN_COUNTER, RONLY, var_snmp, 1, {20}},
+ {SNMPOUTNOSUCHNAMES, ASN_COUNTER, RONLY, var_snmp, 1, {21}},
+ {SNMPOUTBADVALUES, ASN_COUNTER, RONLY, var_snmp, 1, {22}},
+ {SNMPOUTGENERRS, ASN_COUNTER, RONLY, var_snmp, 1, {24}},
+ {SNMPOUTGETREQUESTS, ASN_COUNTER, RONLY, var_snmp, 1, {25}},
+ {SNMPOUTGETNEXTS, ASN_COUNTER, RONLY, var_snmp, 1, {26}},
+ {SNMPOUTSETREQUESTS, ASN_COUNTER, RONLY, var_snmp, 1, {27}},
+ {SNMPOUTGETRESPONSES, ASN_COUNTER, RONLY, var_snmp, 1, {28}},
+ {SNMPOUTTRAPS, ASN_COUNTER, RONLY, var_snmp, 1, {29}},
+ {SNMPENABLEAUTHENTRAPS, ASN_INTEGER, RWRITE, var_snmp, 1, {30}},
+ {SNMPSILENTDROPS, ASN_COUNTER, RONLY, var_snmp, 1, {31}},
+ {SNMPPROXYDROPS, ASN_COUNTER, RONLY, var_snmp, 1, {32}}
+};
+
+/* Define the OID pointer to the top of the mib tree that we're
+ registering underneath */
+oid snmp_variables_oid[] = { SNMP_OID_MIB2,11 };
+#ifdef USING_MIBII_SYSTEM_MIB_MODULE
+extern oid system_module_oid[];
+extern int system_module_oid_len;
+extern int system_module_count;
+#endif
+
+void
+init_snmp_mib(void) {
+ /* register ourselves with the agent to handle our mib tree */
+ REGISTER_MIB("mibII/snmp", snmp_variables, variable2, snmp_variables_oid);
+
+#ifdef USING_MIBII_SYSTEM_MIB_MODULE
+ if ( ++system_module_count == 3 )
+ REGISTER_SYSOR_TABLE( system_module_oid, system_module_oid_len,
+ "The MIB module for SNMPv2 entities");
+#endif
+}
+
+/*
+ header_snmp(...
+ Arguments:
+ vp IN - pointer to variable entry that points here
+ name IN/OUT - IN/name requested, OUT/name found
+ length IN/OUT - length of IN/OUT oid's
+ exact IN - TRUE if an exact match was requested
+ var_len OUT - length of variable or 0 if function returned
+ write_method
+
+*/
+
+ /*********************
+ *
+ * System specific implementation functions
+ * (actually common!)
+ *
+ *********************/
+
+
+u_char *
+var_snmp(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ static long long_ret;
+
+ *write_method = 0; /* assume it isnt writable for the time being */
+ *var_len = sizeof(long_ret); /* assume an integer and change later if not */
+
+ if (header_generic(vp, name, length, exact, var_len, write_method)
+ == MATCH_FAILED)
+ return NULL;
+
+ /* this is where we do the value assignments for the mib results. */
+ if (vp->magic == SNMPENABLEAUTHENTRAPS) {
+ *write_method = write_snmp;
+ long_return = snmp_enableauthentraps;
+ return (u_char *) &long_return;
+ } else if ( (vp->magic >= 1)
+ && (vp->magic <= (STAT_SNMP_STATS_END - STAT_SNMP_STATS_START + 1)) ) {
+ long_ret = snmp_get_statistic(vp->magic + STAT_SNMP_STATS_START - 1);
+ return (unsigned char *) &long_ret;
+ }
+ return NULL;
+}
+
+/*
+ * only for snmpEnableAuthenTraps:
+ */
+
+int
+write_snmp (int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ long intval = *((long *) var_val);
+
+ switch ( action ) {
+ case RESERVE1: /* Check values for acceptability */
+ if (var_val_type != ASN_INTEGER){
+ DEBUGMSGTL(("mibII/snmp_mib", "%x not integer type", var_val_type));
+ return SNMP_ERR_WRONGTYPE;
+ }
+
+ if (intval != 1 && intval != 2) {
+ DEBUGMSGTL(("mibII/snmp_mib", "not valid %x\n", intval));
+ return SNMP_ERR_WRONGVALUE;
+ }
+ break;
+
+ case RESERVE2: /* Allocate memory and similar resources */
+
+ /* Using static variables, so nothing needs to be done */
+ break;
+
+ case ACTION: /* Perform the SET action (if reversible) */
+
+ /* Save the old value, in case of UNDO */
+ old_snmp_enableauthentraps = snmp_enableauthentraps;
+ snmp_enableauthentraps = intval;
+ break;
+
+ case UNDO: /* Reverse the SET action and free resources */
+
+ snmp_enableauthentraps = old_snmp_enableauthentraps;
+ break;
+
+ case COMMIT: /* Confirm the SET, performing any irreversible actions,
+ and free resources */
+ /* save_into_conffile ("authentraps:", intval == 1 ? "yes" : "no"); */
+ break;
+
+ case FREE: /* Free any resources allocated */
+ break;
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+/*********************
+ *
+ * Internal implementation functions
+ *
+ *********************/
Index: v2_0/src/mibgroup/mibII/tcp.c
===================================================================
--- v2_0/src/mibgroup/mibII/tcp.c (nonexistent)
+++ v2_0/src/mibgroup/mibII/tcp.c (revision 1765)
@@ -0,0 +1,673 @@
+//==========================================================================
+//
+// snmp/snmpagent/current/src/mibgroup/mibII/tcp.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt, Andrew Lunn
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* This file was generated by mib2c and is intended for use as a mib module
+ for the ucd-snmp snmpd agent. */
+
+#include
+/* This should always be included first before anything else */
+#include
+
+
+/* minimal include directives */
+#include "mibincl.h"
+#include "mibgroup/util_funcs.h"
+#include "mibgroup/mibII/tcp.h"
+
+#include
+
+#define _KERNEL
+#include
+#include
+#include
+#include
+#include
+#include
+//#define TCPOUTFLAGS
+#include
+#include
+#include
+#include
+#include
+#include
+
+/*
+ * tcp_variables_oid:
+ * this is the top level oid that we want to register under. This
+ * is essentially a prefix, with the suffix appearing in the
+ * variable below.
+ */
+
+
+oid tcp_variables_oid[] = { 1,3,6,1,2,1,6 };
+
+
+/*
+ * variable4 tcp_variables:
+ * this variable defines function callbacks and type return information
+ * for the tcp mib section
+ */
+
+
+struct variable4 tcp_variables[] = {
+/* magic number , variable type , ro/rw , callback fn , L, oidsuffix */
+#define TCPRTOALGORITHM 1
+ { TCPRTOALGORITHM , ASN_INTEGER , RONLY , var_tcp, 1, { 1 } },
+#define TCPRTOMIN 2
+ { TCPRTOMIN , ASN_INTEGER , RONLY , var_tcp, 1, { 2 } },
+#define TCPRTOMAX 3
+ { TCPRTOMAX , ASN_INTEGER , RONLY , var_tcp, 1, { 3 } },
+#define TCPMAXCONN 4
+ { TCPMAXCONN , ASN_INTEGER , RONLY , var_tcp, 1, { 4 } },
+#define TCPACTIVEOPENS 5
+ { TCPACTIVEOPENS , ASN_COUNTER , RONLY , var_tcp, 1, { 5 } },
+#define TCPPASSIVEOPENS 6
+ { TCPPASSIVEOPENS , ASN_COUNTER , RONLY , var_tcp, 1, { 6 } },
+#define TCPATTEMPTFAILS 7
+ { TCPATTEMPTFAILS , ASN_COUNTER , RONLY , var_tcp, 1, { 7 } },
+#define TCPESTABRESETS 8
+ { TCPESTABRESETS , ASN_COUNTER , RONLY , var_tcp, 1, { 8 } },
+#define TCPCURRESTAB 9
+ { TCPCURRESTAB , ASN_GAUGE , RONLY , var_tcp, 1, { 9 } },
+#define TCPINSEGS 10
+ { TCPINSEGS , ASN_COUNTER , RONLY , var_tcp, 1, { 10 } },
+#define TCPOUTSEGS 11
+ { TCPOUTSEGS , ASN_COUNTER , RONLY , var_tcp, 1, { 11 } },
+#define TCPRETRANSSEGS 12
+ { TCPRETRANSSEGS , ASN_COUNTER , RONLY , var_tcp, 1, { 12 } },
+#define TCPCONNSTATE 15
+ { TCPCONNSTATE , ASN_INTEGER , RWRITE, var_tcpConnTable, 3, { 13,1,1 } },
+#define TCPCONNLOCALADDRESS 16
+ { TCPCONNLOCALADDRESS , ASN_IPADDRESS , RONLY , var_tcpConnTable, 3, { 13,1,2 } },
+#define TCPCONNLOCALPORT 17
+ { TCPCONNLOCALPORT , ASN_INTEGER , RONLY , var_tcpConnTable, 3, { 13,1,3 } },
+#define TCPCONNREMADDRESS 18
+ { TCPCONNREMADDRESS , ASN_IPADDRESS , RONLY , var_tcpConnTable, 3, { 13,1,4 } },
+#define TCPCONNREMPORT 19
+ { TCPCONNREMPORT , ASN_INTEGER , RONLY , var_tcpConnTable, 3, { 13,1,5 } },
+#define TCPINERRS 20
+ { TCPINERRS , ASN_COUNTER , RONLY , var_tcp, 1, { 14 } },
+#define TCPOUTRSTS 21
+ { TCPOUTRSTS , ASN_COUNTER , RONLY , var_tcp, 1, { 15 } },
+//#define IPV6TCPCONNSTATE 29
+// { IPV6TCPCONNSTATE , ASN_INTEGER , RWRITE, var_ipv6TcpConnTable, 3, { 16,1,6 } },
+
+};
+/* (L = length of the oidsuffix) */
+
+
+/*
+ * init_tcp():
+ * Initialization routine. This is called when the agent starts up.
+ * At a minimum, registration of your variables should take place here.
+ */
+void init_tcp(void) {
+
+
+ /* register ourselves with the agent to handle our mib tree */
+ REGISTER_MIB("tcp", tcp_variables, variable4,
+ tcp_variables_oid);
+
+
+ /* place any other initialization junk you need here */
+}
+
+
+/*
+ * var_tcp():
+ * This function is called every time the agent gets a request for
+ * a scalar variable that might be found within your mib section
+ * registered above. It is up to you to do the right thing and
+ * return the correct value.
+ * You should also correct the value of "var_len" if necessary.
+ *
+ * Please see the documentation for more information about writing
+ * module extensions, and check out the examples in the examples
+ * and mibII directories.
+ */
+unsigned char *
+var_tcp(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ static long long_ret;
+
+ if (header_generic(vp,name,length,exact,var_len,write_method)
+ == MATCH_FAILED )
+ return NULL;
+
+ switch(vp->magic) {
+
+ case TCPRTOALGORITHM:
+ long_ret = 1; // meaning "other"
+ return (unsigned char *) &long_ret;
+
+ case TCPRTOMIN:
+ long_ret = TCPTV_MIN / PR_SLOWHZ * 1000;;
+ return (unsigned char *) &long_ret;
+
+ case TCPRTOMAX:
+ long_ret = TCPTV_REXMTMAX / PR_SLOWHZ * 1000;;
+ return (unsigned char *) &long_ret;
+
+ case TCPMAXCONN:
+ long_ret = -1; // It is dynamic.
+ return (unsigned char *) &long_ret;
+
+ case TCPACTIVEOPENS:
+ long_ret = tcpstat.tcps_connattempt;
+ return (unsigned char *) &long_ret;
+
+ case TCPPASSIVEOPENS:
+ long_ret = tcpstat.tcps_accepts;
+ return (unsigned char *) &long_ret;
+
+ case TCPATTEMPTFAILS:
+ long_ret = tcpstat.tcps_conndrops;
+ return (unsigned char *) &long_ret;
+
+ case TCPESTABRESETS:
+ long_ret = tcpstat.tcps_drops;
+ return (unsigned char *) &long_ret;
+
+ case TCPCURRESTAB: {
+ struct inpcb *inp;
+ long_ret = 0;
+ for (
+#ifdef CYGPKG_NET_OPENBSD_STACK
+ inp = tcbtable.inpt_queue.cqh_first;
+ inp != (struct inpcb *)&tcbtable.inpt_queue;
+ inp = inp->inp_queue.cqe_next
+#endif
+#ifdef CYGPKG_NET_FREEBSD_STACK
+ inp = tcb.lh_first;
+ inp;
+ inp = inp->inp_list.le_next
+#endif
+ ) {
+ struct tcpcb *tp = intotcpcb( inp );
+ if ( tp && (TCPS_ESTABLISHED == tp->t_state ||
+ TCPS_CLOSE_WAIT == tp->t_state) )
+ long_ret++;
+ }
+ return (unsigned char *) &long_ret;
+ }
+
+ case TCPINSEGS:
+ long_ret = tcpstat.tcps_rcvtotal;
+ return (unsigned char *) &long_ret;
+
+ case TCPOUTSEGS:
+ long_ret = tcpstat.tcps_sndtotal - tcpstat.tcps_sndrexmitpack;
+ if ( long_ret < 0 )
+ long_ret = 0;
+ return (unsigned char *) &long_ret;
+
+ case TCPRETRANSSEGS:
+ long_ret = tcpstat.tcps_sndrexmitpack;
+ return (unsigned char *) &long_ret;
+
+ case TCPINERRS:
+ long_ret = tcpstat.tcps_rcvbadsum
+ + tcpstat.tcps_rcvbadoff
+ + tcpstat.tcps_rcvshort
+ + tcpstat.tcps_rcvmemdrop; // Is that last one an input error?
+ return (unsigned char *) &long_ret;
+
+ case TCPOUTRSTS:
+ long_ret = tcpstat.tcps_sndctrl - tcpstat.tcps_closed;
+ if ( long_ret < 0 )
+ long_ret = 0;
+ return (unsigned char *) &long_ret;
+
+ default:
+ ERROR_MSG("");
+ }
+ return NULL;
+}
+
+
+
+
+/*
+ * var_tcpConnTable():
+ * Handle this table separately from the scalar value case.
+ * The workings of this are basically the same as for var_tcpConnTable above.
+ */
+unsigned char *
+var_tcpConnTable(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ static long long_ret;
+ static unsigned char string[SPRINT_MAX_LEN];
+ register struct inpcb *inp;
+ register struct inpcb *low_inp = NULL;
+ oid lowest[24];
+ oid newname[24];
+ u_char *cp;
+ oid *op;
+ struct tcpcb *tp;
+
+ // This is indexed by local-address, local-port, remote-address, remport
+ // at 1,3,6,1,2,1,6,13,1
+ // so we get 1,3,6,1,2,1,6,13,1,?,A,B,C,D,lport,P,Q,R,S,rport
+ // initial length is 10, out-length is 20,
+ // Local address is offsets 10-13, port is offset 14.
+ // Remote address is offsets 15-18, port is offset 19.
+
+ // starting from udbtable, look in
+ // low_pcb->inp_laddr.s_addr
+ // and low_pcb->inp_lport
+ // /_l/_f/ for foreign port,address.
+
+ /* fill in object part of name for current (less sizeof instance part) */
+ memcpy((char *)newname, (char *)vp->name, (int)vp->namelen * sizeof(oid));
+
+ for (
+#ifdef CYGPKG_NET_OPENBSD_STACK
+ inp = tcbtable.inpt_queue.cqh_first;
+ inp != (struct inpcb *)&tcbtable.inpt_queue;
+ inp = inp->inp_queue.cqe_next
+#endif
+#ifdef CYGPKG_NET_FREEBSD_STACK
+ inp = tcb.lh_first;
+ inp;
+ inp = inp->inp_list.le_next
+#endif
+ ) {
+
+ cp = (u_char *)&inp->inp_laddr.s_addr;
+ op = newname + 10;
+ *op++ = *cp++;
+ *op++ = *cp++;
+ *op++ = *cp++;
+ *op++ = *cp++;
+
+ newname[14] = ntohs(inp->inp_lport);
+
+ cp = (u_char *)&inp->inp_faddr.s_addr;
+ op = newname + 15;
+ *op++ = *cp++;
+ *op++ = *cp++;
+ *op++ = *cp++;
+ *op++ = *cp++;
+
+ newname[19] = ntohs(inp->inp_fport);
+
+ if (exact){
+ if (snmp_oid_compare(newname, 20, name, *length) == 0){
+ memcpy( (char *)lowest,(char *)newname, 20 * sizeof(oid));
+ low_inp = inp;
+ break; /* no need to search further */
+ }
+ } else {
+ if ((snmp_oid_compare(newname, 20, name, *length) > 0) &&
+ (!low_inp || (snmp_oid_compare(newname, 20, lowest, 20) < 0))){
+ /*
+ * if new one is greater than input and closer to input than
+ * previous lowest, save this one as the "next" one.
+ */
+ memcpy( (char *)lowest,(char *)newname, 20 * sizeof(oid));
+ low_inp = inp;
+ }
+ }
+ }
+
+ if ( ! low_inp )
+ return NULL;
+
+ tp = intotcpcb( low_inp );
+ if ( ! tp )
+ return NULL; // Shouldn't happen
+
+ memcpy( (char *)name,(char *)lowest, 20 * sizeof(oid));
+ *length = 20;
+ *var_len = sizeof( long_ret );
+ *write_method = 0;
+
+ switch(vp->magic) {
+ case TCPCONNSTATE:
+ // NOTSUPPORTED: *write_method = write_tcpConnState;
+ switch ( tp->t_state ) {
+ case TCPS_CLOSED : // 0 /* closed */
+ long_ret = 1; break;
+ case TCPS_LISTEN : // 1 /* listening for connection */
+ long_ret = 2; break;
+ case TCPS_SYN_SENT : // 2 /* active, have sent syn */
+ long_ret = 3; break;
+ case TCPS_SYN_RECEIVED : // 3 /* have sent and received syn */
+ long_ret = 4; break;
+ case TCPS_ESTABLISHED : // 4 /* established */
+ long_ret = 5; break;
+ case TCPS_CLOSE_WAIT : // 5 /* rcvd fin, waiting for close */
+ long_ret = 8; break;
+ case TCPS_FIN_WAIT_1 : // 6 /* have closed, sent fin */
+ long_ret = 6; break;
+ case TCPS_CLOSING : // 7 /* closed xchd FIN; await ACK */
+ long_ret = 10; break;
+ case TCPS_LAST_ACK : // 8 /* had fin and close; await FIN ACK */
+ long_ret = 9; break;
+ case TCPS_FIN_WAIT_2 : // 9 /* have closed, fin is acked */
+ long_ret = 7; break;
+ case TCPS_TIME_WAIT : // 10 /* in 2*msl quiet wait after close */
+ long_ret = 11; break;
+ default:
+ long_ret = 1;
+ }
+ return (unsigned char *) &long_ret;
+
+ case TCPCONNLOCALADDRESS:
+ cp = (u_char *)&low_inp->inp_laddr.s_addr;
+ string[0] = *cp++;
+ string[1] = *cp++;
+ string[2] = *cp++;
+ string[3] = *cp++;
+ *var_len = 4;
+ return (unsigned char *) string;
+
+ case TCPCONNLOCALPORT:
+ long_ret = (long)ntohs(low_inp->inp_lport);
+ return (unsigned char *) &long_ret;
+
+ case TCPCONNREMADDRESS:
+ cp = (u_char *)&low_inp->inp_faddr.s_addr;
+ string[0] = *cp++;
+ string[1] = *cp++;
+ string[2] = *cp++;
+ string[3] = *cp++;
+ *var_len = 4;
+ return (unsigned char *) string;
+
+ case TCPCONNREMPORT:
+ long_ret = (long)ntohs(low_inp->inp_fport);
+ return (unsigned char *) &long_ret;
+
+ default:
+ ERROR_MSG("");
+ }
+ return NULL;
+}
+
+
+#if 0 // NOTSUPPORTED:
+int
+write_tcpConnState(int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ static long *long_ret;
+ int size;
+
+
+ switch ( action ) {
+ case RESERVE1:
+ if (var_val_type != ASN_INTEGER){
+ fprintf(stderr, "write to tcpConnState not ASN_INTEGER\n");
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(long_ret)){
+ fprintf(stderr,"write to tcpConnState: bad length\n");
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ break;
+
+
+ case RESERVE2:
+ size = var_val_len;
+ long_ret = (long *) var_val;
+
+
+ break;
+
+
+ case FREE:
+ /* Release any resources that have been allocated */
+ break;
+
+
+ case ACTION:
+ /* The variable has been stored in long_ret for
+ you to use, and you have just been asked to do something with
+ it. Note that anything done here must be reversable in the UNDO case */
+ break;
+
+
+ case UNDO:
+ /* Back out any changes made in the ACTION case */
+ break;
+
+
+ case COMMIT:
+ /* Things are working well, so it's now safe to make the change
+ permanently. Make sure that anything done here can't fail! */
+ break;
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+#endif
+
+
+
+
+#if 0 // NOTSUPPORTED:
+/*
+ * var_ipv6TcpConnTable():
+ * Handle this table separately from the scalar value case.
+ * The workings of this are basically the same as for var_tcp above.
+ */
+unsigned char *
+var_ipv6TcpConnTable(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+
+
+ /* variables we may use later */
+ static long long_ret;
+ static unsigned char string[SPRINT_MAX_LEN];
+ static oid objid[MAX_OID_LEN];
+ static struct counter64 c64;
+
+
+ /*
+ * This assumes that the table is a 'simple' table.
+ * See the implementation documentation for the meaning of this.
+ * You will need to provide the correct value for the TABLE_SIZE parameter
+ *
+ * If this table does not meet the requirements for a simple table,
+ * you will need to provide the replacement code yourself.
+ * Mib2c is not smart enough to write this for you.
+ * Again, see the implementation documentation for what is required.
+ */
+// if (header_simple_table(vp,name,length,exact,var_len,write_method,
+// IPV6TCPCONNTABLE_TABLE_SIZE)
+// == MATCH_FAILED )
+ return NULL;
+
+
+ /*
+ * this is where we do the value assignments for the mib results.
+ */
+ switch(vp->magic) {
+
+
+ case IPV6TCPCONNSTATE:
+ *write_method = write_ipv6TcpConnState;
+ long_ret = 0;
+ return (unsigned char *) &long_ret;
+
+
+ default:
+ ERROR_MSG("");
+ }
+ return NULL;
+}
+
+
+
+
+int
+write_ipv6TcpConnState(int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ static long *long_ret;
+ int size;
+
+
+ switch ( action ) {
+ case RESERVE1:
+ if (var_val_type != ASN_INTEGER){
+ fprintf(stderr, "write to tcpConnState not ASN_INTEGER\n");
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(long_ret)){
+ fprintf(stderr,"write to tcpConnState: bad length\n");
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ break;
+
+
+ case RESERVE2:
+ size = var_val_len;
+ long_ret = (long *) var_val;
+
+
+ break;
+
+
+ case FREE:
+ /* Release any resources that have been allocated */
+ break;
+
+
+ case ACTION:
+ /* The variable has been stored in long_ret for
+ you to use, and you have just been asked to do something with
+ it. Note that anything done here must be reversable in the UNDO case */
+ break;
+
+
+ case UNDO:
+ /* Back out any changes made in the ACTION case */
+ break;
+
+
+ case COMMIT:
+ /* Things are working well, so it's now safe to make the change
+ permanently. Make sure that anything done here can't fail! */
+ break;
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+#endif // NOTSUPPORTED: ipv6
+
+// EOF tcp.c
Index: v2_0/src/mibgroup/mibII/sysORTable.c
===================================================================
--- v2_0/src/mibgroup/mibII/sysORTable.c (nonexistent)
+++ v2_0/src/mibgroup/mibII/sysORTable.c (revision 1765)
@@ -0,0 +1,382 @@
+//==========================================================================
+//
+// ./agent/current/src/mibgroup/mibII/sysORTable.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * Template MIB group implementation - sysORTable.c
+ *
+ */
+#include
+#if HAVE_STDLIB_H
+#include
+#endif
+#include
+#if TIME_WITH_SYS_TIME
+# ifdef WIN32
+# include
+# else
+# include
+# endif
+# include
+#else
+# if HAVE_SYS_TIME_H
+# include
+# else
+# include
+# endif
+#endif
+#if HAVE_STRING_H
+#include
+#else
+#include
+#endif
+
+#if HAVE_WINSOCK_H
+#include
+#endif
+
+#if HAVE_DMALLOC_H
+#include
+#endif
+
+#include "mibincl.h"
+#include "system.h"
+#include "mibgroup/struct.h"
+#include "mibgroup/util_funcs.h"
+#include "mibgroup/mibII/sysORTable.h"
+#include "snmpd.h"
+#include "default_store.h"
+#include "ds_agent.h"
+#include "callback.h"
+#include "agent_callbacks.h"
+
+#ifdef USING_AGENTX_SUBAGENT_MODULE
+#include "agentx/subagent.h"
+#include "agentx/client.h"
+#endif
+
+extern struct timeval starttime;
+
+struct timeval sysOR_lastchange;
+static struct sysORTable *table=NULL;
+static int numEntries=0;
+
+/* define the structure we're going to ask the agent to register our
+ information at */
+struct variable2 sysORTable_variables[] = {
+ { SYSORTABLEID, ASN_OBJECT_ID, RONLY, var_sysORTable, 1, {2}},
+ { SYSORTABLEDESCR, ASN_OCTET_STR, RONLY, var_sysORTable, 1, {3}},
+ { SYSORTABLEUPTIME, ASN_TIMETICKS, RONLY, var_sysORTable, 1, {4}}
+};
+
+/* Define the OID pointer to the top of the mib tree that we're
+ registering underneath */
+oid sysORTable_variables_oid[] = { SNMP_OID_MIB2,1,9,1 };
+#ifdef USING_MIBII_SYSTEM_MIB_MODULE
+extern oid system_module_oid[];
+extern int system_module_oid_len;
+extern int system_module_count;
+#endif
+
+void
+init_sysORTable(void) {
+ /* register ourselves with the agent to handle our mib tree */
+
+#ifdef USING_AGENTX_SUBAGENT_MODULE
+ if ( ds_get_boolean(DS_APPLICATION_ID, DS_AGENT_ROLE) == MASTER_AGENT )
+ (void)register_mib_priority("mibII/sysORTable",
+ (struct variable *) sysORTable_variables,
+ sizeof(struct variable2),
+ sizeof(sysORTable_variables)/sizeof(struct variable2),
+ sysORTable_variables_oid,
+ sizeof(sysORTable_variables_oid)/sizeof(oid), 1);
+ else
+#endif
+ REGISTER_MIB("mibII/sysORTable", sysORTable_variables, variable2, sysORTable_variables_oid);
+
+#ifdef USING_MIBII_SYSTEM_MIB_MODULE
+ if ( ++system_module_count == 3 )
+ REGISTER_SYSOR_TABLE( system_module_oid, system_module_oid_len,
+ "The MIB module for SNMPv2 entities");
+#endif
+
+ gettimeofday(&sysOR_lastchange, NULL);
+}
+
+ /*********************
+ *
+ * System specific implementation functions
+ *
+ *********************/
+
+u_char *
+var_sysORTable(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ struct timeval diff;
+ int i;
+ struct sysORTable *ptr;
+
+ if (header_simple_table(vp, name, length, exact, var_len, write_method, numEntries))
+ return NULL;
+
+ DEBUGMSGTL(("mibII/sysORTable", "sysORTable -- "));
+ for(i = 1, ptr=table; ptr != NULL && i < (int)name[*length-1];
+ ptr = ptr->next, i++) {
+ DEBUGMSGTL(("mibII/sysORTable", "sysORTable -- %d != %d\n",i,name[*length-1]));
+ }
+ if (ptr == NULL) {
+ DEBUGMSGTL(("mibII/sysORTable", "sysORTable -- no match: %d\n",i));
+ return NULL;
+ }
+ DEBUGMSGTL(("mibII/sysORTable", "sysORTable -- match: %d\n",i));
+
+ switch (vp->magic){
+ case SYSORTABLEID:
+ *var_len = ptr->OR_oidlen*sizeof(ptr->OR_oid[0]);
+ return (u_char *) ptr->OR_oid;
+
+ case SYSORTABLEDESCR:
+ *var_len = strlen(ptr->OR_descr);
+ return (u_char *) ptr->OR_descr;
+
+ case SYSORTABLEUPTIME:
+ ptr->OR_uptime.tv_sec--;
+ ptr->OR_uptime.tv_usec += 1000000L;
+ diff.tv_sec = ptr->OR_uptime.tv_sec - 1 - starttime.tv_sec;
+ diff.tv_usec = ptr->OR_uptime.tv_usec + 1000000L - starttime.tv_usec;
+ if (diff.tv_usec > 1000000L){
+ diff.tv_usec -= 1000000L;
+ diff.tv_sec++;
+ }
+ if ((diff.tv_sec * 100) + (diff.tv_usec / 10000) < 0)
+ long_return = 0;
+ else
+ long_return = ((diff.tv_sec * 100) + (diff.tv_usec / 10000));
+ return ((u_char *) &long_return);
+
+ default:
+ DEBUGMSGTL(("snmpd", "unknown sub-id %d in var_sysORTable\n", vp->magic));
+ }
+ return NULL;
+}
+
+
+int register_sysORTable_sess(oid *oidin,
+ size_t oidlen,
+ const char *descr,
+ struct snmp_session *ss)
+{
+ struct sysORTable **ptr=&table;
+ struct register_sysOR_parameters reg_sysOR_parms;
+
+ DEBUGMSGTL(("mibII/sysORTable", "sysORTable registering: "));
+ DEBUGMSGOID(("mibII/sysORTable", oidin, oidlen));
+ DEBUGMSG(("mibII/sysORTable","\n"));
+
+ while(*ptr != NULL)
+ ptr = &((*ptr)->next);
+ *ptr = (struct sysORTable *) malloc(sizeof(struct sysORTable));
+ if ( *ptr == NULL ) {
+ return SYS_ORTABLE_REGISTRATION_FAILED;
+ }
+ (*ptr)->OR_descr = (char *) malloc(strlen(descr)+1);
+ if ( (*ptr)->OR_descr == NULL ) {
+ free( *ptr );
+ return SYS_ORTABLE_REGISTRATION_FAILED;
+ }
+ strcpy((*ptr)->OR_descr, descr);
+ (*ptr)->OR_oidlen = oidlen;
+ (*ptr)->OR_oid = (oid *) malloc(sizeof(oid)*oidlen);
+ if ( (*ptr)->OR_oid == NULL ) {
+ free( *ptr );
+ free( (*ptr)->OR_descr );
+ return SYS_ORTABLE_REGISTRATION_FAILED;
+ }
+ memcpy((*ptr)->OR_oid, oidin, sizeof(oid)*oidlen);
+ gettimeofday(&((*ptr)->OR_uptime), NULL);
+ (*ptr)->OR_sess = ss;
+ (*ptr)->next = NULL;
+ numEntries++;
+
+ reg_sysOR_parms.name = oidin;
+ reg_sysOR_parms.namelen = oidlen;
+ reg_sysOR_parms.descr = descr;
+ snmp_call_callbacks(SNMP_CALLBACK_APPLICATION, SNMPD_CALLBACK_REG_SYSOR,
+ ®_sysOR_parms);
+
+ return SYS_ORTABLE_REGISTERED_OK;
+}
+
+int register_sysORTable(oid *oidin,
+ size_t oidlen,
+ const char *descr)
+{
+ return register_sysORTable_sess( oidin, oidlen, descr, NULL );
+}
+
+
+
+int unregister_sysORTable_sess(oid *oidin,
+ size_t oidlen,
+ struct snmp_session *ss)
+{
+ struct sysORTable **ptr=&table, *prev=NULL;
+ int found = SYS_ORTABLE_NO_SUCH_REGISTRATION;
+ struct register_sysOR_parameters reg_sysOR_parms;
+
+ DEBUGMSGTL(("mibII/sysORTable", "sysORTable unregistering: "));
+ DEBUGMSGOID(("mibII/sysORTable", oidin, oidlen));
+ DEBUGMSG(("mibII/sysORTable","\n"));
+
+ while(*ptr != NULL) {
+ if ( snmp_oid_compare( oidin, oidlen, (*ptr)->OR_oid, (*ptr)->OR_oidlen) == 0 ) {
+ if ( (*ptr)->OR_sess != ss )
+ continue; /* different session */
+ if ( prev == NULL )
+ table = (*ptr)->next;
+ else
+ prev->next = (*ptr)->next;
+
+ free( (*ptr)->OR_descr );
+ free( (*ptr)->OR_oid );
+ free( (*ptr) );
+ numEntries--;
+ found = SYS_ORTABLE_UNREGISTERED_OK;
+ break;
+ }
+ prev = *ptr;
+ ptr = &((*ptr)->next);
+ }
+
+ reg_sysOR_parms.name = oidin;
+ reg_sysOR_parms.namelen = oidlen;
+ snmp_call_callbacks(SNMP_CALLBACK_APPLICATION, SNMPD_CALLBACK_UNREG_SYSOR,
+ ®_sysOR_parms);
+
+ return found;
+}
+
+
+int unregister_sysORTable(oid *oidin,
+ size_t oidlen)
+{
+ return unregister_sysORTable_sess( oidin, oidlen, NULL );
+}
+
+void unregister_sysORTable_by_session(struct snmp_session *ss)
+{
+ struct sysORTable *ptr=table, *prev=NULL, *next;
+
+ while ( ptr != NULL ) {
+ next = ptr->next;
+ if (( (ss->flags & SNMP_FLAGS_SUBSESSION) && ptr->OR_sess == ss ) ||
+ (!(ss->flags & SNMP_FLAGS_SUBSESSION) &&
+ ptr->OR_sess->subsession == ss )) {
+ if ( prev == NULL )
+ table = next;
+ else
+ prev->next = next;
+ free( ptr->OR_descr );
+ free( ptr->OR_oid );
+ free( ptr );
+ numEntries--;
+
+ }
+ else
+ prev = ptr;
+ ptr = next;
+ }
+}
+
Index: v2_0/src/mibgroup/mibII/icmp.c
===================================================================
--- v2_0/src/mibgroup/mibII/icmp.c (nonexistent)
+++ v2_0/src/mibgroup/mibII/icmp.c (revision 1765)
@@ -0,0 +1,324 @@
+//==========================================================================
+//
+// snmp/snmpagent/current/src/mibgroup/mibII/icmp.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* This file was generated by mib2c and is intended for use as a mib module
+ for the ucd-snmp snmpd agent. */
+
+
+/* This should always be included first before anything else */
+#include
+
+
+/* minimal include directives */
+#include "mibincl.h"
+#include "mibgroup/util_funcs.h"
+#include "mibgroup/mibII/icmp.h"
+
+
+#define _KERNEL
+#include
+#include
+
+/*
+ * icmp_variables_oid:
+ * this is the top level oid that we want to register under. This
+ * is essentially a prefix, with the suffix appearing in the
+ * variable below.
+ */
+
+
+oid icmp_variables_oid[] = { 1,3,6,1,2,1,5 };
+
+
+/*
+ * variable2 icmp_variables:
+ * this variable defines function callbacks and type return information
+ * for the icmp mib section
+ */
+
+
+struct variable2 icmp_variables[] = {
+/* magic number , variable type , ro/rw , callback fn , L, oidsuffix */
+#define ICMPINMSGS 1
+ { ICMPINMSGS , ASN_COUNTER , RONLY , var_icmp, 1, { 1 } },
+#define ICMPINERRORS 2
+ { ICMPINERRORS , ASN_COUNTER , RONLY , var_icmp, 1, { 2 } },
+#define ICMPINDESTUNREACHS 3
+ { ICMPINDESTUNREACHS , ASN_COUNTER , RONLY , var_icmp, 1, { 3 } },
+#define ICMPINTIMEEXCDS 4
+ { ICMPINTIMEEXCDS , ASN_COUNTER , RONLY , var_icmp, 1, { 4 } },
+#define ICMPINPARMPROBS 5
+ { ICMPINPARMPROBS , ASN_COUNTER , RONLY , var_icmp, 1, { 5 } },
+#define ICMPINSRCQUENCHS 6
+ { ICMPINSRCQUENCHS , ASN_COUNTER , RONLY , var_icmp, 1, { 6 } },
+#define ICMPINREDIRECTS 7
+ { ICMPINREDIRECTS , ASN_COUNTER , RONLY , var_icmp, 1, { 7 } },
+#define ICMPINECHOS 8
+ { ICMPINECHOS , ASN_COUNTER , RONLY , var_icmp, 1, { 8 } },
+#define ICMPINECHOREPS 9
+ { ICMPINECHOREPS , ASN_COUNTER , RONLY , var_icmp, 1, { 9 } },
+#define ICMPINTIMESTAMPS 10
+ { ICMPINTIMESTAMPS , ASN_COUNTER , RONLY , var_icmp, 1, { 10 } },
+#define ICMPINTIMESTAMPREPS 11
+ { ICMPINTIMESTAMPREPS , ASN_COUNTER , RONLY , var_icmp, 1, { 11 } },
+#define ICMPINADDRMASKS 12
+ { ICMPINADDRMASKS , ASN_COUNTER , RONLY , var_icmp, 1, { 12 } },
+#define ICMPINADDRMASKREPS 13
+ { ICMPINADDRMASKREPS , ASN_COUNTER , RONLY , var_icmp, 1, { 13 } },
+#define ICMPOUTMSGS 14
+ { ICMPOUTMSGS , ASN_COUNTER , RONLY , var_icmp, 1, { 14 } },
+#define ICMPOUTERRORS 15
+ { ICMPOUTERRORS , ASN_COUNTER , RONLY , var_icmp, 1, { 15 } },
+#define ICMPOUTDESTUNREACHS 16
+ { ICMPOUTDESTUNREACHS , ASN_COUNTER , RONLY , var_icmp, 1, { 16 } },
+#define ICMPOUTTIMEEXCDS 17
+ { ICMPOUTTIMEEXCDS , ASN_COUNTER , RONLY , var_icmp, 1, { 17 } },
+#define ICMPOUTPARMPROBS 18
+ { ICMPOUTPARMPROBS , ASN_COUNTER , RONLY , var_icmp, 1, { 18 } },
+#define ICMPOUTSRCQUENCHS 19
+ { ICMPOUTSRCQUENCHS , ASN_COUNTER , RONLY , var_icmp, 1, { 19 } },
+#define ICMPOUTREDIRECTS 20
+ { ICMPOUTREDIRECTS , ASN_COUNTER , RONLY , var_icmp, 1, { 20 } },
+#define ICMPOUTECHOS 21
+ { ICMPOUTECHOS , ASN_COUNTER , RONLY , var_icmp, 1, { 21 } },
+#define ICMPOUTECHOREPS 22
+ { ICMPOUTECHOREPS , ASN_COUNTER , RONLY , var_icmp, 1, { 22 } },
+#define ICMPOUTTIMESTAMPS 23
+ { ICMPOUTTIMESTAMPS , ASN_COUNTER , RONLY , var_icmp, 1, { 23 } },
+#define ICMPOUTTIMESTAMPREPS 24
+ { ICMPOUTTIMESTAMPREPS, ASN_COUNTER , RONLY , var_icmp, 1, { 24 } },
+#define ICMPOUTADDRMASKS 25
+ { ICMPOUTADDRMASKS , ASN_COUNTER , RONLY , var_icmp, 1, { 25 } },
+#define ICMPOUTADDRMASKREPS 26
+ { ICMPOUTADDRMASKREPS , ASN_COUNTER , RONLY , var_icmp, 1, { 26 } },
+
+};
+/* (L = length of the oidsuffix) */
+
+
+/*
+ * init_icmp():
+ * Initialization routine. This is called when the agent starts up.
+ * At a minimum, registration of your variables should take place here.
+ */
+void init_icmp(void) {
+
+
+ /* register ourselves with the agent to handle our mib tree */
+ REGISTER_MIB("icmp", icmp_variables, variable2,
+ icmp_variables_oid);
+
+
+ /* place any other initialization junk you need here */
+}
+
+
+/*
+ * var_icmp():
+ * This function is called every time the agent gets a request for
+ * a scalar variable that might be found within your mib section
+ * registered above. It is up to you to do the right thing and
+ * return the correct value.
+ * You should also correct the value of "var_len" if necessary.
+ *
+ * Please see the documentation for more information about writing
+ * module extensions, and check out the examples in the examples
+ * and mibII directories.
+ */
+unsigned char *
+var_icmp(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ /* variables we may use later */
+ static long long_ret;
+ int i;
+
+ if (header_generic(vp,name,length,exact,var_len,write_method)
+ == MATCH_FAILED )
+ return NULL;
+
+ switch (vp->magic){
+ case ICMPINMSGS:
+ long_ret = icmpstat.icps_badcode + icmpstat.icps_tooshort +
+ icmpstat.icps_checksum + icmpstat.icps_badlen;
+ for (i=0; i <= ICMP_MAXTYPE; i++)
+ long_ret += icmpstat.icps_inhist[i];
+ return (u_char *)&long_ret;
+ case ICMPINERRORS:
+ long_ret = icmpstat.icps_badcode + icmpstat.icps_tooshort +
+ icmpstat.icps_checksum + icmpstat.icps_badlen;
+ return (u_char *)&long_ret;
+ case ICMPINDESTUNREACHS:
+ long_ret = icmpstat.icps_inhist[ICMP_UNREACH];
+ return (u_char *) &long_ret;
+ case ICMPINTIMEEXCDS:
+ long_ret = icmpstat.icps_inhist[ICMP_TIMXCEED];
+ return (u_char *) &long_ret;
+ case ICMPINPARMPROBS:
+ long_ret = icmpstat.icps_inhist[ICMP_PARAMPROB];
+ return (u_char *) &long_ret;
+ case ICMPINSRCQUENCHS:
+ long_ret = icmpstat.icps_inhist[ICMP_SOURCEQUENCH];
+ return (u_char *) &long_ret;
+ case ICMPINREDIRECTS:
+ long_ret = icmpstat.icps_inhist[ICMP_REDIRECT];
+ return (u_char *) &long_ret;
+ case ICMPINECHOS:
+ long_ret = icmpstat.icps_inhist[ICMP_ECHO];
+ return (u_char *) &long_ret;
+ case ICMPINECHOREPS:
+ long_ret = icmpstat.icps_inhist[ICMP_ECHOREPLY];
+ return (u_char *) &long_ret;
+ case ICMPINTIMESTAMPS:
+ long_ret = icmpstat.icps_inhist[ICMP_TSTAMP];
+ return (u_char *) &long_ret;
+ case ICMPINTIMESTAMPREPS:
+ long_ret = icmpstat.icps_inhist[ICMP_TSTAMPREPLY];
+ return (u_char *) &long_ret;
+ case ICMPINADDRMASKS:
+ long_ret = icmpstat.icps_inhist[ICMP_MASKREQ];
+ return (u_char *) &long_ret;
+ case ICMPINADDRMASKREPS:
+ long_ret = icmpstat.icps_inhist[ICMP_MASKREPLY];
+ return (u_char *) &long_ret;
+ case ICMPOUTMSGS:
+ long_ret = icmpstat.icps_oldshort + icmpstat.icps_oldicmp;
+ for (i=0; i <= ICMP_MAXTYPE; i++)
+ long_ret += icmpstat.icps_outhist[i];
+ return (u_char *)&long_ret;
+ case ICMPOUTERRORS:
+ long_ret = icmpstat.icps_oldshort + icmpstat.icps_oldicmp;
+ return (u_char *)&long_ret;
+ case ICMPOUTDESTUNREACHS:
+ long_ret = icmpstat.icps_outhist[ICMP_UNREACH];
+ return (u_char *) &long_ret;
+ case ICMPOUTTIMEEXCDS:
+ long_ret = icmpstat.icps_outhist[ICMP_TIMXCEED];
+ return (u_char *) &long_ret;
+ case ICMPOUTPARMPROBS:
+ long_ret = icmpstat.icps_outhist[ICMP_PARAMPROB];
+ return (u_char *) &long_ret;
+ case ICMPOUTSRCQUENCHS:
+ long_ret = icmpstat.icps_outhist[ICMP_SOURCEQUENCH];
+ return (u_char *) &long_ret;
+ case ICMPOUTREDIRECTS:
+ long_ret = icmpstat.icps_outhist[ICMP_REDIRECT];
+ return (u_char *) &long_ret;
+ case ICMPOUTECHOS:
+ long_ret = icmpstat.icps_outhist[ICMP_ECHO];
+ return (u_char *) &long_ret;
+ case ICMPOUTECHOREPS:
+ long_ret = icmpstat.icps_outhist[ICMP_ECHOREPLY];
+ return (u_char *) &long_ret;
+ case ICMPOUTTIMESTAMPS:
+ long_ret = icmpstat.icps_outhist[ICMP_TSTAMP];
+ return (u_char *) &long_ret;
+ case ICMPOUTTIMESTAMPREPS:
+ long_ret = icmpstat.icps_outhist[ICMP_TSTAMPREPLY];
+ return (u_char *) &long_ret;
+ case ICMPOUTADDRMASKS:
+ long_ret = icmpstat.icps_outhist[ICMP_MASKREQ];
+ return (u_char *) &long_ret;
+ case ICMPOUTADDRMASKREPS:
+ long_ret = icmpstat.icps_outhist[ICMP_MASKREPLY];
+ return (u_char *) &long_ret;
+ default:
+ DEBUGMSGTL(("snmpd", "unknown sub-id %d in var_icmp\n", vp->magic));
+ }
+
+ return NULL;
+}
+
+// EOF icmp.c
Index: v2_0/src/mibgroup/mibII/ip.c
===================================================================
--- v2_0/src/mibgroup/mibII/ip.c (nonexistent)
+++ v2_0/src/mibgroup/mibII/ip.c (revision 1765)
@@ -0,0 +1,988 @@
+//==========================================================================
+//
+// snmp/snmpagent/current/src/mibgroup/mibII/ip.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt, Andrew Lunn
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* This file was generated by mib2c and is intended for use as a mib module
+ for the ucd-snmp snmpd agent. */
+
+#include
+#include
+#include
+#include
+#include
+#ifdef CYGPKG_NET_FREEBSD_STACK
+#include
+#endif
+#include
+#include
+#include
+#include
+#include
+
+/* This should always be included first before anything else */
+#include
+
+/* minimal include directives */
+#include "mibincl.h"
+#include "mibgroup/util_funcs.h"
+#include "mibgroup/mibII/ip.h"
+
+#include
+
+extern struct in_ifaddrhead in_ifaddr;
+
+/*
+ * ip_variables_oid:
+ * this is the top level oid that we want to register under. This
+ * is essentially a prefix, with the suffix appearing in the
+ * variable below.
+ */
+
+
+oid ip_variables_oid[] = { 1,3,6,1,2,1,4 };
+
+/*
+ * variable4 ip_variables:
+ * this variable defines function callbacks and type return information
+ * for the ip mib section
+ */
+
+struct variable4 ip_variables[] = {
+/* magic number , variable type , ro/rw , callback fn , L, oidsuffix */
+#define IPFORWARDING 1
+ { IPFORWARDING , ASN_INTEGER , RWRITE, var_ip, 1, { 1 } },
+#define IPDEFAULTTTL 2
+ { IPDEFAULTTTL , ASN_INTEGER , RWRITE, var_ip, 1, { 2 } },
+#define IPINRECEIVES 3
+ { IPINRECEIVES , ASN_COUNTER , RONLY , var_ip, 1, { 3 } },
+#define IPINHDRERRORS 4
+ { IPINHDRERRORS , ASN_COUNTER , RONLY , var_ip, 1, { 4 } },
+#define IPINADDRERRORS 5
+ { IPINADDRERRORS , ASN_COUNTER , RONLY , var_ip, 1, { 5 } },
+#define IPFORWDATAGRAMS 6
+ { IPFORWDATAGRAMS , ASN_COUNTER , RONLY , var_ip, 1, { 6 } },
+#define IPINUNKNOWNPROTOS 7
+ { IPINUNKNOWNPROTOS , ASN_COUNTER , RONLY , var_ip, 1, { 7 } },
+#define IPINDISCARDS 8
+ { IPINDISCARDS , ASN_COUNTER , RONLY , var_ip, 1, { 8 } },
+#define IPINDELIVERS 9
+ { IPINDELIVERS , ASN_COUNTER , RONLY , var_ip, 1, { 9 } },
+#define IPOUTREQUESTS 10
+ { IPOUTREQUESTS , ASN_COUNTER , RONLY , var_ip, 1, { 10 } },
+#define IPOUTDISCARDS 11
+ { IPOUTDISCARDS , ASN_COUNTER , RONLY , var_ip, 1, { 11 } },
+#define IPOUTNOROUTES 12
+ { IPOUTNOROUTES , ASN_COUNTER , RONLY , var_ip, 1, { 12 } },
+#define IPREASMTIMEOUT 13
+ { IPREASMTIMEOUT , ASN_INTEGER , RONLY , var_ip, 1, { 13 } },
+#define IPREASMREQDS 14
+ { IPREASMREQDS , ASN_COUNTER , RONLY , var_ip, 1, { 14 } },
+#define IPREASMOKS 15
+ { IPREASMOKS , ASN_COUNTER , RONLY , var_ip, 1, { 15 } },
+#define IPREASMFAILS 16
+ { IPREASMFAILS , ASN_COUNTER , RONLY , var_ip, 1, { 16 } },
+#define IPFRAGOKS 17
+ { IPFRAGOKS , ASN_COUNTER , RONLY , var_ip, 1, { 17 } },
+#define IPFRAGFAILS 18
+ { IPFRAGFAILS , ASN_COUNTER , RONLY , var_ip, 1, { 18 } },
+#define IPFRAGCREATES 19
+ { IPFRAGCREATES , ASN_COUNTER , RONLY , var_ip, 1, { 19 } },
+
+
+#define IPADENTADDR 22
+ { IPADENTADDR , ASN_IPADDRESS , RONLY , var_ipAddrTable, 3, { 20,1,1 } },
+#define IPADENTIFINDEX 23
+ { IPADENTIFINDEX , ASN_INTEGER , RONLY , var_ipAddrTable, 3, { 20,1,2 } },
+#define IPADENTNETMASK 24
+ { IPADENTNETMASK , ASN_IPADDRESS , RONLY , var_ipAddrTable, 3, { 20,1,3 } },
+#define IPADENTBCASTADDR 25
+ { IPADENTBCASTADDR , ASN_INTEGER , RONLY , var_ipAddrTable, 3, { 20,1,4 } },
+#define IPADENTREASMMAXSIZE 26
+ { IPADENTREASMMAXSIZE , ASN_INTEGER , RONLY , var_ipAddrTable, 3, { 20,1,5 } },
+
+// ROUTE TABLE is OBSOLETE according to my book
+//#define IPROUTEDEST 29
+// { IPROUTEDEST , ASN_IPADDRESS , RWRITE, var_ipRouteTable, 3, { 21,1,1 } },
+//#define IPROUTEIFINDEX 30
+// { IPROUTEIFINDEX , ASN_INTEGER , RWRITE, var_ipRouteTable, 3, { 21,1,2 } },
+//#define IPROUTEMETRIC1 31
+// { IPROUTEMETRIC1 , ASN_INTEGER , RWRITE, var_ipRouteTable, 3, { 21,1,3 } },
+//#define IPROUTEMETRIC2 32
+// { IPROUTEMETRIC2 , ASN_INTEGER , RWRITE, var_ipRouteTable, 3, { 21,1,4 } },
+//#define IPROUTEMETRIC3 33
+// { IPROUTEMETRIC3 , ASN_INTEGER , RWRITE, var_ipRouteTable, 3, { 21,1,5 } },
+//#define IPROUTEMETRIC4 34
+// { IPROUTEMETRIC4 , ASN_INTEGER , RWRITE, var_ipRouteTable, 3, { 21,1,6 } },
+//#define IPROUTENEXTHOP 35
+// { IPROUTENEXTHOP , ASN_IPADDRESS , RWRITE, var_ipRouteTable, 3, { 21,1,7 } },
+//#define IPROUTETYPE 36
+// { IPROUTETYPE , ASN_INTEGER , RWRITE, var_ipRouteTable, 3, { 21,1,8 } },
+//#define IPROUTEPROTO 37
+// { IPROUTEPROTO , ASN_INTEGER , RONLY , var_ipRouteTable, 3, { 21,1,9 } },
+//#define IPROUTEAGE 38
+// { IPROUTEAGE , ASN_INTEGER , RWRITE, var_ipRouteTable, 3, { 21,1,10 } },
+//#define IPROUTEMASK 39
+// { IPROUTEMASK , ASN_IPADDRESS , RWRITE, var_ipRouteTable, 3, { 21,1,11 } },
+//#define IPROUTEMETRIC5 40
+// { IPROUTEMETRIC5 , ASN_INTEGER , RWRITE, var_ipRouteTable, 3, { 21,1,12 } },
+//#define IPROUTEINFO 41
+// { IPROUTEINFO , ASN_OBJECT_ID , RONLY , var_ipRouteTable, 3, { 21,1,13 } },
+
+#define IPNETTOMEDIAIFINDEX 44
+ { IPNETTOMEDIAIFINDEX , ASN_INTEGER , RWRITE, var_ipNetToMediaTable, 3, { 22,1,1 } },
+#define IPNETTOMEDIAPHYSADDRESS 45
+ { IPNETTOMEDIAPHYSADDRESS, ASN_OCTET_STR, RWRITE, var_ipNetToMediaTable, 3, { 22,1,2 } },
+#define IPNETTOMEDIANETADDRESS 46
+ { IPNETTOMEDIANETADDRESS, ASN_IPADDRESS , RWRITE, var_ipNetToMediaTable, 3, { 22,1,3 } },
+#define IPNETTOMEDIATYPE 47
+ { IPNETTOMEDIATYPE , ASN_INTEGER , RWRITE, var_ipNetToMediaTable, 3, { 22,1,4 } },
+
+#define IPROUTINGDISCARDS 48
+ { IPROUTINGDISCARDS , ASN_COUNTER , RONLY , var_ip, 1, { 23 } },
+
+};
+/* (L = length of the oidsuffix) */
+
+
+/*
+ * init_ip():
+ * Initialization routine. This is called when the agent starts up.
+ * At a minimum, registration of your variables should take place here.
+ */
+void init_ip(void) {
+
+
+ /* register ourselves with the agent to handle our mib tree */
+ REGISTER_MIB("ip", ip_variables, variable4,
+ ip_variables_oid);
+
+
+ /* place any other initialization junk you need here */
+}
+
+
+/*
+ * var_ip():
+ * This function is called every time the agent gets a request for
+ * a scalar variable that might be found within your mib section
+ * registered above. It is up to you to do the right thing and
+ * return the correct value.
+ * You should also correct the value of "var_len" if necessary.
+ *
+ * Please see the documentation for more information about writing
+ * module extensions, and check out the examples in the examples
+ * and mibII directories.
+ */
+unsigned char *
+var_ip(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+
+
+ /* variables we may use later */
+ static long long_ret;
+
+ if (header_generic(vp,name,length,exact,var_len,write_method)
+ == MATCH_FAILED )
+ return NULL;
+
+ switch(vp->magic) {
+
+ case IPFORWARDING:
+ *write_method = write_ipForwarding;
+ long_ret = ipforwarding ? 1 : 2;
+ return (unsigned char *) &long_ret;
+
+ case IPDEFAULTTTL:
+ *write_method = write_ipDefaultTTL;
+ long_ret = ip_defttl;
+ return (unsigned char *) &long_ret;
+
+ case IPINRECEIVES:
+ long_ret = ipstat.ips_total;
+ return (unsigned char *) &long_ret;
+
+ case IPINHDRERRORS:
+ long_ret = ipstat.ips_badsum
+ + ipstat.ips_badhlen
+ + ipstat.ips_badlen
+ + ipstat.ips_badoptions
+ + ipstat.ips_badvers
+#ifdef CYGPKG_NET_OPENBSD_STACK
+ + ipstat.ips_badfrags
+#endif
+ + ipstat.ips_toolong
+ ;
+ return (unsigned char *) &long_ret;
+
+ case IPINADDRERRORS:
+ long_ret = ipstat.ips_cantforward;
+ return (unsigned char *) &long_ret;
+
+ case IPFORWDATAGRAMS:
+ long_ret = ipstat.ips_forward;
+ return (unsigned char *) &long_ret;
+
+ case IPINUNKNOWNPROTOS:
+ long_ret = ipstat.ips_noproto;
+ return (unsigned char *) &long_ret;
+
+ case IPINDISCARDS:
+ long_ret = ipstat.ips_total - ipstat.ips_delivered -
+ (
+ ipstat.ips_badsum
+ + ipstat.ips_badhlen
+ + ipstat.ips_badlen
+ + ipstat.ips_badoptions
+ + ipstat.ips_badvers
+#ifdef CYGPKG_NET_OPENBSD_STACK
+ + ipstat.ips_badfrags
+#endif
+ + ipstat.ips_toolong
+ ) -
+ ipstat.ips_cantforward;
+ if ( 0 > long_ret )
+ long_ret = 0;
+ return (unsigned char *) &long_ret;
+
+ case IPINDELIVERS:
+ long_ret = ipstat.ips_delivered;
+ return (unsigned char *) &long_ret;
+
+ case IPOUTREQUESTS:
+ long_ret = ipstat.ips_localout;
+ return (unsigned char *) &long_ret;
+
+ case IPOUTDISCARDS:
+ long_ret = ipstat.ips_odropped;
+ return (unsigned char *) &long_ret;
+
+ case IPOUTNOROUTES:
+ long_ret = ipstat.ips_noroute;
+ return (unsigned char *) &long_ret;
+
+ case IPREASMTIMEOUT:
+ long_ret = 0; //FIXME
+ return (unsigned char *) &long_ret;
+
+ case IPREASMREQDS:
+ long_ret = ipstat.ips_fragments;
+ return (unsigned char *) &long_ret;
+
+ case IPREASMOKS:
+ long_ret = ipstat.ips_reassembled;
+ return (unsigned char *) &long_ret;
+
+ case IPREASMFAILS:
+ long_ret = ipstat.ips_fragments -
+ (ipstat.ips_fragdropped + ipstat.ips_fragtimeout);
+ return (unsigned char *) &long_ret;
+
+ case IPFRAGOKS:
+ long_ret = ipstat.ips_fragmented;
+ return (unsigned char *) &long_ret;
+
+ case IPFRAGFAILS:
+ long_ret = ipstat.ips_cantfrag;
+ return (unsigned char *) &long_ret;
+
+ case IPFRAGCREATES:
+ long_ret = ipstat.ips_ofragments;
+ return (unsigned char *) &long_ret;
+
+ case IPROUTINGDISCARDS:
+ long_ret = ipstat.ips_noroute;
+ return (unsigned char *) &long_ret;
+
+ default:
+ ERROR_MSG("");
+ }
+ return NULL;
+}
+
+
+/*
+ * var_ipAddrTable():
+ * Handle this table separately from the scalar value case.
+ * The workings of this are basically the same as for var_ipAddrTable above.
+ */
+unsigned char *
+var_ipAddrTable(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ /*
+ * object identifier is of form:
+ * 1.3.6.1.2.1.4.20.1.?.A.B.C.D, where A.B.C.D is IP address.
+ * IPADDR starts at offset 10.
+ */
+ oid lowest[14];
+ oid current[14], *op;
+ u_char *cp;
+
+ static long long_ret;
+ static unsigned char string[SPRINT_MAX_LEN];
+
+ register struct in_ifaddr *ia;
+ register struct in_ifaddr *low_ia = NULL;
+
+ register struct ifnet *ifp;
+ int interface_count = 1;
+
+ /* fill in object part of name for current (less sizeof instance part) */
+ memcpy( (char *)current,(char *)vp->name, (int)vp->namelen * sizeof(oid));
+
+ for (
+#ifdef CYGPKG_NET_OPENBSD_STACK
+ ia = in_ifaddr.tqh_first; ia;
+ ia = ia->ia_list.tqe_next
+#endif
+#ifdef CYGPKG_NET_FREEBSD_STACK
+ ia = in_ifaddrhead.tqh_first; ia;
+ ia = ia->ia_link.tqe_next
+#endif
+ ) {
+ cp = (u_char *)&(ia->ia_addr.sin_addr.s_addr);
+
+ op = current + 10;
+ *op++ = *cp++;
+ *op++ = *cp++;
+ *op++ = *cp++;
+ *op++ = *cp++;
+ if (exact){
+ if (snmp_oid_compare(current, 14, name, *length) == 0) {
+ memcpy( (char *)lowest,(char *)current, 14 * sizeof(oid));
+ low_ia = ia;
+ break; /* no need to search further */
+ }
+ } else {
+ if ((snmp_oid_compare(current, 14, name, *length) > 0) &&
+ (!low_ia || (snmp_oid_compare(current, 14, lowest, 14) < 0))) {
+ /*
+ * if new one is greater than input and closer to input than
+ * previous lowest, save this one as the "next" one.
+ */
+ memcpy( (char *)lowest,(char *)current, 14 * sizeof(oid));
+ low_ia = ia;
+ }
+ }
+ }
+
+ if ( ! low_ia )
+ return NULL;
+
+ memcpy( (char *)name,(char *)lowest, 14 * sizeof(oid));
+ *length = 14;
+ *write_method = 0;
+ *var_len = sizeof(long_return);
+
+ /*
+ * this is where we do the value assignments for the mib results.
+ */
+ switch(vp->magic) {
+
+ case IPADENTADDR:
+ cp = (u_char *)&(low_ia->ia_addr.sin_addr.s_addr);
+ string[0] = *cp++;
+ string[1] = *cp++;
+ string[2] = *cp++;
+ string[3] = *cp++;
+ *var_len = 4;
+ return (unsigned char *) string;
+
+ case IPADENTIFINDEX:
+ ifp = ifnet.tqh_first;
+ while (ifp && ifp->if_index != low_ia->ia_ifa.ifa_ifp->if_index) {
+ interface_count++;
+ ifp = ifp->if_list.tqe_next;
+ }
+ if (!ifp) {
+ return NULL;
+ }
+ long_ret = interface_count;
+ return (unsigned char *) &long_ret;
+
+ case IPADENTNETMASK:
+ cp = (u_char *)&(low_ia->ia_subnetmask);
+ string[0] = *cp++;
+ string[1] = *cp++;
+ string[2] = *cp++;
+ string[3] = *cp++;
+ *var_len = 4;
+ return (unsigned char *) string;
+
+ case IPADENTBCASTADDR:
+ long_ret = 1;
+ return (unsigned char *) &long_ret;
+
+ case IPADENTREASMMAXSIZE:
+ long_ret = IP_MAXPACKET;
+ return (unsigned char *) &long_ret;
+
+ default:
+ ERROR_MSG("");
+ }
+ return NULL;
+}
+
+
+
+
+/*
+ * var_ipNetToMediaTable():
+ * Handle this table separately from the scalar value case.
+ * The workings of this are basically the same as for var_ip above.
+ */
+
+// According to sections 6.1.5 (ip) and 6.1.4 (at) pp.130-138 of the book
+// by William Stallings, this lists *our* interfaces only, not the ARP
+// table. The MIBs are rather ambiguous, as is Mark A. Miller's book also.
+//
+// Specifically, the indexing by interface Id suggests there should only be
+// one entry per interface.
+
+unsigned char *
+var_ipNetToMediaTable(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ static long long_ret;
+ static unsigned char string[SPRINT_MAX_LEN];
+ /*
+ * IP Net to Media table object identifier is of form:
+ * 1.3.6.1.2.1.4.22.1.?.interface.A.B.C.D, where A.B.C.D is IP address.
+ * Interface is at offset 10,
+ * IPADDR starts at offset 11.
+ */
+ u_char *cp;
+ oid *op;
+ oid lowest[16];
+ oid current[16];
+
+ register struct in_ifaddr *ia;
+ register struct in_ifaddr *low_ia = NULL;
+
+ /* fill in object part of name for current (less sizeof instance part) */
+ memcpy((char *)current, (char *)vp->name, (int)vp->namelen * sizeof(oid));
+
+ for (
+#ifdef CYGPKG_NET_OPENBSD_STACK
+ ia = in_ifaddr.tqh_first; ia;
+ ia = ia->ia_list.tqe_next
+#endif
+#ifdef CYGPKG_NET_FREEBSD_STACK
+ ia = in_ifaddrhead.tqh_first; ia;
+ ia = ia->ia_link.tqe_next
+#endif
+ ) {
+ // interface number
+ current[10] = ia->ia_ifa.ifa_ifp->if_index;
+ // IP address
+ cp = (u_char *)&(ia->ia_addr.sin_addr.s_addr);
+ op = current + 11;
+ *op++ = *cp++;
+ *op++ = *cp++;
+ *op++ = *cp++;
+ *op++ = *cp++;
+
+ if (exact){
+ if (snmp_oid_compare(current, 15, name, *length) == 0){
+ memcpy( (char *)lowest,(char *)current, 15 * sizeof(oid));
+ low_ia = ia;
+ break; /* no need to search further */
+ }
+ } else {
+ if ((snmp_oid_compare(current, 15, name, *length) > 0) &&
+ ((!low_ia) || (snmp_oid_compare(current, 15, lowest, 15) < 0))) {
+ /*
+ * if new one is greater than input and closer to input than
+ * previous lowest, save this one as the "next" one.
+ */
+ memcpy( (char *)lowest,(char *)current, 15 * sizeof(oid));
+ low_ia = ia;
+ }
+ }
+ }
+ if ( ! low_ia )
+ return(NULL);
+
+ memcpy( (char *)name,(char *)lowest, 15 * sizeof(oid));
+ *length = 15;
+ *write_method = 0;
+ *var_len = sizeof(long_return);
+
+ /*
+ * this is where we do the value assignments for the mib results.
+ */
+ switch(vp->magic) {
+ case IPNETTOMEDIAIFINDEX:
+ //NOTSUPPORTED: *write_method = write_ipNetToMediaIfIndex;
+ long_ret = low_ia->ia_ifa.ifa_ifp->if_index;
+ return (unsigned char *) &long_ret;
+
+ case IPNETTOMEDIAPHYSADDRESS: {
+ struct eth_drv_sc *sc = low_ia->ia_ifa.ifa_ifp->if_softc;
+ if (!sc) {
+ // No hardware associated with this device.
+ return(NULL);
+ }
+ bcopy(&sc->sc_arpcom.ac_enaddr, string, ETHER_ADDR_LEN);
+ *var_len = ETHER_ADDR_LEN;
+ //NOTSUPPORTED: *write_method = write_ipNetToMediaPhysAddress;
+ return (unsigned char *) string;
+ }
+ case IPNETTOMEDIANETADDRESS:
+ //NOTSUPPORTED: *write_method = write_ipNetToMediaNetAddress;
+ cp = (u_char *)&(low_ia->ia_addr.sin_addr.s_addr);
+ string[0] = *cp++;
+ string[1] = *cp++;
+ string[2] = *cp++;
+ string[3] = *cp++;
+ *var_len = 4;
+ return (unsigned char *) string;
+
+ case IPNETTOMEDIATYPE:
+ //NOTSUPPORTED: *write_method = write_ipNetToMediaType;
+ long_ret = 4; // Static mapping
+ return (unsigned char *) &long_ret;
+
+ default:
+ ERROR_MSG("");
+ }
+ return NULL;
+}
+
+
+
+
+int
+write_ipForwarding(int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ static long setval;
+
+ switch ( action ) {
+ case RESERVE1:
+ if (var_val_type != ASN_INTEGER){
+ fprintf(stderr, "write to ipForwarding not ASN_INTEGER\n");
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(setval)){
+ fprintf(stderr,"write to ipForwarding: bad length\n");
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ setval = *(long *)var_val;
+ if ( 1 != setval && 2 != setval )
+ return SNMP_ERR_WRONGVALUE;
+ break;
+
+ case RESERVE2:
+ case FREE:
+ case ACTION:
+ case UNDO:
+ break;
+
+ case COMMIT:
+ ipforwarding = (setval == 1);
+ break;
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+
+
+
+int
+write_ipDefaultTTL(int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ static long setval;
+
+ switch ( action ) {
+ case RESERVE1:
+ if (var_val_type != ASN_INTEGER){
+ fprintf(stderr, "write to ipDefaultTTL not ASN_INTEGER\n");
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(setval)){
+ fprintf(stderr,"write to ipDefaultTTL: bad length\n");
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ setval = *(long *)var_val;
+ break;
+
+ case RESERVE2:
+ case FREE:
+ case ACTION:
+ case UNDO:
+ break;
+
+ case COMMIT:
+ ip_defttl = setval;
+ break;
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+
+// ---------------------------------------------------------------------------
+// writing these is not supported. The templates from mib2c are retained.
+//
+//NOTSUPPORTED:
+#if 0
+int
+write_ipNetToMediaIfIndex(int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ static long *long_ret;
+ int size;
+
+
+ switch ( action ) {
+ case RESERVE1:
+ if (var_val_type != ASN_INTEGER){
+ fprintf(stderr, "write to ipNetToMediaIfIndex not ASN_INTEGER\n");
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(long_ret)){
+ fprintf(stderr,"write to ipNetToMediaIfIndex: bad length\n");
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ break;
+
+
+ case RESERVE2:
+ size = var_val_len;
+ long_ret = (long *) var_val;
+
+
+ break;
+
+
+ case FREE:
+ /* Release any resources that have been allocated */
+ break;
+
+
+ case ACTION:
+ /* The variable has been stored in long_ret for
+ you to use, and you have just been asked to do something with
+ it. Note that anything done here must be reversable in the UNDO case */
+ break;
+
+
+ case UNDO:
+ /* Back out any changes made in the ACTION case */
+ break;
+
+
+ case COMMIT:
+ /* Things are working well, so it's now safe to make the change
+ permanently. Make sure that anything done here can't fail! */
+ break;
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+
+
+
+int
+write_ipNetToMediaPhysAddress(int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ static unsigned char string[SPRINT_MAX_LEN];
+ int size;
+
+
+ switch ( action ) {
+ case RESERVE1:
+ if (var_val_type != ASN_OCTET_STR){
+ fprintf(stderr, "write to ipNetToMediaPhysAddress not ASN_OCTET_STR\n");
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(string)){
+ fprintf(stderr,"write to ipNetToMediaPhysAddress: bad length\n");
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ break;
+
+
+ case RESERVE2:
+ size = var_val_len;
+ //string = (char *) var_val;
+
+
+ break;
+
+
+ case FREE:
+ /* Release any resources that have been allocated */
+ break;
+
+
+ case ACTION:
+ /* The variable has been stored in string for
+ you to use, and you have just been asked to do something with
+ it. Note that anything done here must be reversable in the UNDO case */
+ break;
+
+
+ case UNDO:
+ /* Back out any changes made in the ACTION case */
+ break;
+
+
+ case COMMIT:
+ /* Things are working well, so it's now safe to make the change
+ permanently. Make sure that anything done here can't fail! */
+ break;
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+
+
+
+int
+write_ipNetToMediaNetAddress(int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ static unsigned char string[SPRINT_MAX_LEN];
+ int size;
+
+
+ switch ( action ) {
+ case RESERVE1:
+ if (var_val_type != ASN_IPADDRESS){
+ fprintf(stderr, "write to ipNetToMediaNetAddress not ASN_IPADDRESS\n");
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(string)){
+ fprintf(stderr,"write to ipNetToMediaNetAddress: bad length\n");
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ break;
+
+
+ case RESERVE2:
+ size = var_val_len;
+ //string = (char *) var_val;
+
+
+ break;
+
+
+ case FREE:
+ /* Release any resources that have been allocated */
+ break;
+
+
+ case ACTION:
+ /* The variable has been stored in string for
+ you to use, and you have just been asked to do something with
+ it. Note that anything done here must be reversable in the UNDO case */
+ break;
+
+
+ case UNDO:
+ /* Back out any changes made in the ACTION case */
+ break;
+
+
+ case COMMIT:
+ /* Things are working well, so it's now safe to make the change
+ permanently. Make sure that anything done here can't fail! */
+ break;
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+
+
+
+int
+write_ipNetToMediaType(int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ static long *long_ret;
+ int size;
+
+
+ switch ( action ) {
+ case RESERVE1:
+ if (var_val_type != ASN_INTEGER){
+ fprintf(stderr, "write to ipNetToMediaType not ASN_INTEGER\n");
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(long_ret)){
+ fprintf(stderr,"write to ipNetToMediaType: bad length\n");
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ break;
+
+
+ case RESERVE2:
+ size = var_val_len;
+ long_ret = (long *) var_val;
+
+
+ break;
+
+
+ case FREE:
+ /* Release any resources that have been allocated */
+ break;
+
+
+ case ACTION:
+ /* The variable has been stored in long_ret for
+ you to use, and you have just been asked to do something with
+ it. Note that anything done here must be reversable in the UNDO case */
+ break;
+
+
+ case UNDO:
+ /* Back out any changes made in the ACTION case */
+ break;
+
+
+ case COMMIT:
+ /* Things are working well, so it's now safe to make the change
+ permanently. Make sure that anything done here can't fail! */
+ break;
+ }
+ return SNMP_ERR_NOERROR;
+}
+
+#endif
+// ---------------------------------------------------------------------------
+
+// EOF ip.c
Index: v2_0/src/mibgroup/mibII/udp.c
===================================================================
--- v2_0/src/mibgroup/mibII/udp.c (nonexistent)
+++ v2_0/src/mibgroup/mibII/udp.c (revision 1765)
@@ -0,0 +1,324 @@
+//==========================================================================
+//
+// snmp/snmpagent/current/src/mibgroup/mibII/udp.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt, Andrew Lunn
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* This file was generated by mib2c and is intended for use as a mib module
+ for the ucd-snmp snmpd agent. */
+
+#include
+
+/* This should always be included first before anything else */
+#include
+
+/* minimal include directives */
+#include "mibincl.h"
+#include "mibgroup/util_funcs.h"
+#include "mibgroup/mibII/udp.h"
+
+#include
+
+#define _KERNEL
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/*
+ * udp_variables_oid:
+ * this is the top level oid that we want to register under. This
+ * is essentially a prefix, with the suffix appearing in the
+ * variable below.
+ */
+
+
+oid udp_variables_oid[] = { 1,3,6,1,2,1,7 };
+
+
+/*
+ * variable4 udp_variables:
+ * this variable defines function callbacks and type return information
+ * for the udp mib section
+ */
+
+
+struct variable4 udp_variables[] = {
+/* magic number , variable type , ro/rw , callback fn , L, oidsuffix */
+#define UDPINDATAGRAMS 1
+ { UDPINDATAGRAMS , ASN_COUNTER , RONLY , var_udp, 1, { 1 } },
+#define UDPNOPORTS 2
+ { UDPNOPORTS , ASN_COUNTER , RONLY , var_udp, 1, { 2 } },
+#define UDPINERRORS 3
+ { UDPINERRORS , ASN_COUNTER , RONLY , var_udp, 1, { 3 } },
+#define UDPOUTDATAGRAMS 4
+ { UDPOUTDATAGRAMS , ASN_COUNTER , RONLY , var_udp, 1, { 4 } },
+#define UDPLOCALADDRESS 7
+ { UDPLOCALADDRESS , ASN_IPADDRESS , RONLY , var_udpTable, 3, { 5,1,1 } },
+#define UDPLOCALPORT 8
+ { UDPLOCALPORT , ASN_INTEGER , RONLY , var_udpTable, 3, { 5,1,2 } },
+
+//#define IPV6UDPIFINDEX 13
+// { IPV6UDPIFINDEX , ASN_INTEGER , RONLY , var_ipv6UdpTable, 3, { 6,1,3 } },
+
+};
+/* (L = length of the oidsuffix) */
+
+
+/*
+ * init_udp():
+ * Initialization routine. This is called when the agent starts up.
+ * At a minimum, registration of your variables should take place here.
+ */
+void init_udp(void) {
+
+
+ /* register ourselves with the agent to handle our mib tree */
+ REGISTER_MIB("udp", udp_variables, variable4,
+ udp_variables_oid);
+
+
+ /* place any other initialization junk you need here */
+}
+
+
+/*
+ * var_udp():
+ * This function is called every time the agent gets a request for
+ * a scalar variable that might be found within your mib section
+ * registered above. It is up to you to do the right thing and
+ * return the correct value.
+ * You should also correct the value of "var_len" if necessary.
+ *
+ * Please see the documentation for more information about writing
+ * module extensions, and check out the examples in the examples
+ * and mibII directories.
+ */
+unsigned char *
+var_udp(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ static long long_ret;
+
+ if (header_generic(vp,name,length,exact,var_len,write_method)
+ == MATCH_FAILED )
+ return NULL;
+
+ switch(vp->magic) {
+ case UDPINDATAGRAMS:
+ long_ret = udpstat.udps_ipackets;
+ return (u_char *) &long_ret;
+ case UDPNOPORTS:
+ long_ret = udpstat.udps_noport;
+ return (u_char *) &long_ret;
+ case UDPOUTDATAGRAMS:
+ long_ret = udpstat.udps_opackets;
+ return (u_char *) &long_ret;
+ case UDPINERRORS:
+ long_ret = udpstat.udps_hdrops + udpstat.udps_badsum +
+ udpstat.udps_badlen;
+ return (u_char *) &long_ret;
+ default:
+ ERROR_MSG("");
+ }
+ return NULL;
+}
+
+
+/*
+ * var_udpTable():
+ * Handle this table separately from the scalar value case.
+ * The workings of this are basically the same as for var_udpTable above.
+ */
+unsigned char *
+var_udpTable(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ static long long_ret;
+ static unsigned char string[SPRINT_MAX_LEN];
+ register struct inpcb *inp;
+ register struct inpcb *low_inp = NULL;
+ oid lowest[16];
+ oid newname[16];
+ u_char *cp;
+ oid *op;
+
+ // This is indexed by local-address, local-port, at 1,3,6,1,2,1,7,5,1,1,
+ // so we get 1,3,6,1,2,1,7,5,1,?,A,B,C,D,port
+ // initial length is 10, out-length is 15,
+ // Address is offsets 10-13, port is offset 14.
+
+ // starting from udbtable, look in
+ // low_pcb->inp_laddr.s_addr
+ // and low_pcb->inp_lport
+
+ /* fill in object part of name for current (less sizeof instance part) */
+ memcpy((char *)newname, (char *)vp->name, (int)vp->namelen * sizeof(oid));
+
+ for (
+#ifdef CYGPKG_NET_OPENBSD_STACK
+ inp = udbtable.inpt_queue.cqh_first;
+ inp != (struct inpcb *)&udbtable.inpt_queue;
+ inp = inp->inp_queue.cqe_next
+#endif
+#ifdef CYGPKG_NET_FREEBSD_STACK
+ inp = udb.lh_first;
+ inp;
+ inp = inp->inp_list.le_next
+#endif
+ ) {
+ cp = (u_char *)&inp->inp_laddr.s_addr;
+ op = newname + 10;
+ *op++ = *cp++;
+ *op++ = *cp++;
+ *op++ = *cp++;
+ *op++ = *cp++;
+
+ newname[14] = ntohs(inp->inp_lport);
+
+ if (exact){
+ if (snmp_oid_compare(newname, 15, name, *length) == 0){
+ memcpy( (char *)lowest,(char *)newname, 15 * sizeof(oid));
+ low_inp = inp;
+ break; /* no need to search further */
+ }
+ } else {
+ if ((snmp_oid_compare(newname, 15, name, *length) > 0) &&
+ (!low_inp || (snmp_oid_compare(newname, 15, lowest, 15) < 0))){
+ /*
+ * if new one is greater than input and closer to input than
+ * previous lowest, save this one as the "next" one.
+ */
+ memcpy( (char *)lowest,(char *)newname, 15 * sizeof(oid));
+ low_inp = inp;
+ }
+ }
+ }
+
+ if ( ! low_inp )
+ return NULL;
+
+ memcpy( (char *)name,(char *)lowest, 15 * sizeof(oid));
+ *length = 15;
+ *var_len = sizeof( long_ret );
+ *write_method = 0;
+
+ switch(vp->magic) {
+
+ case UDPLOCALADDRESS:
+ cp = (u_char *)&low_inp->inp_laddr.s_addr;
+ string[0] = *cp++;
+ string[1] = *cp++;
+ string[2] = *cp++;
+ string[3] = *cp++;
+ *var_len = 4;
+ return (unsigned char *) string;
+
+ case UDPLOCALPORT:
+ long_ret = (long)ntohs(low_inp->inp_lport);
+ return (unsigned char *) &long_ret;
+
+ default:
+ ERROR_MSG("");
+ }
+ return NULL;
+}
+
+
+// EOF udp.c
Index: v2_0/src/mibgroup/mibII/dot3.c
===================================================================
--- v2_0/src/mibgroup/mibII/dot3.c (nonexistent)
+++ v2_0/src/mibgroup/mibII/dot3.c (revision 1765)
@@ -0,0 +1,499 @@
+//==========================================================================
+//
+// snmp/snmpagent/current/src/mibgroup/mibII/dot3.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/* This file was generated by mib2c and is intended for use as a mib module
+ for the ucd-snmp snmpd agent. */
+
+
+/* This should always be included first before anything else */
+#include
+
+
+/* minimal include directives */
+#include "mibincl.h"
+#include "mibgroup/util_funcs.h"
+#include "mibgroup/mibII/dot3.h"
+#include "mibgroup/mibII/ifr_helper.h"
+
+#include
+#include
+#ifdef CYGPKG_NET_FREEBSD_STACK
+#include
+#endif
+
+// Get info about the device
+#include
+
+// These two two acquire all the statistics.
+#include
+#include
+
+/*
+ * dot3_variables_oid:
+ * this is the top level oid that we want to register under. This
+ * is essentially a prefix, with the suffix appearing in the
+ * variable below.
+ */
+
+oid dot3_variables_oid[] = { 1,3,6,1,2,1,10,7 };
+
+
+extern struct ifnet_head ifnet;
+
+
+/*
+ * variable4 dot3_variables:
+ * this variable defines function callbacks and type return information
+ * for the dot3 mib section
+ */
+struct variable4 dot3_variables[] = {
+/* magic number , variable type , ro/rw , callback fn , L, oidsuffix */
+#define DOT3STATSINDEX 3
+ { DOT3STATSINDEX , ASN_INTEGER , RONLY , var_dot3StatsTable, 3, { 2,1,1 } },
+#define DOT3STATSALIGNMENTERRORS 4
+ { DOT3STATSALIGNMENTERRORS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,2 } },
+#define DOT3STATSFCSERRORS 5
+ { DOT3STATSFCSERRORS , ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,3 } },
+#define DOT3STATSSINGLECOLLISIONFRAMES 6
+ { DOT3STATSSINGLECOLLISIONFRAMES, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,4 } },
+#define DOT3STATSMULTIPLECOLLISIONFRAMES 7
+ { DOT3STATSMULTIPLECOLLISIONFRAMES, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,5 } },
+#define DOT3STATSSQETESTERRORS 8
+ { DOT3STATSSQETESTERRORS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,6 } },
+#define DOT3STATSDEFERREDTRANSMISSIONS 9
+ { DOT3STATSDEFERREDTRANSMISSIONS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,7 } },
+#define DOT3STATSLATECOLLISIONS 10
+ { DOT3STATSLATECOLLISIONS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,8 } },
+#define DOT3STATSEXCESSIVECOLLISIONS 11
+ { DOT3STATSEXCESSIVECOLLISIONS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,9 } },
+#define DOT3STATSINTERNALMACTRANSMITERRORS 12
+ { DOT3STATSINTERNALMACTRANSMITERRORS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,10 } },
+#define DOT3STATSCARRIERSENSEERRORS 13
+ { DOT3STATSCARRIERSENSEERRORS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,11 } },
+#define DOT3STATSFRAMETOOLONGS 14
+ { DOT3STATSFRAMETOOLONGS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,13 } },
+#define DOT3STATSINTERNALMACRECEIVEERRORS 15
+ { DOT3STATSINTERNALMACRECEIVEERRORS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,16 } },
+#define DOT3STATSETHERCHIPSET 16
+ { DOT3STATSETHERCHIPSET, ASN_OBJECT_ID , RONLY , var_dot3StatsTable, 3, { 2,1,17 } },
+#define DOT3STATSSYMBOLERRORS 17
+ { DOT3STATSSYMBOLERRORS, ASN_COUNTER , RONLY , var_dot3StatsTable, 3, { 2,1,18 } },
+#define DOT3STATSDUPLEXSTATUS 18
+ { DOT3STATSDUPLEXSTATUS, ASN_INTEGER , RONLY , var_dot3StatsTable, 3, { 2,1,19 } },
+
+// We do not have this histogram available:
+//#define DOT3COLLFREQUENCIES 22
+// { DOT3COLLFREQUENCIES , ASN_COUNTER , RONLY , var_dot3CollTable, 3, { 5,1,3 } },
+
+//UNSUPPORTED: currently we do not get these statistics out
+//#define DOT3CONTROLFUNCTIONSSUPPORTED 25
+// { DOT3CONTROLFUNCTIONSSUPPORTED, ASN_BIT_STR , RONLY , var_dot3ControlTable, 3, { 9,1,1 } },
+//#define DOT3CONTROLINUNKNOWNOPCODES 26
+// { DOT3CONTROLINUNKNOWNOPCODES, ASN_COUNTER , RONLY , var_dot3ControlTable, 3, { 9,1,2 } },
+
+
+//UNSUPPORTED: currently we do not get these statistics out
+//#define DOT3PAUSEADMINMODE 29
+// { DOT3PAUSEADMINMODE , ASN_INTEGER , RWRITE, var_dot3PauseTable, 3, { 10,1,1 } },
+//#define DOT3PAUSEOPERMODE 30
+// { DOT3PAUSEOPERMODE , ASN_INTEGER , RONLY , var_dot3PauseTable, 3, { 10,1,2 } },
+//#define DOT3INPAUSEFRAMES 31
+// { DOT3INPAUSEFRAMES , ASN_COUNTER , RONLY , var_dot3PauseTable, 3, { 10,1,3 } },
+//#define DOT3OUTPAUSEFRAMES 32
+// { DOT3OUTPAUSEFRAMES , ASN_COUNTER , RONLY , var_dot3PauseTable, 3, { 10,1,4 } },
+
+};
+/* (L = length of the oidsuffix) */
+
+
+/*
+ * init_dot3():
+ * Initialization routine. This is called when the agent starts up.
+ * At a minimum, registration of your variables should take place here.
+ */
+void init_dot3(void)
+{
+ /* register ourselves with the agent to handle our mib tree */
+ REGISTER_MIB("dot3", dot3_variables, variable4,
+ dot3_variables_oid);
+
+ /* place any other initialization junk you need here */
+}
+
+
+/*
+ * var_dot3StatsTable():
+ * Handle this table separately from the scalar value case.
+ * The workings of this are basically the same as for var_dot3StatsTable above.
+ */
+unsigned char *
+var_dot3StatsTable(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ static long long_ret;
+ static oid nullobjid[] = { 0,0 };
+ static oid etherobjid[ SNMP_CHIPSET_LEN ];
+
+ register struct ifnet *ifp;
+ int interface_count = 0;
+ int supports_dot3 = 0, i;
+ struct ether_drv_stats x;
+
+ interface_count = cyg_snmp_num_interfaces();
+
+ if ( header_simple_table( vp,name,length,exact,var_len,write_method,
+ interface_count)
+ == MATCH_FAILED )
+ return NULL;
+
+ ifp = cyg_snmp_get_if(name[ (*length)-1 ]);
+
+ if ( ! ifp )
+ return NULL;
+
+ /* If its an ethernet call the IOCTL and see if the device supports
+ dot3. If it does it will return all the values needed */
+ if ( IFT_ETHER == ifp->if_type ) {
+ bzero( &x, sizeof( x ) );
+ if ( NULL != ifp->if_ioctl ) {
+ if (!(*ifp->if_ioctl)(ifp, SIOCGIFSTATSUD, (caddr_t)&x)) {
+ supports_dot3 = x.supports_dot3;
+ }
+ }
+ }
+
+ if ( (IFT_LOOP == ifp->if_type ) ||
+ (IFT_PROPVIRTUAL == ifp->if_type ) ||
+ (!supports_dot3)) {
+ switch(vp->magic) {
+ case DOT3STATSINDEX:
+ long_ret = name[(*length)-1];
+ return (unsigned char *) &long_ret;
+
+ case DOT3STATSETHERCHIPSET:
+ *var_len = sizeof(nullobjid);
+ return (unsigned char *) nullobjid;
+
+ case DOT3STATSDUPLEXSTATUS:
+ long_ret = 1;
+ return (unsigned char *) &long_ret;
+
+ default:
+ long_ret = 0; // a dummy value for most of them
+ return (unsigned char *) &long_ret;
+ }
+ }
+
+ /* If we got here, the device does support dot3 */
+ switch(vp->magic) {
+ case DOT3STATSINDEX:
+ long_ret = name[(*length)-1];
+ return (unsigned char *) &long_ret;
+
+ case DOT3STATSALIGNMENTERRORS:
+ long_ret = x.rx_align_errors;
+ return (unsigned char *) &long_ret;
+
+ case DOT3STATSFCSERRORS:
+ long_ret = x.rx_crc_errors;
+ return (unsigned char *) &long_ret;
+
+ case DOT3STATSSINGLECOLLISIONFRAMES:
+ long_ret = x.tx_single_collisions;
+ return (unsigned char *) &long_ret;
+
+ case DOT3STATSMULTIPLECOLLISIONFRAMES:
+ long_ret = x.tx_mult_collisions;
+ return (unsigned char *) &long_ret;
+
+ case DOT3STATSSQETESTERRORS:
+ long_ret = x.tx_sqetesterrors;
+ return (unsigned char *) &long_ret;
+
+ case DOT3STATSDEFERREDTRANSMISSIONS:
+ long_ret = x.tx_deferred;
+ return (unsigned char *) &long_ret;
+
+ case DOT3STATSLATECOLLISIONS:
+ long_ret = x.tx_late_collisions;
+ return (unsigned char *) &long_ret;
+
+ case DOT3STATSEXCESSIVECOLLISIONS:
+ long_ret = x.tx_max_collisions;
+ return (unsigned char *) &long_ret;
+
+ case DOT3STATSINTERNALMACTRANSMITERRORS:
+ long_ret = x.tx_underrun;
+ return (unsigned char *) &long_ret;
+
+ case DOT3STATSCARRIERSENSEERRORS:
+ long_ret = x.tx_carrier_loss;
+ return (unsigned char *) &long_ret;
+
+ case DOT3STATSFRAMETOOLONGS:
+ long_ret = x.rx_too_long_frames;
+ return (unsigned char *) &long_ret;
+
+ case DOT3STATSINTERNALMACRECEIVEERRORS:
+ long_ret = x.rx_overrun_errors +
+ x.rx_resource_errors;
+ return (unsigned char *) &long_ret;
+
+ case DOT3STATSSYMBOLERRORS:
+ long_ret = x.rx_symbol_errors;
+ return (unsigned char *) &long_ret;
+
+ case DOT3STATSETHERCHIPSET:
+ i = 0;
+ while ( i < sizeof(etherobjid) ) {
+ if ( 0 == (etherobjid[i] = x.snmp_chipset[i]) )
+ break;
+ i++;
+ }
+ *var_len = i;
+ return (unsigned char *) etherobjid;
+
+ case DOT3STATSDUPLEXSTATUS:
+ long_ret = x.duplex;
+ if ( 1 > long_ret || 3 < long_ret )
+ long_ret = 1;
+ return (unsigned char *) &long_ret;
+
+ default:
+ ERROR_MSG("");
+ return NULL;
+ }
+}
+
+
+#if 0 // UNSUPPORTED: we do not have the information for these tables.
+/*
+ * var_dot3ControlTable():
+ * Handle this table separately from the scalar value case.
+ * The workings of this are basically the same as for var_dot3ControlTable above.
+ */
+unsigned char *
+var_dot3ControlTable(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ /* variables we may use later */
+ static long long_ret;
+ static unsigned char string[SPRINT_MAX_LEN];
+ static oid objid[MAX_OID_LEN];
+ static struct counter64 c64;
+ if (header_simple_table(vp,name,length,exact,var_len,write_method, TABLE_SIZE)
+ == MATCH_FAILED )
+ return NULL;
+
+ switch(vp->magic) {
+ case DOT3CONTROLFUNCTIONSSUPPORTED:
+ long_ret = 1;
+ return &long_ret;
+
+ case DOT3CONTROLINUNKNOWNOPCODES:
+ long_ret = 0;
+ return (unsigned char *) &long_ret;
+
+ default:
+ ERROR_MSG("");
+ }
+ return NULL;
+}
+
+/*
+ * var_dot3PauseTable():
+ * Handle this table separately from the scalar value case.
+ * The workings of this are basically the same as for var_dot3PauseTable above.
+ */
+unsigned char *
+var_dot3PauseTable(struct variable *vp,
+ oid *name,
+ size_t *length,
+ int exact,
+ size_t *var_len,
+ WriteMethod **write_method)
+{
+ /* variables we may use later */
+ static long long_ret;
+ static unsigned char string[SPRINT_MAX_LEN];
+ static oid objid[MAX_OID_LEN];
+ static struct counter64 c64;
+
+ if (header_simple_table(vp,name,length,exact,var_len,write_method, TABLE_SIZE)
+ == MATCH_FAILED )
+ return NULL;
+
+ switch(vp->magic) {
+ case DOT3PAUSEADMINMODE:
+ *write_method = write_dot3PauseAdminMode;
+ long_ret = 0;
+ return (unsigned char *) &long_ret;
+
+ case DOT3PAUSEOPERMODE:
+ long_ret = 0;
+ return (unsigned char *) &long_ret;
+
+ case DOT3INPAUSEFRAMES:
+ long_ret = 0;
+ return (unsigned char *) &long_ret;
+
+ case DOT3OUTPAUSEFRAMES:
+ long_ret = 0;
+ return (unsigned char *) &long_ret;
+
+ default:
+ ERROR_MSG("");
+ }
+ return NULL;
+}
+
+
+int
+write_dot3PauseAdminMode(int action,
+ u_char *var_val,
+ u_char var_val_type,
+ size_t var_val_len,
+ u_char *statP,
+ oid *name,
+ size_t name_len)
+{
+ static long *long_ret;
+ int size;
+
+ switch ( action ) {
+ case RESERVE1:
+ if (var_val_type != ASN_INTEGER){
+ fprintf(stderr, "write to dot3PauseAdminMode not ASN_INTEGER\n");
+ return SNMP_ERR_WRONGTYPE;
+ }
+ if (var_val_len > sizeof(long_ret)){
+ fprintf(stderr,"write to dot3PauseAdminMode: bad length\n");
+ return SNMP_ERR_WRONGLENGTH;
+ }
+ break;
+
+ case RESERVE2:
+ size = var_val_len;
+ long_ret = (long *) var_val;
+ break;
+
+ case FREE:
+ /* Release any resources that have been allocated */
+ break;
+
+ case ACTION:
+ /* The variable has been stored in long_ret for
+ you to use, and you have just been asked to do something with
+ it. Note that anything done here must be reversable in the UNDO case */
+ break;
+
+ case UNDO:
+ /* Back out any changes made in the ACTION case */
+ break;
+
+ case COMMIT:
+ /* Things are working well, so it's now safe to make the change
+ permanently. Make sure that anything done here can't fail! */
+ break;
+ }
+ return SNMP_ERR_NOERROR;
+}
+#endif // UNSUPPORTED
+
+// EOF dot3.c
Index: v2_0/src/mibgroup/mibII/system_mib.c
===================================================================
--- v2_0/src/mibgroup/mibII/system_mib.c (nonexistent)
+++ v2_0/src/mibgroup/mibII/system_mib.c (revision 1765)
@@ -0,0 +1,517 @@
+//==========================================================================
+//
+// ./agent/current/src/mibgroup/mibII/system_mib.c
+//
+//
+//==========================================================================
+//####ECOSGPLCOPYRIGHTBEGIN####
+// -------------------------------------------
+// This file is part of eCos, the Embedded Configurable Operating System.
+// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
+//
+// eCos is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 2 or (at your option) any later version.
+//
+// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with eCos; if not, write to the Free Software Foundation, Inc.,
+// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+//
+// As a special exception, if other files instantiate templates or use macros
+// or inline functions from this file, or you compile this file and link it
+// with other works to produce a work based on this file, this file does not
+// by itself cause the resulting work to be covered by the GNU General Public
+// License. However the source code for this file must still be made available
+// in accordance with section (3) of the GNU General Public License.
+//
+// This exception does not invalidate any other reasons why a work based on
+// this file might be covered by the GNU General Public License.
+//
+// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
+// at http://sources.redhat.com/ecos/ecos-license/
+// -------------------------------------------
+//####ECOSGPLCOPYRIGHTEND####
+//####UCDSNMPCOPYRIGHTBEGIN####
+//
+// -------------------------------------------
+//
+// Portions of this software may have been derived from the UCD-SNMP
+// project, from the University of
+// California at Davis, which was originally based on the Carnegie Mellon
+// University SNMP implementation. Portions of this software are therefore
+// covered by the appropriate copyright disclaimers included herein.
+//
+// The release used was version 4.1.2 of May 2000. "ucd-snmp-4.1.2"
+// -------------------------------------------
+//
+//####UCDSNMPCOPYRIGHTEND####
+//==========================================================================
+//#####DESCRIPTIONBEGIN####
+//
+// Author(s): hmt
+// Contributors: hmt
+// Date: 2000-05-30
+// Purpose: Port of UCD-SNMP distribution to eCos.
+// Description:
+//
+//
+//####DESCRIPTIONEND####
+//
+//==========================================================================
+/********************************************************************
+ Copyright 1989, 1991, 1992 by Carnegie Mellon University
+
+ Derivative Work -
+Copyright 1996, 1998, 1999, 2000 The Regents of the University of California
+
+ 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 appears in all copies and
+that both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of CMU and The Regents of
+the University of California not be used in advertising or publicity
+pertaining to distribution of the software without specific written
+permission.
+
+CMU AND THE REGENTS OF THE UNIVERSITY OF CALIFORNIA DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL CMU OR
+THE REGENTS OF THE UNIVERSITY OF CALIFORNIA BE LIABLE FOR ANY SPECIAL,
+INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+FROM THE 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.
+*********************************************************************/
+/*
+ * System MIB group implementation - system.c
+ *
+ */
+
+#include
+#if HAVE_STDLIB_H
+#include
+#endif
+#if HAVE_UNISTD_H
+#include