|
|
1.1 root 1: /* test.c - main */
2:
3: #include "../h/conf.h"
4: #include "../h/kernel.h"
5: #include "../h/deqna.h"
6: #include "../h/ether.h"
7:
8: /*------------------------------------------------------------------------
9: * main -- test ethernet by reading packets
10: *------------------------------------------------------------------------
11: */
12: main()
13: {
14: char buff[1600];
15: int i, len;
16: char *p, ch;
17: struct epacket *epkptr;
18:
19: /* call buffer pool stuff so 'freebuf' can be mentioned */
20: /* without generating a load-time error */
21: mkpool(10,10);
22:
23: kprintf("Read from Ethernet\n");
24: epkptr = (struct epacket *)buff;
25: while (1) {
26: if ( (len=read(ETHER, buff, 1500)) == SYSERR) {
27: kprintf("\nError\n");
28: } else if (epkptr->ep_hdr.e_ptype == EP_ARP) {
29: /* do ARP */ kprintf("ARP...\n");
30: } else {
31: p = (char *)buff;
32: kprintf("\n LEN: %d\n TO: ",len);
33: for (i=0 ; i<6 ; i++)
34: kprintf("%03o ", 0377& *p++);
35: kprintf("\nFROM: ");
36: for (i=0 ; i<6 ; i++)
37: kprintf("%03o ", 0377& *p++);
38: kprintf("\nTYPE: ");
39: kprintf("%03o ", 0377 & *p++);
40: kprintf("%03o ", 0377 & *p++);
41: kprintf("\nDATA: ");
42: for (i=0 ; i<60 ; i++)
43: if ( printable(ch = *p++) )
44: kprintf("%c",ch);
45: kprintf("\n");
46: }
47: }
48: }
49:
50: /*------------------------------------------------------------------------
51: * printable - return TRUE iff characher is printable
52: *------------------------------------------------------------------------
53: */
54: printable(ch)
55: char ch;
56: {
57: return( (ch >= ' ') && (ch <= '~') );
58: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.