flags masked incorrectly
[unix-history] / usr / src / sys / vax / if / if_en.c
CommitLineData
e3631d06 1/* if_en.c 4.49 82/04/01 */
11720282
BJ
2
3#include "en.h"
a9f3e174 4#include "imp.h"
f1b2fa5b 5
11720282 6/*
f1b2fa5b 7 * Xerox prototype (3 Mb) Ethernet interface driver.
11720282
BJ
8 */
9
10#include "../h/param.h"
11#include "../h/systm.h"
12#include "../h/mbuf.h"
11720282
BJ
13#include "../h/pte.h"
14#include "../h/buf.h"
8a13b737
BJ
15#include "../h/protosw.h"
16#include "../h/socket.h"
11720282
BJ
17#include "../h/ubareg.h"
18#include "../h/ubavar.h"
11720282 19#include "../h/enreg.h"
11720282 20#include "../h/cpu.h"
8a13b737
BJ
21#include "../h/mtpr.h"
22#include "../h/vmmac.h"
23#include "../net/in.h"
24#include "../net/in_systm.h"
25#include "../net/if.h"
26#include "../net/if_en.h"
27#include "../net/if_uba.h"
28#include "../net/ip.h"
29#include "../net/ip_var.h"
31c2345c 30#include "../net/pup.h"
f6311fb6 31#include "../net/route.h"
8a13b737 32
a453e1b5 33#define ENMTU (1024+512)
11720282 34
11720282
BJ
35int enprobe(), enattach(), enrint(), enxint(), encollide();
36struct uba_device *eninfo[NEN];
37u_short enstd[] = { 0 };
38struct uba_driver endriver =
b454c3ea 39 { enprobe, 0, enattach, 0, enstd, "en", eninfo };
11720282
BJ
40#define ENUNIT(x) minor(x)
41
f1b2fa5b
BJ
42int eninit(),enoutput(),enreset();
43
44/*
45 * Ethernet software status per interface.
46 *
47 * Each interface is referenced by a network interface structure,
48 * es_if, which the routing code uses to locate the interface.
49 * This structure contains the output queue for the interface, its address, ...
50 * We also have, for each interface, a UBA interface structure, which
51 * contains information about the UNIBUS resources held by the interface:
52 * map registers, buffered data paths, etc. Information is cached in this
53 * structure for use by the if_uba.c routines in running the interface
54 * efficiently.
55 */
8a13b737 56struct en_softc {
f1b2fa5b
BJ
57 struct ifnet es_if; /* network-visible interface */
58 struct ifuba es_ifuba; /* UNIBUS resources */
59 short es_delay; /* current output delay */
60 short es_mask; /* mask for current output delay */
61 u_char es_lastx; /* host last transmitted to */
62 short es_oactive; /* is output active? */
63 short es_olen; /* length of last output */
8a13b737 64} en_softc[NEN];
11720282 65
f1b2fa5b
BJ
66/*
67 * Do output DMA to determine interface presence and
68 * interrupt vector. DMA is too short to disturb other hosts.
69 */
11720282
BJ
70enprobe(reg)
71 caddr_t reg;
72{
b454c3ea 73 register int br, cvec; /* r11, r10 value-result */
11720282
BJ
74 register struct endevice *addr = (struct endevice *)reg;
75
8a13b737 76COUNT(ENPROBE);
11720282
BJ
77#ifdef lint
78 br = 0; cvec = br; br = cvec;
2b4b57cd 79 enrint(0); enxint(0); encollide(0);
11720282 80#endif
11720282 81 addr->en_istat = 0;
11720282
BJ
82 addr->en_owc = -1;
83 addr->en_oba = 0;
941ee7ef 84 addr->en_ostat = EN_IEN|EN_GO;
11720282
BJ
85 DELAY(100000);
86 addr->en_ostat = 0;
11720282
BJ
87 return (1);
88}
89
f1b2fa5b
BJ
90/*
91 * Interface exists: make available by filling in network interface
92 * record. System will initialize the interface when it is ready
93 * to accept packets.
94 */
11720282
BJ
95enattach(ui)
96 struct uba_device *ui;
97{
f1b2fa5b 98 register struct en_softc *es = &en_softc[ui->ui_unit];
ee787340 99 register struct sockaddr_in *sin;
8a13b737 100COUNT(ENATTACH);
f1b2fa5b
BJ
101
102 es->es_if.if_unit = ui->ui_unit;
b454c3ea 103 es->es_if.if_name = "en";
f1b2fa5b 104 es->es_if.if_mtu = ENMTU;
e3631d06 105 es->es_if.if_net = ui->ui_flags & 0xff;
f1b2fa5b 106 es->es_if.if_host[0] =
ee787340
SL
107 (~(((struct endevice *)eninfo[ui->ui_unit]->ui_addr)->en_addr)) & 0xff;
108 sin = (struct sockaddr_in *)&es->es_if.if_addr;
109 sin->sin_family = AF_INET;
110 sin->sin_addr = if_makeaddr(es->es_if.if_net, es->es_if.if_host[0]);
111 sin = (struct sockaddr_in *)&es->es_if.if_broadaddr;
112 sin->sin_family = AF_INET;
113 sin->sin_addr = if_makeaddr(es->es_if.if_net, 0);
114 es->es_if.if_flags = IFF_BROADCAST;
f1b2fa5b 115 es->es_if.if_init = eninit;
b454c3ea 116 es->es_if.if_output = enoutput;
f1b2fa5b 117 es->es_if.if_ubareset = enreset;
7a66118b 118 es->es_ifuba.ifu_flags = UBA_NEEDBDP | UBA_NEED16;
405c9168 119 if_attach(&es->es_if);
a9f3e174
SL
120#if NIMP == 0
121 /* here's one for you john baby.... */
cd66a61f 122 enlhinit((ui->ui_flags &~ 0xff) | 0x0a);
a9f3e174 123#endif
11720282
BJ
124}
125
f1b2fa5b
BJ
126/*
127 * Reset of interface after UNIBUS reset.
128 * If interface is on specified uba, reset its state.
129 */
130enreset(unit, uban)
131 int unit, uban;
8a13b737 132{
11720282 133 register struct uba_device *ui;
f1b2fa5b 134COUNT(ENRESET);
11720282 135
b454c3ea
BJ
136 if (unit >= NEN || (ui = eninfo[unit]) == 0 || ui->ui_alive == 0 ||
137 ui->ui_ubanum != uban)
f1b2fa5b 138 return;
b454c3ea 139 printf(" en%d", unit);
f1b2fa5b
BJ
140 eninit(unit);
141}
142
143/*
144 * Initialization of interface; clear recorded pending
145 * operations, and reinitialize UNIBUS usage.
146 */
147eninit(unit)
148 int unit;
149{
b454c3ea
BJ
150 register struct en_softc *es = &en_softc[unit];
151 register struct uba_device *ui = eninfo[unit];
f1b2fa5b 152 register struct endevice *addr;
f1b2fa5b
BJ
153 int s;
154
f1b2fa5b 155 if (if_ubainit(&es->es_ifuba, ui->ui_ubanum,
81950b45 156 sizeof (struct en_header), (int)btoc(ENMTU)) == 0) {
b454c3ea 157 printf("en%d: can't initialize\n", unit);
ee787340 158 es->es_if.if_flags &= ~IFF_UP;
8a13b737 159 return;
11720282 160 }
11720282 161 addr = (struct endevice *)ui->ui_addr;
8a13b737 162 addr->en_istat = addr->en_ostat = 0;
11720282 163
f1b2fa5b 164 /*
b454c3ea
BJ
165 * Hang a receive and start any
166 * pending writes by faking a transmit complete.
f1b2fa5b
BJ
167 */
168 s = splimp();
b454c3ea
BJ
169 addr->en_iba = es->es_ifuba.ifu_r.ifrw_info;
170 addr->en_iwc = -(sizeof (struct en_header) + ENMTU) >> 1;
171 addr->en_istat = EN_IEN|EN_GO;
172 es->es_oactive = 1;
ee787340 173 es->es_if.if_flags |= IFF_UP;
f1b2fa5b
BJ
174 enxint(unit);
175 splx(s);
f6311fb6 176 if_rtinit(&es->es_if, RTF_DIRECT|RTF_UP);
11720282
BJ
177}
178
3552a746 179int enlastdel = 25;
8a13b737 180
f1b2fa5b
BJ
181/*
182 * Start or restart output on interface.
183 * If interface is already active, then this is a retransmit
184 * after a collision, and just restuff registers and delay.
185 * If interface is not already active, get another datagram
186 * to send off of the interface queue, and map it to the interface
187 * before starting the output.
188 */
ae348eea 189enstart(dev)
11720282
BJ
190 dev_t dev;
191{
b454c3ea
BJ
192 int unit = ENUNIT(dev);
193 struct uba_device *ui = eninfo[unit];
194 register struct en_softc *es = &en_softc[unit];
8a13b737 195 register struct endevice *addr;
8a13b737
BJ
196 struct mbuf *m;
197 int dest;
ae348eea 198COUNT(ENSTART);
11720282 199
8a13b737
BJ
200 if (es->es_oactive)
201 goto restart;
f1b2fa5b
BJ
202
203 /*
204 * Not already active: dequeue another request
205 * and map it to the UNIBUS. If no more requests,
206 * just return.
207 */
208 IF_DEQUEUE(&es->es_if.if_snd, m);
8a13b737
BJ
209 if (m == 0) {
210 es->es_oactive = 0;
11720282
BJ
211 return;
212 }
a453e1b5 213 dest = mtod(m, struct en_header *)->en_dhost;
8a13b737 214 es->es_olen = if_wubaput(&es->es_ifuba, m);
f1b2fa5b
BJ
215
216 /*
217 * Ethernet cannot take back-to-back packets (no
218 * buffering in interface. To avoid overrunning
219 * receiver, enforce a small delay (about 1ms) in interface
220 * on successive packets sent to same host.
221 */
8a13b737
BJ
222 if (es->es_lastx && es->es_lastx == dest)
223 es->es_delay = enlastdel;
224 else
225 es->es_lastx = dest;
f1b2fa5b 226
8a13b737 227restart:
f1b2fa5b
BJ
228 /*
229 * Have request mapped to UNIBUS for transmission.
230 * Purge any stale data from this BDP, and start the otput.
231 */
ee787340
SL
232 if (es->es_ifuba.ifu_flags & UBA_NEEDBDP)
233 UBAPURGE(es->es_ifuba.ifu_uba, es->es_ifuba.ifu_w.ifrw_bdp);
11720282 234 addr = (struct endevice *)ui->ui_addr;
405c9168 235 addr->en_oba = (int)es->es_ifuba.ifu_w.ifrw_info;
8a13b737
BJ
236 addr->en_odelay = es->es_delay;
237 addr->en_owc = -((es->es_olen + 1) >> 1);
941ee7ef 238 addr->en_ostat = EN_IEN|EN_GO;
8a13b737 239 es->es_oactive = 1;
11720282
BJ
240}
241
f1b2fa5b
BJ
242/*
243 * Ethernet interface transmitter interrupt.
244 * Start another output if more data to send.
245 */
11720282
BJ
246enxint(unit)
247 int unit;
248{
b454c3ea
BJ
249 register struct uba_device *ui = eninfo[unit];
250 register struct en_softc *es = &en_softc[unit];
519a1ecf 251 register struct endevice *addr = (struct endevice *)ui->ui_addr;
11720282
BJ
252COUNT(ENXINT);
253
8a13b737
BJ
254 if (es->es_oactive == 0)
255 return;
519a1ecf 256 if (es->es_mask && (addr->en_ostat&EN_OERROR)) {
89413846 257 es->es_if.if_oerrors++;
4020bf24
BJ
258 if (es->es_if.if_oerrors % 100 == 0)
259 printf("en%d: += 100 output errors\n", unit);
519a1ecf
BJ
260 endocoll(unit);
261 return;
89413846 262 }
519a1ecf
BJ
263 es->es_if.if_opackets++;
264 es->es_oactive = 0;
265 es->es_delay = 0;
266 es->es_mask = ~0;
7a66118b
BJ
267 if (es->es_ifuba.ifu_xtofree) {
268 m_freem(es->es_ifuba.ifu_xtofree);
269 es->es_ifuba.ifu_xtofree = 0;
270 }
f1b2fa5b 271 if (es->es_if.if_snd.ifq_head == 0) {
8a13b737 272 es->es_lastx = 0;
11720282
BJ
273 return;
274 }
8a13b737 275 enstart(unit);
11720282
BJ
276}
277
f1b2fa5b
BJ
278/*
279 * Collision on ethernet interface. Do exponential
280 * backoff, and retransmit. If have backed off all
ee787340 281 * the way print warning diagnostic, and drop packet.
f1b2fa5b 282 */
11720282
BJ
283encollide(unit)
284 int unit;
285{
519a1ecf 286 struct en_softc *es = &en_softc[unit];
11720282
BJ
287COUNT(ENCOLLIDE);
288
f1b2fa5b 289 es->es_if.if_collisions++;
8a13b737 290 if (es->es_oactive == 0)
11720282 291 return;
519a1ecf
BJ
292 endocoll(unit);
293}
294
295endocoll(unit)
296 int unit;
297{
298 register struct en_softc *es = &en_softc[unit];
299
b454c3ea
BJ
300 /*
301 * Es_mask is a 16 bit number with n low zero bits, with
302 * n the number of backoffs. When es_mask is 0 we have
303 * backed off 16 times, and give up.
304 */
8a13b737 305 if (es->es_mask == 0) {
a453e1b5 306 printf("en%d: send error\n", unit);
8a13b737 307 enxint(unit);
b454c3ea 308 return;
11720282 309 }
b454c3ea
BJ
310 /*
311 * Another backoff. Restart with delay based on n low bits
312 * of the interval timer.
313 */
314 es->es_mask <<= 1;
315 es->es_delay = mfpr(ICR) &~ es->es_mask;
316 enstart(unit);
11720282
BJ
317}
318
31c2345c
SL
319struct sockaddr_pup pupsrc = { AF_PUP };
320struct sockaddr_pup pupdst = { AF_PUP };
321struct sockproto pupproto = { PF_PUP };
f1b2fa5b
BJ
322/*
323 * Ethernet interface receiver interrupt.
324 * If input error just drop packet.
325 * Otherwise purge input buffered data path and examine
326 * packet to determine type. If can't determine length
327 * from type, then have to drop packet. Othewise decapsulate
328 * packet based on type and pass to type specific higher-level
329 * input routine.
330 */
11720282
BJ
331enrint(unit)
332 int unit;
333{
b454c3ea
BJ
334 register struct en_softc *es = &en_softc[unit];
335 struct endevice *addr = (struct endevice *)eninfo[unit]->ui_addr;
336 register struct en_header *en;
8a13b737 337 struct mbuf *m;
b454c3ea
BJ
338 int len;
339 register struct ifqueue *inq;
8a13b737 340 int off;
11720282
BJ
341COUNT(ENRINT);
342
b454c3ea 343 es->es_if.if_ipackets++;
f1b2fa5b
BJ
344
345 /*
b454c3ea 346 * Purge BDP; drop if input error indicated.
f1b2fa5b 347 */
ee787340
SL
348 if (es->es_ifuba.ifu_flags & UBA_NEEDBDP)
349 UBAPURGE(es->es_ifuba.ifu_uba, es->es_ifuba.ifu_r.ifrw_bdp);
941ee7ef 350 if (addr->en_istat&EN_IERROR) {
f1b2fa5b 351 es->es_if.if_ierrors++;
4020bf24
BJ
352 if (es->es_if.if_ierrors % 100 == 0)
353 printf("en%d: += 100 input errors\n", unit);
8a13b737 354 goto setup;
11720282 355 }
f1b2fa5b
BJ
356
357 /*
358 * Get pointer to ethernet header (in input buffer).
359 * Deal with trailer protocol: if type is PUP trailer
360 * get true type from first 16-bit word past data.
361 * Remember that type was trailer by setting off.
362 */
363 en = (struct en_header *)(es->es_ifuba.ifu_r.ifrw_addr);
8a13b737
BJ
364#define endataaddr(en, off, type) ((type)(((caddr_t)((en)+1)+(off))))
365 if (en->en_type >= ENPUP_TRAIL &&
366 en->en_type < ENPUP_TRAIL+ENPUP_NTRAILER) {
367 off = (en->en_type - ENPUP_TRAIL) * 512;
b454c3ea
BJ
368 if (off >= ENMTU)
369 goto setup; /* sanity */
8a13b737 370 en->en_type = *endataaddr(en, off, u_short *);
8a13b737
BJ
371 } else
372 off = 0;
f1b2fa5b
BJ
373
374 /*
375 * Attempt to infer packet length from type;
376 * can't deal with packet if can't infer length.
377 */
8a13b737
BJ
378 switch (en->en_type) {
379
380#ifdef INET
381 case ENPUP_IPTYPE:
ee787340
SL
382 len = htons((u_short)endataaddr(en,
383 off ? off + sizeof (u_short) : 0, struct ip *)->ip_len);
11720282
BJ
384 break;
385#endif
31c2345c
SL
386#ifdef PUP
387 case ENPUP_PUPTYPE:
ee787340
SL
388 len = endataaddr(en, off ? off + sizeof (u_short) : 0,
389 struct pup_header *)->pup_length;
31c2345c
SL
390 break;
391#endif
392
8a13b737 393 default:
5d855bdf 394 printf("en%d: unknown pkt type 0x%x\n", unit, en->en_type);
8a13b737 395 goto setup;
11720282 396 }
80a4458b
SL
397 if (off)
398 len += sizeof (u_short);
8a13b737
BJ
399 if (len == 0)
400 goto setup;
f1b2fa5b
BJ
401
402 /*
403 * Pull packet off interface. Off is nonzero if packet
404 * has trailing header; if_rubaget will then force this header
405 * information to be at the front, but we still have to drop
b454c3ea 406 * the two-byte type which is at the front of any trailer data.
f1b2fa5b
BJ
407 */
408 m = if_rubaget(&es->es_ifuba, len, off);
a453e1b5
BJ
409 if (m == 0)
410 goto setup;
f1b2fa5b 411 if (off) {
ee787340
SL
412 m->m_off += sizeof (u_short);
413 m->m_len -= sizeof (u_short);
f1b2fa5b 414 }
31c2345c
SL
415 switch (en->en_type) {
416
417#ifdef INET
418 case ENPUP_IPTYPE:
9c8692e9 419 schednetisr(NETISR_IP);
31c2345c
SL
420 inq = &ipintrq;
421 break;
422#endif
ee787340 423#ifdef PUP
31c2345c
SL
424 case ENPUP_PUPTYPE: {
425 struct pup_header *pup = mtod(m, struct pup_header *);
426
427 pupproto.sp_protocol = pup->pup_type;
428 pupdst.spup_addr = pup->pup_dport;
429 pupsrc.spup_addr = pup->pup_sport;
668cc26d 430 raw_input(m, &pupproto, (struct sockaddr *)&pupdst,
ee787340 431 (struct sockaddr *)&pupsrc);
31c2345c 432 goto setup;
31c2345c 433 }
ee787340
SL
434#endif
435 }
436
1e977657
BJ
437 if (IF_QFULL(inq)) {
438 IF_DROP(inq);
ee787340 439 m_freem(m);
1e977657
BJ
440 } else
441 IF_ENQUEUE(inq, m);
f1b2fa5b 442
ae348eea 443setup:
f1b2fa5b
BJ
444 /*
445 * Reset for next packet.
446 */
447 addr->en_iba = es->es_ifuba.ifu_r.ifrw_info;
8a13b737 448 addr->en_iwc = -(sizeof (struct en_header) + ENMTU) >> 1;
941ee7ef 449 addr->en_istat = EN_IEN|EN_GO;
ae348eea 450}
11720282 451
8a13b737
BJ
452/*
453 * Ethernet output routine.
454 * Encapsulate a packet of type family for the local net.
f1b2fa5b
BJ
455 * Use trailer local net encapsulation if enough data in first
456 * packet leaves a multiple of 512 bytes of data in remainder.
8a13b737 457 */
ee787340 458enoutput(ifp, m0, dst)
8a13b737
BJ
459 struct ifnet *ifp;
460 struct mbuf *m0;
ee787340 461 struct sockaddr *dst;
11720282 462{
ee787340 463 int type, dest, s;
f1b2fa5b 464 register struct mbuf *m = m0;
8a13b737 465 register struct en_header *en;
ee787340 466 register int off;
8a13b737 467
9d1b03e0 468COUNT(ENOUTPUT);
ee787340 469 switch (dst->sa_family) {
11720282 470
8a13b737 471#ifdef INET
ee787340
SL
472 case AF_INET:
473 dest = ((struct sockaddr_in *)dst)->sin_addr.s_addr >> 24;
474 off = ntohs((u_short)mtod(m, struct ip *)->ip_len) - m->m_len;
475 if (off > 0 && (off & 0x1ff) == 0 &&
476 m->m_off >= MMINOFF + sizeof (u_short)) {
8a13b737 477 type = ENPUP_TRAIL + (off>>9);
ee787340
SL
478 m->m_off -= sizeof (u_short);
479 m->m_len += sizeof (u_short);
f1b2fa5b
BJ
480 *mtod(m, u_short *) = ENPUP_IPTYPE;
481 goto gottrailertype;
8a13b737 482 }
f1b2fa5b
BJ
483 type = ENPUP_IPTYPE;
484 off = 0;
485 goto gottype;
8a13b737 486#endif
31c2345c 487#ifdef PUP
ee787340
SL
488 case AF_PUP:
489 dest = ((struct sockaddr_pup *)dst)->spup_addr.pp_host;
490 off = mtod(m, struct pup_header *)->pup_length - m->m_len;
491 if (off > 0 && (off & 0x1ff) == 0 &&
492 m->m_off >= MMINOFF + sizeof (u_short)) {
31c2345c 493 type = ENPUP_TRAIL + (off>>9);
ee787340
SL
494 m->m_off -= sizeof (u_short);
495 m->m_len += sizeof (u_short);
31c2345c
SL
496 *mtod(m, u_short *) = ENPUP_PUPTYPE;
497 goto gottrailertype;
498 }
499 type = ENPUP_PUPTYPE;
500 off = 0;
501 goto gottype;
31c2345c 502#endif
8a13b737
BJ
503
504 default:
ee787340
SL
505 printf("en%d: can't handle af%d\n", ifp->if_unit,
506 dst->sa_family);
8a13b737
BJ
507 m_freem(m0);
508 return (0);
509 }
f1b2fa5b 510
b454c3ea 511gottrailertype:
f1b2fa5b
BJ
512 /*
513 * Packet to be sent as trailer: move first packet
514 * (control information) to end of chain.
515 */
f1b2fa5b
BJ
516 while (m->m_next)
517 m = m->m_next;
518 m->m_next = m0;
519 m = m0->m_next;
520 m0->m_next = 0;
b454c3ea 521 m0 = m;
f1b2fa5b 522
b454c3ea 523gottype:
f1b2fa5b
BJ
524 /*
525 * Add local net header. If no space in first mbuf,
526 * allocate another.
527 */
a453e1b5
BJ
528 if (m->m_off > MMAXOFF ||
529 MMINOFF + sizeof (struct en_header) > m->m_off) {
ef9b4258 530 m = m_get(M_DONTWAIT);
8a13b737
BJ
531 if (m == 0) {
532 m_freem(m0);
533 return (0);
534 }
535 m->m_next = m0;
536 m->m_off = MMINOFF;
537 m->m_len = sizeof (struct en_header);
538 } else {
8a13b737
BJ
539 m->m_off -= sizeof (struct en_header);
540 m->m_len += sizeof (struct en_header);
11720282 541 }
8a13b737
BJ
542 en = mtod(m, struct en_header *);
543 en->en_shost = ifp->if_host[0];
544 en->en_dhost = dest;
545 en->en_type = type;
f1b2fa5b
BJ
546
547 /*
548 * Queue message on interface, and start output if interface
549 * not yet active.
550 */
8a13b737 551 s = splimp();
1e977657
BJ
552 if (IF_QFULL(&ifp->if_snd)) {
553 IF_DROP(&ifp->if_snd);
554 m_freem(m);
555 splx(s);
556 return (0);
557 }
8a13b737 558 IF_ENQUEUE(&ifp->if_snd, m);
8a13b737
BJ
559 if (en_softc[ifp->if_unit].es_oactive == 0)
560 enstart(ifp->if_unit);
89413846 561 splx(s);
f1b2fa5b 562 return (1);
11720282 563}
a9f3e174
SL
564
565#if NIMP == 0 && NEN > 0
566/*
567 * Logical host interface driver.
568 * Allows host to appear as an ARPAnet
569 * logical host. Must also have routing
570 * table entry set up to forward packets
571 * to appropriate gateway on localnet.
572 */
573
574struct ifnet enlhif;
575int enlhoutput();
576
577/*
578 * Called by localnet interface to allow logical
579 * host interface to "attach". Nothing should ever
580 * be sent locally to this interface, it's purpose
581 * is simply to establish the host's arpanet address.
582 */
583enlhinit(addr)
584 int addr;
585{
586 register struct ifnet *ifp = &enlhif;
587 register struct sockaddr_in *sin;
588
589COUNT(ENLHINIT);
590 ifp->if_name = "lh";
591 ifp->if_mtu = ENMTU;
592 sin = (struct sockaddr_in *)&ifp->if_addr;
593 sin->sin_family = AF_INET;
594 sin->sin_addr.s_addr = addr;
595 ifp->if_net = sin->sin_addr.s_net;
596 ifp->if_flags = IFF_UP;
597 ifp->if_output = enlhoutput; /* should never be used */
598 if_attach(ifp);
599}
600
601enlhoutput(ifp, m0, dst)
602 struct ifnet *ifp;
603 struct mbuf *m0;
604 struct sockaddr *dst;
605{
606COUNT(ENLHOUTPUT);
607 ifp->if_oerrors++;
608 m_freem(m0);
609 return (0);
610}
611#endif