1smi_config(3)         SMI Management Information Library         smi_config(3)
2
3
4

NAME

6       smiInit,  smiExit, smiSetErrorLevel, smiGetFlags, smiSetFlags, smiLoad‐
7       Module, smiGetPath, smiSetPath, smiReadConfig - SMI library  configura‐
8       tion routines
9

SYNOPSIS

11       #include <smi.h>
12
13
14       int smiInit(const char *tag);
15
16       int smiExit();
17
18       void smiSetErrorLevel(int level);
19
20       int smiGetFlags();
21
22       void smiSetFlags(int userflags);
23
24       char *smiLoadModule(char *module);
25
26       int smiIsLoaded(char *module);
27
28       char *smiGetPath();
29
30       int smiSetPath(char *path);
31
32       int smiSetSeverity(char *pattern, int severity);
33
34       int smiReadConfig(char *filename, const char *tag);
35
36       void smiSetErrorHandler(SmiErrorHandler *smiErrorHandler);
37
38       typedef void (SmiErrorHandler) (char *path, int line,
39                           int severity, char *msg, char *tag);
40
41

DESCRIPTION

43       These  functions  provide some initialization and adjustment operations
44       for the SMI library.
45
46       The smiInit() function should be the first SMI function  called  in  an
47       application.  It  initializes  its  internal  structures. If tag is not
48       NULL, the global configuration file and (on UNIX systems) a  user  con‐
49       figuration file are read implicitly, if existent. All global statements
50       and those statements with a tag (a ``tag: '' prefix) that  matches  the
51       tag argument are executed.  (see also CONFIGURATION FILES below).  smi‐
52       Init() returns zero on success, or otherwise a negative value.
53
54       The smiInit() function can also be used to support multiple sets of MIB
55       data.  In this case, the tag argument may be prepended by a colon and a
56       name to differentiate the data sets. Any library function  call  subse‐
57       quent  to  an  smiInit("tag:dataset")  call is using the specified data
58       set.
59
60       The smiExit() function should be called when the application no  longer
61       needs any SMI information to release any allocated SMI resources.
62
63       The  smiSetErrorLevel()  function  sets the pedantic level (0-9) of the
64       SMI parsers of the SMI library,  currently  SMIv1/v2  and  SMIng.   The
65       higher  the  level,  the  louder it complains. Values up to 3 should be
66       regarded as errors, higher level could be interpreted as warnings.  But
67       note  that  this  classification  is  some kind of personal taste.  The
68       default level is 0, since usually only MIB  checkers  want  to  tune  a
69       higher level.
70
71       The  smiGetFlags()  and smiSetFlags() functions allow to fetch, modify,
72       and set some userflags that control the SMI  library's  behaviour.   If
73       SMI_FLAG_ERRORS  is  not  set,  no error messages are printed at all to
74       keep the SMI library totally quiet, which might be mandatory  for  some
75       applications.  If SMI_FLAG_STATS is set, the library prints some module
76       statistics. If SMI_FLAG_RECURSIVE is set, the  library  also  complains
77       about  errors  in  modules  that  are read due to import statements. If
78       SMI_FLAG_NODESCR is set, no  description  and  references  strings  are
79       stored  in  memory.  This  may  save a huge amount of memory in case of
80       applications that do not need this information.
81
82       The smiSetSeverity() function allows to set the severity of  all  error
83       that have name prefixed by pattern to the value severity.
84
85       The  smiLoadModule()  function  specifies an additional MIB module that
86       the application claims to know or an  additional  file  path  to  read.
87       Only  after  a  module  is  made known through this function, iterating
88       retrieval functions and retrieval  functions  without  fully  qualified
89       identifiers  will  return  results  from  this  module. smiLoadModule()
90       returns the name of the loaded module, of  NULL  if  it  could  not  be
91       loaded.
92
93       The smiIsLoaded() function returns a positive value if the module named
94       module is already loaded, or zero otherwise.
95
96       The smiGetPath() and smiSetPath() functions allow to fetch, modify, and
97       set  the path that is used to search MIB modules.  smiGetPath() returns
98       a copy of the current search path in the form "DIR1:DIR2:...", or  NULL
99       if no path is set.  The application should free this string if it is no
100       longer needed. smiSetPath() sets the search path to path.
101
102       The smiReadConfig() function reads  the  configuration  file  filename.
103       All  global  statements  in the configuration file and those statements
104       with a tag (a ``tag: '' prefix)  that  matches  the  tag  argument,  if
105       present, are executed.
106
107       The  smiSetErrorHandler()  function  allows  to set a callback function
108       that is called by the MIB parsers deviating from  the  builtin  default
109       error  handler, that prints error messages to stderr. The error handler
110       has to comply with the SmiErrorHandler function type. The  path,  line,
111       severity, msg, and tag arguements carry the module's pathname, the line
112       number within the module, the error severity  level,  a  textual  error
113       message, and a short error name of the error being reported.
114

MODULE LOCATIONS

116       The  SMI  library  may  retrieve  MIB  modules  from different kinds of
117       resources. Currently, SMIv1/v2 and SMIng module  files  are  supported.
118       If  in an smiLoadModule() function call a module is specified by a path
119       name (identified by containing at least one dot  or  slash  character),
120       this is assumed to be the exact file to read. Otherwise, if a module is
121       identified by its plain module name,  the  correspondant  file  (either
122       SMIv1/2  or  SMIng)  is searched along a path. This path is initialized
123       with
124       /usr/share/mibs/ietf:/usr/share/mibs/iana:/usr/share/mibs/irtf:/usr/share/mibs/site:/usr/share/mibs/tubs:/usr/share/pibs/ietf:/usr/share/pibs/site:/usr/share/pibs/tubs.
125       Afterwards the optional global and user configuration files are  parsed
126       for `path' commands, and finally the optional SMIPATH environment vari‐
127       able is evaluated. The `path'  command  argument  and  the  environment
128       variable either start with a path separator character (`:' on UNIX-like
129       systems, `;' on MS-Windows systems) to append to the path, or end  with
130       a  path  separator  character to prepend to the path, or otherwise com‐
131       pletely replace the path.  The path  can  also  be  controlled  by  the
132       smiGetPath() and smiSetPath() functions (see above).
133
134       When  files  are  searched  by  a given module name, they might have no
135       extension or one of the extensions `.my', `.smiv2',  `.sming',  `.mib',
136       or `.txt'. However, the MIB module language is identified by the file's
137       content, not by its file name extension.
138

CONFIGURATION FILES

140       SMI library configuration files read at initialization and on demand by
141       smiReadConfig()  have  a  simple  line oriented syntax. Empty lines and
142       those starting with `#' are ignored. Other lines start with an optional
143       tag (prepended by a colon), followed by a command and options dependent
144       on the command. Tags are used to limit the scope of a command to  those
145       applications that are using this tag.
146
147       The  load  command  is  used to preload a given MIB module. If multiple
148       modules shall be preloaded, multiple load commands must be used.
149
150       The path command allows to prepend or append components to the MIB mod‐
151       ule  search  path or to modify it completely (see also MODULE LOCATIONS
152       above).
153
154       The cache command allows to add an additional directory for MIB  module
155       lookup as a last resort. The first argument specifies the directory and
156       the rest of the line starting from the second  argument  specifies  the
157       caching  method,  which is invoked with the MIB module name appended if
158       the module is found neither in one of the regular  directories  nor  in
159       the cache directory beforehand.
160
161       The level command sets the error level.
162
163       The  hide  command allows to tune the list of errors that are reported.
164       It raises all errors with names prefixed by the given pattern to sever‐
165       ity level 9. [Currently, there is no way to list the error names. RTFS:
166       error.c.]
167
168       Example configuration:
169
170         #
171         # $HOME/.smirc
172         #
173
174         # add a private directory
175         path :/usr/home/strauss/lib/mibs
176
177         # don't show any errors by default
178         level 0
179
180         # preload some basic modules
181         load SNMPv2-SMI
182         load SNMPv2-TC
183         load SNMPv2-CONF
184
185         # want to make smilint shout
186         smilint: level 8
187
188         # but please don't claim about
189         # any names longer than 32 chars
190         smilint: hide namelength-32
191
192         tcpdump: load DISMAN-SCRIPT-MIB
193
194         smiquery: load IF-MIB
195         smiquery: load DISMAN-SCRIPT-MIB
196

FILES

198       /etc/smi.conf    global configuration file
199       $HOME/.smirc               user configuration file
200       /usr/include/smi.h   SMI library header file
201       /usr/share/mibs/     SMI module repository directory
202

SEE ALSO

204       libsmi(3), smi.h
205

AUTHOR

207       (C)    1999-2001    Frank    Strauss,    TU    Braunschweig,    Germany
208       <strauss@ibr.cs.tu-bs.de>
209
210
211
212IBR                             August 22, 2001                  smi_config(3)
Impressum