Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net Add a new ioctl PPPIOCGRAWIN to get the last charact...
details: https://anonhg.NetBSD.org/src/rev/321545ca4562
branches: trunk
changeset: 551211:321545ca4562
user: christos <christos%NetBSD.org@localhost>
date: Mon Sep 01 16:51:25 2003 +0000
description:
Add a new ioctl PPPIOCGRAWIN to get the last characters we got from the
remote site.
diffstat:
sys/net/if_ppp.c | 19 +++++++++++++++++--
sys/net/if_ppp.h | 8 +++++++-
sys/net/if_pppvar.h | 6 +++---
sys/net/ppp_tty.c | 30 ++++++++++++++++++------------
4 files changed, 45 insertions(+), 18 deletions(-)
diffs (149 lines):
diff -r 08a58d7e9eb7 -r 321545ca4562 sys/net/if_ppp.c
--- a/sys/net/if_ppp.c Mon Sep 01 16:44:03 2003 +0000
+++ b/sys/net/if_ppp.c Mon Sep 01 16:51:25 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ppp.c,v 1.84 2003/05/02 03:15:24 itojun Exp $ */
+/* $NetBSD: if_ppp.c,v 1.85 2003/09/01 16:51:25 christos Exp $ */
/* Id: if_ppp.c,v 1.6 1997/03/04 03:33:00 paulus Exp */
/*
@@ -102,7 +102,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.84 2003/05/02 03:15:24 itojun Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ppp.c,v 1.85 2003/09/01 16:51:25 christos Exp $");
#include "ppp.h"
@@ -431,6 +431,21 @@
*(u_int *)data = sc->sc_flags;
break;
+ case PPPIOCGRAWIN:
+ {
+ struct ppp_rawin *rwin = (struct ppp_rawin *)data;
+ u_char p, q = 0;
+
+ for (p = sc->sc_rawin_start; p < sizeof(sc->sc_rawin.buf);)
+ rwin->buf[q++] = sc->sc_rawin.buf[p++];
+
+ for (p = 0; p < sc->sc_rawin_start;)
+ rwin->buf[q++] = sc->sc_rawin.buf[p++];
+
+ rwin->count = sc->sc_rawin.count;
+ }
+ break;
+
case PPPIOCSFLAGS:
if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
return (error);
diff -r 08a58d7e9eb7 -r 321545ca4562 sys/net/if_ppp.h
--- a/sys/net/if_ppp.h Mon Sep 01 16:44:03 2003 +0000
+++ b/sys/net/if_ppp.h Mon Sep 01 16:51:25 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ppp.h,v 1.19 2002/07/01 22:09:33 itojun Exp $ */
+/* $NetBSD: if_ppp.h,v 1.20 2003/09/01 16:51:26 christos Exp $ */
/* Id: if_ppp.h,v 1.16 1997/04/30 05:46:04 paulus Exp */
/*
@@ -110,10 +110,16 @@
struct ppp_comp_stats stats;
};
+struct ppp_rawin {
+ u_char buf[19];
+ u_char count;
+};
+
/*
* Ioctl definitions.
*/
+#define PPPIOCGRAWIN _IOR('t', 91, struct ppp_rawin) /* get raw input */
#define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */
#define PPPIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */
#define PPPIOCGASYNCMAP _IOR('t', 88, int) /* get async map */
diff -r 08a58d7e9eb7 -r 321545ca4562 sys/net/if_pppvar.h
--- a/sys/net/if_pppvar.h Mon Sep 01 16:44:03 2003 +0000
+++ b/sys/net/if_pppvar.h Mon Sep 01 16:51:25 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppvar.h,v 1.17 2003/07/08 07:13:51 itojun Exp $ */
+/* $NetBSD: if_pppvar.h,v 1.18 2003/09/01 16:51:27 christos Exp $ */
/* Id: if_pppvar.h,v 1.3 1996/07/01 01:04:37 paulus Exp */
/*
@@ -141,8 +141,8 @@
u_int16_t sc_ilen; /* length of input packet so far */
u_int16_t sc_fcs; /* FCS so far (input) */
u_int16_t sc_outfcs; /* FCS so far for output packet */
- u_char sc_rawin[16]; /* chars as received */
- int sc_rawin_count; /* # in sc_rawin */
+ u_char sc_rawin_start; /* current char start */
+ struct ppp_rawin sc_rawin; /* chars as received */
};
#ifdef _KERNEL
diff -r 08a58d7e9eb7 -r 321545ca4562 sys/net/ppp_tty.c
--- a/sys/net/ppp_tty.c Mon Sep 01 16:44:03 2003 +0000
+++ b/sys/net/ppp_tty.c Mon Sep 01 16:51:25 2003 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ppp_tty.c,v 1.33 2003/02/26 06:31:13 matt Exp $ */
+/* $NetBSD: ppp_tty.c,v 1.34 2003/09/01 16:51:27 christos Exp $ */
/* Id: ppp_tty.c,v 1.3 1996/07/01 01:04:11 paulus Exp */
/*
@@ -93,7 +93,7 @@
/* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ppp_tty.c,v 1.33 2003/02/26 06:31:13 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ppp_tty.c,v 1.34 2003/09/01 16:51:27 christos Exp $");
#include "ppp.h"
@@ -1038,14 +1038,13 @@
sc->sc_flags |= SC_RCV_EVNP;
splx(s);
- if (sc->sc_flags & SC_LOG_RAWIN)
- ppplogchar(sc, c);
+ ppplogchar(sc, c);
if (c == PPP_FLAG) {
ilen = sc->sc_ilen;
sc->sc_ilen = 0;
- if (sc->sc_rawin_count > 0)
+ if ((sc->sc_flags & SC_LOG_RAWIN) && sc->sc_rawin.count > 0)
ppplogchar(sc, -1);
/*
@@ -1234,13 +1233,20 @@
struct ppp_softc *sc;
int c;
{
- if (c >= 0)
- sc->sc_rawin[sc->sc_rawin_count++] = c;
- if (sc->sc_rawin_count >= sizeof(sc->sc_rawin)
- || (c < 0 && sc->sc_rawin_count > 0)) {
- printf("%s input: ", sc->sc_if.if_xname);
- pppdumpb(sc->sc_rawin, sc->sc_rawin_count);
- sc->sc_rawin_count = 0;
+ if (c >= 0) {
+ sc->sc_rawin.buf[sc->sc_rawin_start++] = c;
+ if (sc->sc_rawin.count < sizeof(sc->sc_rawin.buf))
+ sc->sc_rawin.count++;
+ }
+ if (sc->sc_rawin_start >= sizeof(sc->sc_rawin.buf)
+ || (c < 0 && sc->sc_rawin_start > 0)) {
+ if (sc->sc_flags & (SC_LOG_FLUSH|SC_LOG_RAWIN)) {
+ printf("%s input: ", sc->sc_if.if_xname);
+ pppdumpb(sc->sc_rawin.buf, sc->sc_rawin_start);
+ }
+ if (c < 0)
+ sc->sc_rawin.count = 0;
+ sc->sc_rawin_start = 0;
}
}
Home |
Main Index |
Thread Index |
Old Index