Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_spppsubr.c
Show First 20 Lines • Show All 774 Lines • ▼ Show 20 Lines | sppp_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, | ||||
struct sppp *sp = IFP2SP(ifp); | struct sppp *sp = IFP2SP(ifp); | ||||
struct ppp_header *h; | struct ppp_header *h; | ||||
struct ifqueue *ifq = NULL; | struct ifqueue *ifq = NULL; | ||||
int error, rv = 0; | int error, rv = 0; | ||||
#ifdef INET | #ifdef INET | ||||
int ipproto = PPP_IP; | int ipproto = PPP_IP; | ||||
#endif | #endif | ||||
int debug = ifp->if_flags & IFF_DEBUG; | int debug = ifp->if_flags & IFF_DEBUG; | ||||
int af = RO_GET_FAMILY(ro, dst); | |||||
SPPP_LOCK(sp); | SPPP_LOCK(sp); | ||||
if (!(ifp->if_flags & IFF_UP) || | if (!(ifp->if_flags & IFF_UP) || | ||||
(!(ifp->if_flags & IFF_AUTO) && | (!(ifp->if_flags & IFF_AUTO) && | ||||
!(ifp->if_drv_flags & IFF_DRV_RUNNING))) { | !(ifp->if_drv_flags & IFF_DRV_RUNNING))) { | ||||
#ifdef INET6 | #ifdef INET6 | ||||
drop: | drop: | ||||
Show All 9 Lines | #ifdef INET6 | ||||
/* | /* | ||||
* XXX | * XXX | ||||
* | * | ||||
* Hack to prevent the initialization-time generated | * Hack to prevent the initialization-time generated | ||||
* IPv6 multicast packet to erroneously cause a | * IPv6 multicast packet to erroneously cause a | ||||
* dialout event in case IPv6 has been | * dialout event in case IPv6 has been | ||||
* administratively disabled on that interface. | * administratively disabled on that interface. | ||||
*/ | */ | ||||
if (dst->sa_family == AF_INET6 && | if (af == AF_INET6 && | ||||
!(sp->confflags & CONF_ENABLE_IPV6)) | !(sp->confflags & CONF_ENABLE_IPV6)) | ||||
goto drop; | goto drop; | ||||
#endif | #endif | ||||
/* | /* | ||||
* Interface is not yet running, but auto-dial. Need | * Interface is not yet running, but auto-dial. Need | ||||
* to start LCP for it. | * to start LCP for it. | ||||
*/ | */ | ||||
ifp->if_drv_flags |= IFF_DRV_RUNNING; | ifp->if_drv_flags |= IFF_DRV_RUNNING; | ||||
lcp.Open(sp); | lcp.Open(sp); | ||||
} | } | ||||
#ifdef INET | #ifdef INET | ||||
if (dst->sa_family == AF_INET) { | if (af == AF_INET) { | ||||
/* XXX Check mbuf length here? */ | /* XXX Check mbuf length here? */ | ||||
struct ip *ip = mtod (m, struct ip*); | struct ip *ip = mtod (m, struct ip*); | ||||
struct tcphdr *tcp = (struct tcphdr*) ((long*)ip + ip->ip_hl); | struct tcphdr *tcp = (struct tcphdr*) ((long*)ip + ip->ip_hl); | ||||
/* | /* | ||||
* When using dynamic local IP address assignment by using | * When using dynamic local IP address assignment by using | ||||
* 0.0.0.0 as a local address, the first TCP session will | * 0.0.0.0 as a local address, the first TCP session will | ||||
* not connect because the local TCP checksum is computed | * not connect because the local TCP checksum is computed | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | if (sp->pp_mode != IFF_CISCO && sp->pp_mode != PP_FR && | ||||
m_freem(m); | m_freem(m); | ||||
SPPP_UNLOCK(sp); | SPPP_UNLOCK(sp); | ||||
return (EINVAL); | return (EINVAL); | ||||
} | } | ||||
} | } | ||||
#endif | #endif | ||||
#ifdef INET6 | #ifdef INET6 | ||||
if (dst->sa_family == AF_INET6) { | if (af == AF_INET6) { | ||||
/* XXX do something tricky here? */ | /* XXX do something tricky here? */ | ||||
} | } | ||||
#endif | #endif | ||||
if (sp->pp_mode == PP_FR) { | if (sp->pp_mode == PP_FR) { | ||||
/* Add frame relay header. */ | /* Add frame relay header. */ | ||||
m = sppp_fr_header (sp, m, dst->sa_family); | m = sppp_fr_header (sp, m, af); | ||||
if (! m) | if (! m) | ||||
goto nobufs; | goto nobufs; | ||||
goto out; | goto out; | ||||
} | } | ||||
/* | /* | ||||
* Prepend general data packet PPP header. For now, IP only. | * Prepend general data packet PPP header. For now, IP only. | ||||
*/ | */ | ||||
Show All 14 Lines | nobufs: if (debug) | ||||
if (sp->pp_mode == IFF_CISCO) { | if (sp->pp_mode == IFF_CISCO) { | ||||
h->address = CISCO_UNICAST; /* unicast address */ | h->address = CISCO_UNICAST; /* unicast address */ | ||||
h->control = 0; | h->control = 0; | ||||
} else { | } else { | ||||
h->address = PPP_ALLSTATIONS; /* broadcast address */ | h->address = PPP_ALLSTATIONS; /* broadcast address */ | ||||
h->control = PPP_UI; /* Unnumbered Info */ | h->control = PPP_UI; /* Unnumbered Info */ | ||||
} | } | ||||
switch (dst->sa_family) { | switch (af) { | ||||
#ifdef INET | #ifdef INET | ||||
case AF_INET: /* Internet Protocol */ | case AF_INET: /* Internet Protocol */ | ||||
if (sp->pp_mode == IFF_CISCO) | if (sp->pp_mode == IFF_CISCO) | ||||
h->protocol = htons (ETHERTYPE_IP); | h->protocol = htons (ETHERTYPE_IP); | ||||
else { | else { | ||||
/* | /* | ||||
* Don't choke with an ENETDOWN early. It's | * Don't choke with an ENETDOWN early. It's | ||||
* possible that we just started dialing out, | * possible that we just started dialing out, | ||||
▲ Show 20 Lines • Show All 4,480 Lines • Show Last 20 Lines |