136395Ssklower
236395Ssklower /*
336395Ssklower * $Header: te.c,v 1.1 88/06/29 15:00:09 hagens Exp $
436395Ssklower * $Source: /usr/argo/sys/netiso/RCS/te.c,v $
536395Ssklower *
636395Ssklower * EON rfc
736395Ssklower * Layer between IP and CLNL
836395Ssklower *
936395Ssklower * TODO:
1036395Ssklower * Put together a current rfc986 address format and get the right offset
1136395Ssklower * for the nsel
1236395Ssklower */
1336395Ssklower #define RFC986_NSEL_OFFSET 5
1436395Ssklower
1536395Ssklower #ifndef lint
1636395Ssklower static char *rcsid = "$Header: te.c,v 1.1 88/06/29 15:00:09 hagens Exp $";
1736395Ssklower #endif lint
1836395Ssklower
1936395Ssklower #include "eon.h"
2036395Ssklower #if NEON>0
2136395Ssklower
2236395Ssklower #include <stdio.h>
2336395Ssklower
2436395Ssklower #include "param.h"
2536395Ssklower #include "systm.h"
2636395Ssklower #include "types.h"
2736395Ssklower #include "mbuf.h"
2836395Ssklower #include "buf.h"
2936395Ssklower #include "protosw.h"
3036395Ssklower #include "socket.h"
3136395Ssklower #include "ioctl.h"
3236395Ssklower #include "errno.h"
3336395Ssklower #include "types.h"
3436395Ssklower
35*37518Smckusick #include "machine/io.h"
3636395Ssklower #include "../machineio/ioccvar.h"
3736395Ssklower
3836395Ssklower #include "../net/if.h"
3936395Ssklower #include "../net/netisr.h"
4036395Ssklower #include "../net/route.h"
4136395Ssklower
4236395Ssklower #include "../netinet/in.h"
4336395Ssklower #include "../netinet/in_systm.h"
4436395Ssklower #include "../netinet/ip.h"
4536395Ssklower #include "../netinet/ip_var.h"
4636395Ssklower #include "../netinet/if_ether.h"
4736395Ssklower
4836395Ssklower #include "../netiso/iso.h"
4936395Ssklower #include "../netiso/argo_debug.h"
5036395Ssklower #include "../netiso/iso_errno.h"
5136395Ssklower #include "../netiso/eonvar.h"
5236395Ssklower
5336395Ssklower #define EOK 0
5436395Ssklower
5536395Ssklower #undef insque
5636395Ssklower #define insque(p,q) _insque((queue_t)q,(queue_t)p)
5736395Ssklower #define remque(q) _remque((queue_t)q)
5836395Ssklower
5936395Ssklower
6036395Ssklower struct eon_centry {
6136395Ssklower struct qhdr eonc_q_LINK;
6236395Ssklower #define eonc_nextLINK eonc_q_LINK.link
6336395Ssklower #define eonc_prevLINK eonc_q_LINK.flink
6436395Ssklower
6536395Ssklower struct qhdr eonc_q_IS;
6636395Ssklower #define eonc_nextIS eonc_q_IS.link
6736395Ssklower #define eonc_prevIS eonc_q_IS.flink
6836395Ssklower
6936395Ssklower struct qhdr eonc_q_ES;
7036395Ssklower #define eonc_nextES eonc_q_ES.link
7136395Ssklower #define eonc_prevES eonc_q_ES.flink
7236395Ssklower
7336395Ssklower struct in_addr eonc_addr;
7436395Ssklower u_short eonc_status;
7536395Ssklower };
7636395Ssklower
7736395Ssklower /* kinda like mtod() but for eon_centries */
7836395Ssklower #define qtocentry(q, off) ((struct eon_centry *) (((caddr_t)(q)) - off))
7936395Ssklower #define centrytoq(c, off) ((struct qhdr *) (((caddr_t)(c)) + off))
8036395Ssklower
8136395Ssklower struct qhdr eon_LINK_hdr = {
8236395Ssklower (struct qhdr *)0,
8336395Ssklower (struct qhdr *)0,
8436395Ssklower };
8536395Ssklower static struct qhdr eon_IS_hdr = {
8636395Ssklower (struct qhdr *)0,
8736395Ssklower (struct qhdr *)0,
8836395Ssklower };
8936395Ssklower static struct qhdr eon_ES_hdr = {
9036395Ssklower (struct qhdr *)0,
9136395Ssklower (struct qhdr *)0,
9236395Ssklower };
9336395Ssklower static struct qhdr eon_FREE_hdr = {
9436395Ssklower (struct qhdr *)0,
9536395Ssklower (struct qhdr *)0,
9636395Ssklower };
9736395Ssklower
eon_dumpcache(which)9836395Ssklower eon_dumpcache(which)
9936395Ssklower int which;
10036395Ssklower {
10136395Ssklower register int off;
10236395Ssklower register struct eon_centry *ent;
10336395Ssklower struct qhdr *hdr;
10436395Ssklower
10536395Ssklower switch (which) {
10636395Ssklower case E_FREE:
10736395Ssklower printf("FREE LIST\n");
10836395Ssklower off = _offsetof( struct eon_centry, eonc_q_LINK);
10936395Ssklower hdr = &eon_FREE_hdr;
11036395Ssklower ent = qtocentry( hdr->link,
11136395Ssklower _offsetof( struct eon_centry, eonc_q_LINK));
11236395Ssklower break;
11336395Ssklower case E_ES:
11436395Ssklower printf("ES LIST\n");
11536395Ssklower off = _offsetof( struct eon_centry, eonc_q_ES);
11636395Ssklower hdr = &eon_ES_hdr;
11736395Ssklower ent = qtocentry( hdr->link,
11836395Ssklower _offsetof( struct eon_centry, eonc_q_ES));
11936395Ssklower break;
12036395Ssklower case E_IS:
12136395Ssklower printf("IS LIST\n");
12236395Ssklower off = _offsetof( struct eon_centry, eonc_q_IS);
12336395Ssklower hdr = &eon_IS_hdr;
12436395Ssklower ent = qtocentry( hdr->link,
12536395Ssklower _offsetof( struct eon_centry, eonc_q_IS));
12636395Ssklower break;
12736395Ssklower case E_LINK:
12836395Ssklower printf("LINK LIST\n");
12936395Ssklower off = _offsetof( struct eon_centry, eonc_q_LINK);
13036395Ssklower hdr = &eon_LINK_hdr;
13136395Ssklower ent = qtocentry( hdr->link,
13236395Ssklower _offsetof( struct eon_centry, eonc_q_LINK));
13336395Ssklower break;
13436395Ssklower }
13536395Ssklower if(hdr == centrytoq(ent, off)->link )
13636395Ssklower printf("EMPTY\n");
13736395Ssklower else while(1) {
13836395Ssklower printf("0x%x: %d.%d.%d.%d, %s %s\n", ent,
13936395Ssklower (ent->eonc_addr.s_addr>>24)&0xff,
14036395Ssklower (ent->eonc_addr.s_addr>>16)&0xff,
14136395Ssklower (ent->eonc_addr.s_addr>>8)&0xff,
14236395Ssklower (ent->eonc_addr.s_addr)&0xff,
14336395Ssklower ((ent->eonc_status & EON_ESLINK_UP)?"ES^":
14436395Ssklower (ent->eonc_status & EON_ESLINK_DOWN)?"es*": " "),
14536395Ssklower ((ent->eonc_status & EON_ISLINK_UP)?"IS^":
14636395Ssklower (ent->eonc_status & EON_ISLINK_DOWN)?"is*": " ")
14736395Ssklower );
14836395Ssklower dump_buf(ent, sizeof(struct eon_centry) );
14936395Ssklower
15036395Ssklower { /* ent = ent.next: */
15136395Ssklower register struct qhdr *q;
15236395Ssklower
15336395Ssklower q = centrytoq(ent, off)->link;
15436395Ssklower if( q == hdr)
15536395Ssklower break;
15636395Ssklower if( q == (struct qhdr *)0) /* panic */ {
15736395Ssklower printf("eon0: BAD Q HDR or CENTRY! q 0x%x ent 0x%x off 0x%x\n",
15836395Ssklower q, ent, off);
15936395Ssklower break;
16036395Ssklower }
16136395Ssklower ent = qtocentry( q, off );
16236395Ssklower }
16336395Ssklower }
16436395Ssklower }
16536395Ssklower
16636395Ssklower initq(q)
16736395Ssklower struct qhdr *q;
16836395Ssklower {
16936395Ssklower q->rlink = q->link = q;
17036395Ssklower }
main()17136395Ssklower main()
17236395Ssklower {
17336395Ssklower static struct eon_centry eoncache[EON_CACHESIZE];
17436395Ssklower register int i;
17536395Ssklower register struct eon_centry *ent;
17636395Ssklower
17736395Ssklower initq( &eon_FREE_hdr );
17836395Ssklower initq( &eon_LINK_hdr );
17936395Ssklower initq( &eon_ES_hdr );
18036395Ssklower initq( &eon_IS_hdr );
18136395Ssklower
18236395Ssklower bzero( eoncache, EON_CACHESIZE*sizeof(struct eon_centry));
18336395Ssklower ent = eoncache;
18436395Ssklower
18536395Ssklower for(i=0; i< EON_CACHESIZE; i++,ent++) {
18636395Ssklower insque(&eon_FREE_hdr,
18736395Ssklower centrytoq(ent, _offsetof( struct eon_centry, eonc_q_LINK)));
18836395Ssklower }
18936395Ssklower
19036395Ssklower eon_dumpcache(E_FREE);
19136395Ssklower eon_dumpcache(E_ES);
19236395Ssklower }
19336395Ssklower #endif NEON>0
19436395Ssklower
19536395Ssklower #define MAX_COLUMNS 8
dump_buf(buf,len)19636395Ssklower dump_buf(buf, len)
19736395Ssklower char *buf;
19836395Ssklower int len;
19936395Ssklower {
20036395Ssklower int i,j;
20136395Ssklower
20236395Ssklower printf("Dump buf 0x%x len 0x%x\n", buf, len);
20336395Ssklower for (i = 0; i < len; i += MAX_COLUMNS) {
20436395Ssklower printf("+%d:\t", i);
20536395Ssklower for (j = 0; j < MAX_COLUMNS; j++) {
20636395Ssklower if (i + j < len) {
20736395Ssklower printf("%x/%d\t", buf[i+j], buf[i+j]);
20836395Ssklower } else {
20936395Ssklower printf(" ");
21036395Ssklower }
21136395Ssklower }
21236395Ssklower
21336395Ssklower for (j = 0; j < MAX_COLUMNS; j++) {
21436395Ssklower if (i + j < len) {
21536395Ssklower if (((buf[i+j]) > 31) && ((buf[i+j]) < 128))
21636395Ssklower printf("%c", buf[i+j]);
21736395Ssklower else
21836395Ssklower printf(".");
21936395Ssklower }
22036395Ssklower }
22136395Ssklower printf("\n");
22236395Ssklower }
22336395Ssklower }
22436395Ssklower
_insque(new,header)22536395Ssklower _insque(new, header)
22636395Ssklower register struct qhdr *new, *header;
22736395Ssklower {
22836395Ssklower (*new).link = (*header).link;
22936395Ssklower (*new).rlink = header;
23036395Ssklower (*(*header).link).rlink = new;
23136395Ssklower (*header).link = new;
23236395Ssklower }
233