kludge to properly restrict broadcast
[unix-history] / usr / src / sys / vax / if / if_en.c
CommitLineData
4e818526 1/* if_en.c 4.52 82/04/07 */
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 */
0658a645 61 short es_lastx; /* host last transmitted to */
f1b2fa5b
BJ
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
0658a645 179int enalldelay = 0;
3552a746 180int enlastdel = 25;
0658a645 181int enlastmask = (~0) << 5;
8a13b737 182
f1b2fa5b
BJ
183/*
184 * Start or restart output on interface.
185 * If interface is already active, then this is a retransmit
186 * after a collision, and just restuff registers and delay.
187 * If interface is not already active, get another datagram
188 * to send off of the interface queue, and map it to the interface
189 * before starting the output.
190 */
ae348eea 191enstart(dev)
11720282
BJ
192 dev_t dev;
193{
b454c3ea
BJ
194 int unit = ENUNIT(dev);
195 struct uba_device *ui = eninfo[unit];
196 register struct en_softc *es = &en_softc[unit];
8a13b737 197 register struct endevice *addr;
8a13b737
BJ
198 struct mbuf *m;
199 int dest;
ae348eea 200COUNT(ENSTART);
11720282 201
8a13b737
BJ
202 if (es->es_oactive)
203 goto restart;
f1b2fa5b
BJ
204
205 /*
206 * Not already active: dequeue another request
207 * and map it to the UNIBUS. If no more requests,
208 * just return.
209 */
210 IF_DEQUEUE(&es->es_if.if_snd, m);
8a13b737
BJ
211 if (m == 0) {
212 es->es_oactive = 0;
11720282
BJ
213 return;
214 }
a453e1b5 215 dest = mtod(m, struct en_header *)->en_dhost;
8a13b737 216 es->es_olen = if_wubaput(&es->es_ifuba, m);
f1b2fa5b
BJ
217
218 /*
219 * Ethernet cannot take back-to-back packets (no
0658a645
BJ
220 * buffering in interface. To help avoid overrunning
221 * receivers, enforce a small delay (about 1ms) in interface:
222 * * between all packets when enalldelay
223 * * whenever last packet was broadcast
224 * * whenever this packet is to same host as last packet
f1b2fa5b 225 */
0658a645 226 if (enalldelay || es->es_lastx == 0 || es->es_lastx == dest) {
8a13b737 227 es->es_delay = enlastdel;
0658a645
BJ
228 es->es_mask = enlastmask;
229 }
230 es->es_lastx = dest;
f1b2fa5b 231
8a13b737 232restart:
f1b2fa5b
BJ
233 /*
234 * Have request mapped to UNIBUS for transmission.
235 * Purge any stale data from this BDP, and start the otput.
236 */
ee787340
SL
237 if (es->es_ifuba.ifu_flags & UBA_NEEDBDP)
238 UBAPURGE(es->es_ifuba.ifu_uba, es->es_ifuba.ifu_w.ifrw_bdp);
11720282 239 addr = (struct endevice *)ui->ui_addr;
405c9168 240 addr->en_oba = (int)es->es_ifuba.ifu_w.ifrw_info;
8a13b737
BJ
241 addr->en_odelay = es->es_delay;
242 addr->en_owc = -((es->es_olen + 1) >> 1);
941ee7ef 243 addr->en_ostat = EN_IEN|EN_GO;
8a13b737 244 es->es_oactive = 1;
11720282
BJ
245}
246
f1b2fa5b
BJ
247/*
248 * Ethernet interface transmitter interrupt.
249 * Start another output if more data to send.
250 */
11720282
BJ
251enxint(unit)
252 int unit;
253{
b454c3ea
BJ
254 register struct uba_device *ui = eninfo[unit];
255 register struct en_softc *es = &en_softc[unit];
519a1ecf 256 register struct endevice *addr = (struct endevice *)ui->ui_addr;
11720282
BJ
257COUNT(ENXINT);
258
8a13b737
BJ
259 if (es->es_oactive == 0)
260 return;
519a1ecf 261 if (es->es_mask && (addr->en_ostat&EN_OERROR)) {
89413846 262 es->es_if.if_oerrors++;
4020bf24
BJ
263 if (es->es_if.if_oerrors % 100 == 0)
264 printf("en%d: += 100 output errors\n", unit);
519a1ecf
BJ
265 endocoll(unit);
266 return;
89413846 267 }
519a1ecf
BJ
268 es->es_if.if_opackets++;
269 es->es_oactive = 0;
270 es->es_delay = 0;
271 es->es_mask = ~0;
7a66118b
BJ
272 if (es->es_ifuba.ifu_xtofree) {
273 m_freem(es->es_ifuba.ifu_xtofree);
274 es->es_ifuba.ifu_xtofree = 0;
275 }
f1b2fa5b 276 if (es->es_if.if_snd.ifq_head == 0) {
0658a645 277 es->es_lastx = 256; /* putatively illegal */
11720282
BJ
278 return;
279 }
8a13b737 280 enstart(unit);
11720282
BJ
281}
282
f1b2fa5b
BJ
283/*
284 * Collision on ethernet interface. Do exponential
285 * backoff, and retransmit. If have backed off all
ee787340 286 * the way print warning diagnostic, and drop packet.
f1b2fa5b 287 */
11720282
BJ
288encollide(unit)
289 int unit;
290{
519a1ecf 291 struct en_softc *es = &en_softc[unit];
11720282
BJ
292COUNT(ENCOLLIDE);
293
f1b2fa5b 294 es->es_if.if_collisions++;
8a13b737 295 if (es->es_oactive == 0)
11720282 296 return;
519a1ecf
BJ
297 endocoll(unit);
298}
299
300endocoll(unit)
301 int unit;
302{
303 register struct en_softc *es = &en_softc[unit];
304
b454c3ea
BJ
305 /*
306 * Es_mask is a 16 bit number with n low zero bits, with
307 * n the number of backoffs. When es_mask is 0 we have
308 * backed off 16 times, and give up.
309 */
8a13b737 310 if (es->es_mask == 0) {
a453e1b5 311 printf("en%d: send error\n", unit);
8a13b737 312 enxint(unit);
b454c3ea 313 return;
11720282 314 }
b454c3ea
BJ
315 /*
316 * Another backoff. Restart with delay based on n low bits
317 * of the interval timer.
318 */
319 es->es_mask <<= 1;
320 es->es_delay = mfpr(ICR) &~ es->es_mask;
321 enstart(unit);
11720282
BJ
322}
323
31c2345c
SL
324struct sockaddr_pup pupsrc = { AF_PUP };
325struct sockaddr_pup pupdst = { AF_PUP };
326struct sockproto pupproto = { PF_PUP };
f1b2fa5b
BJ
327/*
328 * Ethernet interface receiver interrupt.
329 * If input error just drop packet.
330 * Otherwise purge input buffered data path and examine
331 * packet to determine type. If can't determine length
332 * from type, then have to drop packet. Othewise decapsulate
333 * packet based on type and pass to type specific higher-level
334 * input routine.
335 */
11720282
BJ
336enrint(unit)
337 int unit;
338{
b454c3ea
BJ
339 register struct en_softc *es = &en_softc[unit];
340 struct endevice *addr = (struct endevice *)eninfo[unit]->ui_addr;
341 register struct en_header *en;
8a13b737 342 struct mbuf *m;
0658a645 343 int len, plen; short resid;
b454c3ea 344 register struct ifqueue *inq;
8a13b737 345 int off;
11720282
BJ
346COUNT(ENRINT);
347
b454c3ea 348 es->es_if.if_ipackets++;
f1b2fa5b
BJ
349
350 /*
b454c3ea 351 * Purge BDP; drop if input error indicated.
f1b2fa5b 352 */
ee787340
SL
353 if (es->es_ifuba.ifu_flags & UBA_NEEDBDP)
354 UBAPURGE(es->es_ifuba.ifu_uba, es->es_ifuba.ifu_r.ifrw_bdp);
941ee7ef 355 if (addr->en_istat&EN_IERROR) {
f1b2fa5b 356 es->es_if.if_ierrors++;
4020bf24
BJ
357 if (es->es_if.if_ierrors % 100 == 0)
358 printf("en%d: += 100 input errors\n", unit);
8a13b737 359 goto setup;
11720282 360 }
f1b2fa5b
BJ
361
362 /*
0658a645 363 * Calculate input data length.
f1b2fa5b
BJ
364 * Get pointer to ethernet header (in input buffer).
365 * Deal with trailer protocol: if type is PUP trailer
366 * get true type from first 16-bit word past data.
367 * Remember that type was trailer by setting off.
368 */
0658a645
BJ
369 resid = addr->en_iwc;
370 if (resid)
371 resid |= 0176000;
372 len = (((sizeof (struct en_header) + ENMTU) >> 1) + resid) << 1;
373 len -= sizeof (struct en_header);
374 if (len >= ENMTU)
375 goto setup; /* sanity */
f1b2fa5b 376 en = (struct en_header *)(es->es_ifuba.ifu_r.ifrw_addr);
8a13b737
BJ
377#define endataaddr(en, off, type) ((type)(((caddr_t)((en)+1)+(off))))
378 if (en->en_type >= ENPUP_TRAIL &&
379 en->en_type < ENPUP_TRAIL+ENPUP_NTRAILER) {
380 off = (en->en_type - ENPUP_TRAIL) * 512;
b454c3ea
BJ
381 if (off >= ENMTU)
382 goto setup; /* sanity */
8a13b737 383 en->en_type = *endataaddr(en, off, u_short *);
0658a645
BJ
384 resid = *(endataaddr(en, off+2, u_short *));
385 if (off + resid > len)
386 goto setup; /* sanity */
387 len = off + resid;
8a13b737
BJ
388 } else
389 off = 0;
8a13b737
BJ
390 if (len == 0)
391 goto setup;
f1b2fa5b
BJ
392 /*
393 * Pull packet off interface. Off is nonzero if packet
394 * has trailing header; if_rubaget will then force this header
395 * information to be at the front, but we still have to drop
0658a645 396 * the type and length which are at the front of any trailer data.
f1b2fa5b
BJ
397 */
398 m = if_rubaget(&es->es_ifuba, len, off);
a453e1b5
BJ
399 if (m == 0)
400 goto setup;
f1b2fa5b 401 if (off) {
0658a645
BJ
402 m->m_off += 2 * sizeof (u_short);
403 m->m_len -= 2 * sizeof (u_short);
f1b2fa5b 404 }
31c2345c
SL
405 switch (en->en_type) {
406
407#ifdef INET
408 case ENPUP_IPTYPE:
9c8692e9 409 schednetisr(NETISR_IP);
31c2345c
SL
410 inq = &ipintrq;
411 break;
412#endif
ee787340 413#ifdef PUP
31c2345c
SL
414 case ENPUP_PUPTYPE: {
415 struct pup_header *pup = mtod(m, struct pup_header *);
416
417 pupproto.sp_protocol = pup->pup_type;
418 pupdst.spup_addr = pup->pup_dport;
419 pupsrc.spup_addr = pup->pup_sport;
668cc26d 420 raw_input(m, &pupproto, (struct sockaddr *)&pupdst,
ee787340 421 (struct sockaddr *)&pupsrc);
31c2345c 422 goto setup;
31c2345c 423 }
ee787340 424#endif
c8f8184f
BJ
425 default:
426 m_freem(m);
427 goto setup;
ee787340
SL
428 }
429
1e977657
BJ
430 if (IF_QFULL(inq)) {
431 IF_DROP(inq);
ee787340 432 m_freem(m);
1e977657
BJ
433 } else
434 IF_ENQUEUE(inq, m);
f1b2fa5b 435
ae348eea 436setup:
f1b2fa5b
BJ
437 /*
438 * Reset for next packet.
439 */
440 addr->en_iba = es->es_ifuba.ifu_r.ifrw_info;
8a13b737 441 addr->en_iwc = -(sizeof (struct en_header) + ENMTU) >> 1;
941ee7ef 442 addr->en_istat = EN_IEN|EN_GO;
ae348eea 443}
11720282 444
8a13b737
BJ
445/*
446 * Ethernet output routine.
447 * Encapsulate a packet of type family for the local net.
f1b2fa5b
BJ
448 * Use trailer local net encapsulation if enough data in first
449 * packet leaves a multiple of 512 bytes of data in remainder.
8a13b737 450 */
ee787340 451enoutput(ifp, m0, dst)
8a13b737
BJ
452 struct ifnet *ifp;
453 struct mbuf *m0;
ee787340 454 struct sockaddr *dst;
11720282 455{
ee787340 456 int type, dest, s;
f1b2fa5b 457 register struct mbuf *m = m0;
8a13b737 458 register struct en_header *en;
ee787340 459 register int off;
8a13b737 460
9d1b03e0 461COUNT(ENOUTPUT);
ee787340 462 switch (dst->sa_family) {
11720282 463
8a13b737 464#ifdef INET
ee787340 465 case AF_INET:
4e818526
BJ
466 dest = ((struct sockaddr_in *)dst)->sin_addr.s_addr;
467 if (dest & 0x00ffff00)
468 goto drop;
469 dest = (dest >> 24) & 0xff;
ee787340
SL
470 off = ntohs((u_short)mtod(m, struct ip *)->ip_len) - m->m_len;
471 if (off > 0 && (off & 0x1ff) == 0 &&
0658a645 472 m->m_off >= MMINOFF + 2 * sizeof (u_short)) {
8a13b737 473 type = ENPUP_TRAIL + (off>>9);
0658a645
BJ
474 m->m_off -= 2 * sizeof (u_short);
475 m->m_len += 2 * sizeof (u_short);
f1b2fa5b 476 *mtod(m, u_short *) = ENPUP_IPTYPE;
0658a645 477 *(mtod(m, u_short *) + 1) = m->m_len;
f1b2fa5b 478 goto gottrailertype;
8a13b737 479 }
f1b2fa5b
BJ
480 type = ENPUP_IPTYPE;
481 off = 0;
482 goto gottype;
8a13b737 483#endif
31c2345c 484#ifdef PUP
ee787340
SL
485 case AF_PUP:
486 dest = ((struct sockaddr_pup *)dst)->spup_addr.pp_host;
31c2345c
SL
487 type = ENPUP_PUPTYPE;
488 off = 0;
489 goto gottype;
31c2345c 490#endif
8a13b737
BJ
491
492 default:
ee787340
SL
493 printf("en%d: can't handle af%d\n", ifp->if_unit,
494 dst->sa_family);
8a13b737
BJ
495 m_freem(m0);
496 return (0);
497 }
f1b2fa5b 498
b454c3ea 499gottrailertype:
f1b2fa5b
BJ
500 /*
501 * Packet to be sent as trailer: move first packet
502 * (control information) to end of chain.
503 */
f1b2fa5b
BJ
504 while (m->m_next)
505 m = m->m_next;
506 m->m_next = m0;
507 m = m0->m_next;
508 m0->m_next = 0;
b454c3ea 509 m0 = m;
f1b2fa5b 510
b454c3ea 511gottype:
f1b2fa5b
BJ
512 /*
513 * Add local net header. If no space in first mbuf,
514 * allocate another.
515 */
a453e1b5
BJ
516 if (m->m_off > MMAXOFF ||
517 MMINOFF + sizeof (struct en_header) > m->m_off) {
ef9b4258 518 m = m_get(M_DONTWAIT);
8a13b737
BJ
519 if (m == 0) {
520 m_freem(m0);
521 return (0);
522 }
523 m->m_next = m0;
524 m->m_off = MMINOFF;
525 m->m_len = sizeof (struct en_header);
526 } else {
8a13b737
BJ
527 m->m_off -= sizeof (struct en_header);
528 m->m_len += sizeof (struct en_header);
11720282 529 }
8a13b737
BJ
530 en = mtod(m, struct en_header *);
531 en->en_shost = ifp->if_host[0];
532 en->en_dhost = dest;
533 en->en_type = type;
f1b2fa5b
BJ
534
535 /*
536 * Queue message on interface, and start output if interface
537 * not yet active.
538 */
8a13b737 539 s = splimp();
1e977657
BJ
540 if (IF_QFULL(&ifp->if_snd)) {
541 IF_DROP(&ifp->if_snd);
4e818526 542 goto bad;
1e977657 543 }
8a13b737 544 IF_ENQUEUE(&ifp->if_snd, m);
8a13b737
BJ
545 if (en_softc[ifp->if_unit].es_oactive == 0)
546 enstart(ifp->if_unit);
89413846 547 splx(s);
f1b2fa5b 548 return (1);
4e818526
BJ
549bad:
550 m_freem(m);
551 splx(s);
552 return (0);
11720282 553}
a9f3e174
SL
554
555#if NIMP == 0 && NEN > 0
556/*
557 * Logical host interface driver.
558 * Allows host to appear as an ARPAnet
559 * logical host. Must also have routing
560 * table entry set up to forward packets
561 * to appropriate gateway on localnet.
562 */
563
564struct ifnet enlhif;
565int enlhoutput();
566
567/*
568 * Called by localnet interface to allow logical
569 * host interface to "attach". Nothing should ever
570 * be sent locally to this interface, it's purpose
571 * is simply to establish the host's arpanet address.
572 */
573enlhinit(addr)
574 int addr;
575{
576 register struct ifnet *ifp = &enlhif;
577 register struct sockaddr_in *sin;
578
579COUNT(ENLHINIT);
580 ifp->if_name = "lh";
581 ifp->if_mtu = ENMTU;
582 sin = (struct sockaddr_in *)&ifp->if_addr;
583 sin->sin_family = AF_INET;
584 sin->sin_addr.s_addr = addr;
585 ifp->if_net = sin->sin_addr.s_net;
586 ifp->if_flags = IFF_UP;
587 ifp->if_output = enlhoutput; /* should never be used */
588 if_attach(ifp);
589}
590
591enlhoutput(ifp, m0, dst)
592 struct ifnet *ifp;
593 struct mbuf *m0;
594 struct sockaddr *dst;
595{
596COUNT(ENLHOUTPUT);
597 ifp->if_oerrors++;
598 m_freem(m0);
599 return (0);
600}
601#endif