xref: /6.6.0/sigar/src/os/solaris/get_mib2.h (revision 42d0b984)
1/*
2 * get_mib2.h -- definitions for the get_mib2() function
3 *
4 * V. Abell <abe@cc.purdue.edu>
5 * Purdue University Computing Center
6 */
7
8
9/*
10 * Copyright 1995 Purdue Research Foundation, West Lafayette, Indiana
11 * 47907.  All rights reserved.
12 *
13 * Written by Victor A. Abell <abe@cc.purdue.edu>
14 *
15 * This software is not subject to any license of the American Telephone
16 * and Telegraph Company or the Regents of the University of California.
17 *
18 * Permission is granted to anyone to use this software for any purpose on
19 * any computer system, and to alter it and redistribute it freely, subject
20 * to the following restrictions:
21 *
22 * 1. Neither Victor A  Abell nor Purdue University are responsible for
23 *    any consequences of the use of this software.
24 *
25 * 2. The origin of this software must not be misrepresented, either by
26 *    explicit claim or by omission.  Credit to Victor A. Abell and Purdue
27 *    University must appear in documentation and sources.
28 *
29 * 3. Altered versions must be plainly marked as such, and must not be
30 *    misrepresented as being the original software.
31 *
32 * 4. This notice may not be removed or altered.
33 */
34
35/*
36 * Altered for sigar:
37 * - remove static stuff to make thread-safe by Doug MacEachern (3/11/05)
38 */
39
40#if     !defined(GET_MIB2_H)
41#define GET_MIB2_H
42
43
44/*
45 * Required header files
46 */
47
48#include <stropts.h>
49#include <sys/types.h>
50#include <sys/socket.h>
51#include <sys/stream.h>
52#include <sys/tihdr.h>
53#include <sys/tiuser.h>
54#include <inet/mib2.h>
55#include <inet/led.h>
56
57
58/*
59 * Miscellaneous definitions
60 */
61
62#define GET_MIB2_ARPDEV         "/dev/arp"      /* ARP stream devi9ce */
63#define GET_MIB2_ERRMSGL        1024            /* ErrMsg buffer length */
64#define GET_MIB2_TCPSTREAM      "tcp"           /* TCP stream name */
65#define GET_MIB2_UDPSTREAM      "udp"           /* UDP stream name */
66
67
68/*
69 * get_mib2() response codes
70 *
71 *      -1              End of MIB2 information
72 *       0              Next MIB2 structure returned
73 *      >0              Error code
74 */
75
76#define GET_MIB2_EOD            -1      /* end of data */
77#define GET_MIB2_OK             0       /* function succeeded */
78#define GET_MIB2_ERR_ACK        1       /* getmsg() ACK error received */
79#define GET_MIB2_ERR_ARPOPEN    2       /* error opening ARPDEV */
80#define GET_MIB2_ERR_CLOSE      3       /* MIB2 access close error */
81#define GET_MIB2_ERR_GETMSGD    4       /* error getting message data */
82#define GET_MIB2_ERR_GETMSGR    5       /* error getting message reply */
83#define GET_MIB2_ERR_NODATA     6       /* data expected; not received */
84#define GET_MIB2_ERR_NOSPC      7       /* no malloc() space */
85#define GET_MIB2_ERR_NOTOPEN    8       /* MIB2 access not open */
86#define GET_MIB2_ERR_OPEN       9       /* MIB2 access open error */
87#define GET_MIB2_ERR_PUTMSG     10      /* error putting request message */
88#define GET_MIB2_ERR_TCPPUSH    11      /* error pushing TCPSTREAM */
89#define GET_MIB2_ERR_UDPPUSH    12      /* error pushing UDPSTREAM */
90
91#define GET_MIB2_ERR_MAX        13      /* maximum error number + 1 */
92
93
94typedef struct {
95    char *db;       /* data buffer */
96    int db_len;     /* data buffer length */
97    char *smb;      /* stream message buffer */
98    size_t smb_len; /* size of Smb[] */
99    int sd;         /* stream device descriptor */
100    char errmsg[GET_MIB2_ERRMSGL];      /* error message buffer */
101    struct T_optmgmt_ack *op_ack;       /* message ACK pointer */
102    struct strbuf ctlbuf;               /* streams control buffer */
103    struct T_error_ack *err_ack;        /* message error pointer */
104    struct opthdr *op;                  /* message option pointer */
105    struct T_optmgmt_req *req;          /* message request pointer */
106} solaris_mib2_t;
107
108/*
109 * Function prototypes
110 */
111
112int close_mib2(                         /* close acccess to MIB2 information */
113        solaris_mib2_t *mib2
114        );
115int get_mib2(                           /* get MIB2 information */
116        solaris_mib2_t *mib2,
117        struct opthdr **opt,                    /* opthdr pointer return (see
118                                                 * <sys/socket.h> */
119        char **data,                            /* data buffer return address */
120        int *datalen                            /* data buffer length return
121                                                 * address */
122        );
123int open_mib2(                          /* open acccess to MIB2 information */
124        solaris_mib2_t *mib2
125        );
126
127#endif  /* !defined(GET_MIB2_H) */
128