/*
 * This is the statistic file.
 *
 * Copyright 1990 by the Massachusetts Institute of Technology.
 *
 * For copying and distribution information, please see the file
 * <mit-copyright.h>.
 *
 * Tom Coppeto
 * MIT Network Services
 * 8 August 1990
 *
 *    $Source: /afs/.net.mit.edu/tools/src/xinterface/RCS/stats.c,v $
 *    $Author: tom $
 *    $Locker: tom $
 *    $Log:	stats.c,v $
 * Revision 1.4  94/07/25  14:52:09  tom
 * *** empty log message ***
 * 
 * Revision 1.3  1994/07/25  10:47:43  tom
 * *** empty log message ***
 *
 * Revision 1.2  91/02/21  13:48:03  tom
 * *** empty log message ***
 * 
 * Revision 1.1  90/08/15  01:13:12  tom
 * Initial revision
 * 
 */

#ifndef lint
static char *rcsid = "$Header: /afs/.net.mit.edu/tools/src/xinterface/RCS/stats.c,v 1.4 94/07/25 14:52:09 tom Exp Locker: tom $";
#endif

#include "xport.h"
#include <mit-copyright.h>

/*
 * The foolkit will do its own allocation for the text. We just have
 * to make enough room to get it there.
 */

extern char *buf;
static char buf2[BUFSIZ];


void
do_update_status()
{
  objident *obj[SNMPMAXVARS];
  caddr_t *dat;
  int i, o;

  for(i = 0; i < nints; i++)
    {
      vIfAdminStatus.cmp[vIfAdminStatus.ncmp-1] = i + 1;
      vIfOperStatus.cmp[vIfOperStatus.ncmp-1]   = i + 1;
      vIfLastChange.cmp[vIfLastChange.ncmp-1]   = i + 1;

      o = 0;
      obj[o++] = &vIfAdminStatus;
      obj[o++] = &vIfOperStatus;
      obj[o++] = &vIfLastChange;
      if(vendor == CISCO)
	{
	  vCiscoIfOutBitsSec.cmp[vCiscoIfOutBitsSec.ncmp - 1] = i + 1;
	  obj[o++] = &vCiscoIfOutBitsSec;
	}
      obj[o++] = (objident *) NULL;

      if(!(dat = make_lots_o_snmp_queries(obj)))
	return;

      o = 0;
      bcopy(dat[o++], &(interface[i].admin.status),
	    sizeof(interface[i].admin.status));
      if(interface[i].admin.status == 2)
	interface[i].admin.status = 0;

      bcopy(dat[o++], &(interface[i].oper.status), 
	    sizeof(interface[i].oper.status));
      if(interface[i].oper.status == 2)
	interface[i].oper.status = 0;

      bcopy(dat[o++], &(interface[i].lastchanged), 
	    sizeof(interface[i].lastchanged));

      if(vendor == CISCO)
	bcopy(dat[o++], &(interface[i].gage.status),
	      sizeof(interface[i].gage.status));
    }
}



char *
do_interface_stats(i)
     int i;
{
  char a[16];

  if((i < 1) || (i > nints))
    return((char *) NULL);
  
  if(make_buf(BUFSIZ) < 0)
    return((char *) NULL);

  strncpy(a, format_number(interface[i-1].type), sizeof(a) - 1);
  sprintf(buf, "%-15s %s (%s)\n%-15s %u %s\n%-15s %s %s\n",
	  "type:",        a,  
	                  get_interface_type(interface[i-1].type),
	  "mtu:",         interface[i-1].mtu,   "bytes",
	  "bandwidth:",   format_number(interface[i-1].speed), "bps"); 
  
  return(buf);
}




char *
do_ip_stats()
{
  int      forwarding      = 0;
  int      ttl             = 0;
  int      in_receives     = 0;
  int      in_hdrerrors    = 0;
  int      in_addrerrors   = 0;
  int      forw_datagrams  = 0;
  int      unknown_prots   = 0;
  int      in_discards     = 0;
  int      in_delivers     = 0;
  int      out_discards    = 0;
  int      out_requests    = 0;
  int      out_noroutes    = 0;
  int      reasm_timeout   = 0;
  int      reasm_reqds     = 0;
  int      reasm_oks       = 0;
  int      reasm_fails     = 0;
  int      frag_oks        = 0;
  int      frag_fails      = 0;
  int      frag_creates    = 0;
  int      len = 0;
  int      l;
  extern   getreq reply;
  objident *obj[SNMPMAXVARS];
  caddr_t  *dat;
  int      o = 0;


  o = 0;
  obj[o++] = &vIPForwarding;
  obj[o++] = &vIPDefaultTTL;
  obj[o++] = &vIPInReceives;
  obj[o++] = &vIPInHdrErrors;
  obj[o++] = &vIPForwDatagrams;
  obj[o++] = &vIPInUnknownProtos;
  obj[o++] = &vIPInDiscards;
  obj[o++] = &vIPInDelivers;
  obj[o] = (objident *) NULL;

  if(!(dat = make_lots_o_snmp_queries(obj)))
    return((char *) NULL);
  
  o = 0;
  bcopy(dat[o++], &forwarding,     sizeof(forwarding));
  bcopy(dat[o++], &ttl,            sizeof(ttl));
  bcopy(dat[o++], &in_receives,    sizeof(in_receives));
  bcopy(dat[o++], &in_hdrerrors,   sizeof(in_hdrerrors));
  bcopy(dat[o++], &unknown_prots,  sizeof(unknown_prots));
  bcopy(dat[o++], &in_discards,    sizeof(in_discards));
  bcopy(dat[o++], &in_delivers,    sizeof(in_delivers));

  o = 0;
  obj[o++] = &vIPOutRequests;
  obj[o++] = &vIPOutDiscards;
  obj[o++] = &vIPOutNoRoutes;
  obj[o++] = &vIPReasmTimeout;
  obj[o++] = &vIPReasmReqds;
  obj[o++] = &vIPReasmOKs;
  obj[o++] = &vIPReasmFails;
  obj[o++] = &vIPFragOKs;
  obj[o++] = &vIPFragFails;
  obj[o++] = &vIPFragCreates;
  obj[o] = (objident *) NULL;

  if(!(dat = make_lots_o_snmp_queries(obj)))
    return((char *) NULL);
  
  o = 0;
  bcopy(dat[o++], &out_requests,   sizeof(out_requests));
  bcopy(dat[o++], &out_discards,   sizeof(out_discards));
  bcopy(dat[o++], &out_noroutes,   sizeof(out_noroutes));
  bcopy(dat[o++], &reasm_timeout,  sizeof(reasm_timeout));
  bcopy(dat[o++], &reasm_reqds,    sizeof(reasm_reqds));
  bcopy(dat[o++], &reasm_oks,      sizeof(reasm_oks));
  bcopy(dat[o++], &reasm_fails,    sizeof(reasm_fails));
  bcopy(dat[o++], &frag_oks,       sizeof(frag_oks));
  bcopy(dat[o++], &frag_fails,     sizeof(frag_fails));
  bcopy(dat[o++], &frag_creates,   sizeof(frag_creates));

  sprintf(buf2, "%-20s %s\n%-20s %s\n", 
	  "forwarding: ",      forwarding == 1 ? "yes" : "no",
	  "default ttl:",      format_number(ttl));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);
  
  sprintf(buf2, "%-20s %s\n", 
	  "received:",         format_number(in_receives));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n", 
	  "header errors:",    format_number(in_hdrerrors));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n", 
	  "address errors:",   format_number(in_addrerrors));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n", 
	  "forwarded:",        format_number(forw_datagrams));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n", 
	  "unknown proto.:",   format_number(unknown_prots));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n", 
	  "input discards:",   format_number(in_discards));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n", 
	  "delivered:",        format_number(in_delivers));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n", 
	  "transmitted:",      format_number(out_requests));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n", 
	  "output discards:",  format_number(out_discards));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);
  
  sprintf(buf2, "%-20s %s\n", 
	  "no routes:",        format_number(out_noroutes));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "\n%s\n%-20s %s\n", "Reassembly",
	  "timeout:",          format_number(reasm_timeout));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n", 
	  "requests",          format_number(reasm_reqds));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);
  
  sprintf(buf2, "%-20s %s\n", 
	  "success:",          format_number(reasm_oks));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n", 
	  "fails:",            format_number(reasm_fails));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "\n%s\n%-20s %s\n", "Fragmentation",
	  "succeed:",          format_number(frag_oks));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n", 
	  "failed:",           format_number(frag_fails));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n", 
	  "created:",          format_number(frag_creates));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  return(buf);
}






char *
do_icmp_stats()
{
  int      in_msgs            = 0;
  int      in_errors          = 0;
  int      in_destunreach     = 0;
  int      in_timeexceed      = 0;
  int      in_paramprobs      = 0;
  int      in_srcquenchs      = 0;
  int      in_redirects       = 0;
  int      in_echos           = 0;
  int      in_echoreps        = 0;
  int      in_timestamps      = 0;
  int      in_timestampreps   = 0;
  int      in_addrmasks       = 0;
  int      in_assrmaskreps    = 0;
  int      out_msgs           = 0;
  int      out_errors         = 0;
  int      out_destunreach    = 0;
  int      out_timeexceed     = 0;
  int      out_paramprobs     = 0;
  int      out_srcquenchs     = 0;
  int      out_redirects      = 0;
  int      out_echos          = 0;
  int      out_echoreps       = 0;
  int      out_timestamps     = 0;
  int      out_timestampreps  = 0;
  int      out_addrmasks      = 0;
  int      out_assrmaskreps   = 0;
  int      len = 0;
  int      l;
  extern   getreq reply;
  objident *obj[SNMPMAXVARS];
  char     d[32];
  caddr_t  *dat;
  int      o = 0;


  o = 0;
  obj[o++] = &vICMPInMsgs;
  obj[o++] = &vICMPInErrors;
  obj[o++] = &vICMPInDestUnreachs;
  obj[o++] = &vICMPInTimeExds;
  obj[o++] = &vICMPInParmProbs;
  obj[o++] = &vICMPInSrcQuenchs;
  obj[o++] = &vICMPInRedirects;
  obj[o++] = &vICMPInEchos;
  obj[o++] = &vICMPInEchoReps;
  obj[o++] = &vICMPInTimestamps;
  obj[o++] = &vICMPInTimestampReps;
  obj[o] = (objident *) NULL;

  if(!(dat = make_lots_o_snmp_queries(obj)))
    return((char *) NULL);
  
  o = 0;
  bcopy(dat[o++], &in_msgs,           sizeof(in_msgs));
  bcopy(dat[o++], &in_errors,         sizeof(in_errors));
  bcopy(dat[o++], &in_destunreach,    sizeof(in_destunreach));
  bcopy(dat[o++], &in_timeexceed,     sizeof(in_timeexceed));
  bcopy(dat[o++], &in_paramprobs,     sizeof(in_paramprobs));
  bcopy(dat[o++], &in_srcquenchs,     sizeof(in_srcquenchs));
  bcopy(dat[o++], &in_redirects,      sizeof(in_redirects));
  bcopy(dat[o++], &in_echos,          sizeof(in_echos));
  bcopy(dat[o++], &in_echoreps,       sizeof(in_echoreps));
  bcopy(dat[o++], &in_timestamps,     sizeof(in_timestamps));
  bcopy(dat[o++], &in_timestampreps,  sizeof(in_timestampreps));

  o = 0;
  obj[o++] = &vICMPOutMsgs;
  obj[o++] = &vICMPOutErrors;
  obj[o++] = &vICMPOutDestUnreachs;
  obj[o++] = &vICMPOutTimeExds;
  obj[o++] = &vICMPOutParmProbs;
  obj[o++] = &vICMPOutSrcQuenchs;
  obj[o++] = &vICMPOutRedirects;
  obj[o++] = &vICMPOutEchos;
  obj[o++] = &vICMPOutEchoReps;
  obj[o++] = &vICMPOutTimestamps;
  obj[o++] = &vICMPOutTimestampReps;
  obj[o] = (objident *) NULL;

  if(!(dat = make_lots_o_snmp_queries(obj)))
    return((char *) NULL);
  
  o = 0;
  bcopy(dat[o++], &out_msgs,          sizeof(out_msgs));
  bcopy(dat[o++], &out_errors,        sizeof(out_errors));
  bcopy(dat[o++], &out_destunreach,   sizeof(out_destunreach));
  bcopy(dat[o++], &out_timeexceed,    sizeof(out_timeexceed));
  bcopy(dat[o++], &out_paramprobs,    sizeof(out_paramprobs));
  bcopy(dat[o++], &out_srcquenchs,    sizeof(out_srcquenchs));
  bcopy(dat[o++], &out_redirects,     sizeof(out_redirects));
  bcopy(dat[o++], &out_echos,         sizeof(out_echos));
  bcopy(dat[o++], &out_echoreps,      sizeof(out_echoreps));
  bcopy(dat[o++], &out_timestamps,    sizeof(out_timestamps));
  bcopy(dat[o++], &out_timestampreps, sizeof(out_timestampreps));

  strcpy(d, format_number(in_msgs));
  sprintf(buf2, "%-20s %-12s %s\n%-20s %-12s %s\n", 
	  "",                   "In",     "Out",
	  "messages:",          d,        format_number(out_msgs));  
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  strcpy(d, format_number(in_errors));
  sprintf(buf2, "%-20s %-12s %s\n", 
	  "errors:",            d,        format_number(out_errors));  
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  strcpy(d, format_number(in_destunreach));
  sprintf(buf2, "%-20s %-12s %s\n", 
	  "dest. unreachable:", d,        format_number(out_destunreach));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  strcpy(d, format_number(in_timeexceed));
  sprintf(buf2, "%-20s %-12s %s\n", 
	  "time exceeds:",      d,        format_number(out_timeexceed));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  strcpy(d, format_number(in_paramprobs));
  sprintf(buf2, "%-20s %-12s %s\n", 
	  "param problems:",    d,        format_number(out_paramprobs));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  strcpy(d, format_number(in_srcquenchs));
  sprintf(buf2, "%-20s %-12s %s\n", 
	  "source quenches:",   d,        format_number(out_srcquenchs));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  strcpy(d, format_number(in_redirects));
  sprintf(buf2, "%-20s %-12s %s\n", 
	  "redirects:",         d,        format_number(out_redirects));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  strcpy(d, format_number(in_echos));
  sprintf(buf2, "%-20s %-12s %s\n", 
	  "echos:",             d,        format_number(out_echos));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  strcpy(d, format_number(in_echoreps));
  sprintf(buf2, "%-20s %-12s %s\n", 
	  "echo replies:",      d,        format_number(out_echoreps));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  strcpy(d, format_number(in_timestamps));
  sprintf(buf2, "%-20s %-12s %s\n", 
	  "timestamps:",        d,        format_number(out_timestamps));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  strcpy(d, format_number(in_timestampreps));
  sprintf(buf2, "%-20s %-12s %s\n", 
	  "timestamp replies:", d,        format_number(out_timestampreps));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  return(buf);
}





char *
do_udp_stats()
{
  int      in_dgrams   = 0;
  int      no_ports    = 0;
  int      in_errors   = 0;
  int      out_dgrams  = 0;
  int      len = 0;
  int      l;
  extern   getreq reply;
  objident *obj[SNMPMAXVARS];
  caddr_t  *dat;
  int      o = 0;

  o = 0;
  obj[o++] = &vUDPInDatagrams;
  obj[o++] = &vUDPNoPorts;
  obj[o++] = &vUDPInErrors;
  obj[o++] = &vUDPOutDatagrams;
  obj[o] = (objident *) NULL;

  if(!(dat = make_lots_o_snmp_queries(obj)))
    return((char *) NULL);

  o = 0;
  bcopy(dat[o++], &in_dgrams,    sizeof(in_dgrams));
  bcopy(dat[o++], &no_ports,     sizeof(no_ports));
  bcopy(dat[o++], &in_errors,    sizeof(in_errors));
  bcopy(dat[o++], &out_dgrams,   sizeof(out_dgrams));

  sprintf(buf2, "%-20s %s\n",  "datagrams in:",     format_number(in_dgrams));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n",  "port unreachable:", format_number(no_ports));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n",  "errors:",           format_number(in_errors));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n",  "datagrams out:",    format_number(out_dgrams));
  l    = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);
  return(buf);
}







char *
do_tcp_stats()
{
  int      to_algorithm   = 0;
  int      to_min         = 0;
  int      to_max         = 0;
  int      max_conn       = 0;
  int      active_opens   = 0;
  int      passive_opens  = 0;
  int      attempt_fails  = 0;
  int      estab_resets   = 0;
  int      curr_estab     = 0;
  int      in_segs        = 0;
  int      out_segs       = 0;
  int      retrans_segs   = 0;
  int      conn_state     = 0;
  int      conn_localport = 0;
  int      conn_remport   = 0;
  struct   in_addr conn_localaddr;
  struct   in_addr conn_remaddr;
  extern   getreq reply;
  objident *obj[SNMPMAXVARS];
  caddr_t  *dat;
  caddr_t  datt;
  int      len = 0;
  int      l;
  int      o = 0;
  int      i;
  char     local[16];
  char     remote[64];
  char     localport[16];
  char     *host;

  o = 0;
  obj[o++] = &vTCPRtoAlgorithm;
  obj[o++] = &vTCPRtoMin;
  obj[o++] = &vTCPRtoMax;
  obj[o++] = &vTCPMaxConn;
  obj[o++] = &vTCPActiveOpens;
  obj[o++] = &vTCPPassiveOpens;
  obj[o++] = &vTCPAttemptFails;
  obj[o++] = &vTCPEstabResets;
  obj[o++] = &vTCPCurrEstab;
  obj[o++] = &vTCPInSegs;
  obj[o++] = &vTCPOutSegs;
  obj[o++] = &vTCPRetransSegs;
  obj[o++] = (objident *) NULL;
  obj[o] = (objident *) NULL;

  if(!(dat = make_lots_o_snmp_queries(obj)))
    return((char *) NULL);

  o = 0;
  bcopy(dat[o++], &to_algorithm,   sizeof(to_algorithm));
  bcopy(dat[o++], &to_min,         sizeof(to_min));
  bcopy(dat[o++], &to_max,         sizeof(to_max));
  bcopy(dat[o++], &max_conn,       sizeof(max_conn));
  bcopy(dat[o++], &active_opens,   sizeof(active_opens));
  bcopy(dat[o++], &passive_opens,  sizeof(passive_opens));
  bcopy(dat[o++], &attempt_fails,  sizeof(attempt_fails));
  bcopy(dat[o++], &estab_resets,   sizeof(estab_resets));
  bcopy(dat[o++], &curr_estab,     sizeof(curr_estab));
  bcopy(dat[o++], &in_segs,        sizeof(in_segs));
  bcopy(dat[o++], &out_segs,       sizeof(out_segs));
  bcopy(dat[o++], &retrans_segs,   sizeof(retrans_segs));

  sprintf(buf2, "%-20s %s\n%-20s %s\n",
	  "timeout algorithm:",    get_tcp_timeout_algorithm(to_algorithm),
	  "timeout min (ms):",     format_number(to_min));
  l = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n",
	  "timeout max (ms):",     format_number(to_max));
  l = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n",
	  "max connections:",      format_number(max_conn));
  l = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n",
	  "active opens:",         format_number(active_opens));
  l = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n",
	  "passive opens:",        format_number(passive_opens));
  l = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n",
	  "attempt fails:",        format_number(attempt_fails));
  l = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n",
	  "estab.  resets:",       format_number(estab_resets));
  l = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n",
	  "current estab.:",       format_number(curr_estab));
  l = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n",
	  "segments received:",    format_number(in_segs));
  l = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n",
	  "segments sent:",        format_number(out_segs));
  l = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %s\n",
	  "segments retrans.:",    format_number(retrans_segs));
  l = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);


  /*
   * clear out the last 10 elements
   */
  bzero(&vTCPConnState.cmp[vTCPConnState.ncmp - 10],             
	10 * sizeof(reply.varlist.elem[0].name.cmp[0]));
  bzero(&vTCPConnLocalAddress.cmp[vTCPConnLocalAddress.ncmp - 10],
	10 * sizeof(reply.varlist.elem[0].name.cmp[0]));
  bzero(&vTCPConnLocalPort.cmp[vTCPConnLocalPort.ncmp - 10],     
	10 * sizeof(reply.varlist.elem[0].name.cmp[0]));
  bzero(&vTCPConnRemAddress.cmp[vTCPConnRemAddress.ncmp - 10],   
	10 * sizeof(reply.varlist.elem[0].name.cmp[0]));
  bzero(&vTCPConnRemAddress.cmp[vTCPConnRemAddress.ncmp - 10],   
	10 * sizeof(reply.varlist.elem[0].name.cmp[0]));

  o = 0;
  obj[o++] = &vTCPConnState;
  obj[o++] = &vTCPConnLocalAddress;
  obj[o++] = &vTCPConnLocalPort;
  obj[o++] = &vTCPConnRemAddress;
  obj[o++] = &vTCPConnRemPort;

  if(!(datt = make_snmp_next(obj[0])))
    return((char *) NULL);

  i = 0;
  while(datt)
    {
      if(oidncmp(obj[0], &(reply.varlist.elem[0].name), 10) != 0)
	break;
      
      bcopy(&(reply.varlist.elem[0].name.cmp[reply.varlist.elem[0].name.ncmp 
					     - 10]),
	    &vTCPConnState.cmp[vTCPConnState.ncmp - 10],             
	    10 * sizeof(reply.varlist.elem[0].name.cmp[0]));

      bcopy(&(reply.varlist.elem[0].name.cmp[reply.varlist.elem[0].name.ncmp 
					     - 10]),
	    &vTCPConnLocalAddress.cmp[vTCPConnLocalAddress.ncmp - 10],
	    10 * sizeof(reply.varlist.elem[0].name.cmp[0]));

      bcopy(&(reply.varlist.elem[0].name.cmp[reply.varlist.elem[0].name.ncmp 
					     - 10]),
	    &vTCPConnLocalPort.cmp[vTCPConnLocalPort.ncmp - 10],     
	    10 * sizeof(reply.varlist.elem[0].name.cmp[0]));

      bcopy(&(reply.varlist.elem[0].name.cmp[reply.varlist.elem[0].name.ncmp 
					     - 10]),
	    &vTCPConnRemAddress.cmp[vTCPConnRemAddress.ncmp - 10],   
	    10 * sizeof(reply.varlist.elem[0].name.cmp[0]));

      bcopy(&(reply.varlist.elem[0].name.cmp[reply.varlist.elem[0].name.ncmp 
					     - 10]),
	    &vTCPConnRemPort.cmp[vTCPConnRemPort.ncmp - 10],   
	    10 * sizeof(reply.varlist.elem[0].name.cmp[0]));

      if(!(dat = make_lots_o_snmp_queries(obj)))
	return((char *) NULL);

      o = 0;
      bcopy(dat[o++], &conn_state,     sizeof(conn_state));
      bcopy(dat[o++], &conn_localaddr, sizeof(conn_localaddr));
      bcopy(dat[o++], &conn_localport, sizeof(conn_localport));
      bcopy(dat[o++], &conn_remaddr,   sizeof(conn_remaddr));
      bcopy(dat[o++], &conn_remport,   sizeof(conn_remport));
      
      if(i == 0)
	{
	  sprintf(buf2, "\n%-31s %-16s %-12s %-16s %-12s %s\n\n",
		  "remote hostname", "address", "port", 
		  "local address", "port", "state");
	  len += strlen(buf2);
	  if(make_buf(len + 1) < 0)
	    return((char *) NULL);
	  strcat(buf, buf2);
	  ++i;
	}

      host = get_hostname(&conn_remaddr);
      sprintf(remote, "%-30.29s  %s", host ? host:"", inet_ntoa(conn_remaddr));
      sprintf(local,  "%s", inet_ntoa(conn_localaddr));
      sprintf(localport, "%s", get_servname(conn_localport));
      sprintf(buf2, "%-48s %-12s %-16s %-12s %s\n",	      
	      remote, get_servname(conn_remport), local,
	      localport, get_tcp_connection_state(conn_state));
      len += strlen(buf2);
      if(make_buf(len + 1) < 0)
	return((char *) NULL);
      strcat(buf, buf2);

      datt = make_snmp_next(obj[0]);
    }
  return(buf);
}




char *
do_address_stats(i)
     int i;
{
  struct   in_addr netmask;
  struct   in_addr addrwho;
  struct   in_addr addrhelper;
  char     b[100];
  char     *ethaddr;
  char     addrhow[32];
  int      unreachable;
  int      redirects;
  int      security;
  int      bcast;
  char     cbuf[5];
  int      len = 0;
  extern   getreq reply;
  objident *obj[SNMPMAXVARS];
  caddr_t  *dat;
  int      o = 0;

  make_variable_addr(&vIANetMask,     interface[i-1].addr);
  make_variable_addr(&vIABcastAddr,   interface[i-1].addr);
  vAtPhysAddress.cmp[vAtPhysAddress.ncmp - 6] = i;
  vAtPhysAddress.cmp[vAtPhysAddress.ncmp - 5] = 1; /* what is this ? */
  make_variable_addr(&vAtPhysAddress, interface[i-1].addr);

  o = 0;
  obj[o++] = &vIANetMask;
  obj[o++] = &vIABcastAddr;
  obj[o++] = &vAtPhysAddress;
  obj[o]   = (objident *) NULL;

  if(!(dat  = make_lots_o_snmp_queries(obj)))
    return((char *) NULL);
  
  o = 0;
  bcopy(dat[o++], &netmask, sizeof(netmask));
  bcopy(dat[o++], &bcast,   sizeof(bcast));
  ethaddr = make_phys_address(&(reply.varlist.elem[2].val));

  sprintf(buf2, "%-20s %d.%d.%d.%d\n%-20s %s\n%-20s %s\n%-20s %d\n",
	  "ip address:", interface[i-1].addr[0], interface[i-1].addr[1],
	  interface[i-1].addr[2], interface[i-1].addr[3],
	  "ethernet address:", ethaddr ? ethaddr : "unsupported",
	  "netmask:", inet_ntoa(netmask),
	  "broadcast address:", bcast);

  len = strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf, buf2);

  if(vendor == CISCO)
    {
      make_variable_addr(&vCiscoIPAddrHow,     interface[i-1].addr);
      make_variable_addr(&vCiscoIPAddrWho,     interface[i-1].addr);
      make_variable_addr(&vCiscoIPAddrHelper,  interface[i-1].addr);
      make_variable_addr(&vCiscoIPSecurity,    interface[i-1].addr);
      make_variable_addr(&vCiscoIPRedirects,   interface[i-1].addr);
      make_variable_addr(&vCiscoIPUnreachable, interface[i-1].addr);

      o = 0;
      obj[o++] = &vCiscoIPAddrHow;
      obj[o++] = &vCiscoIPAddrWho;
      obj[o++] = &vCiscoIPAddrHelper;
      obj[o++] = &vCiscoIPSecurity;
      obj[o++] = &vCiscoIPRedirects;
      obj[o++] = &vCiscoIPUnreachable;
      obj[o] = (objident *) NULL;
      
      if(!(dat = make_lots_o_snmp_queries(obj)))
	return((char *) NULL);
      
      o = 0;
      strncpy(addrhow, dat[o++],     sizeof(addrhow) - 1);
      bcopy(dat[o++], &addrwho,     sizeof(addrwho));
      bcopy(dat[o++], &addrhelper,  sizeof(addrhelper));
      bcopy(dat[o++], &security,    sizeof(security));
      bcopy(dat[o++], &redirects,   sizeof(redirects));
      bcopy(dat[o++], &unreachable, sizeof(unreachable));

      sprintf(b, "%s", inet_ntoa(addrhelper));
      sprintf(buf2, "\nCisco Local Variables:\n%-20s %s\n%-20s %s\n%-20s %s\n%-20s %d\n%-20s %s\n%-20s %s\n", 
	      "address set by:", addrhow, 
	      "address set from:", inet_ntoa(addrwho),
	      "ip helper address:", b, 
	      "security level:", security,
	      "send icmp redirect:", redirects == 1 ?  "yes" : "no",
	      "send icmp unreach:", unreachable == 1 ? "yes" : "no");

      len += strlen(buf2);
      if(make_buf(len + 1) < 0)
	return((char *) NULL);
      strcat(buf, buf2);
    }

  return(buf);
}






char *
do_ifstats(i)
     int i;
{
  objident *obj[SNMPMAXVARS];
  char     d[32];
  caddr_t  *dat;
  int in_octets         = 0;
  int in_ucast_pkts     = 0;
  int in_nucast_pkts    = 0;
  int in_discards       = 0;
  int in_errors         = 0;
  int in_unknown_protos = 0;
  int out_octets        = 0;
  int out_ucast_pkts    = 0;
  int out_nucast_pkts   = 0;
  int out_discards      = 0;
  int out_errors        = 0;
  int out_qlen          = 0;
  int in_bps            = 0;
  int out_bps           = 0;
  int in_pps            = 0;
  int out_pps           = 0;
  int in_runts          = 0;
  int in_giants         = 0;
  int in_crc            = 0;
  int in_frame          = 0;
  int in_overrun        = 0;
  int in_ignored        = 0;
  int in_abort          = 0;
  int len               = 0;
  int o                 = 0;
  int l;

  vIfInOctets.cmp[vIfInOctets.ncmp - 1]                 = i;
  vIfInUcastPackets.cmp[vIfInUcastPackets.ncmp - 1]     = i;
  vIfInNUcastPackets.cmp[vIfInNUcastPackets.ncmp - 1]   = i;
  vIfInDiscards.cmp[vIfInDiscards.ncmp - 1]             = i;
  vIfInErrors.cmp[vIfInErrors.ncmp - 1]                 = i;
  vIfInUnknownProtos.cmp[vIfInUnknownProtos.ncmp - 1]   = i;
  vIfOutOctets.cmp[vIfOutOctets.ncmp - 1]               = i;
  vIfOutUcastPackets.cmp[vIfOutUcastPackets.ncmp - 1]   = i;
  vIfOutNUcastPackets.cmp[vIfOutNUcastPackets.ncmp - 1] = i;
  vIfOutDiscards.cmp[vIfOutDiscards.ncmp - 1]           = i;
  vIfOutErrors.cmp[vIfOutErrors.ncmp - 1]               = i;
  vIfOutQLen.cmp[vIfOutQLen.ncmp - 1]                   = i;

  o = 0;
  obj[o++] = &vIfInOctets;
  obj[o++] = &vIfInUcastPackets;
  obj[o++] = &vIfInNUcastPackets;
  obj[o++] = &vIfInDiscards;
  obj[o++] = &vIfInErrors;
  obj[o++] = &vIfInUnknownProtos;
  obj[o++] = &vIfOutOctets;
  obj[o++] = &vIfOutUcastPackets;
  obj[o++] = &vIfOutNUcastPackets;
  obj[o++] = &vIfOutDiscards;
  obj[o++] = &vIfOutErrors;
  obj[o++] = &vIfOutQLen;
  obj[o]   = (objident *) NULL;

  if(!(dat = make_lots_o_snmp_queries(obj)))
    return((char *) NULL);
  o = 0;
  bcopy(dat[o++], &in_octets,         sizeof(in_octets));
  bcopy(dat[o++], &in_ucast_pkts,     sizeof(in_ucast_pkts));
  bcopy(dat[o++], &in_nucast_pkts,    sizeof(in_nucast_pkts));
  bcopy(dat[o++], &in_discards,       sizeof(in_discards));
  bcopy(dat[o++], &in_errors,         sizeof(in_errors));
  bcopy(dat[o++], &in_unknown_protos, sizeof(in_unknown_protos));
  bcopy(dat[o++], &out_octets,        sizeof(out_octets));
  bcopy(dat[o++], &out_ucast_pkts,    sizeof(out_ucast_pkts));
  bcopy(dat[o++], &out_nucast_pkts,   sizeof(out_nucast_pkts));
  bcopy(dat[o++], &out_discards,      sizeof(out_discards));
  bcopy(dat[o++], &out_errors,        sizeof(out_errors));
  bcopy(dat[o++], &out_qlen,          sizeof(out_qlen));
/*  time = time(0);
  ifrates.in_octets = 
    (in_octets - interface[i].in_octets) /
      (time - interface[i].time);
  ifrates.in_ucast_pkts = 
    (in_ucast_pkts - interface[i].in_ucast_pkts) /
      (time - interface[i].time);
  ifrates.in_nucast_pkts = 
    (in_nucast_pkts - interface[i].in_nucast_pkts) /
      (time - interface[i].time);
  ifrates.in_discards = 
    (in_discards - interface[i].in_discards) /
      (time - interface[i].time);
  ifrates.in_errors = 
    (in_errors - interface[i].in_errors) /
      (time - interface[i].time);
  ifrates.in_unknown_protos = 
    (in_unknown_protos - interface[i].in_unknown_protos) /
      (time - interface[i].time);

  ifrates.out_octets = 
    (out_octets - interface[i].out_octets) /
      (time - interface[i].time);
  ifrates.out_ucast_pkts = 
    (out_ucast_pkts - interface[i].out_ucast_pkts) /
      (time - interface[i].time);
  ifrates.out_nucast_pkts = 
    (out_nucast_pkts - interface[i].out_nucast_pkts) /
      (time - interface[i].time);
  ifrates.out_discards = 
    (out_discards - interface[i].out_discards) /
      (time - interface[i].time);
  ifrates.out_errors = 
    (out_errors - interface[i].out_errors) /
      (time - interface[i].time);
  ifrates.out_qlen = 
    (out_qlen - interface[i].out_qlen) /
      (time - interface[i].time);
*/
  strcpy(d, format_number(in_octets));
  sprintf(buf2, " %-20s%-13s %s\n%-20s %-13s %s\n",
	  "",                   "In", "Out", 
	  "Octets:",             d,  format_number(out_octets));
  l   = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  strcpy(d, format_number(in_ucast_pkts));
  sprintf(buf2, "%-20s %-13s %s\n",
	  "Ucast pkts: ",        d,  format_number(out_ucast_pkts));
  l   = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  strcpy(d, format_number(in_nucast_pkts));
  sprintf(buf2, "%-20s %-13s %s\n",
	  "NUcast pkts: ",        d, format_number(out_nucast_pkts));
  l   = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  strcpy(d, format_number(in_discards));
  sprintf(buf2, "%-20s %-13s %s\n",
	  "Discards: ",           d, format_number(out_discards));
  l   = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  strcpy(d, format_number(in_errors));
  sprintf(buf2, "%-20s %-13s %s\n",
          "Errors: ",             d, format_number(out_errors));
  l   = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %-13s\n",
	  "Unknown Protocol: ",      format_number(in_unknown_protos));
  l   = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  sprintf(buf2, "%-20s %-13s %s\n",
	  "Qlen: ",             "",  format_number(out_qlen));
  l   = len;
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf + l, buf2);

  if(vendor == CISCO)
    {
      vCiscoIfInBitsSec.cmp[vCiscoIfInBitsSec.ncmp - 1]   = i;
      vCiscoIfInPktsSec.cmp[vCiscoIfInPktsSec.ncmp - 1]   = i;
      vCiscoIfOutBitsSec.cmp[vCiscoIfOutBitsSec.ncmp - 1] = i;
      vCiscoIfOutPktsSec.cmp[vCiscoIfOutPktsSec.ncmp - 1] = i;
      vCiscoIfInRunts.cmp[vCiscoIfInRunts.ncmp - 1]       = i;
      vCiscoIfInGiants.cmp[vCiscoIfInGiants.ncmp - 1]     = i;
      vCiscoIfInCRC.cmp[vCiscoIfInCRC.ncmp - 1]           = i;
      vCiscoIfInFrame.cmp[vCiscoIfInFrame.ncmp - 1]       = i;
      vCiscoIfInOverrun.cmp[vCiscoIfInOverrun.ncmp - 1]   = i;
      vCiscoIfInIgnored.cmp[vCiscoIfInIgnored.ncmp - 1]   = i;
      vCiscoIfInAbort.cmp[vCiscoIfInAbort.ncmp - 1]       = i;

      o = 0;
      obj[o++] = &vCiscoIfInBitsSec;
      obj[o++] = &vCiscoIfInPktsSec;
      obj[o++] = &vCiscoIfOutBitsSec;
      obj[o++] = &vCiscoIfOutPktsSec;
      obj[o++] = &vCiscoIfInRunts;
      obj[o++] = &vCiscoIfInGiants;
      obj[o++] = &vCiscoIfInCRC;
      obj[o++] = &vCiscoIfInFrame;
      obj[o++] = &vCiscoIfInOverrun;
      obj[o++] = &vCiscoIfInIgnored;
      obj[o++] = &vCiscoIfInAbort;

      if(!(dat = make_lots_o_snmp_queries(obj)))
	return((char *) NULL);

      o = 0;
      bcopy(dat[o++], &in_bps,     sizeof(in_bps));
      bcopy(dat[o++], &in_pps,     sizeof(in_pps));      
      bcopy(dat[o++], &out_bps,    sizeof(out_bps));
      bcopy(dat[o++], &out_pps,    sizeof(out_pps));
      bcopy(dat[o++], &in_runts,   sizeof(in_runts));
      bcopy(dat[o++], &in_giants,  sizeof(in_giants));
      bcopy(dat[o++], &in_crc,     sizeof(in_crc));
      bcopy(dat[o++], &in_frame,   sizeof(in_frame));
      bcopy(dat[o++], &in_overrun, sizeof(in_overrun));
      bcopy(dat[o++], &in_ignored, sizeof(in_ignored));
      bcopy(dat[o++], &in_abort,   sizeof(in_abort));

      strcpy(d, format_number(in_bps));
      sprintf(buf2, "\nCisco Local Variables:\n%-20s %-13s %s\n",
	  "Bits/sec (5 min):",    d,    format_number(out_bps));
      l   = len;
      len += strlen(buf2);
      if(make_buf(len + 1) < 0)
	return((char *) NULL);
      strcpy(buf + l, buf2);

      strcpy(d, format_number(in_pps));
      sprintf(buf2, "%-20s %-13s %s\n",
	  "Packets/sec (5 min):", d,    format_number(out_pps));
      l   = len;
      len += strlen(buf2);
      if(make_buf(len + 1) < 0)
	return((char *) NULL);
      strcpy(buf + l, buf2);

      sprintf(buf2, "%-20s %s\n",
	  "Runts:",              format_number(in_runts));
      l   = len;
      len += strlen(buf2);
      if(make_buf(len + 1) < 0)
	return((char *) NULL);
      strcpy(buf + l, buf2);

      sprintf(buf2, "%-20s %s\n",
	  "Giants:",              format_number(in_giants));
      l   = len;
      len += strlen(buf2);
      if(make_buf(len + 1) < 0)
	return((char *) NULL);
      strcpy(buf + l, buf2);

      sprintf(buf2, "%-20s %s\n",
	  "CRC:",              format_number(in_crc));
      l   = len;
      len += strlen(buf2);
      if(make_buf(len + 1) < 0)
	return((char *) NULL);
      strcpy(buf + l, buf2);

      sprintf(buf2, "%-20s %s\n",
	  "Frame:",              format_number(in_frame));
      l   = len;
      len += strlen(buf2);
      if(make_buf(len + 1) < 0)
	return((char *) NULL);
      strcpy(buf + l, buf2);

      sprintf(buf2, "%-20s %s\n",
	  "Overrun:",              format_number(in_overrun));
      l   = len;
      len += strlen(buf2);
      if(make_buf(len + 1) < 0)
	return((char *) NULL);
      strcpy(buf + l, buf2);

      sprintf(buf2, "%-20s %s\n",
	  "Ignored:",              format_number(in_ignored));
      l   = len;
      len += strlen(buf2);
      if(make_buf(len + 1) < 0)
	return((char *) NULL);
      strcpy(buf + l, buf2);

      sprintf(buf2, "%-20s %s\n",
	  "Abort:",              format_number(in_abort));
      l   = len;
      len += strlen(buf2);
      if(make_buf(len + 1) < 0)
	return((char *) NULL);
      strcpy(buf + l, buf2);
    }
  return(buf);
}



char *
do_ifaddr(i)
     int i;
{
  caddr_t dat;
  extern getreq reply;
  objident obj;
  int len = 0;

  vAtPhysAddress.cmp[vAtPhysAddress.ncmp - 6] = i;
  vAtPhysAddress.cmp[vAtPhysAddress.ncmp - 5] = 1;
  vAtPhysAddress.cmp[vAtPhysAddress.ncmp - 4] = 0;
  vAtPhysAddress.cmp[vAtPhysAddress.ncmp - 3] = 0;
  vAtPhysAddress.cmp[vAtPhysAddress.ncmp - 2] = 0;
  vAtPhysAddress.cmp[vAtPhysAddress.ncmp - 1] = 0;

  if(buf)
    *buf = '\0';

  dat = make_snmp_next(&vAtPhysAddress);
  while(dat)
    {
      if(oidncmp(&vAtPhysAddress, &(reply.varlist.elem[0].name), 12) != 0)
         break;
      sprintf(buf2, "%d.%d.%d.%d:\t%s\n",
	   reply.varlist.elem[0].name.cmp[reply.varlist.elem[0].name.ncmp - 4],
	   reply.varlist.elem[0].name.cmp[reply.varlist.elem[0].name.ncmp - 3],
	   reply.varlist.elem[0].name.cmp[reply.varlist.elem[0].name.ncmp - 2],
	   reply.varlist.elem[0].name.cmp[reply.varlist.elem[0].name.ncmp - 1],
	   make_phys_address(&(reply.varlist.elem[0].val)));

      len += strlen(buf2);
      if(make_buf(len + 1) < 0)
	return((char *) NULL); /* I should leave some work for someone else */
      strcat(buf, buf2);

      bcopy(&(reply.varlist.elem[0].name), &obj, sizeof(obj));
      dat = make_snmp_next(&obj);
    }
  return(buf);
}




char *
do_ifroute(i)
     int i;
{
  static int addr[4] = {0, 0, 0, 0};
  struct in_addr *ia;
  char nexthop[15];
  int m1     = 0;
  int m2     = 0;
  int m3     = 0;
  int m4     = 0;
  int type   = 0;
  int proto  = 0;
  int age    = 0;
  int uses   = 0;
  int count  = 0;
  int len    = 0;
  int index;
  objident *obj[SNMPMAXVARS];
  objident *ci;
  objident save;
  caddr_t  *dat;
  caddr_t  datt;
  extern   getreq reply;
  int      o = 0;

  make_variable_addr(&vIPRtIfIndex, addr);

  sprintf(buf2, "%-16s %-16s %-10s %-10s %-3s %-8s %-8s %-8s %-8s",
	  "destination", "next hop", "type", "protocol", "age", 
	  "metric1", "metric2", "metric3", "metric4");
  len = strlen(buf2) + 5;
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf, buf2);

  if(vendor == CISCO)
    {
      sprintf(buf2, " %-5s %-10s %-16s", "Count", "Uses", "Mask");
      len += strlen(buf2);
      if(make_buf(len + 1) < 0)
	return((char *) NULL);
      strcat(buf, buf2);
    }
  strcat(buf, "\n\n");

  bzero(&(vIPRtMetric1.cmp[vIPRtMetric1.ncmp - 4]), 
	4 * sizeof(reply.varlist.elem[0].name.cmp[0]));
  bzero(&(vIPRtIfIndex.cmp[vIPRtIfIndex.ncmp - 4]), 
	4 * sizeof(reply.varlist.elem[0].name.cmp[0]));


  index = 0;
  vIPRtIfIndex.ncmp-=4;
  datt = make_snmp_next(&vIPRtIfIndex);
  vIPRtIfIndex.ncmp+=4;
  if(datt)
    {
      bcopy(datt, &index, sizeof(index));
      if((index < 0) || (index >= 255)) /* !!! */
	{
	  ci = &vIPRtDest;
	  ci->ncmp-=4;
	  datt = make_snmp_next(ci);
	  ci->ncmp+=4;
	  if(datt == (caddr_t) NULL)
	    return("ERROR");
	  index = -1;
	}
      else
	ci = &vIPRtIfIndex;
    }

  while(datt)
    {
      if(oidncmp(ci, &(reply.varlist.elem[0].name), 10) != 0)
         break;
      bcopy(&(reply.varlist.elem[0].name), &save, sizeof(save));
      if(index >= 0)
	bcopy(datt, &index, sizeof(index));

      if((index == i) || (index < 0))
	{
	  o = 0;

	  /*
	   * psi's agent doesn't support ifindexing.. so we use
	   * the routedest variable to walk through. Two assumptions:
	   * we don't have to worry about ciscos and we can display
	   * the entire table for each interface.
	   */

	  bcopy(&(save.cmp[save.ncmp - 4]),
		&(vIPRtMetric1.cmp[save.ncmp - 4]), 
		4 * sizeof(reply.varlist.elem[0].name.cmp[0]));
	  bcopy(&(save.cmp[save.ncmp - 4]),
		&(vIPRtMetric2.cmp[vIPRtMetric2.ncmp - 4]), 
		4 * sizeof(reply.varlist.elem[0].name.cmp[0]));
	  bcopy(&(save.cmp[save.ncmp - 4]),
		&(vIPRtMetric3.cmp[vIPRtMetric3.ncmp - 4]), 
		4 * sizeof(reply.varlist.elem[0].name.cmp[0]));
	  bcopy(&(save.cmp[save.ncmp - 4]),
		&(vIPRtMetric4.cmp[vIPRtMetric4.ncmp - 4]), 
		4 * sizeof(reply.varlist.elem[0].name.cmp[0]));
	  bcopy(&(save.cmp[save.ncmp - 4]),
		&(vIPRtType.cmp[vIPRtType.ncmp - 4]), 
		4 * sizeof(reply.varlist.elem[0].name.cmp[0]));
	  bcopy(&(save.cmp[save.ncmp - 4]),
		&(vIPRtProto.cmp[vIPRtProto.ncmp - 4]), 
		4 * sizeof(reply.varlist.elem[0].name.cmp[0]));
	  bcopy(&(save.cmp[save.ncmp - 4]),
		&(vIPRtAge.cmp[vIPRtAge.ncmp - 4]), 
		4 * sizeof(reply.varlist.elem[0].name.cmp[0]));
	  bcopy(&(save.cmp[save.ncmp - 4]),
		&(vIPRtNextHop.cmp[vIPRtNextHop.ncmp - 4]), 
		4 * sizeof(reply.varlist.elem[0].name.cmp[0]));
	  
	  obj[o++] = &vIPRtMetric1;       	 
	  obj[o++] = &vIPRtMetric2;
	  obj[o++] = &vIPRtMetric3;
	  obj[o++] = &vIPRtMetric4;
	  obj[o++] = &vIPRtType;
	  obj[o++] = &vIPRtProto;
	  obj[o++] = &vIPRtAge;
	  obj[o++] = &vIPRtNextHop;
	  obj[o++] = (objident *) NULL;
	  
	  if(!(dat = make_lots_o_snmp_queries(obj)))
	    return((char *) NULL);
	  
	  o = 0;

	  bcopy(dat[o++], &m1,    sizeof(m1));
	  bcopy(dat[o++], &m2,    sizeof(m2));
	  bcopy(dat[o++], &m3,    sizeof(m3));
	  bcopy(dat[o++], &m4,    sizeof(m4));
	  bcopy(dat[o++], &type,  sizeof(type));
	  bcopy(dat[o++], &proto, sizeof(proto));
	  bcopy(dat[o++], &age,   sizeof(age));
      

          ia = (struct in_addr *) dat[o++];
	  sprintf(nexthop, "%s", inet_ntoa(*ia));
	  
	  sprintf(buf2, 
		 "%-16s %-16s %-10s %-10s %-3d %-8d %-8d %-8d %-8d ",
		  get_route_addr(&(save.cmp[save.ncmp - 4])),
		  nexthop, 
		  get_route_type(type), 
		  get_route_protocol(proto), 
		  age, m1, m2, m3, m4);

	  len += strlen(buf2) + 2;
	  if(make_buf(len) < 0)
	    return((char *) NULL);
	  strcat(buf, buf2);

	  if(vendor == CISCO)
	    {
	      bcopy(&(save.cmp[save.ncmp - 4]),
		    &(vCiscoIPRtMask.cmp[vCiscoIPRtMask.ncmp - 4]), 
		    4 * sizeof(reply.varlist.elem[0].name.cmp[0]));
	      bcopy(&(save.cmp[save.ncmp - 4]),
		    &(vCiscoIPRtCount.cmp[vCiscoIPRtCount.ncmp - 4]), 
		    4 * sizeof(reply.varlist.elem[0].name.cmp[0]));
	      bcopy(&(save.cmp[save.ncmp - 4]),
		    &(vCiscoIPRtUses.cmp[vCiscoIPRtUses.ncmp - 4]), 
		    4 * sizeof(reply.varlist.elem[0].name.cmp[0]));

	      o = 0;
	      obj[o++] = &vCiscoIPRtMask;
	      obj[o++] = &vCiscoIPRtCount;
	      obj[o++] = &vCiscoIPRtUses;
	      obj[o++] = (objident *) NULL;

	      if(!(dat = make_lots_o_snmp_queries(obj)))
		return((char *) NULL);

	      o = 0;
	      ia = (struct in_addr *) dat[o++];
	      sprintf(nexthop, "%s", inet_ntoa(*ia));
	      bcopy(dat[o++], &count, sizeof(count));
	      bcopy(dat[o++], &uses,  sizeof(uses));

	      sprintf(buf2, "%-5d %-10d %s", count, uses, nexthop);
	      len += strlen(buf2) + 1;
	      if(make_buf(len) < 0)
		return((char *) NULL);
	      strcat(buf, buf2);
	    }
	  strcat(buf, "\n");	  
	}
      datt = make_snmp_next(&save);
    }
  return(buf);
}



char *
do_ifmisc(i)
     int i;
{
  int  last_change   = 0;
  int  last_in       = 0;
  int  last_out      = 0;
  int  last_out_hang = 0;
  int  len           = 0;
  int  resets        = 0;
  int  restarts      = 0;
  int  keepalive     = 0;
  int  uptime        = 0;
  char *reason       = 0;
  char last_in_str[100];
  char last_out_str[100];
  objident *obj[SNMPMAXVARS];
  caddr_t  *dat;
  int o;

  vIfLastChange.cmp[vIfLastChange.ncmp - 1] = i;
  o = 0;
  obj[o++] = &vIfLastChange;
  obj[o++] = &vSysUptime;
  obj[o++] = (objident *) NULL;

  if(!(dat = make_lots_o_snmp_queries(obj)))
    return((char *) NULL);

  o = 0;
  bcopy(dat[o++], &last_change, sizeof(last_change));
  bcopy(dat[o++], &uptime,      sizeof(uptime));

  sprintf(buf2, "%-20s %s\n", "Last status change:", 
	  elapsed_time((uptime - last_change)/100));
  len = strlen(buf2) + 1;
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf, buf2);
    
  if(vendor == CISCO)
    {
      vCiscoIfLastIn.cmp[vCiscoIfLastIn.ncmp - 1]           = i;
      vCiscoIfLastOut.cmp[vCiscoIfLastOut.ncmp - 1]         = i;
      vCiscoIfLastOutHang.cmp[vCiscoIfLastOutHang.ncmp - 1] = i;
      vCiscoIfResets.cmp[vCiscoIfResets.ncmp - 1]           = i;
      vCiscoIfRestarts.cmp[vCiscoIfRestarts.ncmp - 1]       = i;
      vCiscoIfKeep.cmp[vCiscoIfKeep.ncmp - 1]               = i;
      vCiscoIfReason.cmp[vCiscoIfReason.ncmp - 1]           = i;

      o = 0;
      obj[o++] = &vCiscoIfLastIn;
      obj[o++] = &vCiscoIfLastOut;
      obj[o++] = &vCiscoIfLastOutHang;
      obj[o++] = &vCiscoIfResets;
      obj[o++] = &vCiscoIfRestarts;
      obj[o++] = &vCiscoIfKeep;
      obj[o++] = &vCiscoIfReason;       
      obj[o++] = (objident *) NULL;
      
      if(!(dat = make_lots_o_snmp_queries(obj)))
	return((char *) NULL);

      o = 0;
      bcopy(dat[o++], &last_in,       sizeof(last_in));
      bcopy(dat[o++], &last_out,      sizeof(last_out));
      bcopy(dat[o++], &last_out_hang, sizeof(last_out_hang));
      bcopy(dat[o++], &resets,        sizeof(resets));
      bcopy(dat[o++], &restarts,      sizeof(restarts));
      bcopy(dat[o++], &keepalive,     sizeof(keepalive));
      reason = (char *) dat[o++];

      strcpy(last_in_str,  elapsed_time(last_in/1000));
      strcpy(last_out_str, elapsed_time(last_out/1000));

      sprintf(buf2, "\nCisco Local Variables:\n%-20s %s\n%-20s %s\n%-20s %s\n\n%-20s %d\n%-20s %d\n%-20s %s\n%-20s %s\n",
	      "Last in:",       last_in_str,
	      "Last out:",      last_out_str,
	      "Last out hang:", elapsed_time(last_out_hang/1000),
	      "Resets:",        resets,
	      "Restarts:",      restarts,
	      "Keepalives:",    keepalive == 1 ? "enabled" : "disabled",
	      "Status:",        reason);

      len += strlen(buf2);
      if(make_buf(len + 1) < 0)
	return((char *) NULL);
      strcat(buf, buf2);
    }
  return(buf);
}




char *
do_cisco_memory()
{
  int free      = 0;
  int bfail     = 0;
  int bnomem    = 0;
  int belfree   = 0;
  int belmax    = 0;
  int belhit    = 0;
  int belmiss   = 0;
  int belcreate = 0;
  int bsmsize   = 0;
  int bsmtotal  = 0;
  int bsmfree   = 0;
  int bsmmax    = 0;
  int bsmhit    = 0;
  int bsmmiss   = 0;
  int bsmtrim   = 0;
  int bsmcreate = 0;
  int bmdsize   = 0;
  int bmdtotal  = 0;
  int bmdfree   = 0;
  int bmdmax    = 0;
  int bmdhit    = 0;
  int bmdmiss   = 0;
  int bmdtrim   = 0;
  int bmdcreate = 0;
  int bbgsize   = 0;
  int bbgtotal  = 0;
  int bbgfree   = 0;
  int bbgmax    = 0;
  int bbghit    = 0;
  int bbgmiss   = 0;
  int bbgtrim   = 0;
  int bbgcreate = 0;
  int blgsize   = 0;
  int blgtotal  = 0;
  int blgfree   = 0;
  int blgmax    = 0;
  int blghit    = 0;
  int blgmiss   = 0;
  int blgtrim   = 0;
  int blgcreate = 0;
  objident *obj[SNMPMAXVARS];
  caddr_t  *dat;
  int len = 0;
  int o;

  if(vendor != CISCO)
    return("not supported");

  o = 0;
  obj[o++] = &vCiscoFreeMem;
  obj[o++] = &vCiscoBufferFail;
  obj[o++] = &vCiscoBufferNoMem;
  obj[o++] = &vCiscoBufferElFree;
  obj[o++] = &vCiscoBufferElMax;
  obj[o++] = &vCiscoBufferElHit;
  obj[o++] = &vCiscoBufferElMiss;
  obj[o++] = &vCiscoBufferElCreate;
  obj[o++] = (objident *) NULL;

  if(!(dat = make_lots_o_snmp_queries(obj)))
    return((char *) NULL);

  o = 0;
  bcopy(dat[o++], &free,      sizeof(free));
  bcopy(dat[o++], &bfail,     sizeof(bfail));
  bcopy(dat[o++], &bnomem,    sizeof(bnomem));
  bcopy(dat[o++], &belfree,   sizeof(belfree));
  bcopy(dat[o++], &belmax,    sizeof(belmax));
  bcopy(dat[o++], &belhit,    sizeof(belhit));
  bcopy(dat[o++], &belmiss,   sizeof(belmiss));
  bcopy(dat[o++], &belcreate, sizeof(belcreate));

  o = 0;
  obj[o++] = &vCiscoBufferSmSize;
  obj[o++] = &vCiscoBufferSmTotal;
  obj[o++] = &vCiscoBufferSmFree;
  obj[o++] = &vCiscoBufferSmMax;
  obj[o++] = &vCiscoBufferSmHit;
  obj[o++] = &vCiscoBufferSmMiss;
  obj[o++] = &vCiscoBufferSmTrim;
  obj[o++] = &vCiscoBufferSmCreate;
  obj[o++] = (objident *) NULL;

  if(!(dat = make_lots_o_snmp_queries(obj)))
    return((char *) NULL);

  o = 0;
  bcopy(dat[o++], &bsmsize,   sizeof(bsmsize));
  bcopy(dat[o++], &bsmtotal,  sizeof(bsmtotal));
  bcopy(dat[o++], &bsmfree,   sizeof(bsmfree));
  bcopy(dat[o++], &bsmmax,    sizeof(bsmmax));
  bcopy(dat[o++], &bsmhit,    sizeof(bsmhit));
  bcopy(dat[o++], &bsmmiss,   sizeof(bsmmiss));
  bcopy(dat[o++], &bsmtrim,   sizeof(bsmtrim));
  bcopy(dat[o++], &bsmcreate, sizeof(bsmcreate));

  o = 0;
  obj[o++] = &vCiscoBufferMdSize;
  obj[o++] = &vCiscoBufferMdTotal;
  obj[o++] = &vCiscoBufferMdFree;
  obj[o++] = &vCiscoBufferMdMax;
  obj[o++] = &vCiscoBufferMdHit;
  obj[o++] = &vCiscoBufferMdMiss;
  obj[o++] = &vCiscoBufferMdTrim;
  obj[o++] = &vCiscoBufferMdCreate;
  obj[o++] = (objident *) NULL;

  if(!(dat = make_lots_o_snmp_queries(obj)))
    return((char *) NULL);
  
  o = 0;
  bcopy(dat[o++], &bmdsize,   sizeof(bmdsize));
  bcopy(dat[o++], &bmdtotal,  sizeof(bmdtotal));
  bcopy(dat[o++], &bmdfree,   sizeof(bmdfree));
  bcopy(dat[o++], &bmdmax,    sizeof(bmdmax));
  bcopy(dat[o++], &bmdhit,    sizeof(bmdhit));
  bcopy(dat[o++], &bmdmiss,   sizeof(bmdmiss));
  bcopy(dat[o++], &bmdtrim,   sizeof(bmdtrim));
  bcopy(dat[o++], &bmdcreate, sizeof(bmdcreate));

  o = 0;
  obj[o++] = &vCiscoBufferBgSize;
  obj[o++] = &vCiscoBufferBgTotal;
  obj[o++] = &vCiscoBufferBgFree;
  obj[o++] = &vCiscoBufferBgMax;
  obj[o++] = &vCiscoBufferBgHit;
  obj[o++] = &vCiscoBufferBgMiss;
  obj[o++] = &vCiscoBufferBgTrim;
  obj[o++] = &vCiscoBufferBgCreate;
  obj[o++] = (objident *) NULL;

  if(!(dat = make_lots_o_snmp_queries(obj)))
    return((char *) NULL);

  o = 0;
  bcopy(dat[o++], &bbgsize,   sizeof(bbgsize));
  bcopy(dat[o++], &bbgtotal,  sizeof(bbgtotal));
  bcopy(dat[o++], &bbgfree,   sizeof(bbgfree));
  bcopy(dat[o++], &bbgmax,    sizeof(bbgmax));
  bcopy(dat[o++], &bbghit,    sizeof(bbghit));
  bcopy(dat[o++], &bbgmiss,   sizeof(bbgmiss));
  bcopy(dat[o++], &bbgtrim,   sizeof(bbgtrim));
  bcopy(dat[o++], &bbgcreate, sizeof(bbgcreate));

  o = 0;
  obj[o++] = &vCiscoBufferLgSize;
  obj[o++] = &vCiscoBufferLgTotal;
  obj[o++] = &vCiscoBufferLgFree;
  obj[o++] = &vCiscoBufferLgMax;
  obj[o++] = &vCiscoBufferLgHit;
  obj[o++] = &vCiscoBufferLgMiss;
  obj[o++] = &vCiscoBufferLgTrim;
  obj[o++] = &vCiscoBufferLgCreate;
  obj[o++] = (objident *) NULL;

  if(!(dat = make_lots_o_snmp_queries(obj)))
    return((char *) NULL);

  o = 0;
  bcopy(dat[o++], &blgsize,   sizeof(blgsize));
  bcopy(dat[o++], &blgtotal,  sizeof(blgtotal));
  bcopy(dat[o++], &blgfree,   sizeof(blgfree));
  bcopy(dat[o++], &blgmax,    sizeof(blgmax));
  bcopy(dat[o++], &blghit,    sizeof(blghit));
  bcopy(dat[o++], &blgmiss,   sizeof(blgmiss));
  bcopy(dat[o++], &blgtrim,   sizeof(blgtrim));
  bcopy(dat[o++], &blgcreate, sizeof(blgcreate));

  sprintf(buf2, 
      "%-30s %d \n%-30s %u\n%-30s %u\n\n%-10s %-10s %-10s %-10s %-10s %s\n",
	  "free memory (bytes):",             free,
	  "buffer alloc fails:",              bfail,
	  "buffer alloc fails (no mem):",     bnomem,
	  "", "element", "small", "medium", "big", "large");

  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf, buf2);

  sprintf(buf2, 
    "%-10s %-10s %-10u %-10u %-10u %-10u\n%-10s %-10s %-10u %-10u %-10u %u\n",
	  "size",  "", bsmsize,  bmdsize,  bbgsize,  blgsize,
	  "total", "", bsmtotal, bmdtotal, bbgtotal, blgtotal);
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcat(buf, buf2);

  sprintf(buf2, "%-10s %-10u %-10u %-10u %-10u %u\n%-10s %-10u %-10u %-10u %-10u %u\n%-10s %-10u %-10u %-10u %-10u %u\n%-10s %-10u %-10u %-10u %-10u %u\n%-10s %-10u %-10u %-10u %-10u %u\n",
	  "free",   belfree,   bsmfree,   bmdfree,   bbgfree,   blgfree,
	  "max",    belmax,    bsmmax,    bmdmax,    bbgmax,    blgmax,
	  "hit",    belhit,    bsmhit,    bmdhit,    bbghit,    blghit,
	  "miss",   belmiss,   bsmmiss,   bmdmiss,   bbgmiss,   blgmiss,
	  "create", belcreate, bsmcreate, bmdcreate, bbgcreate, blgcreate); 
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcat(buf, buf2);
  
  sprintf(buf2, "%-10s %-10s %-10u %-10u %-10u %u\n",
	  "trim",  "", bsmtrim,  bmdtrim,  bbgtrim,  blgtrim);
  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcat(buf, buf2);

  return(buf);
}



char *
do_cisco_boot_info()
{
  char     *romid;
  char     *why;
  char     *hostname;
  char     *domain;
  struct   in_addr *boothost;
  struct   in_addr *netip;
  char     *netname;
  char     *netset;
  struct   in_addr *hostip;
  char     *hname;
  char     *hostset; 
  char     *bh[100];
  char     *ni[100];
  objident *obj[SNMPMAXVARS];
  caddr_t  *dat;
  int len = 0;
  int o;

  if(vendor != CISCO)
    return("unsupported");

  o = 0;
  obj[o++] = &vCiscoRomID;
  obj[o++] = &vCiscoWhyReload;
  obj[o++] = &vCiscoHostName;
  obj[o++] = &vCiscoDomainName;
  obj[o++] = &vCiscoBootHost;
  obj[o++] = &vCiscoNetConfigIP;
  obj[o++] = &vCiscoNetConfigName;
  obj[o++] = &vCiscoNetConfigSet;
  obj[o++] = &vCiscoHostConfigIP;
  obj[o++] = &vCiscoHostConfigName;
  obj[o++] = &vCiscoHostConfigSet;
  obj[o++] = (objident *) NULL;  

  if(!(dat = make_lots_o_snmp_queries(obj)))
    return((char *) NULL);

  o = 0;
  romid     = (char *) dat[o++];
  why       = (char *) dat[o++];
  hname     = (char *) dat[o++];
  domain    = (char *) dat[o++];
  boothost  = (struct in_addr *) dat[o++];
  netip     = (struct in_addr *) dat[o++];
  netname   = (char *) dat[o++];
  netset    = (char *) dat[o++];
  hostip    = (struct in_addr *) dat[o++];
  hostname  = (char *) dat[o++];
  hostset   = (char *) dat[o++];

  sprintf(bh, "%s", inet_ntoa(*boothost));
  sprintf(ni, "%s", inet_ntoa(*netip));
  sprintf(buf2, "%-20s %s\n\n%-20s %s\n%-20s %s\n%-20s %s\n\n%-20s %s\n%-20s %s\n%-20s %s\n%-20s %s\n%-20s %-16s\n%-20s %s\n%-20s %s",
	  "bootstrap desc:",           romid,
	  "restart cause:",            why,
	  "configured hostname:",      hname,
	  "configured domain:",        domain,
	  "boot host:",                bh, 
	  "net config server:",        ni,
	  "net config name:",          netname,
	  "permit loading:",           netset,
	  "host config server:",       inet_ntoa(*hostip),
	  "host config name:",         hname,
	  "permit loading:",           hostset);

  len += strlen(buf2);
  if(make_buf(len + 1) < 0)
    return((char *) NULL);
  strcpy(buf, buf2);
   
  return(buf);
}



make_variable_addr(obj, addr)
     objident *obj;
     int addr[];
{
  obj->cmp[obj->ncmp - 4] = addr[0];
  obj->cmp[obj->ncmp - 3] = addr[1];
  obj->cmp[obj->ncmp - 2] = addr[2];
  obj->cmp[obj->ncmp - 1] = addr[3];
}



char *
get_route_addr(a)
     unsigned long  *a;
{
  static char addr[16];
  
  if((a[0] == 0) && (a[1] == 0) && (a[2] == 0) && (a[3] == 0))
    return("default");
  
  if((a[0] == 127) && (a[1] == 0) && (a[2] == 0) && (a[3] == 0))
    return("localhost");

  sprintf(addr, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
  return(addr);
}



char *
get_interface_type(i)
     int i;
{
  if((i < 0) || (i > num_interface_types))
    return("unknown");

  return(interface_type[i - 1]);
}



char *
get_route_protocol(p)
     int p;
{
  if((p < 0) || (p > num_route_protocols))
    return("unknown");

  return(route_protocol[p - 1]);
}


char *
get_route_type(t)
     int t;
{
  if((t < 0) || (t > num_route_types))
    return("unknown");

  return(route_type[t - 1]);
}


char *
get_tcp_timeout_algorithm(t)
     int t;
{
  if((t < 0) || (t > num_tcp_timeout_algorithms))
    return("unknown");

  return(tcp_timeout_algorithm[t - 1]);
}



char *
get_tcp_connection_state(t)
     int t;
{
  if((t < 0) || (t > num_tcp_connection_states))
    return("unknown");

  return(tcp_connection_state[t - 1]);
}


char *
get_servname(p)
     int p;
{
  static struct servent *sent;
  static char label[16];

  if((sent = getservbyport(htons(p), NULL)) == (struct servent *) NULL)
    {
      sprintf(label, "%d", p);
      return(label);
    }
  else
    return(sent->s_name);
}


char *
get_hostname(in)
     struct in_addr *in;
{
  struct hostent *hp = (struct hostent *) NULL;

  if((hp = gethostbyaddr((char *) &(in->s_addr), 4, AF_INET)) == 
     (struct hostent *) NULL)
    return((char *) NULL);

  return(hp->h_name);
}
