summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1997-09-03 02:08:20 +0000
committerbrian <brian@FreeBSD.org>1997-09-03 02:08:20 +0000
commita5b9ae295918c9219a141f439a54c0478e8463c3 (patch)
treef025931d5d51eb8c3d89f9373f64572853a573de /usr.sbin/ppp
parent2ee142dce306fa15e6b932e9243a4fed3e1be7c8 (diff)
downloadFreeBSD-src-a5b9ae295918c9219a141f439a54c0478e8463c3.zip
FreeBSD-src-a5b9ae295918c9219a141f439a54c0478e8463c3.tar.gz
Bring CCP and IPCP layers down properly when LCP
comes down. Give a count of bytes sent/received in IPCP log.
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r--usr.sbin/ppp/ipcp.c48
-rw-r--r--usr.sbin/ppp/ipcp.h4
-rw-r--r--usr.sbin/ppp/lcp.c4
-rw-r--r--usr.sbin/ppp/os.c13
4 files changed, 52 insertions, 17 deletions
diff --git a/usr.sbin/ppp/ipcp.c b/usr.sbin/ppp/ipcp.c
index ebdf521..3ac6953 100644
--- a/usr.sbin/ppp/ipcp.c
+++ b/usr.sbin/ppp/ipcp.c
@@ -17,20 +17,23 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ipcp.c,v 1.26 1997/08/25 00:29:14 brian Exp $
+ * $Id: ipcp.c,v 1.27 1997/08/31 22:59:29 brian Exp $
*
* TODO:
* o More RFC1772 backwoard compatibility
*/
-#include "fsm.h"
-#include "lcpproto.h"
-#include "lcp.h"
-#include "ipcp.h"
+#include <sys/types.h>
#include <netdb.h>
#include <netinet/in_systm.h>
+#include <netinet/in.h>
#include <netinet/ip.h>
#include <arpa/inet.h>
#include <sys/socket.h>
+#include <limits.h>
+#include "fsm.h"
+#include "lcpproto.h"
+#include "lcp.h"
+#include "ipcp.h"
#include "slcompress.h"
#include "os.h"
#include "phase.h"
@@ -64,6 +67,7 @@ static void IpcpInitRestartCounter(struct fsm *);
struct pppTimer IpcpReportTimer;
static int lastInOctets, lastOutOctets;
+static int StartingIpIn, StartingIpOut;
#define REJECTED(p, x) (p->his_reject & (1<<x))
@@ -136,7 +140,11 @@ ReportIpcpStatus()
inet_ntoa(icp->his_ipaddr), icp->his_compproto);
fprintf(VarTerm, " my side: %s, %lx\n",
inet_ntoa(icp->want_ipaddr), icp->want_compproto);
- fprintf(VarTerm, "connected: %d secs, idle: %d secs\n\n", ipConnectSecs, ipIdleSecs);
+ fprintf(VarTerm, "Connected: %d secs, idle: %d secs\n\n",
+ ipConnectSecs, ipIdleSecs);
+ fprintf(VarTerm, " %d octets in, %d octets out\n",
+ IpcpOctetsIn(), IpcpOctetsOut());
+
fprintf(VarTerm, "Defaults:\n");
fprintf(VarTerm, " My Address: %s/%d\n",
inet_ntoa(DefMyAddress.ipaddr), DefMyAddress.width);
@@ -183,9 +191,9 @@ IpcpInit()
}
/*
- * Some implementation of PPP are: Starting a negotiaion by require sending
- * *special* value as my address, even though standard of PPP is defined
- * full negotiation based. (e.g. "0.0.0.0" or Not "0.0.0.0")
+ * Some implementations of PPP require that we send a
+ * *special* value as our address, even though the rfc specifies
+ * full negotiation (e.g. "0.0.0.0" or Not "0.0.0.0").
*/
if (HaveTriggerAddress) {
icp->want_ipaddr.s_addr = TriggerAddress.s_addr;
@@ -197,6 +205,8 @@ IpcpInit()
icp->want_compproto = 0;
icp->heis1172 = 0;
IpcpFsm.maxconfig = 10;
+ StartingIpIn = ipInOctets;
+ StartingIpOut = ipOutOctets;
}
static void
@@ -253,10 +263,28 @@ IpcpLayerFinish(struct fsm * fp)
NewPhase(PHASE_TERMINATE);
}
+int
+IpcpOctetsIn()
+{
+ return ipInOctets < StartingIpIn ?
+ INT_MAX - StartingIpIn + ipInOctets - INT_MIN + 1 :
+ ipInOctets - StartingIpIn;
+}
+
+int
+IpcpOctetsOut()
+{
+ return ipOutOctets < StartingIpOut ?
+ INT_MAX - StartingIpOut + ipOutOctets - INT_MIN + 1 :
+ ipOutOctets - StartingIpOut;
+}
+
static void
IpcpLayerDown(struct fsm * fp)
{
LogPrintf(LogIPCP, "IpcpLayerDown.\n");
+ LogPrintf(LogIPCP, "%d octets in, %d octets out\n",
+ IpcpOctetsIn(), IpcpOctetsOut());
StopTimer(&IpcpReportTimer);
}
@@ -282,6 +310,8 @@ IpcpLayerUp(struct fsm * fp)
if (mode & MODE_ALIAS)
VarPacketAliasSetAddress(IpcpInfo.want_ipaddr);
OsLinkup();
+ StartingIpIn = ipInOctets;
+ StartingIpOut = ipOutOctets;
IpcpStartReport();
StartIdleTimer();
}
diff --git a/usr.sbin/ppp/ipcp.h b/usr.sbin/ppp/ipcp.h
index 4f76105..aea08d5 100644
--- a/usr.sbin/ppp/ipcp.h
+++ b/usr.sbin/ppp/ipcp.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: ipcp.h,v 1.8 1997/08/19 01:10:22 brian Exp $
+ * $Id: ipcp.h,v 1.9 1997/08/25 00:29:15 brian Exp $
*
* TODO:
*/
@@ -76,5 +76,7 @@ extern struct in_addr nbns_entries[2];
extern void IpcpInit(void);
extern void IpcpDefAddress(void);
+extern int IpcpOctetsIn(void);
+extern int IpcpOctetsOut(void);
#endif
diff --git a/usr.sbin/ppp/lcp.c b/usr.sbin/ppp/lcp.c
index 89f3f75..9484b7b 100644
--- a/usr.sbin/ppp/lcp.c
+++ b/usr.sbin/ppp/lcp.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: lcp.c,v 1.28 1997/08/31 22:59:31 brian Exp $
+ * $Id: lcp.c,v 1.29 1997/09/03 00:40:49 brian Exp $
*
* TODO:
* o Validate magic number received from peer.
@@ -366,9 +366,9 @@ LcpLayerUp(struct fsm * fp)
static void
LcpLayerDown(struct fsm * fp)
{
- LogPrintf(LogLCP, "LcpLayerDown\n");
StopAllTimers();
OsLinkdown();
+ LogPrintf(LogLCP, "LcpLayerDown\n");
NewPhase(PHASE_TERMINATE);
}
diff --git a/usr.sbin/ppp/os.c b/usr.sbin/ppp/os.c
index f8eed52..bde3b3b 100644
--- a/usr.sbin/ppp/os.c
+++ b/usr.sbin/ppp/os.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: os.c,v 1.25 1997/08/31 22:59:44 brian Exp $
+ * $Id: os.c,v 1.26 1997/09/03 00:40:50 brian Exp $
*
*/
#include "fsm.h"
@@ -234,13 +234,16 @@ void
OsLinkdown()
{
char *s;
+ int Level;
if (linkup) {
+ FsmDown(&CcpFsm); /* CCP must come down */
+
s = (char *) inet_ntoa(peer_addr);
- if (LogIsKept(LogLINK))
- LogPrintf(LogLINK, "OsLinkdown: %s\n", s);
- else
- LogPrintf(LogLCP, "OsLinkdown: %s\n", s);
+ Level = LogIsKept(LogLINK) ? LogLINK : LogIPCP;
+ LogPrintf(Level, "OsLinkdown: %s\n", s);
+
+ FsmDown(&IpcpFsm); /* IPCP must come down */
if (!(mode & MODE_AUTO))
DeleteIfRoutes(0);
OpenPOWER on IntegriCloud