URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Subversion Repositories openrisc_me
[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [snmp/] [agent/] [v2_0/] [utils/] [mib2c/] [mib2c.conf] - Rev 307
Go to most recent revision | Compare with Previous | Blame | View Log
#
# 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:
Go to most recent revision | Compare with Previous | Blame | View Log