[BACK]Return to smi.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / snmp

Annotation of src/usr.bin/snmp/smi.h, Revision 1.3

1.3     ! martijn     1: /*     $OpenBSD: smi.h,v 1.2 2020/05/19 13:41:01 martijn Exp $ */
1.1       martijn     2:
                      3: /*
                      4:  * Copyright (c) 2019 Martijn van Duren <martijn@openbsd.org>
                      5:  * Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org>
                      6:  *
                      7:  * Permission to use, copy, modify, and distribute this software for any
                      8:  * purpose with or without fee is hereby granted, provided that the above
                      9:  * copyright notice and this permission notice appear in all copies.
                     10:  *
                     11:  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     12:  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     13:  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     14:  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     15:  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     16:  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     17:  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
                     18:  */
                     19:
                     20: #include <sys/tree.h>
                     21: #include <sys/queue.h>
                     22:
                     23: #define OID_ROOT               0x00
                     24: #define OID_RD                 0x01
                     25: #define OID_WR                 0x02
                     26: #define OID_IFSET              0x04    /* only if user-specified value */
                     27: #define OID_DYNAMIC            0x08    /* free allocated data */
                     28: #define OID_TABLE              0x10    /* dynamic sub-elements */
                     29: #define OID_MIB                        0x20    /* root-OID of a supported MIB */
                     30: #define OID_KEY                        0x40    /* lookup tables */
                     31: #define        OID_REGISTERED          0x80    /* OID registered by subagent */
                     32:
                     33: #define OID_RS                 (OID_RD|OID_IFSET)
                     34: #define OID_WS                 (OID_WR|OID_IFSET)
                     35: #define OID_RW                 (OID_RD|OID_WR)
                     36: #define OID_RWS                        (OID_RW|OID_IFSET)
                     37:
                     38: #define OID_TRD                        (OID_RD|OID_TABLE)
                     39: #define OID_TWR                        (OID_WR|OID_TABLE)
                     40: #define OID_TRS                        (OID_RD|OID_IFSET|OID_TABLE)
                     41: #define OID_TWS                        (OID_WR|OID_IFSET|OID_TABLE)
                     42: #define OID_TRW                        (OID_RD|OID_WR|OID_TABLE)
                     43: #define OID_TRWS               (OID_RW|OID_IFSET|OID_TABLE)
                     44:
                     45: enum smi_output_string {
                     46:        smi_os_default,
                     47:        smi_os_hex,
                     48:        smi_os_ascii
                     49: };
                     50:
                     51: enum smi_oid_lookup {
                     52:        smi_oidl_numeric,
                     53:        smi_oidl_short,
                     54:        smi_oidl_full
                     55: };
                     56:
                     57: struct oid {
                     58:        struct ber_oid           o_id;
                     59: #define o_oid                   o_id.bo_id
                     60: #define o_oidlen                o_id.bo_n
                     61:
1.3     ! martijn    62:        const char              *o_name;
        !            63:        const char              *o_tcname;
        !            64:        struct textconv         *o_textconv;
1.1       martijn    65:
                     66:        RB_ENTRY(oid)            o_element;
                     67:        RB_ENTRY(oid)            o_keyword;
                     68: };
                     69:
1.3     ! martijn    70: struct textconv {
        !            71:        const char              *tc_name;
        !            72:        const char              *tc_display_hint;
        !            73:        unsigned int             tc_syntax;
        !            74:        RB_ENTRY(textconv)       tc_entry;
        !            75: };
        !            76:
1.1       martijn    77: int smi_init(void);
                     78: unsigned int smi_application(struct ber_element *);
                     79: int smi_string2oid(const char *, struct ber_oid *);
                     80: char *smi_oid2string(struct ber_oid *, char *, size_t, enum smi_oid_lookup);
                     81: void smi_mibtree(struct oid *);
1.3     ! martijn    82: void smi_textconvtree(struct textconv *);
1.2       martijn    83: struct oid *smi_foreach(struct oid *);
1.3     ! martijn    84: void smi_debug_elements(struct ber_element *, int);
        !            85: char *smi_print_element(struct ber_oid *, struct ber_element *, int,
        !            86:     enum smi_output_string, enum smi_oid_lookup, int);