diff options
author | joerg <joerg@FreeBSD.org> | 2001-12-27 22:38:50 +0000 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 2001-12-27 22:38:50 +0000 |
commit | d18dbbbe9a6140b0e0e68bd24def044457afccda (patch) | |
tree | 784972489714166508429d0b689c8f6ad90c4eec /sys/net | |
parent | 3664910955f376f0eedb94998600735c961c6eb0 (diff) | |
download | FreeBSD-src-d18dbbbe9a6140b0e0e68bd24def044457afccda.zip FreeBSD-src-d18dbbbe9a6140b0e0e68bd24def044457afccda.tar.gz |
Break out the relevant fields from struct sppp into a struct
sppp_parms that are needed for the SPPPIO[GS]DEFS ioctl commands.
This allows it to keep struct sppp inside #ifdef _KERNEL (where it
belongs), and prevents userland programs that wish to include
<net/if_sppp.h> from including the earth, the hell, and the universe
before the are able to resolve all the kernel-internal stuff that's in
struct sppp.
Discussed with: hm
MFC after: 1 month
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/if_sppp.h | 68 | ||||
-rw-r--r-- | sys/net/if_spppsubr.c | 8 |
2 files changed, 50 insertions, 26 deletions
diff --git a/sys/net/if_sppp.h b/sys/net/if_sppp.h index c2d3e7d..d565764 100644 --- a/sys/net/if_sppp.h +++ b/sys/net/if_sppp.h @@ -85,6 +85,48 @@ enum ppp_phase { PHASE_AUTHENTICATE, PHASE_NETWORK }; +#define PP_MTU 1500 /* default/minimal MRU */ +#define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */ + +/* + * This is a cut down struct sppp (see below) that can easily be + * exported to/ imported from userland without the need to include + * dozens of kernel-internal header files. It is used by the + * SPPPIO[GS]DEFS ioctl commands below. + */ +struct sppp_parms { + enum ppp_phase pp_phase; /* phase we're currently in */ + int enable_vj; /* VJ header compression enabled */ + struct slcp lcp; /* LCP params */ + struct sipcp ipcp; /* IPCP params */ + struct sipcp ipv6cp; /* IPv6CP params */ + struct sauth myauth; /* auth params, i'm peer */ + struct sauth hisauth; /* auth params, i'm authenticator */ +}; + +/* + * Definitions to pass struct sppp_parms data down into the kernel + * using the SIOC[SG]IFGENERIC ioctl interface. + * + * In order to use this, create a struct spppreq, fill in the cmd + * field with SPPPIOGDEFS, and put the address of this structure into + * the ifr_data portion of a struct ifreq. Pass this struct to a + * SIOCGIFGENERIC ioctl. Then replace the cmd field by SPPPIOSDEFS, + * modify the defs field as desired, and pass the struct ifreq now + * to a SIOCSIFGENERIC ioctl. + */ + +#define SPPPIOGDEFS ((caddr_t)(('S' << 24) + (1 << 16) +\ + sizeof(struct sppp_parms))) +#define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) +\ + sizeof(struct sppp_parms))) + +struct spppreq { + int cmd; + struct sppp_parms defs; +}; + +#ifdef _KERNEL struct sppp { /* NB: pp_if _must_ be first */ struct ifnet pp_if; /* network interface data */ @@ -143,36 +185,12 @@ struct sppp { int pp_loweri; }; +/* bits for pp_flags */ #define PP_KEEPALIVE 0x01 /* use keepalive protocol */ /* 0x04 was PP_TIMO */ #define PP_CALLIN 0x08 /* we are being called */ #define PP_NEEDAUTH 0x10 /* remote requested authentication */ - -#define PP_MTU 1500 /* default/minimal MRU */ -#define PP_MAX_MRU 2048 /* maximal MRU we want to negotiate */ - -/* - * Definitions to pass struct sppp data down into the kernel using the - * SIOC[SG]IFGENERIC ioctl interface. - * - * In order to use this, create a struct spppreq, fill in the cmd - * field with SPPPIOGDEFS, and put the address of this structure into - * the ifr_data portion of a struct ifreq. Pass this struct to a - * SIOCGIFGENERIC ioctl. Then replace the cmd field by SPPPIOCDEFS, - * modify the defs field as desired, and pass the struct ifreq now - * to a SIOCSIFGENERIC ioctl. - */ - -#define SPPPIOGDEFS ((caddr_t)(('S' << 24) + (1 << 16) + sizeof(struct sppp))) -#define SPPPIOSDEFS ((caddr_t)(('S' << 24) + (2 << 16) + sizeof(struct sppp))) - -struct spppreq { - int cmd; - struct sppp defs; -}; - -#ifdef _KERNEL void sppp_attach (struct ifnet *ifp); void sppp_detach (struct ifnet *ifp); void sppp_input (struct ifnet *ifp, struct mbuf *m); diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c index 85530ff..f28b1ad 100644 --- a/sys/net/if_spppsubr.c +++ b/sys/net/if_spppsubr.c @@ -4938,7 +4938,13 @@ sppp_params(struct sppp *sp, u_long cmd, void *data) * called by any user. No need to ever get PAP or * CHAP secrets back to userland anyway. */ - bcopy(sp, &spr.defs, sizeof(struct sppp)); + spr.defs.pp_phase = sp->pp_phase; + spr.defs.enable_vj = sp->enable_vj; + spr.defs.lcp = sp->lcp; + spr.defs.ipcp = sp->ipcp; + spr.defs.ipv6cp = sp->ipv6cp; + spr.defs.myauth = sp->myauth; + spr.defs.hisauth = sp->hisauth; bzero(spr.defs.myauth.secret, AUTHKEYLEN); bzero(spr.defs.myauth.challenge, AUTHKEYLEN); bzero(spr.defs.hisauth.secret, AUTHKEYLEN); |