lapbStats()
PROTOTYPE
#include <lapb.h>
int lapbStats(uint channel, int print, LapbStats *lp, PhysStats *pp);
DESCRIPTION
lapbStats() gets LAPB and physical layer statistics for the channel specified by channel, which must be in the range from 0 to LAPB_MAX_NUM_CHANNELS - 1 and correspond to a registered HDLC channel. If print is not zero, a report on the operating statistics is written to stdout. If lp is not NULL, the channel’s LapbStats structure is written to *lp. If pp is not NULL, the channel’s PhysStats structure is written to *pp.
The PhysStats structure must be defined in the HDLC driver’s include file and its definition must be visible in any application file that uses lapbStats() to access HDLC driver statistics. LapbStats is discussed in “Using TargetLAPB”. It is defined in “lapb.h” and reproduced below:
/*
** LAPB Statistics Structure
*/
typedef struct
{
ui32 iframes_sent; /* number of I frames sent */
ui32 iframes_rcvd; /* number of I frames received */
ui32 RNR_sent; /* number of RNR frames sent */
ui32 RNR_rcvd; /* number of RNR frames received */
ui32 REJ_sent; /* number of REJ frames sent */
ui32 REJ_rcvd; /* number of REJ frames received */
#if LAPB_SREJ
ui32 SREJ_sent; /* number of SREJ frames sent */
ui32 SREJ_rcvd; /* number of SREJ frames received */
#endif
ui32 num_connects; /* number of completed connections */
ui32 conn_resets; /* number of connection resets */
ui32 checkpoints; /* number of checkpoints performed */
ui32 invalids; /* number of invalid frames */
ui32 unsolicited_f; /* number of unsolicited F=1 */
ui32 unsolicited_UA; /* number of unsolicited UA */
ui32 no_rbufs; /* number of failed rbuf requests */
ui32 rbuf_hi_mark; /* recv buffer usage high water mark */
} LapbStats;
If successful, lapbStats() returns 0. Otherwise, it sets errno and returns -1.
ERROR CODES
| LAPB_INVALID_CHAN | channel is not a registered channel in the range from 0 to LAPB_MAX_NUM_CHANNELS - 1. |
| LAPB_UNINITIALIZED | The initialization routine lapbInit() has not been called. |
EXAMPLE
/*-----------------------------------------------------------------*/
/* Print channel's LAPB statistics. */
/*-----------------------------------------------------------------*/
rc = lapbStats(chan, TRUE, NULL, NULL);