| 5043 | #endif /*INET6*/ |
| 5044 | |
| 5045 | static int |
| 5046 | sppp_params(struct sppp *sp, u_long cmd, void *data) |
| 5047 | { |
| 5048 | u_long subcmd; |
| 5049 | struct ifreq *ifr = (struct ifreq *)data; |
| 5050 | struct spppreq *spr; |
| 5051 | int rv = 0; |
| 5052 | |
| 5053 | if ((spr = malloc(sizeof(struct spppreq), M_TEMP, M_NOWAIT)) == NULL) |
| 5054 | return (EAGAIN); |
| 5055 | /* |
| 5056 | * ifr_data_get_ptr(ifr) is supposed to point to a struct spppreq. |
| 5057 | * Check the cmd word first before attempting to fetch all the |
| 5058 | * data. |
| 5059 | */ |
| 5060 | rv = fueword(ifr_data_get_ptr(ifr), &subcmd); |
| 5061 | if (rv == -1) { |
| 5062 | rv = EFAULT; |
| 5063 | goto quit; |
| 5064 | } |
| 5065 | |
| 5066 | if (copyin(ifr_data_get_ptr(ifr), spr, sizeof(struct spppreq)) != 0) { |
| 5067 | rv = EFAULT; |
| 5068 | goto quit; |
| 5069 | } |
| 5070 | |
| 5071 | switch (subcmd) { |
| 5072 | case (u_long)SPPPIOGDEFS: |
| 5073 | if (cmd != SIOCGIFGENERIC) { |
| 5074 | rv = EINVAL; |
| 5075 | break; |
| 5076 | } |
| 5077 | /* |
| 5078 | * We copy over the entire current state, but clean |
| 5079 | * out some of the stuff we don't wanna pass up. |
| 5080 | * Remember, SIOCGIFGENERIC is unprotected, and can be |
| 5081 | * called by any user. No need to ever get PAP or |
| 5082 | * CHAP secrets back to userland anyway. |
| 5083 | */ |
| 5084 | spr->defs.pp_phase = sp->pp_phase; |
| 5085 | spr->defs.enable_vj = (sp->confflags & CONF_ENABLE_VJ) != 0; |
| 5086 | spr->defs.enable_ipv6 = (sp->confflags & CONF_ENABLE_IPV6) != 0; |
| 5087 | spr->defs.lcp = sp->lcp; |
| 5088 | spr->defs.ipcp = sp->ipcp; |
| 5089 | spr->defs.ipv6cp = sp->ipv6cp; |
| 5090 | spr->defs.myauth = sp->myauth; |
| 5091 | spr->defs.hisauth = sp->hisauth; |
| 5092 | bzero(spr->defs.myauth.secret, AUTHKEYLEN); |
| 5093 | bzero(spr->defs.myauth.challenge, AUTHKEYLEN); |
| 5094 | bzero(spr->defs.hisauth.secret, AUTHKEYLEN); |
| 5095 | bzero(spr->defs.hisauth.challenge, AUTHKEYLEN); |
| 5096 | /* |
| 5097 | * Fixup the LCP timeout value to milliseconds so |
| 5098 | * spppcontrol doesn't need to bother about the value |
| 5099 | * of "hz". We do the reverse calculation below when |
| 5100 | * setting it. |
| 5101 | */ |
| 5102 | spr->defs.lcp.timeout = sp->lcp.timeout * 1000 / hz; |
no test coverage detected