Blame local/mib2c-conf.d/mfd-readme.m2c

Packit fcad23
########################################################################
Packit fcad23
## generic include for XXX. Don't use directly.
Packit fcad23
##
Packit fcad23
########################################################################
Packit fcad23
@if $m2c_mark_boundary == 1@
Packit fcad23
/** START code generated by mfd-readme.m2c */
Packit fcad23
@end@
Packit fcad23
########################################################################
Packit fcad23
##
Packit fcad23
@open ${name}-README-FIRST.txt@
Packit fcad23
************************************************************************
Packit fcad23
${name} README
Packit fcad23
------------------------------------------------------------------------
Packit fcad23
This document describes the results of the mib2c code generation
Packit fcad23
system using the mfd code generation template.  The resulting files
Packit fcad23
are documented both in this README file as well as per-table specific
Packit fcad23
README files.  All of the files generated by this run of mib2c will
Packit fcad23
begin with the ${name} prefix.
Packit fcad23
Packit fcad23
Quick Start
Packit fcad23
-----------
Packit fcad23
For those interested in a quick start, to get a pseudo-todo list, try
Packit fcad23
this command in directory with the generated code:
Packit fcad23
Packit fcad23
 grep -n "TODO:" *.[ch] | sed 's/\([^ ]*\) \(.*\)TODO\(.*\)/\3 (\1)/' | sort -n
Packit fcad23
Packit fcad23
Key:
Packit fcad23
  :o: Optional
Packit fcad23
  :r: Recommended
Packit fcad23
  :M: Mandatory
Packit fcad23
  :A: Advanced users
Packit fcad23
Packit fcad23
This will give you and ordered list of places in the code that you
Packit fcad23
may (or must) take a closer look at).
Packit fcad23
Packit fcad23
You may also want to take a look at the on-line tutorial, found here:
Packit fcad23
Packit fcad23
    http://www.net-snmp.org/tutorial/tutorial-5/toolkit/mfd/index.html
Packit fcad23
Packit fcad23
Packit fcad23
MIBs For Dummies Overview
Packit fcad23
-------------------------
Packit fcad23
The MIBs For Dummies (MFD) configuration files have been written to help
Packit fcad23
SNMP novices implement SNMP MIBs. This section will be a brief
Packit fcad23
introduction to some of the general concepts you should be familar with.
Packit fcad23
Packit fcad23
  Managed Information Base (MIB)
Packit fcad23
  ------------------------------
Packit fcad23
  A SNMP MIB (Managed information base) is a text file that describes the
Packit fcad23
  syntax for some set of data objects. The MIB creates a correlation
Packit fcad23
  between an ASCII name for an object and a number OID (Object Identifier).
Packit fcad23
  The SNMP protocol communicates information using the OIDs, and the MIB
Packit fcad23
  allows tools to display a name, which we humans find easier to deal with.
Packit fcad23
Packit fcad23
  To use an analogy, a MIB is much like a menu at a restaurant. If you've
Packit fcad23
  ever been to a reataurant and ordered a meal, and later received a bill
Packit fcad23
  that simply had '#6' on it, you get the idea. The name is easier for
Packit fcad23
  the customers to remember, and the waiters and chefs use the number for
Packit fcad23
  efficency.
Packit fcad23
Packit fcad23
Packit fcad23
    Scalars
Packit fcad23
    -------
Packit fcad23
    A scalar variable is a unique object in a MIB which can represent
Packit fcad23
    a single value. For example, the SNMP standard MIB-II defines a
Packit fcad23
    variable, sysContact.0, which is a string containing the contact
Packit fcad23
    information for the person in charge of a particular agent. Note
Packit fcad23
    that scalar variable always end with '.0'.
Packit fcad23
    
Packit fcad23
Packit fcad23
    Rows and Tables
Packit fcad23
    ---------------
Packit fcad23
    When a group of related attributes occur more than once, they can be
Packit fcad23
    grouped together in a table. A table has an index, which uniquely
Packit fcad23
    identifies a particular row, and data columns, which contain the
Packit fcad23
    attributes for that row.
Packit fcad23
Packit fcad23
    For example, the SNMP standard MIB-II defines a table, ifTable, which
Packit fcad23
    contains information on the ethernet interfaces on a system.
Packit fcad23
    
Packit fcad23
Packit fcad23
  Data Structures
Packit fcad23
  ---------------
Packit fcad23
  The code generated by the MFD configuration files has a few important
Packit fcad23
  structures.
Packit fcad23
Packit fcad23
Packit fcad23
    The Data Context
Packit fcad23
    ----------------
Packit fcad23
    The data context structure should contain the necessary information
Packit fcad23
    to provide the data for the columns in a given row. As long as you
Packit fcad23
    can extract the data for a column for the data context, the data context
Packit fcad23
    can be anything you want: a pointer to an existing structure, the
Packit fcad23
    parameters needed for a function call or an actual copy of the data.
Packit fcad23
Packit fcad23
    By default, a data context structure is generated with storage for
Packit fcad23
    all the data in a row. Information on changing the default is presented
Packit fcad23
    later on in this help.
Packit fcad23
Packit fcad23
Packit fcad23
    The MIB Context
Packit fcad23
    ---------------
Packit fcad23
    The MIB context structure is generated with storage for all the
Packit fcad23
    indexes of a table. This data will be used when searching for the
Packit fcad23
    correct row to process for a request.
Packit fcad23
Packit fcad23
Packit fcad23
    The Row Request Context
Packit fcad23
    -----------------------
Packit fcad23
    Each table will have a unique data structure for holding data during
Packit fcad23
    the processing of a particular row. The row request context contains
Packit fcad23
    the registration context (that you supply during initilization),
Packit fcad23
    the data context, the MIB context, the undo context (for settable
Packit fcad23
    tables) and other data. There is also a netsnmp_data_list, which can
Packit fcad23
    be used to temporary storage during processing.
Packit fcad23
Packit fcad23
Packit fcad23
    The Table Registration Pointer
Packit fcad23
    ------------------------------
Packit fcad23
    During initilization, you may provide a pointer to arbitrary data for
Packit fcad23
    you own use. This pointer will be saved in the row request context,
Packit fcad23
    and is passed as a parameter to several functions. It is not required,
Packit fcad23
    and is provided as a way for you to access table specific data in
Packit fcad23
    the generated code.
Packit fcad23
Packit fcad23
Packit fcad23
Packit fcad23
These files are top-level files potentially useful for all the tables: 
Packit fcad23
------------------------------------------------------------------------
Packit fcad23
Packit fcad23
  File    : ${name}_Makefile
Packit fcad23
  ----------------------------------------------------------------------
Packit fcad23
  Purpose : Make file for compiling a (sub)agent.  This file is only
Packit fcad23
            useful if you don't want to compile your code directly
Packit fcad23
            into the Net-SNMP master agent.
Packit fcad23
  Editable: Optional
Packit fcad23
  Usage   : make -f ${name}_Makefile
Packit fcad23
Packit fcad23
Packit fcad23
  File    : ${name}_subagent.c
Packit fcad23
  ----------------------------------------------------------------------
Packit fcad23
  Purpose : This file contains a main() function for an agent or
Packit fcad23
            sub-agent and is compiled using the Makefile above.
Packit fcad23
Packit fcad23
Packit fcad23
Packit fcad23
Packit fcad23
Table specific README files
Packit fcad23
------------------------------------------------------------------------
Packit fcad23
Each table for which code was generated has its own README file
Packit fcad23
describing the files specifically associated with each table.  You
Packit fcad23
should probably read these next:
Packit fcad23
Packit fcad23
@foreach $table table@
Packit fcad23
@    include m2c_setup_table.m2i@
Packit fcad23
   ${name}-README-${table}.txt
Packit fcad23
@end@
Packit fcad23
Packit fcad23
Packit fcad23
Packit fcad23
These are miscellaneous auto-generated code files you generally
Packit fcad23
shouldn't edit.  They contain code that ties your code together with
Packit fcad23
the Net-SNMP agent.
Packit fcad23
------------------------------------------------------------------------
Packit fcad23
@if $m2c_create_fewer_files == 1@
Packit fcad23
  File    : ${name}.c
Packit fcad23
  Purpose : Initilization for the entire module set, including the
Packit fcad23
            SNMP tables.
Packit fcad23
Packit fcad23
@end@
Packit fcad23
  File    : ${name}.h
Packit fcad23
  Purpose : Header file for the module set.  Includes config_require
Packit fcad23
            macros to auto-load the other code pieces when compiled
Packit fcad23
            into the agent.
Packit fcad23
Packit fcad23
@if $m2c_create_fewer_files != 1@
Packit fcad23
  File    : ${name}_oids.h
Packit fcad23
  Purpose : C #define definitions of the tables, columns, and OIDs
Packit fcad23
Packit fcad23
  File    : ${name}_enums.h
Packit fcad23
  Purpose : C #define definitions of the enumerated type values for
Packit fcad23
            each column of each table that requires them.
Packit fcad23
@else@
Packit fcad23
  File    : ${name}_constants.h
Packit fcad23
  Purpose : C #define definitions of the tables, columns, OIDs, enumerated
Packit fcad23
            type values for each column of each table that requires them.
Packit fcad23
@end@
Packit fcad23
Packit fcad23
  File    : ${name}_interface.c
Packit fcad23
  Purpose : MFD interface to Net-SNMP.  This auto-generated code ties the
Packit fcad23
            functions you will fill out to the code that the agent needs.
Packit fcad23
Packit fcad23
########################################################################
Packit fcad23
@foreach $table table@
Packit fcad23
@    include m2c_setup_table.m2i@
Packit fcad23
@    open ${name}-README-${table}.txt@
Packit fcad23
************************************************************************
Packit fcad23
${context} README
Packit fcad23
------------------------------------------------------------------------
Packit fcad23
  This readme file describes the code generated by mib2c (using the MIBs
Packit fcad23
  for Dummies (MFD) configuration file). The code generated was
Packit fcad23
  generated specifically for the following SNMP table:
Packit fcad23
Packit fcad23
     ${context}
Packit fcad23
Packit fcad23
  Your code will be called when the snmp agent receives requests for
Packit fcad23
  the ${context} table.  The agent will start by looking for the right
Packit fcad23
  row in your existing data to operate on, if one exists.
Packit fcad23
Packit fcad23
Packit fcad23
  Configuration Variables
Packit fcad23
  ------------------------------------------------------------
Packit fcad23
  Some variables used for code generation may be set to affect the code
Packit fcad23
  generation. You may override these variables by setting them in the
Packit fcad23
  file ${m2c_defaults_dir}table-${context}.m2d, and then re-running mib2c.
Packit fcad23
Packit fcad23
    m2c_table_settable (currently '$m2c_table_settable')
Packit fcad23
    --------------------------------------------------------
Packit fcad23
    This variable determines whether or not code is generated to support
Packit fcad23
    MIB object which have an access of read-write or read-create. The
Packit fcad23
    default is set based on whether or not the table contains writable
Packit fcad23
    objects, but can be over-ridden.
Packit fcad23
Packit fcad23
    Syntax: @eval $@m2c_table_settable = 0@
Packit fcad23
Packit fcad23
Packit fcad23
    m2c_table_dependencies (currently '$m2c_table_dependencies')
Packit fcad23
    --------------------------------------------------------
Packit fcad23
    This variable determines whether or not code is generated to support
Packit fcad23
    checking dependencies between columns, rows or tables. The default
Packit fcad23
    is set based on whether or not the table contains writable objects,
Packit fcad23
    but can be over-ridden.
Packit fcad23
Packit fcad23
    Syntax: @eval $@m2c_table_dependencies = 0@
Packit fcad23
Packit fcad23
Packit fcad23
    m2c_table_row_creation (currently '$m2c_table_row_creation')
Packit fcad23
    --------------------------------------------------------
Packit fcad23
    This variable determines whether or not code is generated to support
Packit fcad23
    checking creation of new rows via SNMP. The default is set based on
Packit fcad23
    whether or not the table contains read-create objects, but can be
Packit fcad23
    over-ridden.
Packit fcad23
Packit fcad23
    Syntax: @eval $@m2c_table_row_creation = 0@
Packit fcad23
Packit fcad23
Packit fcad23
    m2c_context_reg (currently '$m2c_context_reg')
Packit fcad23
    --------------------------------------------------------
Packit fcad23
    This variable contains the structure name to typedef for the
Packit fcad23
    ${context}_registration.
Packit fcad23
Packit fcad23
    During initilization, you will provide a pointer to a structure of
Packit fcad23
    this type. This pointer is used as a parameter to many functions so
Packit fcad23
    that you have access to your registration data. The default is a
Packit fcad23
    netsnmp_data_list pointer, which will allow you to keep multiple
Packit fcad23
    pointers tagged by a text name. If you have a new or existing structure
Packit fcad23
    you would rather use, you can redefine this variable.
Packit fcad23
    
Packit fcad23
Packit fcad23
    To avoid regenerating code, you may also change this typedef directly
Packit fcad23
    in the ${table}.h header.
Packit fcad23
Packit fcad23
    Syntax: @eval $@m2c_context_reg = "struct my_registration_context@
Packit fcad23
Packit fcad23
Packit fcad23
    m2c_data_context (currently '$m2c_data_context')
Packit fcad23
    --------------------------------------------------------
Packit fcad23
    This variable contains the structure name to typedef for the
Packit fcad23
    ${context}_data.
Packit fcad23
Packit fcad23
    This typedef is used in the row request context structure for the table,
Packit fcad23
    ${context}_rowreq_ctx.
Packit fcad23
Packit fcad23
    The typedef in the primary table context will be used for the data and
Packit fcad23
    undo structure types. This structure should contain all the data
Packit fcad23
    needed for all the columns in the table. The default is 'generated',
Packit fcad23
    which will cuase a new data strcuture to be generated with data members
Packit fcad23
    for each column.
Packit fcad23
Packit fcad23
    To avoid regenerating code, you may also change this typedef directly
Packit fcad23
    in the ${table}.h header.
Packit fcad23
Packit fcad23
    Syntax: @eval $@m2c_data_context = "struct my_data_context"@
Packit fcad23
Packit fcad23
Packit fcad23
    m2c_data_allocate (currently '$m2c_data_allocate')
Packit fcad23
    --------------------------------------------------------
Packit fcad23
    This variable determines whether or not the data context (see above)
Packit fcad23
    requires memory to be allocated. The default generated data structure
Packit fcad23
    does not. If you are using a custom data context which needs to
Packit fcad23
    allocate memory, override this value and two additional functions
Packit fcad23
    will be generated:
Packit fcad23
Packit fcad23
      ${context}_allocate_data
Packit fcad23
      ${context}_release_data
Packit fcad23
Packit fcad23
    Syntax: @eval $@m2c_data_allocate = 1@
Packit fcad23
Packit fcad23
Packit fcad23
    m2c_data_init (currently '$m2c_data_init')
Packit fcad23
    --------------------------------------------------------
Packit fcad23
    This variable determines whether or not the data context (see above)
Packit fcad23
    or any other items you have added to the table context requires
Packit fcad23
    initialization. The default generated data structure does not. If you
Packit fcad23
    are using a custom data context or have added items needing initialization
Packit fcad23
    to the table context, override this value and two additional functions
Packit fcad23
    will be generated:
Packit fcad23
Packit fcad23
      ${context}_rowreq_ctx_init
Packit fcad23
      ${context}_rowreq_ctx_cleanup
Packit fcad23
Packit fcad23
    Syntax: @eval $m2c_data_init = 1@
Packit fcad23
Packit fcad23
Packit fcad23
    m2c_table_access (currently '$m2c_table_access')
Packit fcad23
    ------------------------------------------------------------------
Packit fcad23
    This variable determines which data interface will be use to generate
Packit fcad23
    code for looking up data for a given index. The default is the
Packit fcad23
    'container-cached' access code, which caches the data in a netsnmp-
Packit fcad23
    container (usually a sorted array).
Packit fcad23
Packit fcad23
    Available options can be determined by checking for mib2c configuration
Packit fcad23
    files that begin with 'mfd-access-*'.
Packit fcad23
Packit fcad23
    Syntax: @eval $@m2c_table_access = '$m2c_table_access'@
Packit fcad23
Packit fcad23
 
Packit fcad23
    m2c_include_examples (currently '$m2c_include_examples')
Packit fcad23
    ------------------------------------------------------------------
Packit fcad23
    This variable determines whether or not to generate example code. The
Packit fcad23
    default is to generate example code.
Packit fcad23
Packit fcad23
    Syntax: @eval $@m2c_include_examples = 0@
Packit fcad23
Packit fcad23
Packit fcad23
    m2c_data_transient (currently '$m2c_data_transient')
Packit fcad23
    ------------------------------------------------------------------
Packit fcad23
    This variable determines how the generated example code deals with the
Packit fcad23
    data during data lookup. See the table readme file for details on how
Packit fcad23
    the current table access method interprets this value. In general,
Packit fcad23
    a value of 0 indicates persistent data, 1 indicates semi-transient and
Packit fcad23
    2 indicates transient data.
Packit fcad23
Packit fcad23
    Syntax: @eval $@m2c_data_transient = 0@
Packit fcad23
Packit fcad23
Packit fcad23
 Index(es) for the ${context} table
Packit fcad23
  ------------------------------------------------------------
Packit fcad23
  The index(es) for the ${context} table are:
Packit fcad23
Packit fcad23
@foreach $node index@
Packit fcad23
@    include m2c_setup_node.m2i@
Packit fcad23
     $node:
Packit fcad23
        Syntax:      $node.syntax
Packit fcad23
        DataType:    $node.perltype
Packit fcad23
        ASN type:    $node.type
Packit fcad23
        C-code type: $m2c_decl
Packit fcad23
@end@ # foreach
Packit fcad23
Packit fcad23
  You should know how to set all these values from your data context,
Packit fcad23
  ${context}_data.
Packit fcad23
Packit fcad23
Packit fcad23
************************************************************************
Packit fcad23
${context} File Overview
Packit fcad23
------------------------------------------------------------------------
Packit fcad23
  Several files have been generated to implement the ${context}
Packit fcad23
  table. We'll go through these files, one by one, explaining each and
Packit fcad23
  letting you know which you need to edit.
Packit fcad23
Packit fcad23
Packit fcad23
File: ${name}_data_access.[c|h]
Packit fcad23
------------------------------------------------------------------------
Packit fcad23
  The ${name}_data_access file contains the interface to your data in
Packit fcad23
  its raw format.  These functions are used to build the row cache or 
Packit fcad23
  locate the row (depending on the table access method).
Packit fcad23
Packit fcad23
  Set MIB context
Packit fcad23
  -----------------
Packit fcad23
  TODO : Set MIB index values
Packit fcad23
  FUNC : ${context}_indexes_set
Packit fcad23
  WHERE: ${context}_data_access.c
Packit fcad23
Packit fcad23
  This is a convenience function for setting the index context from
Packit fcad23
  the native C data. Where necessary, value mapping should be done.
Packit fcad23
Packit fcad23
@if $mfd_readme_verbose == 1@
Packit fcad23
  This function should update the table index values (found in
Packit fcad23
  tbl_idx) for the given raw data.
Packit fcad23
Packit fcad23
@end@
Packit fcad23
  
Packit fcad23
@    eval $m2c_processing_type = 'r'@
Packit fcad23
@    include mfd-access-${m2c_table_access}-defines.m2i@
Packit fcad23
Packit fcad23
Packit fcad23
@if $m2c_create_fewer_files != 1@
Packit fcad23
File: ${name}_enums.h
Packit fcad23
@else@
Packit fcad23
File: ${name}_constants.h
Packit fcad23
@end@
Packit fcad23
------------------------------------------------------------------------
Packit fcad23
  This file contains macros for mapping enumeration values when the
Packit fcad23
  enumerated values defined by the MIB do not match the values used
Packit fcad23
  internally.
Packit fcad23
Packit fcad23
  Review this file to see if any values need to be updated.
Packit fcad23
Packit fcad23
Packit fcad23
@if $m2c_create_fewer_files != 1@
Packit fcad23
File: ${name}_data_get.c
Packit fcad23
@else@
Packit fcad23
File: ${name}.c; GET support
Packit fcad23
@end@
Packit fcad23
------------------------------------------------------------------------
Packit fcad23
@    if ("$m2c_data_allocate" eq "yes") && ("$m2c_data_context" ne "generated")@
Packit fcad23
  Allocate data context
Packit fcad23
  ---------------------
Packit fcad23
  TODO : allocate memory for a data context
Packit fcad23
  FUNC : ${context}_allocate_data
Packit fcad23
Packit fcad23
  This function will be called to allocate memory for a data context
Packit fcad23
  when a new row request context is being created, or to create an
Packit fcad23
  undo context while processing a set request.
Packit fcad23
Packit fcad23
  Release data context
Packit fcad23
  -------
Packit fcad23
  TODO : release memory allocated for a data context
Packit fcad23
  FUNC : ${context}_release_data
Packit fcad23
Packit fcad23
  This function will be called to release any resources held by a
Packit fcad23
  data or undo context. It will be called when a row request context
Packit fcad23
  is released, or during cleanup after a set request.
Packit fcad23
Packit fcad23
Packit fcad23
@    end@
Packit fcad23
@    foreach $node index@
Packit fcad23
@        include m2c_setup_node.m2i@
Packit fcad23
@        if ($m2c_skip_mapping != 1)@
Packit fcad23
  Map native data to MIB format
Packit fcad23
  -----------------------------
Packit fcad23
  TODO : convert data from its native format to the format required by the MIB
Packit fcad23
  FUNC : ${node}_map
Packit fcad23
Packit fcad23
  This function should map between the native format of the node data to
Packit fcad23
  the format or values required by the MIB. For example, a C boolean value
Packit fcad23
  for a MIB node with the TruthValue syntax needs to map the value C
Packit fcad23
  false(0) to TruthValue false(2).
Packit fcad23
Packit fcad23
@        end@ #// skip mapping
Packit fcad23
@    end@ // foreach index
Packit fcad23
@    foreach $node nonindex@
Packit fcad23
@        include m2c_setup_node.m2i@
Packit fcad23
@        if ($m2c_skip_mapping != 1)@
Packit fcad23
  Map native data to MIB format
Packit fcad23
  -----------------------------
Packit fcad23
  TODO : convert data from its native format to the format required by the MIB
Packit fcad23
  FUNC : ${node}_map
Packit fcad23
Packit fcad23
  This function should map between the native format of the node data to
Packit fcad23
  the format or values required by the MIB. For example, a C boolean value
Packit fcad23
  for a MIB node with the TruthValue syntax needs to map the value C
Packit fcad23
  false(0) to TruthValue false(2).
Packit fcad23
Packit fcad23
@        end@ #// skip mapping
Packit fcad23
  Get data for column
Packit fcad23
  -------------------
Packit fcad23
  TODO : retrieve column data from raw data
Packit fcad23
  FUNC : ${node}_get
Packit fcad23
Packit fcad23
@      ifconf syntax-$node.syntax-readme.m2i@
Packit fcad23
@          include syntax-$node.syntax-readme.m2i@
Packit fcad23
@      elsif ($node.enums == 1) && ("$node.perltype" eq "BITS")@
Packit fcad23
  Since this column has enumerated BITS, you should update or replace the
Packit fcad23
  IS_SET_* macros to properly determine whether or not a particular bit
Packit fcad23
  should be set.
Packit fcad23
Packit fcad23
@      end@
Packit fcad23
@   end@
Packit fcad23
Packit fcad23
Packit fcad23
@if $m2c_create_fewer_files != 1@
Packit fcad23
File: ${name}_data_set.c
Packit fcad23
@else@
Packit fcad23
File: ${name}.c; SET support
Packit fcad23
@end@
Packit fcad23
------------------------------------------------------------------------
Packit fcad23
Packit fcad23
@if $m2c_table_settable == 0@
Packit fcad23
  This table does not support set requests.
Packit fcad23
@else@
Packit fcad23
  This code was generated based on the following assumptions or settings:
Packit fcad23
Packit fcad23
@   if $m2c_table_dependencies == 1@
Packit fcad23
  1) None of the values for this table have DEPENDENCIES on other objects.
Packit fcad23
@   else@
Packit fcad23
  1) Some of the values for this table have DEPENDENCIES on other objects.
Packit fcad23
@   end@
Packit fcad23
Packit fcad23
@   if $mfd_readme_verbose != 0@
Packit fcad23
  DEPENDENCIES on other objects complicates SET request processing. When
Packit fcad23
  one or more columns in a table depend on another object (in the same
Packit fcad23
  table, or in another table), a DEPENDENCY exists. For example, if you
Packit fcad23
  have a table that determine a color with three columns (red, green and
Packit fcad23
  blue) that define the percentage of each primary color, the total for
Packit fcad23
  the three columns must equal 100 percent. So, in addition to checking
Packit fcad23
  that each colums has a valid value between 0 and 100, the total of
Packit fcad23
  all three columns must equal 100.
Packit fcad23
Packit fcad23
  Set $@m2c_table_dependencies = 0 in ${m2c_defaults_dir}table-${table}.m2d
Packit fcad23
  and regenerate code if this assumption is incorrect.
Packit fcad23
@   end@
Packit fcad23
Packit fcad23
@if $m2c_table_row_creation == 1@
Packit fcad23
  2) This table supports ROW CREATION.
Packit fcad23
@else@
Packit fcad23
  2) This table does not support ROW CREATION.
Packit fcad23
@end@
Packit fcad23
Packit fcad23
@if $mfd_readme_verbose != 0@
Packit fcad23
  Supporting ROW CREATION allows new rows to be created via SNMP requests.
Packit fcad23
@end@
Packit fcad23
@if $m2c_table_row_creation == 1@
Packit fcad23
Packit fcad23
  To support row creation, the index component of an incoming set request must
Packit fcad23
  be validated. A funciton is generated for each individual index component,
Packit fcad23
  and another for validating all the index components together.
Packit fcad23
Packit fcad23
@    foreach $node externalindex@
Packit fcad23
@        include m2c_setup_node.m2i@
Packit fcad23
  Validate external index
Packit fcad23
  -----------------------
Packit fcad23
  TODO : validate the specified external index component
Packit fcad23
  FUNC : ${context}_${node}_check_index
Packit fcad23
Packit fcad23
@    end@ # foreach externalindex
Packit fcad23
Packit fcad23
@    foreach $node internalindex@
Packit fcad23
@        include m2c_setup_node.m2i@
Packit fcad23
  Validate index component
Packit fcad23
  ------------------------
Packit fcad23
  TODO : validate the specified index component
Packit fcad23
  FUNC : ${node}_check_index
Packit fcad23
Packit fcad23
@    end@
Packit fcad23
Packit fcad23
  Validate index
Packit fcad23
  --------------
Packit fcad23
  TODO : check that all index components are valid
Packit fcad23
  FUNC : ${context}_validate_index
Packit fcad23
@end@
Packit fcad23
Packit fcad23
Packit fcad23
@   if $m2c_table_dependencies == 1@
Packit fcad23
  Check dependencies
Packit fcad23
  ------------------
Packit fcad23
  TODO : check that all dependencies have been satisfied
Packit fcad23
  FUNC : ${context}_check_dependencies
Packit fcad23
Packit fcad23
  This function will be called after all the individual columns have been
Packit fcad23
  set to their new values. Check for any dependencies between rows or
Packit fcad23
  tables in this function.
Packit fcad23
Packit fcad23
@   end@
Packit fcad23
Packit fcad23
  Undo setup
Packit fcad23
  ----------
Packit fcad23
  TODO : save data for undo
Packit fcad23
  FUNC : ${context}_undo_setup
Packit fcad23
Packit fcad23
  This function will be called before the individual undo_setup functions are
Packit fcad23
  called. This is where you should save any undo information which is not
Packit fcad23
  directly related to a particular column. This function will only be called
Packit fcad23
  once per row. After this function is called, any column which is being
Packit fcad23
  set will have its individual node undo_setup function called.
Packit fcad23
Packit fcad23
Packit fcad23
Packit fcad23
@    foreach $node nonindex@
Packit fcad23
@        include m2c_setup_node.m2i@
Packit fcad23
@        if $node.settable == 0@
Packit fcad23
@            next@ # skip to next column
Packit fcad23
@        end@
Packit fcad23
  Check value for column
Packit fcad23
  ----------------------
Packit fcad23
  TODO : perform additional validations on values for a set request
Packit fcad23
  FUNC : ${node}_check_value
Packit fcad23
Packit fcad23
  The generated code will automatically validate incoming requests against
Packit fcad23
  all the requirements specified by the syntax of the MIB. However, it is
Packit fcad23
  often the case that additional requirements are specified in the
Packit fcad23
  description of a MIB object. Those type of validations should be checked
Packit fcad23
  in this function.
Packit fcad23
Packit fcad23
Packit fcad23
  Undo setup for column
Packit fcad23
  ---------------------
Packit fcad23
  TODO : save the value for column
Packit fcad23
  FUNC : ${node}_undo_setup
Packit fcad23
Packit fcad23
  After the table level undo setup function has been called, the individual
Packit fcad23
  node undo setup functions will be called for columns which are being set.
Packit fcad23
Packit fcad23
Packit fcad23
  Set value for column
Packit fcad23
  --------------------
Packit fcad23
  TODO : set the value for column
Packit fcad23
  FUNC : ${node}_set
Packit fcad23
Packit fcad23
  After all the validations have been passed, this function will be called to
Packit fcad23
  set the new value.
Packit fcad23
Packit fcad23
Packit fcad23
  Undo value for column
Packit fcad23
  ---------------------
Packit fcad23
  TODO : undo set for column
Packit fcad23
  FUNC : ${node}_undo
Packit fcad23
Packit fcad23
  If an error occurs after a column has been set, this function will be called
Packit fcad23
  to undo the set and restore the previous state.
Packit fcad23
Packit fcad23
@    end@ # nonindex
Packit fcad23
Packit fcad23
Packit fcad23
  Commit changes
Packit fcad23
  --------------
Packit fcad23
  TODO : commit changes
Packit fcad23
  FUNC : ${context}_commit
Packit fcad23
Packit fcad23
  After all values have been set, the commit function will be called.
Packit fcad23
Packit fcad23
Packit fcad23
@   if $m2c_irreversible_commit == 1@
Packit fcad23
  Commit irreversible changes
Packit fcad23
  ---------------------------
Packit fcad23
  FUNC: ${context}_irreversible_commit
Packit fcad23
Packit fcad23
  This special mode is reserved for committing changes which can not be undone.
Packit fcad23
  (e.g. launching a rocket). It is called after all normal commits have
Packit fcad23
  succeeded.
Packit fcad23
@   end@
Packit fcad23
Packit fcad23
@end@ # settable
Packit fcad23
Packit fcad23
Packit fcad23
************************************************************************
Packit fcad23
${context} Reference
Packit fcad23
------------------------------------------------------------------------
Packit fcad23
Packit fcad23
Function flow
Packit fcad23
----------------------------------------------------
Packit fcad23
To give you the general idea of how the functions flow works, this
Packit fcad23
example flow is from a complete table implementation.
Packit fcad23
Packit fcad23
NOTE: Depending on your configuration, some of the functions used in the
Packit fcad23
      examples below  may not have been generated for the
Packit fcad23
      ${context} table.
Packit fcad23
Packit fcad23
      Conversely, the examples below may not include some functions that
Packit fcad23
      were generated for the ${context} table.
Packit fcad23
Packit fcad23
To watch the flow of the ${context} table, use the
Packit fcad23
following debug tokens:
Packit fcad23
Packit fcad23
        snmp_agent
Packit fcad23
        helper:table:req
Packit fcad23
        ${context}
Packit fcad23
        verbose:${context}
Packit fcad23
        internal:${context}
Packit fcad23
Packit fcad23
e.g.
Packit fcad23
        snmpd -f -Le -D${context},verbose:${context},internal:${context}
Packit fcad23
Packit fcad23
Packit fcad23
@if $m2c_create_fewer_files == 1@
Packit fcad23
@   eval $tmp_mfd_rm_set = "xxx.c"@
Packit fcad23
@   eval $tmp_mfd_rm_get = "xxx.c"@
Packit fcad23
@else@
Packit fcad23
@   eval $tmp_mfd_rm_set = "xxx_data_set.c"@
Packit fcad23
@   eval $tmp_mfd_rm_get = "xxx_data_get.c"@
Packit fcad23
@end@
Packit fcad23
Initialization
Packit fcad23
--------------------------------
Packit fcad23
init_xxxTable: called                           xxx.c
Packit fcad23
   initialize_table_xxxTable                    xxx.c
Packit fcad23
      _xxxTable_initialize_interface            xxx_interface.c
Packit fcad23
         xxxTable_init_data                     xxx_data_access.c
Packit fcad23
      _xxxTable_container_init                  xxx_interface.c
Packit fcad23
         xxxTable_container_init                xxx_data_access.c
Packit fcad23
Packit fcad23
Packit fcad23
GET Request
Packit fcad23
--------------------------------
Packit fcad23
_cache_load                                     xxx_interface.c
Packit fcad23
   xxxTable_cache_load                          xxx_data_access.c
Packit fcad23
      xxxTable_allocate_rowreq_ctx              xxx_interface.c
Packit fcad23
         xxxTable_allocate_data                 $tmp_mfd_rm_get
Packit fcad23
         xxxTable_rowreq_ctx_init               $tmp_mfd_rm_get
Packit fcad23
      xxxTable_indexes_set                      $tmp_mfd_rm_get
Packit fcad23
         xxxTable_indexes_set_tbl_idx           $tmp_mfd_rm_get
Packit fcad23
Packit fcad23
xxxTable_pre_request                              
Packit fcad23
Packit fcad23
_mfd_xxxTable_object_lookup                     xxx_interface.c
Packit fcad23
   xxxTable_row_prep                            xxx_data_access.c
Packit fcad23
Packit fcad23
_mfd_xxxTable_get_values                        xxx_interface.c
Packit fcad23
   _mfd_xxxTable_get_column                     xxx_interface.c
Packit fcad23
      yyy_get                                   $tmp_mfd_rm_get
Packit fcad23
Packit fcad23
xxxTable_post_request
Packit fcad23
Packit fcad23
Packit fcad23
GETNEXT Request
Packit fcad23
--------------------------------
Packit fcad23
_cache_load                                     ...
Packit fcad23
xxxTable_pre_request                            ...
Packit fcad23
_mfd_xxxTable_object_lookup                     ...
Packit fcad23
_mfd_xxxTable_get_values                        ...
Packit fcad23
xxxTable_post_request                           ...
Packit fcad23
Packit fcad23
Packit fcad23
SET Request: success
Packit fcad23
--------------------------------
Packit fcad23
_cache_load                                     ...
Packit fcad23
xxxTable_pre_request
Packit fcad23
_mfd_xxxTable_object_lookup                     ...
Packit fcad23
Packit fcad23
_mfd_xxxTable_check_objects                     xxx_interface.c
Packit fcad23
   _xxxTable_check_column                       xxx_interface.c
Packit fcad23
      yyy_check_value                           $tmp_mfd_rm_set
Packit fcad23
Packit fcad23
_mfd_xxxTable_undo_setup                        xxx_interface.c
Packit fcad23
   xxxTable_allocate_data                       ...
Packit fcad23
   xxxTable_undo_setup                          xxx_interface.c
Packit fcad23
      _xxxTable_undo_setup_column               xxx_interface.c
Packit fcad23
         yyy_undo_setup                         $tmp_mfd_rm_set
Packit fcad23
Packit fcad23
_mfd_xxxTable_set_values                        xxx_interface.c
Packit fcad23
   _xxxTable_set_column                         xxx_interface.c
Packit fcad23
      yyy_set                                   $tmp_mfd_rm_set
Packit fcad23
Packit fcad23
_mfd_xxxTable_check_dependencies                xxx_interface.c
Packit fcad23
   xxxTable_check_dependencies                  $tmp_mfd_rm_set
Packit fcad23
Packit fcad23
_mfd_xxxTable_commit                            xxx_interface.c
Packit fcad23
   xxxTable_commit                              $tmp_mfd_rm_set
Packit fcad23
Packit fcad23
_mfd_xxxTable_undo_cleanup                      xxx_interface.c
Packit fcad23
   xxxTable_undo_cleanup                        $tmp_mfd_rm_set
Packit fcad23
      xxxTable_release_data                     ...
Packit fcad23
Packit fcad23
xxxTable_post_request                           ...
Packit fcad23
Packit fcad23
Packit fcad23
SET Request: row creation
Packit fcad23
--------------------------------
Packit fcad23
_cache_load                                     ...
Packit fcad23
xxxTable_pre_request
Packit fcad23
Packit fcad23
_mfd_xxxTable_object_lookup                     ...
Packit fcad23
   xxxTable_index_from_oid                      xxx_interface.c
Packit fcad23
   xxxTable_allocate_rowreq_ctx                 ...
Packit fcad23
      ...
Packit fcad23
   _xxxTable_check_indexes                      xxx_interface.c
Packit fcad23
      yyy_check_index                           $tmp_mfd_rm_set
Packit fcad23
      xxxTable_validate_index                   $tmp_mfd_rm_set
Packit fcad23
Packit fcad23
_mfd_xxxTable_check_objects                     ...
Packit fcad23
   _xxxTable_check_column                       ...
Packit fcad23
      yyy_check_value                           ...
Packit fcad23
   _xxxTable_check_column                       ...
Packit fcad23
      yyy_check_value                           ...
Packit fcad23
Packit fcad23
_mfd_xxxTable_undo_setup                        ...
Packit fcad23
_mfd_xxxTable_set_values                        ...
Packit fcad23
_mfd_xxxTable_check_dependencies                ...
Packit fcad23
_mfd_xxxTable_commit                            ...
Packit fcad23
_mfd_xxxTable_undo_cleanup                      ...
Packit fcad23
xxxTable_post_request                           ...
Packit fcad23
Packit fcad23
Packit fcad23
SET Resuest: value error
Packit fcad23
--------------------------------
Packit fcad23
_cache_load                                     ...
Packit fcad23
xxxTable_pre_request                            ...
Packit fcad23
_mfd_xxxTable_object_lookup                     ...
Packit fcad23
Packit fcad23
_mfd_xxxTable_check_objects                     ...
Packit fcad23
   _xxxTable_check_column                       ...
Packit fcad23
      yyy_check_value                           ...
Packit fcad23
      ERROR:"yyy value not supported"
Packit fcad23
Packit fcad23
xxxTable_post_request                           ...
Packit fcad23
Packit fcad23
Packit fcad23
SET Request: commit failure
Packit fcad23
--------------------------------
Packit fcad23
_cache_load                                     ...
Packit fcad23
xxxTable_pre_request                            ...
Packit fcad23
_mfd_xxxTable_object_lookup                     ...
Packit fcad23
_mfd_xxxTable_check_objects                     ...
Packit fcad23
_mfd_xxxTable_undo_setup                        ...
Packit fcad23
_mfd_xxxTable_set_values                        ...
Packit fcad23
_mfd_xxxTable_check_dependencies                ...
Packit fcad23
Packit fcad23
_mfd_xxxTable_commit                            ...
Packit fcad23
   xxxTable_commit                              ...
Packit fcad23
   ERROR: bad rc -1
Packit fcad23
Packit fcad23
_mfd_xxxTable_undo_commit                       xxx_interface.c
Packit fcad23
   xxxTable_undo_commit                         $tmp_mfd_rm_set
Packit fcad23
Packit fcad23
_mfd_xxxTable_undo_values                       xxx_interface.c
Packit fcad23
   _xxxTable_undo_column                        xxx_interface.c
Packit fcad23
      yyy_undo                                  $tmp_mfd_rm_set
Packit fcad23
Packit fcad23
_mfd_xxxTable_undo_cleanup                      ...
Packit fcad23
xxxTable_post_request                           ...
Packit fcad23
Packit fcad23
Packit fcad23
Row release (user initiated)
Packit fcad23
--------------------------------
Packit fcad23
xxxTable_release_rowreq_ctx                     xxx_interface.c
Packit fcad23
   xxxTable_rowreq_ctx_cleanup                  $tmp_mfd_rm_get
Packit fcad23
   xxxTable_release_data                        $tmp_mfd_rm_get
Packit fcad23
Packit fcad23
Packit fcad23
Packit fcad23
Table / column details
Packit fcad23
----------------------------------------------------
Packit fcad23
@    include details-table.m2i@
Packit fcad23
Packit fcad23
@    foreach $node column@
Packit fcad23
@        include m2c_setup_node.m2i@
Packit fcad23
@        include details-node.m2i@
Packit fcad23
@    end@
Packit fcad23
Packit fcad23
@end@ # foreach table
Packit fcad23
Packit fcad23
##
Packit fcad23
########################################################################
Packit fcad23
@if $m2c_mark_boundary == 1@
Packit fcad23
/** END code generated by mfd-readme.m2c */
Packit fcad23
@end@