typo
[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 *
270f7144 17 * @(#)if_sl.c 7.16 (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
93 * MCLBYTES - sizeof(struct ifnet *) - 128
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 */
270f7144
MK
111#define SLMTU 576
112#define BUFOFFSET (128+sizeof(struct ifnet **))
113#define SLIP_HIWAT 1024 /* don't start a new packet if HIWAT on queue */
114#define CLISTRESERVE 1024 /* Can't let clists get too low */
4a23a8aa
WN
115/*
116 * SLIP ABORT ESCAPE MECHANISM:
117 * (inspired by HAYES modem escape arrangement)
118 * 1sec escape 1sec escape 1sec escape { 1sec escape 1sec escape }
119 * signals a "soft" exit from slip mode by usermode process
4a23a8aa
WN
120 */
121
122#define ABT_ESC '\033' /* can't be t_intr - distant host must know it*/
123#define ABT_WAIT 1 /* in seconds - idle before an escape & after */
124#define ABT_RECYCLE (5*2+2) /* in seconds - time window processing abort */
125
4a23a8aa 126#define ABT_SOFT 3 /* count of escapes */
41b6e003 127
4a23a8aa 128/*
270f7144
MK
129 * The following disgusting hack gets around the problem that IP TOS
130 * can't be set in BSD/Sun OS yet. We want to put "interactive"
131 * traffic on a high priority queue. To decide if traffic is
132 * interactive, we check that a) it is TCP and b) one of it's ports
133 * if telnet, rlogin or ftp control.
4a23a8aa 134 */
270f7144
MK
135static u_short interactive_ports[8] = {
136 0, 513, 0, 0,
137 0, 21, 0, 23,
138};
139#define INTERACTIVE(p) (interactive_ports[(p) & 7] == (p))
4a23a8aa 140
270f7144 141struct sl_softc sl_softc[NSL];
4a23a8aa 142
270f7144
MK
143#define FRAME_END 0xc0 /* Frame End */
144#define FRAME_ESCAPE 0xdb /* Frame Esc */
145#define TRANS_FRAME_END 0xdc /* transposed frame end */
146#define TRANS_FRAME_ESCAPE 0xdd /* transposed frame esc */
41b6e003
MK
147
148#define t_sc T_LINEP
149
150int sloutput(), slioctl(), ttrstrt();
151
152/*
153 * Called from boot code to establish sl interfaces.
154 */
155slattach()
156{
157 register struct sl_softc *sc;
158 register int i = 0;
159
160 for (sc = sl_softc; i < NSL; sc++) {
161 sc->sc_if.if_name = "sl";
162 sc->sc_if.if_unit = i++;
163 sc->sc_if.if_mtu = SLMTU;
164 sc->sc_if.if_flags = IFF_POINTOPOINT;
165 sc->sc_if.if_ioctl = slioctl;
166 sc->sc_if.if_output = sloutput;
270f7144
MK
167 sc->sc_if.if_snd.ifq_maxlen = 50;
168 sc->sc_fastq.ifq_maxlen = 32;
41b6e003
MK
169 if_attach(&sc->sc_if);
170 }
171}
172
270f7144
MK
173static int
174slinit(sc)
175 register struct sl_softc *sc;
176{
177 register caddr_t p;
178
179 if (sc->sc_ep == (u_char *) 0) {
180 MCLALLOC(p, M_WAIT);
181 if (p)
182 sc->sc_ep = (u_char *)p + (BUFOFFSET + SLMTU);
183 else {
184 printf("sl%d: can't allocate buffer\n", sc - sl_softc);
185 sc->sc_if.if_flags &= ~IFF_UP;
186 return (0);
187 }
188 }
189 sc->sc_buf = sc->sc_ep - SLMTU;
190 sc->sc_mp = sc->sc_buf;
191 sl_compress_init(&sc->sc_comp);
192 return (1);
193}
194
41b6e003
MK
195/*
196 * Line specific open routine.
197 * Attach the given tty to the first available sl unit.
198 */
8011f5df 199/* ARGSUSED */
41b6e003
MK
200slopen(dev, tp)
201 dev_t dev;
202 register struct tty *tp;
203{
204 register struct sl_softc *sc;
205 register int nsl;
06c16dfa 206 int error;
41b6e003 207
06c16dfa
KM
208 if (error = suser(u.u_cred, &u.u_acflag))
209 return (error);
270f7144 210
8011f5df 211 if (tp->t_line == SLIPDISC)
41b6e003
MK
212 return (EBUSY);
213
270f7144 214 for (nsl = NSL, sc = sl_softc; --nsl >= 0; sc++)
41b6e003 215 if (sc->sc_ttyp == NULL) {
8011f5df
MK
216 if (slinit(sc) == 0)
217 return (ENOBUFS);
41b6e003
MK
218 tp->t_sc = (caddr_t)sc;
219 sc->sc_ttyp = tp;
8011f5df 220 ttyflush(tp, FREAD | FWRITE);
41b6e003
MK
221 return (0);
222 }
8011f5df 223 return (ENXIO);
41b6e003
MK
224}
225
226/*
227 * Line specific close routine.
228 * Detach the tty from the sl unit.
229 * Mimics part of ttyclose().
230 */
231slclose(tp)
232 struct tty *tp;
233{
234 register struct sl_softc *sc;
235 int s;
236
237 ttywflush(tp);
270f7144 238 s = splimp(); /* actually, max(spltty, splnet) */
41b6e003 239 tp->t_line = 0;
41b6e003
MK
240 sc = (struct sl_softc *)tp->t_sc;
241 if (sc != NULL) {
242 if_down(&sc->sc_if);
243 sc->sc_ttyp = NULL;
244 tp->t_sc = NULL;
270f7144
MK
245 MCLFREE((struct mbuf *)(sc->sc_ep - (SLMTU + BUFOFFSET)));
246 sc->sc_ep = 0;
247 sc->sc_mp = 0;
8011f5df 248 sc->sc_buf = 0;
41b6e003
MK
249 }
250 splx(s);
251}
252
253/*
254 * Line specific (tty) ioctl routine.
255 * Provide a way to get the sl unit number.
256 */
8011f5df 257/* ARGSUSED */
41b6e003
MK
258sltioctl(tp, cmd, data, flag)
259 struct tty *tp;
260 caddr_t data;
261{
4a23a8aa
WN
262 struct sl_softc *sc = (struct sl_softc *)tp->t_sc;
263 int s;
41b6e003 264
4a23a8aa 265 switch (cmd) {
270f7144
MK
266 case TIOCGETD: /* XXX */
267 case SLIOGUNIT:
4a23a8aa
WN
268 *(int *)data = sc->sc_if.if_unit;
269 break;
4a23a8aa 270
4a23a8aa
WN
271 case SLIOCGFLAGS:
272 *(int *)data = sc->sc_flags;
273 break;
270f7144 274
4a23a8aa
WN
275 case SLIOCSFLAGS:
276#define SC_MASK (SC_COMPRESS|SC_NOICMP)
277 s = splimp();
278 sc->sc_flags =
279 (sc->sc_flags &~ SC_MASK) | ((*(int *)data) & SC_MASK);
280 splx(s);
281 break;
270f7144 282
4a23a8aa
WN
283 default:
284 return (-1);
fc62c320 285 }
4a23a8aa 286 return (0);
41b6e003
MK
287}
288
289/*
290 * Queue a packet. Start transmission if not active.
291 */
292sloutput(ifp, m, dst)
293 register struct ifnet *ifp;
294 register struct mbuf *m;
295 struct sockaddr *dst;
296{
297 register struct sl_softc *sc;
270f7144
MK
298 register struct ip *ip;
299 register struct ifqueue *ifq;
41b6e003
MK
300 int s;
301
302 /*
303 * `Cannot happen' (see slioctl). Someday we will extend
304 * the line protocol to support other address families.
305 */
306 if (dst->sa_family != AF_INET) {
307 printf("sl%d: af%d not supported\n", ifp->if_unit,
308 dst->sa_family);
309 m_freem(m);
310 return (EAFNOSUPPORT);
311 }
312
313 sc = &sl_softc[ifp->if_unit];
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 }
270f7144
MK
322 ifq = &ifp->if_snd;
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);
e8e27e8e 353 if (sc->sc_ttyp->t_outq.c_cc == 0) {
41b6e003
MK
354 splx(s);
355 slstart(sc->sc_ttyp);
356 } else
357 splx(s);
358 return (0);
359}
360
361/*
362 * Start output on interface. Get another datagram
363 * to send from the interface queue and map it to
364 * the interface before starting output.
365 */
366slstart(tp)
367 register struct tty *tp;
368{
369 register struct sl_softc *sc = (struct sl_softc *)tp->t_sc;
370 register struct mbuf *m;
8011f5df 371 register u_char *cp;
270f7144 372 int s;
8011f5df
MK
373 struct mbuf *m2;
374 extern int cfreecount;
41b6e003 375
8011f5df
MK
376 for (;;) {
377 /*
378 * If there is more in the output queue, just send it now.
379 * We are being called in lieu of ttstart and must do what
380 * it would.
381 */
270f7144
MK
382 if (tp->t_outq.c_cc != 0) {
383 (*tp->t_oproc)(tp);
384 if (tp->t_outq.c_cc > SLIP_HIWAT)
385 return;
386 }
8011f5df
MK
387 /*
388 * This happens briefly when the line shuts down.
389 */
390 if (sc == NULL)
391 return;
41b6e003 392
8011f5df
MK
393 /*
394 * Get a packet and send it to the interface.
395 */
396 s = splimp();
270f7144
MK
397 IF_DEQUEUE(&sc->sc_fastq, m);
398 if (m == NULL)
399 IF_DEQUEUE(&sc->sc_if.if_snd, m);
8011f5df 400 splx(s);
e8e27e8e
MK
401 if (m == NULL)
402 return;
270f7144
MK
403 /*
404 * If system is getting low on clists, just flush our
405 * output queue (if the stuff was important, it'll get
406 * retransmitted).
407 */
408 if (cfreecount < CLISTRESERVE + SLMTU) {
409 m_freem(m);
410 sc->sc_if.if_collisions++;
411 continue;
412 }
41b6e003 413
41b6e003 414 /*
8011f5df
MK
415 * The extra FRAME_END will start up a new packet, and thus
416 * will flush any accumulated garbage. We do this whenever
417 * the line may have been idle for some time.
41b6e003 418 */
270f7144
MK
419 if (tp->t_outq.c_cc == 0) {
420 ++sc->sc_bytessent;
8011f5df 421 (void) putc(FRAME_END, &tp->t_outq);
270f7144 422 }
8011f5df
MK
423
424 while (m) {
270f7144
MK
425 register u_char *ep;
426
427 cp = mtod(m, u_char *); ep = cp + m->m_len;
428 while (cp < ep) {
8011f5df
MK
429 /*
430 * Find out how many bytes in the string we can
431 * handle without doing something special.
432 */
270f7144
MK
433 register u_char *bp = cp;
434
435 while (cp < ep) {
436 switch (*cp++) {
437 case FRAME_ESCAPE:
438 case FRAME_END:
439 --cp;
440 goto out;
441 }
442 }
443 out:
444 if (cp > bp) {
8011f5df
MK
445 /*
446 * Put n characters at once
447 * into the tty output queue.
448 */
270f7144 449 if (b_to_q((char *)bp, cp - bp, &tp->t_outq))
8011f5df 450 break;
270f7144 451 sc->sc_bytessent += cp - bp;
8011f5df
MK
452 }
453 /*
454 * If there are characters left in the mbuf,
455 * the first one must be special..
456 * Put it out in a different form.
457 */
270f7144 458 if (cp < ep) {
8011f5df
MK
459 if (putc(FRAME_ESCAPE, &tp->t_outq))
460 break;
270f7144 461 if (putc(*cp++ == FRAME_ESCAPE ?
8011f5df
MK
462 TRANS_FRAME_ESCAPE : TRANS_FRAME_END,
463 &tp->t_outq)) {
464 (void) unputc(&tp->t_outq);
465 break;
466 }
270f7144 467 sc->sc_bytessent += 2;
8011f5df
MK
468 }
469 }
470 MFREE(m, m2);
471 m = m2;
472 }
41b6e003 473
8011f5df
MK
474 if (putc(FRAME_END, &tp->t_outq)) {
475 /*
476 * Not enough room. Remove a char to make room
477 * and end the packet normally.
478 * If you get many collisions (more than one or two
479 * a day) you probably do not have enough clists
480 * and you should increase "nclist" in param.c.
481 */
482 (void) unputc(&tp->t_outq);
483 (void) putc(FRAME_END, &tp->t_outq);
484 sc->sc_if.if_collisions++;
8011f5df 485 } else {
270f7144
MK
486 ++sc->sc_bytessent;
487 sc->sc_if.if_opackets++;
8011f5df
MK
488 }
489 }
41b6e003
MK
490}
491
492/*
270f7144 493 * Copy data buffer to mbuf chain; add ifnet pointer.
41b6e003 494 */
270f7144
MK
495static struct mbuf *
496sl_btom(sc, len)
497 register struct sl_softc *sc;
41b6e003 498 register int len;
41b6e003 499{
270f7144
MK
500 register u_char *cp;
501 register struct mbuf *m;
41b6e003 502
270f7144
MK
503 MGETHDR(m, M_DONTWAIT, MT_DATA);
504 if (m == NULL)
505 return (NULL);
fc62c320 506
270f7144
MK
507 /*
508 * If we have more than MLEN bytes, it's cheaper to
509 * queue the cluster we just filled & allocate a new one
510 * for the input buffer. Otherwise, fill the mbuf we
511 * allocated above. Note that code in the input routine
512 * guarantees that packet will fit in a cluster.
513 */
514 cp = sc->sc_buf;
515 if (len >= MHLEN) {
516 MCLGET(m, M_DONTWAIT);
517 if ((m->m_flags & M_EXT) == 0) {
518 /* we couldn't get a cluster - if memory's this
519 * low, it's time to start dropping packets. */
520 m_freem(m);
41b6e003
MK
521 return (NULL);
522 }
270f7144
MK
523 sc->sc_ep = mtod(m, u_char *) + (BUFOFFSET + SLMTU);
524 m->m_data = (caddr_t)cp;
525 } else
526 bcopy((caddr_t)cp, mtod(m, caddr_t), len);
527
528 m->m_len = len;
529 m->m_pkthdr.len = len;
530 m->m_pkthdr.rcvif = &sc->sc_if;
531 return (m);
41b6e003
MK
532}
533
534/*
535 * tty interface receiver interrupt.
536 */
537slinput(c, tp)
538 register int c;
539 register struct tty *tp;
540{
541 register struct sl_softc *sc;
542 register struct mbuf *m;
270f7144 543 register int len;
41b6e003
MK
544 int s;
545
8011f5df 546 tk_nin++;
41b6e003
MK
547 sc = (struct sl_softc *)tp->t_sc;
548 if (sc == NULL)
549 return;
270f7144 550 if (!(tp->t_state&TS_CARR_ON)) /* XXX */
4a23a8aa 551 return;
41b6e003 552
270f7144
MK
553 ++sc->sc_bytesrcvd;
554 c &= 0xff; /* XXX */
555
556#ifdef ABT_ESC
557 if (sc->sc_flags & SC_ABORT) {
558 /* if we see an abort after "idle" time, count it */
559 if (c == ABT_ESC && time.tv_sec >= sc->sc_lasttime + ABT_WAIT) {
560 sc->sc_abortcount++;
561 /* record when the first abort escape arrived */
562 if (sc->sc_abortcount == 1)
563 sc->sc_starttime = time.tv_sec;
564 }
565 /*
566 * if we have an abort, see that we have not run out of time,
567 * or that we have an "idle" time after the complete escape
568 * sequence
569 */
570 if (sc->sc_abortcount) {
571 if (time.tv_sec >= sc->sc_starttime + ABT_RECYCLE)
572 sc->sc_abortcount = 0;
573 if (sc->sc_abortcount >= ABT_SOFT &&
574 time.tv_sec >= sc->sc_lasttime + ABT_WAIT) {
575 slclose(tp);
576 return;
577 }
578 }
579 sc->sc_lasttime = time.tv_sec;
4a23a8aa 580 }
270f7144 581#endif
4a23a8aa 582
270f7144 583 switch (c) {
41b6e003 584
270f7144
MK
585 case TRANS_FRAME_ESCAPE:
586 if (sc->sc_escape)
41b6e003 587 c = FRAME_ESCAPE;
270f7144 588 break;
41b6e003 589
270f7144
MK
590 case TRANS_FRAME_END:
591 if (sc->sc_escape)
41b6e003 592 c = FRAME_END;
270f7144 593 break;
41b6e003 594
270f7144
MK
595 case FRAME_ESCAPE:
596 sc->sc_escape = 1;
597 return;
41b6e003 598
270f7144
MK
599 case FRAME_END:
600 len = sc->sc_mp - sc->sc_buf;
601 if (len < 3)
602 /* less than min length packet - ignore */
603 goto newpack;
604
605 if ((c = (*sc->sc_buf & 0xf0)) != (IPVERSION << 4)) {
606 if (c & 0x80)
607 c = TYPE_COMPRESSED_TCP;
608 else if (c == TYPE_UNCOMPRESSED_TCP)
609 *sc->sc_buf &= 0x4f; /* XXX */
610 len = sl_uncompress_tcp(&sc->sc_buf, len, (u_int)c,
611 &sc->sc_comp);
612 if (len <= 0)
613 goto error;
614 }
615 m = sl_btom(sc, len);
616 if (m == NULL)
617 goto error;
41b6e003 618
270f7144
MK
619 sc->sc_if.if_ipackets++;
620 s = splimp();
621 if (IF_QFULL(&ipintrq)) {
622 IF_DROP(&ipintrq);
623 sc->sc_if.if_ierrors++;
624 m_freem(m);
625 } else {
626 IF_ENQUEUE(&ipintrq, m);
627 schednetisr(NETISR_IP);
41b6e003 628 }
270f7144
MK
629 splx(s);
630 goto newpack;
41b6e003 631 }
270f7144
MK
632 if (sc->sc_mp < sc->sc_ep) {
633 *sc->sc_mp++ = c;
634 sc->sc_escape = 0;
41b6e003
MK
635 return;
636 }
270f7144
MK
637error:
638 sc->sc_if.if_ierrors++;
639newpack:
640 sc->sc_mp = sc->sc_buf = sc->sc_ep - SLMTU;
641 sc->sc_escape = 0;
41b6e003
MK
642}
643
644/*
645 * Process an ioctl request.
646 */
647slioctl(ifp, cmd, data)
648 register struct ifnet *ifp;
649 int cmd;
650 caddr_t data;
651{
652 register struct ifaddr *ifa = (struct ifaddr *)data;
653 int s = splimp(), error = 0;
654
655 switch (cmd) {
656
657 case SIOCSIFADDR:
b72a6efb 658 if (ifa->ifa_addr->sa_family == AF_INET)
41b6e003
MK
659 ifp->if_flags |= IFF_UP;
660 else
661 error = EAFNOSUPPORT;
662 break;
663
664 case SIOCSIFDSTADDR:
b72a6efb 665 if (ifa->ifa_addr->sa_family != AF_INET)
41b6e003
MK
666 error = EAFNOSUPPORT;
667 break;
668
669 default:
670 error = EINVAL;
671 }
672 splx(s);
673 return (error);
674}
675#endif