|
|
BSD 4.3reno
/* system.c - MIB realization of the System group */
#ifndef lint
static char *rcsid = "$Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/snmp/system.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $";
#endif
/*
* $Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/snmp/system.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $
*
* Contributed by NYSERNet Inc. This work was partially supported by the
* U.S. Defense Advanced Research Projects Agency and the Rome Air Development
* Center of the U.S. Air Force Systems Command under contract number
* F30602-88-C-0016.
*
*
* $Log: system.c,v $
* Revision 1.1.1.1 2018/04/24 16:12:56 root
* BSD 4.3reno
*
* Revision 7.3 90/05/14 15:44:29 mrose
* touch-up
*
* Revision 7.2 90/05/14 13:28:18 mrose
* system
*
* Revision 7.1 90/05/13 16:18:32 mrose
* views
*
* Revision 7.0 89/11/23 22:23:33 mrose
* Release 6.0
*
*/
/*
* NOTICE
*
* Acquisition, use, and distribution of this module and related
* materials are subject to the restrictions of a license agreement.
* Consult the Preface in the User's Manual for the full terms of
* this agreement.
*
*/
#include <stdio.h>
#include "mib.h"
#include "tailor.h"
/* */
static int o_sysUpTime (oi, v, offset)
OI oi;
register struct type_SNMP_VarBind *v;
int offset;
{
struct timeval boottime,
now;
register OID oid = oi -> oi_name;
register OT ot = oi -> oi_type;
static int lastq = -1;
static integer diff;
switch (offset) {
case type_SNMP_PDUs_get__request:
if (oid -> oid_nelem != ot -> ot_name -> oid_nelem + 1
|| oid -> oid_elements[oid -> oid_nelem - 1] != 0)
return int_SNMP_error__status_noSuchName;
break;
case type_SNMP_PDUs_get__next__request:
if (oid -> oid_nelem == ot -> ot_name -> oid_nelem) {
OID new;
if ((new = oid_extend (oid, 1)) == NULLOID)
return int_SNMP_error__status_genErr;
new -> oid_elements[new -> oid_nelem - 1] = 0;
if (v -> name)
free_SNMP_ObjectName (v -> name);
v -> name = new;
}
else
return NOTOK;
break;
default:
return int_SNMP_error__status_genErr;
}
if (quantum != lastq) {
lastq = quantum;
if (getkmem (nl + N_BOOTTIME, (caddr_t) &boottime, sizeof boottime)
== NOTOK)
return int_SNMP_error__status_genErr;
if (gettimeofday (&now, (struct timezone *) 0) == NOTOK) {
advise (LLOG_EXCEPTIONS, "failed", "gettimeofday");
return int_SNMP_error__status_genErr;
}
diff = (now.tv_sec - boottime.tv_sec) * 100
+ ((now.tv_usec - boottime.tv_usec) / 10000);
}
return o_number (oi, v, diff);
}
/* */
static struct sys_pair {
char *s_name;
char *s_text;
IFP s_getfnx;
} pairs[] = {
"sysDescr", sysDescr, o_generic,
"sysObjectID", sysObjectID, o_generic,
"sysUpTime", NULL, o_sysUpTime,
"sysContact", NULL, o_generic,
#define SYS_NAME 4
"sysName", NULL, o_generic,
"sysLocation", NULL, o_generic,
"sysServices", "72", o_generic,
NULL
};
init_system () {
char buffer[BUFSIZ];
register OT ot;
register struct sys_pair *sp;
(void) gethostname (buffer, sizeof buffer);
pairs[SYS_NAME].s_text = buffer;
for (sp = pairs; sp -> s_name; sp++)
if (ot = text2obj (sp -> s_name)) {
ot -> ot_getfnx = sp -> s_getfnx;
if (sp -> s_text)
if (ot -> ot_syntax)
(void) (*ot -> ot_syntax -> os_parse) ((struct qbuf **)
&ot -> ot_info,
sp -> s_text);
else
advise (LLOG_EXCEPTIONS, NULLCP, "%s: no syntax",
sp -> s_name);
}
else
advise (LLOG_EXCEPTIONS, NULLCP, "%s: unknown object",
sp -> s_name);
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.