minor cleanups
[unix-history] / usr / src / sys / net / if_sl.c
CommitLineData
5b519e94 1/*
270f7144 2 * Copyright (c) 1987, 1989 Regents of the University of California.
5b519e94
KB
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms are permitted
50c7758a
KB
6 * provided that the above copyright notice and this paragraph are
7 * duplicated in all such forms and that any documentation,
8 * advertising materials, and other materials related to such
9 * distribution and use acknowledge that the software was developed
10 * by the University of California, Berkeley. The name of the
11 * University may not be used to endorse or promote products derived
12 * from this software without specific prior written permission.
13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
5b519e94 16 *
b25c0eeb 17 * @(#)if_sl.c 7.17 (Berkeley) %G%
5b519e94 18 */
7c2732d1 19
41b6e003
MK
20/*
21 * Serial Line interface
22 *
23 * Rick Adams
24 * Center for Seismic Studies
25 * 1300 N 17th Street, Suite 1450
26 * Arlington, Virginia 22209
27 * (703)276-7900
28 * rick@seismo.ARPA
29 * seismo!rick
30 *
41b6e003 31 * Pounded on heavily by Chris Torek (chris@mimsy.umd.edu, umcp-cs!chris).
8011f5df 32 * N.B.: this belongs in netinet, not net, the way it stands now.
7c2732d1
MK
33 * Should have a link-layer type designation, but wouldn't be
34 * backwards-compatible.
41b6e003
MK
35 *
36 * Converted to 4.3BSD Beta by Chris Torek.
8011f5df 37 * Other changes made at Berkeley, based in part on code by Kirk Smith.
270f7144
MK
38 * W. Jolitz added slip abort.
39 *
40 * Hacked almost beyond recognition by Van Jacobson (van@helios.ee.lbl.gov).
41 * Added priority queuing for "interactive" traffic; hooks for TCP
42 * header compression; ICMP filtering (at 2400 baud, some cretin
43 * pinging you can use up all your bandwidth). Made low clist behavior
44 * more robust and slightly less likely to hang serial line.
45 * Sped up a bunch of things.
46 *
47 * Note that splimp() is used throughout to block both (tty) input
48 * interrupts and network activity; thus, splimp must be >= spltty.
41b6e003
MK
49 */
50
270f7144 51/* $Header: if_sl.c,v 1.7 89/05/31 02:24:52 van Exp $ */
41b6e003
MK
52/* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */
53
54#include "sl.h"
55#if NSL > 0
56
57#include "param.h"
4a23a8aa 58#include "dir.h"
fc62c320 59#include "user.h"
41b6e003
MK
60#include "mbuf.h"
61#include "buf.h"
8672a1f0 62#include "dk.h"
41b6e003
MK
63#include "socket.h"
64#include "ioctl.h"
8011f5df 65#include "file.h"
41b6e003 66#include "tty.h"
4a23a8aa
WN
67#include "kernel.h"
68#include "conf.h"
41b6e003
MK
69#include "errno.h"
70
8011f5df
MK
71#include "if.h"
72#include "netisr.h"
73#include "route.h"
74#if INET
41b6e003
MK
75#include "../netinet/in.h"
76#include "../netinet/in_systm.h"
e42fd7b3 77#include "../netinet/in_var.h"
41b6e003 78#include "../netinet/ip.h"
8011f5df 79#endif
41b6e003 80
0e6c0944 81#include "machine/mtpr.h"
41b6e003 82
270f7144
MK
83#include "slcompress.h"
84#include "if_slvar.h"
85
41b6e003 86/*
270f7144
MK
87 * SLMTU is a hard limit on input packet size. To simplify the code
88 * and improve performance, we require that packets fit in an mbuf
89 * cluster, that there be enough extra room for the ifnet pointer that
90 * IP input requires and, if we get a compressed packet, there's
91 * enough extra room to expand the header into a max length tcp/ip
92 * header (128 bytes). So, SLMTU can be at most
b25c0eeb 93 * MCLBYTES - 128
270f7144
MK
94 *
95 * To insure we get good interactive response, the MTU wants to be
96 * the smallest size that amortizes the header cost. (Remember
97 * that even with type-of-service queuing, we have to wait for any
98 * in-progress packet to finish. I.e., we wait, on the average,
99 * 1/2 * mtu / cps, where cps is the line speed in characters per
100 * second. E.g., 533ms wait for a 1024 byte MTU on a 9600 baud
101 * line. The average compressed header size is 6-8 bytes so any
102 * MTU > 90 bytes will give us 90% of the line bandwidth. A 100ms
103 * wait is tolerable (500ms is not), so want an MTU around 256.
104 * (Since TCP will send 212 byte segments (to allow for 40 byte
105 * headers), the typical packet size on the wire will be around 220
106 * bytes). In 4.3tahoe+ systems, we can set an MTU in a route
107 * so we do that & leave the interface MTU relatively high (so we
108 * don't IP fragment when acting as a gateway to someone using a
109 * stupid MTU).
41b6e003 110 */
b25c0eeb
MK
111#define SLMTU 576
112#define BUFOFFSET 128
113#define SLBUFSIZE (SLMTU + BUFOFFSET)
270f7144
MK
114#define SLIP_HIWAT 1024 /* don't start a new packet if HIWAT on queue */
115#define CLISTRESERVE 1024 /* Can't let clists get too low */
b25c0eeb 116
4a23a8aa
WN
117/*
118 * SLIP ABORT ESCAPE MECHANISM:
119 * (inspired by HAYES modem escape arrangement)
120 * 1sec escape 1sec escape 1sec escape { 1sec escape 1sec escape }
121 * signals a "soft" exit from slip mode by usermode process
4a23a8aa
WN
122 */
123
124#define ABT_ESC '\033' /* can't be t_intr - distant host must know it*/
125#define ABT_WAIT 1 /* in seconds - idle before an escape & after */
126#define ABT_RECYCLE (5*2+2) /* in seconds - time window processing abort */
127
4a23a8aa 128#define ABT_SOFT 3 /* count of escapes */
41b6e003 129
4a23a8aa 130/*
270f7144 131 * The following disgusting hack gets around the problem that IP TOS
b25c0eeb
MK
132 * can't be set yet. We want to put "interactive" traffic on a high
133 * priority queue. To decide if traffic is interactive, we check that
134 * a) it is TCP and b) one of its ports is telnet, rlogin or ftp control.
4a23a8aa 135 */
270f7144
MK
136static u_short interactive_ports[8] = {
137 0, 513, 0, 0,
138 0, 21, 0, 23,
139};
140#define INTERACTIVE(p) (interactive_ports[(p) & 7] == (p))
4a23a8aa 141
270f7144 142struct sl_softc sl_softc[NSL];
4a23a8aa 143
270f7144
MK
144#define FRAME_END 0xc0 /* Frame End */
145#define FRAME_ESCAPE 0xdb /* Frame Esc */
146#define TRANS_FRAME_END 0xdc /* transposed frame end */
147#define TRANS_FRAME_ESCAPE 0xdd /* transposed frame esc */
41b6e003
MK
148
149#define t_sc T_LINEP
150
151int sloutput(), slioctl(), ttrstrt();
152
153/*
154 * Called from boot code to establish sl interfaces.
155 */
156slattach()
157{
158 register struct sl_softc *sc;
159 register int i = 0;
160
161 for (sc = sl_softc; i < NSL; sc++) {
162 sc->sc_if.if_name = "sl";
163 sc->sc_if.if_unit = i++;
164 sc->sc_if.if_mtu = SLMTU;
165 sc->sc_if.if_flags = IFF_POINTOPOINT;
166 sc->sc_if.if_ioctl = slioctl;
167 sc->sc_if.if_output = sloutput;
270f7144
MK
168 sc->sc_if.if_snd.ifq_maxlen = 50;
169 sc->sc_fastq.ifq_maxlen = 32;
41b6e003
MK
170 if_attach(&sc->sc_if);
171 }
172}
173
270f7144
MK
174static int
175slinit(sc)
176 register struct sl_softc *sc;
177{
178 register caddr_t p;
179
180 if (sc->sc_ep == (u_char *) 0) {
181 MCLALLOC(p, M_WAIT);
182 if (p)
b25c0eeb 183 sc->sc_ep = (u_char *)p + SLBUFSIZE;
270f7144
MK
184 else {
185 printf("sl%d: can't allocate buffer\n", sc - sl_softc);
186 sc->sc_if.if_flags &= ~IFF_UP;
187 return (0);
188 }
189 }
190 sc->sc_buf = sc->sc_ep - SLMTU;
191 sc->sc_mp = sc->sc_buf;
192 sl_compress_init(&sc->sc_comp);
193 return (1);
194}
195
41b6e003
MK
196/*
197 * Line specific open routine.
198 * Attach the given tty to the first available sl unit.
199 */
8011f5df 200/* ARGSUSED */
41b6e003
MK
201slopen(dev, tp)
202 dev_t dev;
203 register struct tty *tp;
204{
205 register struct sl_softc *sc;
206 register int nsl;
06c16dfa 207 int error;
41b6e003 208
06c16dfa
KM
209 if (error = suser(u.u_cred, &u.u_acflag))
210 return (error);
270f7144 211
8011f5df 212 if (tp->t_line == SLIPDISC)
b25c0eeb 213 return (0);
41b6e003 214
270f7144 215 for (nsl = NSL, sc = sl_softc; --nsl >= 0; sc++)
41b6e003 216 if (sc->sc_ttyp == NULL) {
8011f5df
MK
217 if (slinit(sc) == 0)
218 return (ENOBUFS);
41b6e003
MK
219 tp->t_sc = (caddr_t)sc;
220 sc->sc_ttyp = tp;
8011f5df 221 ttyflush(tp, FREAD | FWRITE);
41b6e003
MK
222 return (0);
223 }
8011f5df 224 return (ENXIO);
41b6e003
MK
225}
226
227/*
228 * Line specific close routine.
229 * Detach the tty from the sl unit.
230 * Mimics part of ttyclose().
231 */
232slclose(tp)
233 struct tty *tp;
234{
235 register struct sl_softc *sc;
236 int s;
237
238 ttywflush(tp);
270f7144 239 s = splimp(); /* actually, max(spltty, splnet) */
41b6e003 240 tp->t_line = 0;
41b6e003
MK
241 sc = (struct sl_softc *)tp->t_sc;
242 if (sc != NULL) {
243 if_down(&sc->sc_if);
244 sc->sc_ttyp = NULL;
245 tp->t_sc = NULL;
b25c0eeb 246 MCLFREE((caddr_t)(sc->sc_ep - SLBUFSIZE));
270f7144
MK
247 sc->sc_ep = 0;
248 sc->sc_mp = 0;
8011f5df 249 sc->sc_buf = 0;
41b6e003
MK
250 }
251 splx(s);
252}
253
254/*
255 * Line specific (tty) ioctl routine.
256 * Provide a way to get the sl unit number.
257 */
8011f5df 258/* ARGSUSED */
41b6e003
MK
259sltioctl(tp, cmd, data, flag)
260 struct tty *tp;
261 caddr_t data;
262{
4a23a8aa
WN
263 struct sl_softc *sc = (struct sl_softc *)tp->t_sc;
264 int s;
41b6e003 265
4a23a8aa 266 switch (cmd) {
270f7144
MK
267 case TIOCGETD: /* XXX */
268 case SLIOGUNIT:
4a23a8aa
WN
269 *(int *)data = sc->sc_if.if_unit;
270 break;
4a23a8aa 271
4a23a8aa
WN
272 case SLIOCGFLAGS:
273 *(int *)data = sc->sc_flags;
274 break;
270f7144 275
4a23a8aa
WN
276 case SLIOCSFLAGS:
277#define SC_MASK (SC_COMPRESS|SC_NOICMP)
278 s = splimp();
279 sc->sc_flags =
280 (sc->sc_flags &~ SC_MASK) | ((*(int *)data) & SC_MASK);
281 splx(s);
282 break;
270f7144 283
4a23a8aa
WN
284 default:
285 return (-1);
fc62c320 286 }
4a23a8aa 287 return (0);
41b6e003
MK
288}
289
290/*
291 * Queue a packet. Start transmission if not active.
292 */
293sloutput(ifp, m, dst)
b25c0eeb 294 struct ifnet *ifp;
41b6e003
MK
295 register struct mbuf *m;
296 struct sockaddr *dst;
297{
b25c0eeb 298 register struct sl_softc *sc = &sl_softc[ifp->if_unit];
270f7144
MK
299 register struct ip *ip;
300 register struct ifqueue *ifq;
41b6e003
MK
301 int s;
302
303 /*
304 * `Cannot happen' (see slioctl). Someday we will extend
305 * the line protocol to support other address families.
306 */
307 if (dst->sa_family != AF_INET) {
b25c0eeb 308 printf("sl%d: af%d not supported\n", sc->sc_if.if_unit,
41b6e003
MK
309 dst->sa_family);
310 m_freem(m);
311 return (EAFNOSUPPORT);
312 }
313
41b6e003
MK
314 if (sc->sc_ttyp == NULL) {
315 m_freem(m);
316 return (ENETDOWN); /* sort of */
317 }
eadd9817
MK
318 if ((sc->sc_ttyp->t_state & TS_CARR_ON) == 0) {
319 m_freem(m);
320 return (EHOSTUNREACH);
321 }
b25c0eeb 322 ifq = &sc->sc_if.if_snd;
270f7144
MK
323 if ((ip = mtod(m, struct ip *))->ip_p == IPPROTO_TCP) {
324 register int p = ((int *)ip)[ip->ip_hl];
325
326 if (INTERACTIVE(p & 0xffff) || INTERACTIVE(p >> 16))
327 ifq = &sc->sc_fastq;
328
329 if (sc->sc_flags & SC_COMPRESS) {
330 /* if two copies of sl_compress_tcp are running
331 * for the same line, the compression state can
332 * get screwed up. We're assuming that sloutput
333 * was invoked at splnet so this isn't possible
334 * (this assumption is correct for 4.xbsd, x<=4).
335 * In a multi-threaded kernel, a lockout might
336 * be needed here. */
337 p = sl_compress_tcp(m, ip, &sc->sc_comp);
338 *mtod(m, u_char *) |= p;
4a23a8aa 339 }
270f7144
MK
340 } else if (sc->sc_flags & SC_NOICMP && ip->ip_p == IPPROTO_ICMP) {
341 m_freem(m);
342 return (0);
4a23a8aa 343 }
270f7144
MK
344 s = splimp();
345 if (IF_QFULL(ifq)) {
346 IF_DROP(ifq);
41b6e003 347 m_freem(m);
270f7144 348 splx(s);
8011f5df 349 sc->sc_if.if_oerrors++;
41b6e003
MK
350 return (ENOBUFS);
351 }
270f7144 352 IF_ENQUEUE(ifq, m);
b25c0eeb 353 if (sc->sc_ttyp->t_outq.c_cc == 0)
41b6e003 354 slstart(sc->sc_ttyp);
b25c0eeb 355 splx(s);
41b6e003
MK
356 return (0);
357}
358
359/*
360 * Start output on interface. Get another datagram
361 * to send from the interface queue and map it to
362 * the interface before starting output.
363 */
364slstart(tp)
365 register struct tty *tp;
366{
367 register struct sl_softc *sc = (struct sl_softc *)tp->t_sc;
368 register struct mbuf *m;
8011f5df 369 register u_char *cp;
270f7144 370 int s;
8011f5df
MK
371 struct mbuf *m2;
372 extern int cfreecount;
41b6e003 373
8011f5df
MK
374 for (;;) {
375 /*
376 * If there is more in the output queue, just send it now.
377 * We are being called in lieu of ttstart and must do what
378 * it would.
379 */
270f7144
MK
380 if (tp->t_outq.c_cc != 0) {
381 (*tp->t_oproc)(tp);
382 if (tp->t_outq.c_cc > SLIP_HIWAT)
383 return;
384 }
8011f5df
MK
385 /*
386 * This happens briefly when the line shuts down.
387 */
388 if (sc == NULL)
389 return;
41b6e003 390
8011f5df
MK
391 /*
392 * Get a packet and send it to the interface.
393 */
394 s = splimp();
270f7144
MK
395 IF_DEQUEUE(&sc->sc_fastq, m);
396 if (m == NULL)
397 IF_DEQUEUE(&sc->sc_if.if_snd, m);
8011f5df 398 splx(s);
e8e27e8e
MK
399 if (m == NULL)
400 return;
270f7144
MK
401 /*
402 * If system is getting low on clists, just flush our
403 * output queue (if the stuff was important, it'll get
404 * retransmitted).
405 */
406 if (cfreecount < CLISTRESERVE + SLMTU) {
407 m_freem(m);
408 sc->sc_if.if_collisions++;
409 continue;
410 }
41b6e003 411
41b6e003 412 /*
8011f5df
MK
413 * The extra FRAME_END will start up a new packet, and thus
414 * will flush any accumulated garbage. We do this whenever
415 * the line may have been idle for some time.
41b6e003 416 */
270f7144
MK
417 if (tp->t_outq.c_cc == 0) {
418 ++sc->sc_bytessent;
8011f5df 419 (void) putc(FRAME_END, &tp->t_outq);
270f7144 420 }
8011f5df
MK
421
422 while (m) {
270f7144
MK
423 register u_char *ep;
424
425 cp = mtod(m, u_char *); ep = cp + m->m_len;
426 while (cp < ep) {
8011f5df
MK
427 /*
428 * Find out how many bytes in the string we can
429 * handle without doing something special.
430 */
270f7144
MK
431 register u_char *bp = cp;
432
433 while (cp < ep) {
434 switch (*cp++) {
435 case FRAME_ESCAPE:
436 case FRAME_END:
437 --cp;
438 goto out;
439 }
440 }
441 out:
442 if (cp > bp) {
8011f5df
MK
443 /*
444 * Put n characters at once
445 * into the tty output queue.
446 */
270f7144 447 if (b_to_q((char *)bp, cp - bp, &tp->t_outq))
8011f5df 448 break;
270f7144 449 sc->sc_bytessent += cp - bp;
8011f5df
MK
450 }
451 /*
452 * If there are characters left in the mbuf,
453 * the first one must be special..
454 * Put it out in a different form.
455 */
270f7144 456 if (cp < ep) {
8011f5df
MK
457 if (putc(FRAME_ESCAPE, &tp->t_outq))
458 break;
270f7144 459 if (putc(*cp++ == FRAME_ESCAPE ?
8011f5df
MK
460 TRANS_FRAME_ESCAPE : TRANS_FRAME_END,
461 &tp->t_outq)) {
462 (void) unputc(&tp->t_outq);
463 break;
464 }
270f7144 465 sc->sc_bytessent += 2;
8011f5df
MK
466 }
467 }
468 MFREE(m, m2);
469 m = m2;
470 }
41b6e003 471
8011f5df
MK
472 if (putc(FRAME_END, &tp->t_outq)) {
473 /*
474 * Not enough room. Remove a char to make room
475 * and end the packet normally.
476 * If you get many collisions (more than one or two
477 * a day) you probably do not have enough clists
478 * and you should increase "nclist" in param.c.
479 */
480 (void) unputc(&tp->t_outq);
481 (void) putc(FRAME_END, &tp->t_outq);
482 sc->sc_if.if_collisions++;
8011f5df 483 } else {
270f7144
MK
484 ++sc->sc_bytessent;
485 sc->sc_if.if_opackets++;
8011f5df
MK
486 }
487 }
41b6e003
MK
488}
489
490/*
270f7144 491 * Copy data buffer to mbuf chain; add ifnet pointer.
41b6e003 492 */
270f7144
MK
493static struct mbuf *
494sl_btom(sc, len)
495 register struct sl_softc *sc;
41b6e003 496 register int len;
41b6e003 497{
270f7144 498 register struct mbuf *m;
41b6e003 499
270f7144
MK
500 MGETHDR(m, M_DONTWAIT, MT_DATA);
501 if (m == NULL)
502 return (NULL);
fc62c320 503
270f7144 504 /*
b25c0eeb 505 * If we have more than MHLEN bytes, it's cheaper to
270f7144
MK
506 * queue the cluster we just filled & allocate a new one
507 * for the input buffer. Otherwise, fill the mbuf we
508 * allocated above. Note that code in the input routine
509 * guarantees that packet will fit in a cluster.
510 */
270f7144
MK
511 if (len >= MHLEN) {
512 MCLGET(m, M_DONTWAIT);
513 if ((m->m_flags & M_EXT) == 0) {
b25c0eeb
MK
514 /*
515 * we couldn't get a cluster - if memory's this
516 * low, it's time to start dropping packets.
517 */
518 (void) m_free(m);
41b6e003
MK
519 return (NULL);
520 }
b25c0eeb
MK
521 sc->sc_ep = mtod(m, u_char *) + SLBUFSIZE;
522 m->m_data = (caddr_t)sc->sc_buf;
523 m->m_ext.ext_buf = (caddr_t)((int)sc->sc_buf &~ MCLOFSET);
270f7144 524 } else
b25c0eeb 525 bcopy((caddr_t)sc->sc_buf, mtod(m, caddr_t), len);
270f7144
MK
526
527 m->m_len = len;
528 m->m_pkthdr.len = len;
529 m->m_pkthdr.rcvif = &sc->sc_if;
530 return (m);
41b6e003
MK
531}
532
533/*
534 * tty interface receiver interrupt.
535 */
536slinput(c, tp)
537 register int c;
538 register struct tty *tp;
539{
540 register struct sl_softc *sc;
541 register struct mbuf *m;
270f7144 542 register int len;
41b6e003
MK
543 int s;
544
8011f5df 545 tk_nin++;
41b6e003
MK
546 sc = (struct sl_softc *)tp->t_sc;
547 if (sc == NULL)
548 return;
270f7144 549 if (!(tp->t_state&TS_CARR_ON)) /* XXX */
4a23a8aa 550 return;
41b6e003 551
270f7144
MK
552 ++sc->sc_bytesrcvd;
553 c &= 0xff; /* XXX */
554
555#ifdef ABT_ESC
556 if (sc->sc_flags & SC_ABORT) {
557 /* if we see an abort after "idle" time, count it */
558 if (c == ABT_ESC && time.tv_sec >= sc->sc_lasttime + ABT_WAIT) {
559 sc->sc_abortcount++;
560 /* record when the first abort escape arrived */
561 if (sc->sc_abortcount == 1)
562 sc->sc_starttime = time.tv_sec;
563 }
564 /*
565 * if we have an abort, see that we have not run out of time,
566 * or that we have an "idle" time after the complete escape
567 * sequence
568 */
569 if (sc->sc_abortcount) {
570 if (time.tv_sec >= sc->sc_starttime + ABT_RECYCLE)
571 sc->sc_abortcount = 0;
572 if (sc->sc_abortcount >= ABT_SOFT &&
573 time.tv_sec >= sc->sc_lasttime + ABT_WAIT) {
574 slclose(tp);
575 return;
576 }
577 }
578 sc->sc_lasttime = time.tv_sec;
4a23a8aa 579 }
270f7144 580#endif
4a23a8aa 581
270f7144 582 switch (c) {
41b6e003 583
270f7144
MK
584 case TRANS_FRAME_ESCAPE:
585 if (sc->sc_escape)
41b6e003 586 c = FRAME_ESCAPE;
270f7144 587 break;
41b6e003 588
270f7144
MK
589 case TRANS_FRAME_END:
590 if (sc->sc_escape)
41b6e003 591 c = FRAME_END;
270f7144 592 break;
41b6e003 593
270f7144
MK
594 case FRAME_ESCAPE:
595 sc->sc_escape = 1;
596 return;
41b6e003 597
270f7144
MK
598 case FRAME_END:
599 len = sc->sc_mp - sc->sc_buf;
600 if (len < 3)
601 /* less than min length packet - ignore */
602 goto newpack;
603
604 if ((c = (*sc->sc_buf & 0xf0)) != (IPVERSION << 4)) {
605 if (c & 0x80)
606 c = TYPE_COMPRESSED_TCP;
607 else if (c == TYPE_UNCOMPRESSED_TCP)
608 *sc->sc_buf &= 0x4f; /* XXX */
609 len = sl_uncompress_tcp(&sc->sc_buf, len, (u_int)c,
610 &sc->sc_comp);
611 if (len <= 0)
612 goto error;
613 }
614 m = sl_btom(sc, len);
615 if (m == NULL)
616 goto error;
41b6e003 617
270f7144
MK
618 sc->sc_if.if_ipackets++;
619 s = splimp();
620 if (IF_QFULL(&ipintrq)) {
621 IF_DROP(&ipintrq);
622 sc->sc_if.if_ierrors++;
623 m_freem(m);
624 } else {
625 IF_ENQUEUE(&ipintrq, m);
626 schednetisr(NETISR_IP);
41b6e003 627 }
270f7144
MK
628 splx(s);
629 goto newpack;
41b6e003 630 }
270f7144
MK
631 if (sc->sc_mp < sc->sc_ep) {
632 *sc->sc_mp++ = c;
633 sc->sc_escape = 0;
41b6e003
MK
634 return;
635 }
270f7144
MK
636error:
637 sc->sc_if.if_ierrors++;
638newpack:
639 sc->sc_mp = sc->sc_buf = sc->sc_ep - SLMTU;
640 sc->sc_escape = 0;
41b6e003
MK
641}
642
643/*
644 * Process an ioctl request.
645 */
646slioctl(ifp, cmd, data)
647 register struct ifnet *ifp;
648 int cmd;
649 caddr_t data;
650{
651 register struct ifaddr *ifa = (struct ifaddr *)data;
652 int s = splimp(), error = 0;
653
654 switch (cmd) {
655
656 case SIOCSIFADDR:
b72a6efb 657 if (ifa->ifa_addr->sa_family == AF_INET)
41b6e003
MK
658 ifp->if_flags |= IFF_UP;
659 else
660 error = EAFNOSUPPORT;
661 break;
662
663 case SIOCSIFDSTADDR:
b72a6efb 664 if (ifa->ifa_addr->sa_family != AF_INET)
41b6e003
MK
665 error = EAFNOSUPPORT;
666 break;
667
668 default:
669 error = EINVAL;
670 }
671 splx(s);
672 return (error);
673}
674#endif