Add a new ioctl PPPIOCGRAWIN to get the last characters we got from the

remote site.
This commit is contained in:
christos 2003-09-01 16:51:25 +00:00
parent b7510d87e5
commit ab661a6a58
4 changed files with 45 additions and 18 deletions

View File

@ -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 @@ pppioctl(sc, cmd, data, flag, p)
*(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);

View File

@ -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 ifpppcstatsreq {
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 */

View File

@ -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 @@ struct ppp_softc {
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

View File

@ -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 @@ pppinput(c, tp)
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 @@ ppplogchar(sc, c)
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;
}
}