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