Stats 3.16 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
/* Copyright 1998 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
*  Lan Manager client
*
*  Stats.C -- Statistics gathering
*
*  Versions
*  21-08-95 INH Original
*
*/

/* Standard includes */

#include <stdio.h>

/* Our includes */

#include "stdtypes.h"
#include "stats.h"

int Stat_StatTable [STA_MAXSTATS];
int Stat_ClassMask;

struct stat_info
{
  int stat_no;
  int sclass;
  char *name;
};

static struct stat_info statinfo[] =
{
  STA_SERIOUS_BARF, SCLASS_GENERAL,  "Internal errors",
  STA_NETTX_PKTS,   SCLASS_NETBEUI,  "Total Tx packets",
  STA_NETRX_EVTS,   SCLASS_NETBEUI,  "Total Rx events",
  STA_NETRX_PKTS,   SCLASS_NETBEUI,  "Total Rx packets",
  STA_NETRX_OWNTX,  SCLASS_NETBEUI,  "Rx: Own transmission",

  STA_LLCRX_PKTS,   SCLASS_NETBEUI,  "LLC: Rx pkts total",
  STA_LLCRX_NOCONN, SCLASS_NETBEUI,  "LLC: Ignored rx packets",
  STA_LLCRX_TOOSHORT,SCLASS_NETBEUI, "LLC: Rx Too short",
  STA_LLCRX_UIDATA, SCLASS_NETBEUI,  "LLC: Rx Datagram",
  STA_LLCRX_UFORMAT,SCLASS_NETBEUI,  "LLC: Rx U-format",

  STA_LLCRX_SFORMAT,SCLASS_NETBEUI,  "LLC: Rx S-format",
  STA_LLCRX_IFORMAT,SCLASS_NETBEUI,  "LLC: Rx I-format",
  STA_LLCRX_DATA,   SCLASS_NETBEUI,  "LLC: Rx Data pkts accepted",
  STA_LLCRX_REJDATA,SCLASS_NETBEUI,  "LLC: Rx Data pkts rejected",
  STA_LLC_TXPACKETS,SCLASS_NETBEUI,  "LLC: Tx Data pkts sent",

  STA_LLCRX_PKTACKS,SCLASS_NETBEUI,  "LLC: Tx Data pkts acked",
  STA_LLCRX_REJECTS,SCLASS_NETBEUI,  "LLC: Tx Data pkts rejected",
  STA_LLCRX_RESENDS,SCLASS_NETBEUI,  "LLC: Tx Data pkts re-sent",
  STA_LLC_OPENREQ,  SCLASS_NETBEUI,  "LLC: Open Conn requests",
  STA_LLCRX_CONN,   SCLASS_NETBEUI,  "LLC: Connections made",

  STA_LLC_CLOSEREQ, SCLASS_NETBEUI,  "LLC: Close Conn requests",
  STA_LLCRX_DISCON, SCLASS_NETBEUI,  "LLC: Connections ended",
  STA_LLCRX_FRMR,   SCLASS_NETBEUI,  "LLC: Abort with FRMR error",
  STA_LLCRX_DISC,   SCLASS_NETBEUI,  "LLC: Abort with DISC req",
  STA_LLC_T1FAIL,   SCLASS_NETBEUI,  "LLC: Abort with T1 timeout",

  STA_LLCRX_UNKNOWNU, SCLASS_NETBEUI,"LLC: Unknown U-format pkt",
  STA_LLC_T1EXPIRE, SCLASS_NETBEUI,  "LLC: T1 timeouts",

  STA_IP_EVENTS,    SCLASS_IP,       "IP:  Internet events",
  STA_IP_RXDGRAM,   SCLASS_IP,       "IP:  Receive datagrams",


  -1, 0, NULL
};

/* -------------- */

void Stat_Show ( void )
{
  int i;
  for ( i=0; statinfo[i].stat_no >= 0; i++ )
  {
    if ( statinfo[i].sclass & Stat_ClassMask )
      printf("%-30s: %d\n", statinfo[i].name,
             Stat_StatTable[statinfo[i].stat_no] );
  }
  printf("\n");
}

/* ------------- */

bool Stat_Init ( void )
{
  int i;

  Stat_ClassMask = SCLASS_GENERAL;
  for (i=0; i<STA_MAXSTATS; i++)
    Stat_StatTable[i] = 0;

  return true;
}