changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: devip: remove unused eipconvtet.c and ptclbsum.c files

changeset 7035: 65dab5125d9d
parent 7034: fe9f017a9d36
child 7036: 7bb53313aac9
author: cinap_lenrek@felloff.net
date: Wed, 13 Feb 2019 17:42:20 +0100
files: sys/src/9/ip/eipconvtest.c sys/src/9/ip/ptclbsum.c
description: devip: remove unused eipconvtet.c and ptclbsum.c files
     1.1deleted file mode 100644
     1.2--- a/sys/src/9/ip/eipconvtest.c
     1.3+++ /dev/null
     1.4@@ -1,152 +0,0 @@
     1.5-#include <u.h>
     1.6-#include <libc.h>
     1.7-
     1.8-enum
     1.9-{
    1.10-	Isprefix= 16,
    1.11-};
    1.12-
    1.13-uchar prefixvals[256] =
    1.14-{
    1.15-[0x00] 0 | Isprefix,
    1.16-[0x80] 1 | Isprefix,
    1.17-[0xC0] 2 | Isprefix,
    1.18-[0xE0] 3 | Isprefix,
    1.19-[0xF0] 4 | Isprefix,
    1.20-[0xF8] 5 | Isprefix,
    1.21-[0xFC] 6 | Isprefix,
    1.22-[0xFE] 7 | Isprefix,
    1.23-[0xFF] 8 | Isprefix,
    1.24-};
    1.25-
    1.26-uchar v4prefix[16] = {
    1.27-	0, 0, 0, 0,
    1.28-	0, 0, 0, 0,
    1.29-	0, 0, 0xff, 0xff,
    1.30-	0, 0, 0, 0
    1.31-};
    1.32-
    1.33-void
    1.34-hnputl(void *p, ulong v)
    1.35-{
    1.36-	uchar *a;
    1.37-
    1.38-	a = p;
    1.39-	a[0] = v>>24;
    1.40-	a[1] = v>>16;
    1.41-	a[2] = v>>8;
    1.42-	a[3] = v;
    1.43-}
    1.44-
    1.45-int
    1.46-eipconv(va_list *arg, Fconv *f)
    1.47-{
    1.48-	char buf[8*5];
    1.49-	static char *efmt = "%.2lux%.2lux%.2lux%.2lux%.2lux%.2lux";
    1.50-	static char *ifmt = "%d.%d.%d.%d";
    1.51-	uchar *p, ip[16];
    1.52-	ulong *lp;
    1.53-	ushort s;
    1.54-	int i, j, n, eln, eli;
    1.55-
    1.56-	switch(f->chr) {
    1.57-	case 'E':		/* Ethernet address */
    1.58-		p = va_arg(*arg, uchar*);
    1.59-		sprint(buf, efmt, p[0], p[1], p[2], p[3], p[4], p[5]);
    1.60-		break;
    1.61-	case 'I':		/* Ip address */
    1.62-		p = va_arg(*arg, uchar*);
    1.63-common:
    1.64-		if(memcmp(p, v4prefix, 12) == 0)
    1.65-			sprint(buf, ifmt, p[12], p[13], p[14], p[15]);
    1.66-		else {
    1.67-			/* find longest elision */
    1.68-			eln = eli = -1;
    1.69-			for(i = 0; i < 16; i += 2){
    1.70-				for(j = i; j < 16; j += 2)
    1.71-					if(p[j] != 0 || p[j+1] != 0)
    1.72-						break;
    1.73-				if(j > i && j - i > eln){
    1.74-					eli = i;
    1.75-					eln = j - i;
    1.76-				}
    1.77-			}
    1.78-
    1.79-			/* print with possible elision */
    1.80-			n = 0;
    1.81-			for(i = 0; i < 16; i += 2){
    1.82-				if(i == eli){
    1.83-					n += sprint(buf+n, "::");
    1.84-					i += eln;
    1.85-					if(i >= 16)
    1.86-						break;
    1.87-				} else if(i != 0)
    1.88-					n += sprint(buf+n, ":");
    1.89-				s = (p[i]<<8) + p[i+1];
    1.90-				n += sprint(buf+n, "%ux", s);
    1.91-			}
    1.92-		}
    1.93-		break;
    1.94-	case 'i':		/* v6 address as 4 longs */
    1.95-		lp = va_arg(*arg, ulong*);
    1.96-		for(i = 0; i < 4; i++)
    1.97-			hnputl(ip+4*i, *lp++);
    1.98-		p = ip;
    1.99-		goto common;
   1.100-	case 'V':		/* v4 ip address */
   1.101-		p = va_arg(*arg, uchar*);
   1.102-		sprint(buf, ifmt, p[0], p[1], p[2], p[3]);
   1.103-		break;
   1.104-	case 'M':		/* ip mask */
   1.105-		p = va_arg(*arg, uchar*);
   1.106-
   1.107-		/* look for a prefix mask */
   1.108-		for(i = 0; i < 16; i++)
   1.109-			if(p[i] != 0xff)
   1.110-				break;
   1.111-		if(i < 16){
   1.112-			if((prefixvals[p[i]] & Isprefix) == 0)
   1.113-				goto common;
   1.114-			for(j = i+1; j < 16; j++)
   1.115-				if(p[j] != 0)
   1.116-					goto common;
   1.117-			n = 8*i + (prefixvals[p[i]] & ~Isprefix);
   1.118-		} else
   1.119-			n = 8*16;
   1.120-
   1.121-		/* got one, use /xx format */
   1.122-		sprint(buf, "/%d", n);
   1.123-		break;
   1.124-	default:
   1.125-		strcpy(buf, "(eipconv)");
   1.126-	}
   1.127-	strconv(buf, f);
   1.128-	return sizeof(uchar*);
   1.129-}
   1.130-
   1.131-uchar testvec[11][16] =
   1.132-{
   1.133- { 0,0,0,0, 0,0,0,0, 0,0,0xff,0xff, 1,3,4,5, },
   1.134- { 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, },
   1.135- { 0xff,0xff,0x80,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, },
   1.136- { 0xff,0xff,0xff,0xc0, 0,0,0,0, 0,0,0,0, 0,0,0,0, },
   1.137- { 0xff,0xff,0xff,0xff, 0xe0,0,0,0, 0,0,0,0, 0,0,0,0, },
   1.138- { 0xff,0xff,0xff,0xff, 0xff,0xf0,0,0, 0,0,0,0, 0,0,0,0, },
   1.139- { 0xff,0xff,0xff,0xff, 0xff,0xff,0xf8,0, 0,0,0,0, 0,0,0,0, },
   1.140- { 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff, },
   1.141- { 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0, },
   1.142- { 0,0,0,0, 0,0x11,0,0, 0,0,0,0, 0,0,0,0, },
   1.143- { 0,0,0,0x11, 0,0,0,0, 0,0,0,0, 0,0,0,0x12, },
   1.144-};
   1.145-
   1.146-void
   1.147-main(void)
   1.148-{
   1.149-	int i;
   1.150-
   1.151-	fmtinstall('I', eipconv);
   1.152-	fmtinstall('M', eipconv);
   1.153-	for(i = 0; i < 11; i++)
   1.154-		print("%I\n%M\n", testvec[i], testvec[i]);
   1.155-	exits(0);
   1.156-}
     2.1deleted file mode 100644
     2.2--- a/sys/src/9/ip/ptclbsum.c
     2.3+++ /dev/null
     2.4@@ -1,72 +0,0 @@
     2.5-#include	"u.h"
     2.6-#include	"../port/lib.h"
     2.7-#include	"mem.h"
     2.8-#include	"dat.h"
     2.9-#include	"fns.h"
    2.10-#include	"../port/error.h"
    2.11-#include	"ip.h"
    2.12-
    2.13-static	short	endian	= 1;
    2.14-static	uchar*	aendian	= (uchar*)&endian;
    2.15-#define	LITTLE	*aendian
    2.16-
    2.17-ushort
    2.18-ptclbsum(uchar *addr, int len)
    2.19-{
    2.20-	ulong losum, hisum, mdsum, x;
    2.21-	ulong t1, t2;
    2.22-
    2.23-	losum = 0;
    2.24-	hisum = 0;
    2.25-	mdsum = 0;
    2.26-
    2.27-	x = 0;
    2.28-	if((ulong)addr & 1) {
    2.29-		if(len) {
    2.30-			hisum += addr[0];
    2.31-			len--;
    2.32-			addr++;
    2.33-		}
    2.34-		x = 1;
    2.35-	}
    2.36-	while(len >= 16) {
    2.37-		t1 = *(ushort*)(addr+0);
    2.38-		t2 = *(ushort*)(addr+2);	mdsum += t1;
    2.39-		t1 = *(ushort*)(addr+4);	mdsum += t2;
    2.40-		t2 = *(ushort*)(addr+6);	mdsum += t1;
    2.41-		t1 = *(ushort*)(addr+8);	mdsum += t2;
    2.42-		t2 = *(ushort*)(addr+10);	mdsum += t1;
    2.43-		t1 = *(ushort*)(addr+12);	mdsum += t2;
    2.44-		t2 = *(ushort*)(addr+14);	mdsum += t1;
    2.45-		mdsum += t2;
    2.46-		len -= 16;
    2.47-		addr += 16;
    2.48-	}
    2.49-	while(len >= 2) {
    2.50-		mdsum += *(ushort*)addr;
    2.51-		len -= 2;
    2.52-		addr += 2;
    2.53-	}
    2.54-	if(x) {
    2.55-		if(len)
    2.56-			losum += addr[0];
    2.57-		if(LITTLE)
    2.58-			losum += mdsum;
    2.59-		else
    2.60-			hisum += mdsum;
    2.61-	} else {
    2.62-		if(len)
    2.63-			hisum += addr[0];
    2.64-		if(LITTLE)
    2.65-			hisum += mdsum;
    2.66-		else
    2.67-			losum += mdsum;
    2.68-	}
    2.69-
    2.70-	losum += hisum >> 8;
    2.71-	losum += (hisum & 0xff) << 8;
    2.72-	while(hisum = losum>>16)
    2.73-		losum = hisum + (losum & 0xffff);
    2.74-
    2.75-	return losum & 0xffff;
    2.76-}