|
|
1.1 root 1: /* mib.c - MIB realization */
2:
3: #ifndef lint
4: static char *rcsid = "$Header: /f/osi/snmp/RCS/mib.c,v 7.5 90/07/09 14:48:50 mrose Exp $";
5: #endif
6:
7: /*
8: * $Header: /f/osi/snmp/RCS/mib.c,v 7.5 90/07/09 14:48:50 mrose Exp $
9: *
10: * Contributed by NYSERNet Inc. This work was partially supported by the
11: * U.S. Defense Advanced Research Projects Agency and the Rome Air Development
12: * Center of the U.S. Air Force Systems Command under contract number
13: * F30602-88-C-0016.
14: *
15: *
16: * $Log: mib.c,v $
17: * Revision 7.5 90/07/09 14:48:50 mrose
18: * sync
19: *
20: * Revision 7.4 90/05/13 16:18:11 mrose
21: * views
22: *
23: * Revision 7.3 90/02/27 18:49:45 mrose
24: * unix stuff
25: *
26: * Revision 7.2 90/02/17 10:38:19 mrose
27: * smux
28: *
29: * Revision 7.1 90/01/11 18:34:14 mrose
30: * real-sync
31: *
32: * Revision 7.0 89/11/23 22:23:12 mrose
33: * Release 6.0
34: *
35: */
36:
37: /*
38: * NOTICE
39: *
40: * Acquisition, use, and distribution of this module and related
41: * materials are subject to the restrictions of a license agreement.
42: * Consult the Preface in the User's Manual for the full terms of
43: * this agreement.
44: *
45: */
46:
47:
48: #include <stdio.h>
49: #include "mib.h"
50: #ifdef BSD42
51: #include <sys/file.h>
52: #endif
53: #ifdef SYS5
54: #include <fcntl.h>
55: #endif
56:
57: /* DATA */
58:
59: static int kd;
60:
61:
62: struct nlist nl[] = {
63: { "_arptab" },
64: { "_arptab_size" },
65: { "_boottime" },
66: { "_icmpstat" },
67: { "_ifnet" },
68: { "_ipforwarding" },
69: { "_ipstat" },
70: { "_rthashsize" },
71: { "_rthost" },
72: { "_rtnet" },
73: { "_tcb" },
74: { "_tcpstat" },
75: { "_udb" },
76: { "_udpstat" },
77: { "_rtstat" },
78: #ifdef BSD44
79: { "_radix_node_head" },
80: { "_iso_systype" },
81: { "_clnp_stat" },
82: { "_esis_stat" },
83: #endif
84:
85: NULL
86: };
87:
88: /* */
89:
90: readmib () {
91: register struct nlist *nz;
92:
93: if (nlist ("/vmunix", nl) == NOTOK)
94: adios ("/vmunix", "unable to nlist");
95: for (nz = nl; nz -> n_name; nz++)
96: if (nz -> n_value == 0)
97: advise (LLOG_EXCEPTIONS, NULLCP, "\"%s\" not in /vmunix (warning)",
98: nz -> n_name);
99:
100: if ((kd = open ("/dev/kmem", O_RDONLY)) == NOTOK)
101: adios ("/vmunix", "unable to read");
102:
103: init_system (); /* Internet-standard MIB */
104: init_interfaces ();
105: init_ip ();
106: init_icmp ();
107: init_tcp ();
108: init_udp ();
109:
110: init_clnp (); /* experimental CLNP group */
111: }
112:
113: /* */
114:
115: checkmib () {
116: register OT ot;
117:
118: for (ot = text2obj ("ccitt"); ot; ot = ot -> ot_next)
119: if (ot -> ot_status == OT_MANDATORY
120: && ot -> ot_getfnx == o_generic
121: && ot -> ot_info == NULL)
122: advise (LLOG_EXCEPTIONS, NULLCP,
123: "variable \"%s.0\" has no value (warning)", ot -> ot_text);
124: }
125:
126: /* */
127:
128: set_variable (name, newvalue)
129: char *name,
130: *newvalue;
131: {
132: caddr_t value;
133: register OT ot = text2obj (name);
134: register OS os;
135:
136: if (ot == NULLOT) {
137: advise (LLOG_EXCEPTIONS, NULLCP, "unknown object \"%s\"", name);
138: return;
139: }
140: if (ot -> ot_getfnx == NULLIFP) {
141: advise (LLOG_EXCEPTIONS, NULLCP, "no getfnx for object \"%s\"",
142: ot -> ot_text);
143: return;
144: }
145: if (ot -> ot_getfnx != o_generic) {
146: advise (LLOG_EXCEPTIONS, NULLCP,
147: "non-generic getfnx for object \"%s\"", ot -> ot_text);
148: return;
149: }
150: if ((os = ot -> ot_syntax) == NULLOS) {
151: advise (LLOG_EXCEPTIONS, NULLCP, "no syntax defined for object \"%s\"",
152: ot -> ot_text);
153: return;
154: }
155: if ((*os -> os_parse) (&value, newvalue) == NOTOK) {
156: advise (LLOG_EXCEPTIONS, NULLCP,
157: "invalid value for variable \"%s.0\": \"%s\"",
158: ot -> ot_text, newvalue);
159: return;
160: }
161: if (ot -> ot_info) {
162: (*os -> os_free) (ot -> ot_info);
163: ot -> ot_info = NULL;
164: }
165: ot -> ot_info = value;
166: }
167:
168: /* */
169:
170: int getkmem (n, buffer, cc)
171: struct nlist *n;
172: caddr_t buffer;
173: int cc;
174: {
175: if (n -> n_value == 0) {
176: advise (LLOG_EXCEPTIONS, NULLCP, "\"%s\" not in /vmunix", n -> n_name);
177: return NOTOK;
178: }
179: if (lseek (kd, (long) n -> n_value, L_SET) == NOTOK) {
180: advise (LLOG_EXCEPTIONS, "failed", "lseek of 0x%x for \"%s\" in kmem",
181: (long) n -> n_value, n -> n_name);
182: return NOTOK;
183: }
184: if (read (kd, buffer, cc) != cc) {
185: advise (LLOG_EXCEPTIONS, "failed", "read of \"%s\" from kmem",
186: n -> n_name);
187: return NOTOK;
188: }
189:
190: return OK;
191: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.