smi_type(3)
smi_type(3) β SMI type information routines
Okay so bestie, let me tell you about the SMI Management Information Library. This page covers all the type info routines and honestly it's giving main character energy for anyone working with SMI. Let's get into it. π
SYNOPSIS
#include <smi.h>
SmiType *smiGetType(SmiModule *smiModulePtr, char *type);
SmiType *smiGetFirstType(SmiModule *smiModulePtr);
SmiType *smiGetNextType(SmiType *smiTypePtr);
SmiType *smiGetParentType(SmiType *smiTypePtr);
int smiGetTypeLine(SmiType *smiTypePtr);
SmiRange *smiGetFirstRange(SmiType *smiTypePtr);
SmiRange *smiGetNextRange(SmiRange *smiRangePtr);
SmiNamedNumber *smiGetFirstNamedNumber(SmiType *smiTypePtr);
SmiNamedNumber *smiGetNextNamedNumber(SmiNamedNumber *smiNamedNumberPtr);
SmiModule *smiGetTypeModule(SmiType *smiTypePtr);
And here are the structs you'll be working with, no cap:
typedef struct SmiType {
SmiIdentifier name;
SmiBasetype basetype;
SmiDecl decl;
char *format;
SmiValue value;
char *units;
SmiStatus status;
char *description;
char *reference;
} SmiType;
typedef struct SmiNamedNumber {
SmiIdentifier name;
SmiValue value;
} SmiNamedNumber;
typedef struct SmiRange {
SmiValue minValue;
SmiValue maxValue;
} SmiRange;
DESCRIPTION
Okay so these functions are literally your besties for pulling info on a type definition (that's SMIng), or a simple ASN.1 type definition (SMIv1/v2), or a TEXTUAL-CONVENTION definition (SMIv2). And plot twist: you can also grab base types with these same functions. Obsessed. β¨
smiGetType()β This one retrieves astruct SmiTypethat represents a type. The type argument can be either a fully qualified descriptor or just a simple type name. IfsmiModulePtris notNULL, it's used to limit the search to that specific module. And if the type isn't found?smiGetType()returnsNULL. Sad but true. πsmiGetFirstType()andsmiGetNextType()β These two are your iteration besties for pullingstruct SmiTypesone by one.smiGetFirstType()returns the first one defined in the module specified bysmiModulePtr. Then every call tosmiGetNextType()gives you the next one. And when there are no more type definitions in the module?NULLis returned. That's it, that's the end. πsmiGetParentType()β Okay so this function retrieves astruct SmiTypeof the type that the type specified bysmiTypePtris derived from. But if there's no parent type (meaning the type specified bysmiTypePtris already a base type), it just returnsNULL. No parents, no problem. π«ΆsmiGetFirstRange()andsmiGetNextRange()β Same iteration vibe, but forstruct SmiRangesthat represent range restrictions of the type specified bysmiTypePtr. That's either size ranges of an octet string type or value ranges if it's a numeric type. Get those ranges, bestie. π₯smiGetFirstNamedNumber()andsmiGetNextNamedNumber()β Again with the iteration, this time forstruct SmiNamedNumbersthat represent named numbers of the type specified bysmiTypePtr. Heads up though: that type has to be either a bit set or an enumeration type. No exceptions, periodt. πsmiGetTypeModule()β This one returns the module that defines the type given bystruct SmiTypePtr. Find that module, queen. πsmiGetTypeLine()β And this one returns the line number within the module where the type specified bysmiTypePtris defined. So you know exactly where it lives. Iconic. β
FILES
${prefix}/include/smi.hβ the SMI library header file. That's where everything lives. πΈ
SEE ALSO
libsmi(3), smi_module(3), smi.h β go check these out too, bestie. Iykyk. π
AUTHOR
(C) 1999-2001 Frank Strauss, TU Braunschweig, Germany <strauss@ibr.cs.tu-bs.de>
IBR, August 16, 2001, smi_type(3) β and that's the whole vibe, bestie. Slay. π β¨π¦
π¦ where this page comes from
- alpine 3.24: libsmi-doc 0.5.0-r5 Β· BSD-3-Clause AND MIT
- nixos 26.05: libsmi 0.5.0
- nixpkgs unstable: libsmi 0.5.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms