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