Plan 9 from Bell Labs’s /usr/web/sources/extra/9hist/pc/ethersink.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


## diffname pc/ethersink.c 2002/0217
## diff -e /dev/null /n/emeliedump/2002/0217/sys/src/9/pc/ethersink.c
0a
/*
 * An ethernet /dev/null.
 * Useful as a bridging target with ethernet-based VPN.
 */
#include "u.h"
#include "../port/lib.h"
#include "mem.h"
#include "dat.h"
#include "fns.h"
#include "io.h"
#include "../port/error.h"
#include "../port/netif.h"
#include "etherif.h"

static long
ctl(Ether *ether, void *buf, long n)
{
	uchar ea[Eaddrlen];
	Cmdbuf *cb;

	cb = parsecmd(buf, n);
	if(cb->nf >= 2
	&& strcmp(cb->f[0], "ea")==0
	&& parseether(ea, cb->f[1]) == 0){
		free(cb);
		memmove(ether->ea, ea, Eaddrlen);
		memmove(ether->addr, ether->ea, Eaddrlen);
		return 0;
	}
	free(cb);
	error(Ebadctl);
	return -1;	/* not reached */
}

static void
nop(Ether*)
{
}

static int
reset(Ether* ether)
{
	uchar ea[Eaddrlen];

	memset(ea, 0, sizeof ea);
	ether->mbps = 1000;
	ether->attach = nop;
	ether->transmit = nop;
	ether->irq = 0;
	ether->interrupt = nil;
	ether->ifstat = nil;
	ether->ctl = ctl;
	ether->promiscuous = nil;
	ether->multicast = nil;
	ether->arg = ether;
	return 0;
}

void
ethersinklink(void)
{
	addethercard("sink", reset);
}
.
## diffname pc/ethersink.c 2002/0403
## diff -e /n/emeliedump/2002/0217/sys/src/9/pc/ethersink.c /n/emeliedump/2002/0403/sys/src/9/pc/ethersink.c
44a
	if(ether->type==nil)
		return -1;
.
## diffname pc/ethersink.c 2003/0301
## diff -e /n/emeliedump/2002/0403/sys/src/9/pc/ethersink.c /n/emeliedump/2003/0301/sys/src/9/pc/ethersink.c
51c
	ether->irq = -1;
.

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].