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