<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
Hi<br>
<br>
re: Proposed addition to NutOS/PPP<br>
<br>
Please find attached a few simple changes that we use in the 3.9.5
kernel which allow the simple tracking of packets and bytes over PPP
adapters. It is reset each time the adapter is reset but allows a
simple mechanism to track/monitor costs. When you are working with
CDMA and GPRS, they charge like wounded bulls, typically by bytes,
which includes the packet and IP overheads. <br>
<br>
This change allows the application to interogate progressive data
volumes put through the PPP adapter, even unsolicited and network
packets (which you still pay for). We've found it useful also for
tracking faults and latency issues.<br>
<br>
A few notes: <br>
1. Perhaps the changes could be added with #ifdef to keep sturcutres
streamlined for those who dont need it.<br>
2. Should the additional variables be defined as volatile?<br>
<br>
Regards<br>
Brett<br>
<br>
<pre class="moz-signature" cols="72">-----------------------------------------------------------------
</pre>
Add to include/dev/ppp.h:<br>
<br>
/*! \brief Current authentication state.<br>
*/<br>
u_char dcb_auth_state;<br>
<br>
/*! \brief File descriptor of physical device.<br>
*/<br>
int dcb_fd;<br>
<br>
/* Start of Change April 2005, Brett Abbott */<br>
/* Packet and Byte Monitoring, excludes ppp headers and escape
bytes */<br>
u_long sent_packets;<br>
u_long sent_databytes;<br>
u_long recv_packets;<br>
u_long recv_databytes;<br>
/* End of Change April 2005, Brett Abbott */<br>
<br>
};<br>
<pre class="moz-signature" cols="72">-----------------------------------------------------------------
</pre>
// Change to net/pppout.c<br>
<br>
int NutPppOutput(NUTDEVICE * dev, u_short type, u_char * ha, NETBUF *
nb)<br>
{<br>
PPPHDR *ph;<br>
IFNET *nif = dev->dev_icb;<br>
PPPDCB *dcb = dev->dev_dcb;<br>
<br>
/*<br>
* Allocate and set the HDLC header.<br>
*/<br>
if (NutNetBufAlloc(nb, NBAF_DATALINK, sizeof(PPPHDR)) == 0)<br>
return -1;<br>
<br>
ph = (PPPHDR *) nb->nb_dl.vp;<br>
ph->address = AHDLC_ALLSTATIONS;<br>
ph->control = AHDLC_UI;<br>
ph->prot_type = htons(type);<br>
<br>
#ifdef NUTDEBUG<br>
if (__ppp_trf) {<br>
fputs("\nPPP<", __ppp_trs);<br>
NutDumpPpp(__ppp_trs, nb);<br>
}<br>
#elif defined(__IMAGECRAFT__)<br>
/*<br>
* No idea what this is, but ICCAVR fails if this call isn't there.<br>
*/<br>
NutSleep(100);<br>
#endif<br>
<br>
<br>
/* Start of Change April 2005, Brett Abbott */<br>
// Added to count outgoing data<br>
dcb->sent_packets++;<br>
dcb->sent_databytes+=nb->nb_nw.sz + nb->nb_tp.sz +
nb->nb_ap.sz;<br>
/* End of Change April 2005, Brett Abbott */<br>
<br>
/*<br>
* Call the physical device output routine.<br>
*/<br>
if (nif->if_send && (*nif->if_send) ((((NUTFILE *)
(uptr_t) (dcb->dcb_fd)))->nf_dev, nb) == 0) {<br>
return 0;<br>
}<br>
NutNetBufFree(nb);<br>
return -1;<br>
}<br>
-----------------------------------------------------------------<br>
<pre class="moz-signature" cols="72">// Change to net/pppin.c
/* Start of Change April 2005, Brett Abbott */
/*
* We count the bytes and packets - we count the discarded packets as well as we still have to pay
* Added to count data from incoming ppp packets
*/
dcb->recv_packets++;
dcb->recv_databytes+=nb->nb_nw.sz;
/* End of Change April 2005, Brett Abbott */
/*
* Toss all non-LCP packets unless LCP is OPEN.
*/
if (protocol != PPP_LCP && dcb->dcb_lcp_state != PPPS_OPENED) {
NutNetBufFree(nb);
return;
}
-----------------------------------------------------------------
-----------------------------------------------------------------
-----------------------------------------------------------------
</pre>
<pre class="moz-signature" cols="72">--
-----------------------------------------------------------------
Brett Abbott, Managing Director, Digital Telemetry Limited
Email: <a
class="moz-txt-link-abbreviated"
href="mailto:Brett.Abbott@digital-telemetry.com">Brett.Abbott@digital-telemetry.com</a>
PO Box 24 036 Manners Street, Wellington, New Zealand
Phone +64 (4) 5666-860 Mobile +64 (21) 656-144
------------------- Commercial in confidence --------------------
</pre>
</body>
</html>