summaryrefslogtreecommitdiffstats
path: root/sys/net/if_spppsubr.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1995-11-21 01:23:13 +0000
committerpeter <peter@FreeBSD.org>1995-11-21 01:23:13 +0000
commit403c3abc21b1c102c84db3a037b9afce765c465f (patch)
treee6fb995c85482bfe6a4875c286c98caf22608769 /sys/net/if_spppsubr.c
parentfffd71d4c49dfb70e69f1eaf9606566b5baab25a (diff)
downloadFreeBSD-src-403c3abc21b1c102c84db3a037b9afce765c465f.zip
FreeBSD-src-403c3abc21b1c102c84db3a037b9afce765c465f.tar.gz
If a lcp configure request is received in the lcp opened state and it
is acknowledged, it should go to the lcp ack sent state. Don't reply on lcp echo requests when not in the lcp opened state. If the interface is set to CISCO mode, it should still be marked running when ifconfiged. Fixed a few indentations that had gone wrong somewhere. Submitted-by: John.Hay@csir.co.za
Diffstat (limited to 'sys/net/if_spppsubr.c')
-rw-r--r--sys/net/if_spppsubr.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c
index c26fddc..a26a4f0 100644
--- a/sys/net/if_spppsubr.c
+++ b/sys/net/if_spppsubr.c
@@ -357,16 +357,17 @@ int sppp_output (struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, struct
* Put low delay, telnet, rlogin and ftp control packets
* in front of the queue.
*/
- {
- struct ip *ip = mtod (m, struct ip*);
- struct tcphdr *tcp = (struct tcphdr*) ((long*)ip + ip->ip_hl);
-
- if (! IF_QFULL (&sp->pp_fastq) && ((ip->ip_tos & IPTOS_LOWDELAY) ||
- ip->ip_p == IPPROTO_TCP &&
- m->m_len >= sizeof (struct ip) + sizeof (struct tcphdr) &&
- (INTERACTIVE (ntohs (tcp->th_sport)) ||
- INTERACTIVE (ntohs (tcp->th_dport)))))
- ifq = &sp->pp_fastq;
+ if (dst->sa_family == AF_INET) {
+ struct ip *ip = mtod (m, struct ip*);
+ struct tcphdr *tcp = (struct tcphdr*) ((long*)ip + ip->ip_hl);
+
+ if (! IF_QFULL (&sp->pp_fastq) &&
+ ((ip->ip_tos & IPTOS_LOWDELAY) ||
+ ip->ip_p == IPPROTO_TCP &&
+ m->m_len >= sizeof (struct ip) + sizeof (struct tcphdr) &&
+ (INTERACTIVE (ntohs (tcp->th_sport)) ||
+ INTERACTIVE (ntohs (tcp->th_dport)))))
+ ifq = &sp->pp_fastq;
}
#endif
@@ -674,19 +675,19 @@ badreq:
sp->ipcp.state = IPCP_STATE_CLOSED;
}
break;
- }
- /* Send Configure-Ack packet. */
- sp->pp_loopcnt = 0;
- sppp_cp_send (sp, PPP_LCP, LCP_CONF_ACK,
- h->ident, len-4, h+1);
- /* Change the state. */
+ }
+ /* Send Configure-Ack packet. */
+ sp->pp_loopcnt = 0;
+ sppp_cp_send (sp, PPP_LCP, LCP_CONF_ACK,
+ h->ident, len-4, h+1);
+ /* Change the state. */
switch (sp->lcp.state) {
case LCP_STATE_CLOSED:
sp->lcp.state = LCP_STATE_ACK_SENT;
break;
case LCP_STATE_ACK_RCVD:
- sp->lcp.state = LCP_STATE_OPENED;
- sppp_ipcp_open (sp);
+ sp->lcp.state = LCP_STATE_OPENED;
+ sppp_ipcp_open (sp);
break;
case LCP_STATE_OPENED:
/* Remote magic changed -- close session. */
@@ -694,6 +695,8 @@ badreq:
sp->ipcp.state = IPCP_STATE_CLOSED;
/* Initiate renegotiation. */
sppp_lcp_open (sp);
+ /* An ACK has already been sent. */
+ sp->lcp.state = LCP_STATE_ACK_SENT;
break;
}
break;
@@ -762,8 +765,8 @@ badreq:
/* Go to closed state. */
sp->lcp.state = LCP_STATE_CLOSED;
sp->ipcp.state = IPCP_STATE_CLOSED;
- /* Initiate renegotiation. */
- sppp_lcp_open (sp);
+ /* Initiate renegotiation. */
+ sppp_lcp_open (sp);
break;
case LCP_TERM_ACK:
case LCP_CODE_REJ:
@@ -774,6 +777,8 @@ badreq:
/* Discard the packet. */
break;
case LCP_ECHO_REQ:
+ if (sp->lcp.state != LCP_STATE_OPENED)
+ break;
if (len < 8) {
if (ifp->if_flags & IFF_DEBUG)
printf ("%s%d: invalid lcp echo request packet length: %d bytes\n",
@@ -1006,8 +1011,6 @@ int sppp_ioctl (struct ifnet *ifp, int cmd, void *data)
/* fall through... */
case SIOCSIFFLAGS:
- if (sp->pp_flags & PP_CISCO)
- break;
s = splimp ();
going_up = (ifp->if_flags & IFF_UP) &&
! (ifp->if_flags & IFF_RUNNING);
@@ -1023,7 +1026,8 @@ int sppp_ioctl (struct ifnet *ifp, int cmd, void *data)
if (going_up) {
/* Interface is starting -- initiate negotiation. */
ifp->if_flags |= IFF_RUNNING;
- sppp_lcp_open (sp);
+ if (!(sp->pp_flags & PP_CISCO))
+ sppp_lcp_open (sp);
}
splx (s);
break;
@@ -1109,7 +1113,7 @@ int sppp_lcp_conf_parse_options (struct sppp *sp, struct lcp_header *h,
bcopy (p, r, p[1]);
r += p[1];
rlen += p[1];
- }
+ }
if (rlen)
sppp_cp_send (sp, PPP_LCP, LCP_CONF_REJ, h->ident, rlen, buf);
free (buf, M_TEMP);
OpenPOWER on IntegriCloud