diff options
author | brian <brian@FreeBSD.org> | 2001-08-18 13:04:52 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2001-08-18 13:04:52 +0000 |
commit | cfa5d0ff529c7c68582be2d05f344e470d61c5df (patch) | |
tree | a0dbd40d60699c490ea869291dd1aa069e6a2682 /usr.sbin/ppp | |
parent | fb43a54a68c52f79dc2f14a17ce4618c023e958e (diff) | |
download | FreeBSD-src-cfa5d0ff529c7c68582be2d05f344e470d61c5df.zip FreeBSD-src-cfa5d0ff529c7c68582be2d05f344e470d61c5df.tar.gz |
Run correctly on a machine built without AF_INET6 support
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r-- | usr.sbin/ppp/bundle.c | 2 | ||||
-rw-r--r-- | usr.sbin/ppp/command.c | 29 | ||||
-rw-r--r-- | usr.sbin/ppp/fsm.c | 3 | ||||
-rw-r--r-- | usr.sbin/ppp/ip.c | 3 | ||||
-rw-r--r-- | usr.sbin/ppp/ipv6cp.c | 8 | ||||
-rw-r--r-- | usr.sbin/ppp/ncp.c | 53 |
6 files changed, 65 insertions, 33 deletions
diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index adf5257..8f0863f 100644 --- a/usr.sbin/ppp/bundle.c +++ b/usr.sbin/ppp/bundle.c @@ -555,7 +555,7 @@ bundle_DescriptorRead(struct fdescriptor *d, struct bundle *bundle, } af = ntohl(tun.header.family); #ifndef NOINET6 - if (af != AF_INET && af != AF_INET6) + if (af != AF_INET && (!probe.ipv6_available || af != AF_INET6)) #else if (af != AF_INET) #endif diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 2c79b89..d8515c0 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -460,15 +460,17 @@ command_Expand(char **nargv, int argc, char const *const *oargv, nargv[arg] = subst(nargv[arg], "HISADDR", inet_ntoa(bundle->ncp.ipcp.peer_ip)); #ifndef NOINET6 - nargv[arg] = subst(nargv[arg], "HISADDR6", - ncpaddr_ntoa(&bundle->ncp.ipv6cp.hisaddr)); + if (probe.ipv6_available) + nargv[arg] = subst(nargv[arg], "HISADDR6", + ncpaddr_ntoa(&bundle->ncp.ipv6cp.hisaddr)); #endif nargv[arg] = subst(nargv[arg], "AUTHNAME", bundle->cfg.auth.name); nargv[arg] = subst(nargv[arg], "INTERFACE", bundle->iface->name); nargv[arg] = subst(nargv[arg], "MYADDR", inet_ntoa(bundle->ncp.ipcp.my_ip)); #ifndef NOINET6 - nargv[arg] = subst(nargv[arg], "MYADDR6", - ncpaddr_ntoa(&bundle->ncp.ipv6cp.myaddr)); + if (probe.ipv6_available) + nargv[arg] = subst(nargv[arg], "MYADDR6", + ncpaddr_ntoa(&bundle->ncp.ipv6cp.myaddr)); #endif nargv[arg] = subst(nargv[arg], "USER", bundle->ncp.mp.peer.authname); nargv[arg] = subst(nargv[arg], "PEER_ENDDISC", @@ -2340,7 +2342,8 @@ AddCommand(struct cmdargs const *arg) ncpaddr_setip4(&gw, arg->bundle->ncp.ipcp.peer_ip); addrs |= ROUTE_GWHISADDR; #ifndef NOINET6 - } else if (strcasecmp(arg->argv[arg->argn + gw_arg], "HISADDR6") == 0) { + } else if (probe.ipv6_available && + strcasecmp(arg->argv[arg->argn + gw_arg], "HISADDR6") == 0) { ncpaddr_copy(&gw, &arg->bundle->ncp.ipv6cp.hisaddr); addrs |= ROUTE_GWHISADDR6; #endif @@ -2379,7 +2382,8 @@ DeleteCommand(struct cmdargs const *arg) ncprange_setip4host(&dest, arg->bundle->ncp.ipcp.my_ip); addrs = ROUTE_DSTMYADDR; #ifndef NOINET6 - } else if (strcasecmp(arg->argv[arg->argn], "MYADDR6") == 0) { + } else if (probe.ipv6_available && + strcasecmp(arg->argv[arg->argn], "MYADDR6") == 0) { ncprange_sethost(&dest, &arg->bundle->ncp.ipv6cp.myaddr); addrs = ROUTE_DSTMYADDR6; #endif @@ -2387,7 +2391,8 @@ DeleteCommand(struct cmdargs const *arg) ncprange_setip4host(&dest, arg->bundle->ncp.ipcp.peer_ip); addrs = ROUTE_DSTHISADDR; #ifndef NOINET6 - } else if (strcasecmp(arg->argv[arg->argn], "HISADDR6") == 0) { + } else if (probe.ipv6_available && + strcasecmp(arg->argv[arg->argn], "HISADDR6") == 0) { ncprange_sethost(&dest, &arg->bundle->ncp.ipv6cp.hisaddr); addrs = ROUTE_DSTHISADDR6; #endif @@ -2872,8 +2877,11 @@ ClearCommand(struct cmdargs const *arg) } else if (strcasecmp(arg->argv[arg->argn], "ipcp") == 0) t = &arg->bundle->ncp.ipcp.throughput; #ifndef NOINET6 - else if (strcasecmp(arg->argv[arg->argn], "ipv6cp") == 0) + else if (strcasecmp(arg->argv[arg->argn], "ipv6cp") == 0) { + if (!probe.ipv6_available) + return 0; t = &arg->bundle->ncp.ipv6cp.throughput; + } #endif else return -1; @@ -3019,8 +3027,11 @@ IfaceClearCommand(struct cmdargs const *arg) if (strcasecmp(arg->argv[arg->argn], "inet") == 0) family = AF_INET; #ifndef NOINET6 - else if (strcasecmp(arg->argv[arg->argn], "inet6") == 0) + else if (strcasecmp(arg->argv[arg->argn], "inet6") == 0) { + if (!probe.ipv6_available) + return 0; family = AF_INET6; + } #endif else return -1; diff --git a/usr.sbin/ppp/fsm.c b/usr.sbin/ppp/fsm.c index 47bcd68..9f4cc0c 100644 --- a/usr.sbin/ppp/fsm.c +++ b/usr.sbin/ppp/fsm.c @@ -68,6 +68,7 @@ #include "async.h" #include "physical.h" #include "proto.h" +#include "probe.h" static void FsmSendConfigReq(struct fsm *); static void FsmSendTerminateReq(struct fsm *); @@ -896,7 +897,7 @@ FsmRecvProtoRej(struct fsm *fp, struct fsmheader *lhp, struct mbuf *bp) break; #ifndef NOINET6 case PROTO_IPV6CP: - if (fp->proto == PROTO_LCP) { + if (probe.ipv6_available && fp->proto == PROTO_LCP) { log_Printf(LogPHASE, "%s: IPV6CP protocol reject closes IPV6CP !\n", fp->link->name); fsm_Close(&fp->bundle->ncp.ipv6cp.fsm); diff --git a/usr.sbin/ppp/ip.c b/usr.sbin/ppp/ip.c index 30b6cb6..38f5ed2 100644 --- a/usr.sbin/ppp/ip.c +++ b/usr.sbin/ppp/ip.c @@ -79,6 +79,7 @@ #include "ncp.h" #include "bundle.h" #include "tun.h" +#include "probe.h" #define OPCODE_QUERY 0 @@ -941,7 +942,7 @@ ipv6_Input(struct bundle *bundle, struct link *l, struct mbuf *bp) { int nb; - if (bundle->ncp.ipv6cp.fsm.state != ST_OPENED) { + if (!probe.ipv6_available || bundle->ncp.ipv6cp.fsm.state != ST_OPENED) { log_Printf(LogWARN, "ipv6_Input: IPV6CP not open - packet dropped\n"); m_freem(bp); return NULL; diff --git a/usr.sbin/ppp/ipv6cp.c b/usr.sbin/ppp/ipv6cp.c index 6ec1485..5067997 100644 --- a/usr.sbin/ppp/ipv6cp.c +++ b/usr.sbin/ppp/ipv6cp.c @@ -73,6 +73,7 @@ #include "prompt.h" #include "async.h" #include "physical.h" +#include "probe.h" #ifndef NOINET6 @@ -224,6 +225,11 @@ ipv6cp_Show(struct cmdargs const *arg) { struct ipv6cp *ipv6cp = &arg->bundle->ncp.ipv6cp; + if (!probe.ipv6_available) { + prompt_Printf(arg->prompt, "ipv6 not available\n"); + return 0; + } + prompt_Printf(arg->prompt, "%s [%s]\n", ipv6cp->fsm.name, State2Nam(ipv6cp->fsm.state)); if (ipv6cp->fsm.state == ST_OPENED) { @@ -251,7 +257,7 @@ ipv6cp_Input(struct bundle *bundle, struct link *l, struct mbuf *bp) { /* Got PROTO_IPV6CP from link */ m_settype(bp, MB_IPV6CPIN); - if (bundle_Phase(bundle) == PHASE_NETWORK) + if (bundle_Phase(bundle) == PHASE_NETWORK && probe.ipv6_available) fsm_Input(&bundle->ncp.ipv6cp.fsm, bp); else { if (bundle_Phase(bundle) < PHASE_NETWORK) diff --git a/usr.sbin/ppp/ncp.c b/usr.sbin/ppp/ncp.c index a68c91f..8a88800 100644 --- a/usr.sbin/ppp/ncp.c +++ b/usr.sbin/ppp/ncp.c @@ -90,6 +90,7 @@ #include "pap.h" #include "cbcp.h" #include "datalink.h" +#include "probe.h" static u_short default_urgent_tcp_ports[] = { @@ -133,8 +134,9 @@ ncp_Init(struct ncp *ncp, struct bundle *bundle) ipcp_Init(&ncp->ipcp, bundle, &bundle->links->physical->link, &bundle->fsm); #ifndef NOINET6 - ipv6cp_Init(&ncp->ipv6cp, bundle, &bundle->links->physical->link, - &bundle->fsm); + if (probe.ipv6_available) + ipv6cp_Init(&ncp->ipv6cp, bundle, &bundle->links->physical->link, + &bundle->fsm); #endif } @@ -143,7 +145,8 @@ ncp_Destroy(struct ncp *ncp) { ipcp_Destroy(&ncp->ipcp); #ifndef NOINET6 - ipv6cp_Destroy(&ncp->ipv6cp); + if (probe.ipv6_available) + ipv6cp_Destroy(&ncp->ipv6cp); #endif if (ncp->cfg.urgent.tcp.maxports) { @@ -172,7 +175,7 @@ ncp_fsmStart(struct ncp *ncp, struct bundle *bundle) #ifndef NOINET6 } - if (Enabled(bundle, OPT_IPV6CP)) { + if (probe.ipv6_available && Enabled(bundle, OPT_IPV6CP)) { fsm_Up(&ncp->ipv6cp.fsm); fsm_Open(&ncp->ipv6cp.fsm); res++; @@ -209,7 +212,8 @@ ncp_SetLink(struct ncp *ncp, struct link *l) { ipcp_SetLink(&ncp->ipcp, l); #ifndef NOINET6 - ipv6cp_SetLink(&ncp->ipv6cp, l); + if (probe.ipv6_available) + ipv6cp_SetLink(&ncp->ipv6cp, l); #endif } @@ -277,7 +281,8 @@ ncp_QueueLen(struct ncp *ncp) result = ipcp_QueueLen(&ncp->ipcp); #ifndef NOINET6 - result += ipv6cp_QueueLen(&ncp->ipv6cp); + if (probe.ipv6_available) + result += ipv6cp_QueueLen(&ncp->ipv6cp); #endif result += mp_QueueLen(&ncp->mp); /* Usually empty */ @@ -304,9 +309,10 @@ ncp_DeleteQueues(struct ncp *ncp) m_freem(m_dequeue(q)); #ifndef NOINET6 - for (q = ipv6cp->Queue; q < ipv6cp->Queue + IPV6CP_QUEUES(ipv6cp); q++) - while (q->top) - m_freem(m_dequeue(q)); + if (probe.ipv6_available) + for (q = ipv6cp->Queue; q < ipv6cp->Queue + IPV6CP_QUEUES(ipv6cp); q++) + while (q->top) + m_freem(m_dequeue(q)); #endif link_DeleteQueue(&mp->link); /* Usually empty anyway */ @@ -352,7 +358,9 @@ ncp_PushPacket(struct ncp *ncp, int *af, struct link *l) int res; #ifndef NOINET6 - if (*af == AF_INET) { + if (!probe.ipv6_available) + res = ipcp_PushPacket(&bundle->ncp.ipcp, l); + else if (*af == AF_INET) { if ((res = ipcp_PushPacket(&bundle->ncp.ipcp, l))) *af = AF_INET6; else @@ -448,8 +456,9 @@ ncp_Show(struct cmdargs const *arg) int p; #ifndef NOINET6 - prompt_Printf(arg->prompt, "Next queued AF: %s\n", - ncp->afq == AF_INET6 ? "inet6" : "inet"); + if (probe.ipv6_available) + prompt_Printf(arg->prompt, "Next queued AF: %s\n", + ncp->afq == AF_INET6 ? "inet6" : "inet"); #endif if (ncp->route) { @@ -502,7 +511,8 @@ ncp_LayersOpen(struct ncp *ncp) n = !!(ncp->ipcp.fsm.state == ST_OPENED); #ifndef NOINET6 - n += !!(ncp->ipv6cp.fsm.state == ST_OPENED); + if (probe.ipv6_available) + n += !!(ncp->ipv6cp.fsm.state == ST_OPENED); #endif return n; @@ -518,9 +528,10 @@ ncp_LayersUnfinished(struct ncp *ncp) n++; #ifndef NOINET6 - if (ncp->ipv6cp.fsm.state > ST_CLOSED || - ncp->ipv6cp.fsm.state == ST_STARTING) - n++; + if (probe.ipv6_available) + if (ncp->ipv6cp.fsm.state > ST_CLOSED || + ncp->ipv6cp.fsm.state == ST_STARTING) + n++; #endif return n; @@ -534,9 +545,10 @@ ncp_Close(struct ncp *ncp) fsm_Close(&ncp->ipcp.fsm); #ifndef NOINET6 - if (ncp->ipv6cp.fsm.state > ST_CLOSED || - ncp->ipv6cp.fsm.state == ST_STARTING) - fsm_Close(&ncp->ipv6cp.fsm); + if (probe.ipv6_available) + if (ncp->ipv6cp.fsm.state > ST_CLOSED || + ncp->ipv6cp.fsm.state == ST_STARTING) + fsm_Close(&ncp->ipv6cp.fsm); #endif } @@ -545,6 +557,7 @@ ncp2initial(struct ncp *ncp) { fsm2initial(&ncp->ipcp.fsm); #ifndef NOINET6 - fsm2initial(&ncp->ipv6cp.fsm); + if (probe.ipv6_available) + fsm2initial(&ncp->ipv6cp.fsm); #endif } |