kernels/linux-2.4.0/net/wanrouter/wanproc.c
/*
 *	Prepare data for reading <device> entry.
 *	Return length of data.
 *
 *	On entry, the 'start' argument will contain a pointer to WAN device
 *	data space.
 */
Prepare data for reading  entry.
Return length of data.

On entry, the 'start' argument will contain a pointer to WAN device
data space.
Prepare data for reading entry . Return length of data . On entry the ' start ' argument will contain a pointer to WAN device data space .
static int wandev_get_info(char* buf, char** start, off_t offs, int len)
{
	wan_device_t* wandev = (void*)start;
	int cnt = 0;
	int rslt = 0;
	if ((wandev == NULL) || (wandev->magic != ROUTER_MAGIC))
		return 0;
	if (!wandev->state)
		return sprintf(&buf[cnt], "device is not configured!\n");
	if (wandev->update) {
		rslt = wandev->update(wandev);
		if(rslt) {
			switch (rslt) {
			case -EAGAIN:
				return sprintf(&buf[cnt], "Device is busy!\n");
			default:
				return sprintf(&buf[cnt],
					"Device is not configured!\n");
			}
		}
	}
        cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
                "total packets received", wandev->stats.rx_packets);
	cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
                "total packets transmitted", wandev->stats.tx_packets);
        cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
                "total bytes received", wandev->stats.rx_bytes);
        cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
                "total bytes transmitted", wandev->stats.tx_bytes);
        cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
                "bad packets received", wandev->stats.rx_errors);
       	cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
                "packet transmit problems", wandev->stats.tx_errors);
	cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
                "received frames dropped", wandev->stats.rx_dropped);
        cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
                "transmit frames dropped", wandev->stats.tx_dropped);
	cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
                "multicast packets received", wandev->stats.multicast);
        cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
                "transmit collisions", wandev->stats.collisions);
        cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
                "receive length errors", wandev->stats.rx_length_errors);
	cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
		"receiver overrun errors", wandev->stats.rx_over_errors);
	cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
		"CRC errors", wandev->stats.rx_crc_errors);
	cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
		"frame format errors (aborts)", wandev->stats.rx_frame_errors);
        cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
                "receiver fifo overrun", wandev->stats.rx_fifo_errors);
	cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
		"receiver missed packet", wandev->stats.rx_missed_errors);
	cnt += sprintf(&buf[cnt], PROC_STATS_FORMAT,
		"aborted frames transmitted", wandev->stats.tx_aborted_errors);
  	return cnt;
}
static int wandev_get_info ( char * buf , char * * start , off_t offs , int len ) { wan_device_t * wandev = ( void * ) start ; int cnt = 0 ; int rslt = 0 ; if ( ( wandev == NULL ) || ( wandev -> magic != ROUTER_MAGIC ) ) return 0 ; if ( ! wandev -> state ) return sprintf ( & buf [ cnt ] , " \n " ) ; if ( wandev -> update ) { rslt = wandev -> update ( wandev ) ; if ( rslt ) { switch ( rslt ) { case - EAGAIN : return sprintf ( & buf [ cnt ] , " \n " ) ; default : return sprintf ( & buf [ cnt ] , " \n " ) ; } } } cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . rx_packets ) ; cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . tx_packets ) ; cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . rx_bytes ) ; cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . tx_bytes ) ; cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . rx_errors ) ; cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . tx_errors ) ; cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . rx_dropped ) ; cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . tx_dropped ) ; cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . multicast ) ; cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . collisions ) ; cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . rx_length_errors ) ; cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . rx_over_errors ) ; cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . rx_crc_errors ) ; cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . rx_frame_errors ) ; cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . rx_fifo_errors ) ; cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . rx_missed_errors ) ; cnt += sprintf ( & buf [ cnt ] , PROC_STATS_FORMAT , " " , wandev -> stats . tx_aborted_errors ) ; return cnt ; }
Prepare data for reading <device> entry.
Prepare data for reading <device > entry .
/* Update device statistics */