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