1*49345Ssklower
2*49345Ssklower /*
3*49345Ssklower * $Header: te.c,v 1.1 88/06/29 15:00:09 hagens Exp $
4*49345Ssklower * $Source: /usr/argo/sys/netiso/RCS/te.c,v $
5*49345Ssklower *
6*49345Ssklower * EON rfc
7*49345Ssklower * Layer between IP and CLNL
8*49345Ssklower *
9*49345Ssklower * TODO:
10*49345Ssklower * Put together a current rfc986 address format and get the right offset
11*49345Ssklower * for the nsel
12*49345Ssklower */
13*49345Ssklower #define RFC986_NSEL_OFFSET 5
14*49345Ssklower
15*49345Ssklower #ifndef lint
16*49345Ssklower static char *rcsid = "$Header: te.c,v 1.1 88/06/29 15:00:09 hagens Exp $";
17*49345Ssklower #endif lint
18*49345Ssklower
19*49345Ssklower #include "eon.h"
20*49345Ssklower #if NEON>0
21*49345Ssklower
22*49345Ssklower #include <stdio.h>
23*49345Ssklower
24*49345Ssklower #include "param.h"
25*49345Ssklower #include "systm.h"
26*49345Ssklower #include "types.h"
27*49345Ssklower #include "mbuf.h"
28*49345Ssklower #include "buf.h"
29*49345Ssklower #include "protosw.h"
30*49345Ssklower #include "socket.h"
31*49345Ssklower #include "ioctl.h"
32*49345Ssklower #include "errno.h"
33*49345Ssklower #include "types.h"
34*49345Ssklower
35*49345Ssklower #include "machine/io.h"
36*49345Ssklower #include "../machineio/ioccvar.h"
37*49345Ssklower
38*49345Ssklower #include "../net/if.h"
39*49345Ssklower #include "../net/netisr.h"
40*49345Ssklower #include "../net/route.h"
41*49345Ssklower
42*49345Ssklower #include "../netinet/in.h"
43*49345Ssklower #include "../netinet/in_systm.h"
44*49345Ssklower #include "../netinet/ip.h"
45*49345Ssklower #include "../netinet/ip_var.h"
46*49345Ssklower #include "../netinet/if_ether.h"
47*49345Ssklower
48*49345Ssklower #include "../netiso/iso.h"
49*49345Ssklower #include "../netiso/argo_debug.h"
50*49345Ssklower #include "../netiso/iso_errno.h"
51*49345Ssklower #include "../netiso/eonvar.h"
52*49345Ssklower
53*49345Ssklower #define EOK 0
54*49345Ssklower
55*49345Ssklower #undef insque
56*49345Ssklower #define insque(p,q) _insque((queue_t)q,(queue_t)p)
57*49345Ssklower #define remque(q) _remque((queue_t)q)
58*49345Ssklower
59*49345Ssklower
60*49345Ssklower struct eon_centry {
61*49345Ssklower struct qhdr eonc_q_LINK;
62*49345Ssklower #define eonc_nextLINK eonc_q_LINK.link
63*49345Ssklower #define eonc_prevLINK eonc_q_LINK.flink
64*49345Ssklower
65*49345Ssklower struct qhdr eonc_q_IS;
66*49345Ssklower #define eonc_nextIS eonc_q_IS.link
67*49345Ssklower #define eonc_prevIS eonc_q_IS.flink
68*49345Ssklower
69*49345Ssklower struct qhdr eonc_q_ES;
70*49345Ssklower #define eonc_nextES eonc_q_ES.link
71*49345Ssklower #define eonc_prevES eonc_q_ES.flink
72*49345Ssklower
73*49345Ssklower struct in_addr eonc_addr;
74*49345Ssklower u_short eonc_status;
75*49345Ssklower };
76*49345Ssklower
77*49345Ssklower /* kinda like mtod() but for eon_centries */
78*49345Ssklower #define qtocentry(q, off) ((struct eon_centry *) (((caddr_t)(q)) - off))
79*49345Ssklower #define centrytoq(c, off) ((struct qhdr *) (((caddr_t)(c)) + off))
80*49345Ssklower
81*49345Ssklower struct qhdr eon_LINK_hdr = {
82*49345Ssklower (struct qhdr *)0,
83*49345Ssklower (struct qhdr *)0,
84*49345Ssklower };
85*49345Ssklower static struct qhdr eon_IS_hdr = {
86*49345Ssklower (struct qhdr *)0,
87*49345Ssklower (struct qhdr *)0,
88*49345Ssklower };
89*49345Ssklower static struct qhdr eon_ES_hdr = {
90*49345Ssklower (struct qhdr *)0,
91*49345Ssklower (struct qhdr *)0,
92*49345Ssklower };
93*49345Ssklower static struct qhdr eon_FREE_hdr = {
94*49345Ssklower (struct qhdr *)0,
95*49345Ssklower (struct qhdr *)0,
96*49345Ssklower };
97*49345Ssklower
eon_dumpcache(which)98*49345Ssklower eon_dumpcache(which)
99*49345Ssklower int which;
100*49345Ssklower {
101*49345Ssklower register int off;
102*49345Ssklower register struct eon_centry *ent;
103*49345Ssklower struct qhdr *hdr;
104*49345Ssklower
105*49345Ssklower switch (which) {
106*49345Ssklower case E_FREE:
107*49345Ssklower printf("FREE LIST\n");
108*49345Ssklower off = _offsetof( struct eon_centry, eonc_q_LINK);
109*49345Ssklower hdr = &eon_FREE_hdr;
110*49345Ssklower ent = qtocentry( hdr->link,
111*49345Ssklower _offsetof( struct eon_centry, eonc_q_LINK));
112*49345Ssklower break;
113*49345Ssklower case E_ES:
114*49345Ssklower printf("ES LIST\n");
115*49345Ssklower off = _offsetof( struct eon_centry, eonc_q_ES);
116*49345Ssklower hdr = &eon_ES_hdr;
117*49345Ssklower ent = qtocentry( hdr->link,
118*49345Ssklower _offsetof( struct eon_centry, eonc_q_ES));
119*49345Ssklower break;
120*49345Ssklower case E_IS:
121*49345Ssklower printf("IS LIST\n");
122*49345Ssklower off = _offsetof( struct eon_centry, eonc_q_IS);
123*49345Ssklower hdr = &eon_IS_hdr;
124*49345Ssklower ent = qtocentry( hdr->link,
125*49345Ssklower _offsetof( struct eon_centry, eonc_q_IS));
126*49345Ssklower break;
127*49345Ssklower case E_LINK:
128*49345Ssklower printf("LINK LIST\n");
129*49345Ssklower off = _offsetof( struct eon_centry, eonc_q_LINK);
130*49345Ssklower hdr = &eon_LINK_hdr;
131*49345Ssklower ent = qtocentry( hdr->link,
132*49345Ssklower _offsetof( struct eon_centry, eonc_q_LINK));
133*49345Ssklower break;
134*49345Ssklower }
135*49345Ssklower if(hdr == centrytoq(ent, off)->link )
136*49345Ssklower printf("EMPTY\n");
137*49345Ssklower else while(1) {
138*49345Ssklower printf("0x%x: %d.%d.%d.%d, %s %s\n", ent,
139*49345Ssklower (ent->eonc_addr.s_addr>>24)&0xff,
140*49345Ssklower (ent->eonc_addr.s_addr>>16)&0xff,
141*49345Ssklower (ent->eonc_addr.s_addr>>8)&0xff,
142*49345Ssklower (ent->eonc_addr.s_addr)&0xff,
143*49345Ssklower ((ent->eonc_status & EON_ESLINK_UP)?"ES^":
144*49345Ssklower (ent->eonc_status & EON_ESLINK_DOWN)?"es*": " "),
145*49345Ssklower ((ent->eonc_status & EON_ISLINK_UP)?"IS^":
146*49345Ssklower (ent->eonc_status & EON_ISLINK_DOWN)?"is*": " ")
147*49345Ssklower );
148*49345Ssklower dump_buf(ent, sizeof(struct eon_centry) );
149*49345Ssklower
150*49345Ssklower { /* ent = ent.next: */
151*49345Ssklower register struct qhdr *q;
152*49345Ssklower
153*49345Ssklower q = centrytoq(ent, off)->link;
154*49345Ssklower if( q == hdr)
155*49345Ssklower break;
156*49345Ssklower if( q == (struct qhdr *)0) /* panic */ {
157*49345Ssklower printf("eon0: BAD Q HDR or CENTRY! q 0x%x ent 0x%x off 0x%x\n",
158*49345Ssklower q, ent, off);
159*49345Ssklower break;
160*49345Ssklower }
161*49345Ssklower ent = qtocentry( q, off );
162*49345Ssklower }
163*49345Ssklower }
164*49345Ssklower }
165*49345Ssklower
166*49345Ssklower initq(q)
167*49345Ssklower struct qhdr *q;
168*49345Ssklower {
169*49345Ssklower q->rlink = q->link = q;
170*49345Ssklower }
main()171*49345Ssklower main()
172*49345Ssklower {
173*49345Ssklower static struct eon_centry eoncache[EON_CACHESIZE];
174*49345Ssklower register int i;
175*49345Ssklower register struct eon_centry *ent;
176*49345Ssklower
177*49345Ssklower initq( &eon_FREE_hdr );
178*49345Ssklower initq( &eon_LINK_hdr );
179*49345Ssklower initq( &eon_ES_hdr );
180*49345Ssklower initq( &eon_IS_hdr );
181*49345Ssklower
182*49345Ssklower bzero( eoncache, EON_CACHESIZE*sizeof(struct eon_centry));
183*49345Ssklower ent = eoncache;
184*49345Ssklower
185*49345Ssklower for(i=0; i< EON_CACHESIZE; i++,ent++) {
186*49345Ssklower insque(&eon_FREE_hdr,
187*49345Ssklower centrytoq(ent, _offsetof( struct eon_centry, eonc_q_LINK)));
188*49345Ssklower }
189*49345Ssklower
190*49345Ssklower eon_dumpcache(E_FREE);
191*49345Ssklower eon_dumpcache(E_ES);
192*49345Ssklower }
193*49345Ssklower #endif NEON>0
194*49345Ssklower
195*49345Ssklower #define MAX_COLUMNS 8
dump_buf(buf,len)196*49345Ssklower dump_buf(buf, len)
197*49345Ssklower char *buf;
198*49345Ssklower int len;
199*49345Ssklower {
200*49345Ssklower int i,j;
201*49345Ssklower
202*49345Ssklower printf("Dump buf 0x%x len 0x%x\n", buf, len);
203*49345Ssklower for (i = 0; i < len; i += MAX_COLUMNS) {
204*49345Ssklower printf("+%d:\t", i);
205*49345Ssklower for (j = 0; j < MAX_COLUMNS; j++) {
206*49345Ssklower if (i + j < len) {
207*49345Ssklower printf("%x/%d\t", buf[i+j], buf[i+j]);
208*49345Ssklower } else {
209*49345Ssklower printf(" ");
210*49345Ssklower }
211*49345Ssklower }
212*49345Ssklower
213*49345Ssklower for (j = 0; j < MAX_COLUMNS; j++) {
214*49345Ssklower if (i + j < len) {
215*49345Ssklower if (((buf[i+j]) > 31) && ((buf[i+j]) < 128))
216*49345Ssklower printf("%c", buf[i+j]);
217*49345Ssklower else
218*49345Ssklower printf(".");
219*49345Ssklower }
220*49345Ssklower }
221*49345Ssklower printf("\n");
222*49345Ssklower }
223*49345Ssklower }
224*49345Ssklower
_insque(new,header)225*49345Ssklower _insque(new, header)
226*49345Ssklower register struct qhdr *new, *header;
227*49345Ssklower {
228*49345Ssklower (*new).link = (*header).link;
229*49345Ssklower (*new).rlink = header;
230*49345Ssklower (*(*header).link).rlink = new;
231*49345Ssklower (*header).link = new;
232*49345Ssklower }
233