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 a struct SmiType that represents a type. The type argument can be either a fully qualified descriptor or just a simple type name. If smiModulePtr is not NULL, it's used to limit the search to that specific module. And if the type isn't found? smiGetType() returns NULL. Sad but true. 😭
  • smiGetFirstType() and smiGetNextType() β€” These two are your iteration besties for pulling struct SmiTypes one by one. smiGetFirstType() returns the first one defined in the module specified by smiModulePtr. Then every call to smiGetNextType() gives you the next one. And when there are no more type definitions in the module? NULL is returned. That's it, that's the end. πŸ’…
  • smiGetParentType() β€” Okay so this function retrieves a struct SmiType of the type that the type specified by smiTypePtr is derived from. But if there's no parent type (meaning the type specified by smiTypePtr is already a base type), it just returns NULL. No parents, no problem. 🫢
  • smiGetFirstRange() and smiGetNextRange() β€” Same iteration vibe, but for struct SmiRanges that represent range restrictions of the type specified by smiTypePtr. That's either size ranges of an octet string type or value ranges if it's a numeric type. Get those ranges, bestie. πŸ”₯
  • smiGetFirstNamedNumber() and smiGetNextNamedNumber() β€” Again with the iteration, this time for struct SmiNamedNumbers that represent named numbers of the type specified by smiTypePtr. 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 by struct SmiTypePtr. Find that module, queen. πŸ‘‘
  • smiGetTypeLine() β€” And this one returns the line number within the module where the type specified by smiTypePtr is 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