Home | History | Annotate | Line # | Download | only in common
rc.c revision 1.1.1.1
      1 /*
      2  * Copyright (c) 1993-95 Mats O Jansson.  All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  * 1. Redistributions of source code must retain the above copyright
      8  *    notice, this list of conditions and the following disclaimer.
      9  * 2. Redistributions in binary form must reproduce the above copyright
     10  *    notice, this list of conditions and the following disclaimer in the
     11  *    documentation and/or other materials provided with the distribution.
     12  * 3. All advertising materials mentioning features or use of this software
     13  *    must display the following acknowledgement:
     14  *	This product includes software developed by Mats O Jansson.
     15  * 4. The name of the author may not be used to endorse or promote products
     16  *    derived from this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28  */
     29 
     30 #ifndef LINT
     31 static char rcsid[] = "$Id: rc.c,v 1.1.1.1 1997/03/16 22:23:37 cjs Exp $";
     32 #endif
     33 
     34 #include "os.h"
     35 #include "common/get.h"
     36 #include "common/print.h"
     37 #include "common/mopdef.h"
     38 
     39 void
     40 mopDumpRC(fd, pkt, trans)
     41 	FILE	*fd;
     42 	u_char 	*pkt;
     43 	int	 trans;
     44 {
     45 	int	i,index = 0;
     46 	long	tmpl;
     47 	u_char	tmpc,code,control;
     48 	u_short	len,tmps,moplen;
     49 
     50 	len = mopGetLength(pkt, trans);
     51 
     52 	switch (trans) {
     53 	case TRANS_8023:
     54 		index = 22;
     55 		moplen = len - 8;
     56 		break;
     57 	default:
     58 		index = 16;
     59 		moplen = len;
     60 	}
     61 	code = mopGetChar(pkt,&index);
     62 
     63 	switch (code) {
     64 	case MOP_K_CODE_RID:
     65 
     66 		tmpc = mopGetChar(pkt,&index);
     67 		(void)fprintf(fd,"Reserved     :   %02x\n",tmpc);
     68 
     69 		tmps = mopGetShort(pkt,&index);
     70 		(void)fprintf(fd,"Receipt Nbr  : %04x\n",tmps);
     71 
     72 		break;
     73 	case MOP_K_CODE_BOT:
     74 
     75 		if ((moplen == 5)) {
     76 			tmps = mopGetShort(pkt,&index);
     77 			(void)fprintf(fd,"Verification : %04x\n",tmps);
     78 		} else {
     79 
     80 			tmpl = mopGetLong(pkt,&index);
     81 			(void)fprintf(fd,"Verification : %08x\n",tmpl);
     82 
     83 			tmpc = mopGetChar(pkt,&index);	/* Processor */
     84 			(void)fprintf(fd,"Processor    :   %02x ",tmpc);
     85 			mopPrintBPTY(fd, tmpc);  (void)fprintf(fd, "\n");
     86 
     87 			control = mopGetChar(pkt,&index);	/* Control */
     88 			(void)fprintf(fd,"Control    :   %02x ",control);
     89 			if ((control & (1>>MOP_K_BOT_CNTL_SERVER))) {
     90 				(void)fprintf(fd,
     91 					      "Bootserver Requesting system ");
     92 			} else {
     93 				(void)fprintf(fd,
     94 					      "Bootserver System default ");
     95 			}
     96 			if ((control & (1>>MOP_K_BOT_CNTL_DEVICE))) {
     97 				(void)fprintf(fd,
     98 					      "Bootdevice Specified device");
     99 			} else {
    100 				(void)fprintf(fd,
    101 					      "Bootdevice System default");
    102 			}
    103 			(void)fprintf(fd,"\n");
    104 
    105 			if ((control & (1>>MOP_K_BOT_CNTL_DEVICE))) {
    106 				tmpc = mopGetChar(pkt,&index);/* Device ID */
    107 				(void)fprintf(fd,
    108 					      "Device ID    :   %02x '",tmpc);
    109 				for (i = 0; i < ((int) tmpc); i++) {
    110 				  (void)fprintf(fd,"%c",
    111 						mopGetChar(pkt,&index));
    112 				}
    113 				(void)fprintf(fd,"'\n");
    114 			}
    115 
    116 			tmpc = mopGetChar(pkt,&index);      /* Software ID */
    117 			(void)fprintf(fd,"Software ID  :   %02x ",tmpc);
    118 			if ((tmpc == 0)) {
    119 				(void)fprintf(fd,"No software id");
    120 			}
    121 			if ((tmpc == 254)) {
    122 				(void)fprintf(fd,"Maintenance system");
    123 				tmpc = 0;
    124 			}
    125 			if ((tmpc == 255)) {
    126 				(void)fprintf(fd,"Standard operating system");
    127 				tmpc = 0;
    128 			}
    129 			if ((tmpc > 0)) {
    130 				(void)fprintf(fd,"'");
    131 				for (i = 0; i < ((int) tmpc); i++) {
    132 					(void)fprintf(fd,"%c",
    133 						     mopGetChar(pkt,&index));
    134 				}
    135 				(void)fprintf(fd,"'");
    136 			}
    137 			(void)fprintf(fd,"'\n");
    138 
    139 		}
    140 		break;
    141 	case MOP_K_CODE_SID:
    142 
    143 		tmpc = mopGetChar(pkt,&index);		/* Reserved */
    144 		(void)fprintf(fd, "Reserved     :   %02x\n",tmpc);
    145 
    146 		tmps = mopGetShort(pkt,&index);		/* Receipt # */
    147 		(void)fprintf(fd, "Receipt Nbr  : %04x\n",tmpc);
    148 
    149 		mopPrintInfo(fd, pkt, &index, moplen, code, trans);
    150 
    151 		break;
    152 	case MOP_K_CODE_RQC:
    153 
    154 		tmps = mopGetShort(pkt,&index);
    155 		(void)fprintf(fd,"Receipt Nbr  : %04x\n",tmps);
    156 
    157 		break;
    158 	case MOP_K_CODE_CNT:
    159 
    160 		tmps = mopGetShort(pkt,&index);
    161 		(void)fprintf(fd,"Receipt Nbr  : %04x %d\n",tmps,tmps);
    162 
    163 		tmps = mopGetShort(pkt,&index);
    164 		(void)fprintf(fd,"Last Zeroed  : %04x %d\n",tmps,tmps);
    165 
    166 		tmpl = mopGetLong(pkt,&index);
    167 		(void)fprintf(fd,"Bytes rec    : %08x %d\n",tmpl,tmpl);
    168 
    169 		tmpl = mopGetLong(pkt,&index);
    170 		(void)fprintf(fd,"Bytes snd    : %08x %d\n",tmpl,tmpl);
    171 
    172 		tmpl = mopGetLong(pkt,&index);
    173 		(void)fprintf(fd,"Frames rec   : %08x %d\n",tmpl,tmpl);
    174 
    175 		tmpl = mopGetLong(pkt,&index);
    176 		(void)fprintf(fd,"Frames snd   : %08x %d\n",tmpl,tmpl);
    177 
    178 		tmpl = mopGetLong(pkt,&index);
    179 		(void)fprintf(fd,"Mcst Bytes re: %08x %d\n",tmpl,tmpl);
    180 
    181 		tmpl = mopGetLong(pkt,&index);
    182 		(void)fprintf(fd,"Mcst Frame re: %08x %d\n",tmpl,tmpl);
    183 
    184 		tmpl = mopGetLong(pkt,&index);
    185 		(void)fprintf(fd,"Frame snd,def: %08x %d\n",tmpl,tmpl);
    186 
    187 		tmpl = mopGetLong(pkt,&index);
    188 		(void)fprintf(fd,"Frame snd,col: %08x %d\n",tmpl,tmpl);
    189 
    190 		tmpl = mopGetLong(pkt,&index);
    191 		(void)fprintf(fd,"Frame snd,mcl: %08x %d\n",tmpl,tmpl);
    192 
    193 		tmps = mopGetShort(pkt,&index);
    194 		(void)fprintf(fd,"Snd failure  : %04x %d\n",tmps,tmps);
    195 
    196 		tmps = mopGetShort(pkt,&index);
    197 		(void)fprintf(fd,"Snd fail reas: %04x ",tmps);
    198 		if ((tmps &  1)) (void)fprintf(fd,"Excess col  ");
    199 		if ((tmps &  2)) (void)fprintf(fd,"Carrier chk fail  ");
    200 		if ((tmps &  4)) (void)fprintf(fd,"Short circ  ");
    201 		if ((tmps &  8)) (void)fprintf(fd,"Open circ  ");
    202 		if ((tmps & 16)) (void)fprintf(fd,"Frm to long  ");
    203 		if ((tmps & 32)) (void)fprintf(fd,"Rem fail to defer  ");
    204 		(void)fprintf(fd,"\n");
    205 
    206 		tmps = mopGetShort(pkt,&index);
    207 		(void)fprintf(fd,"Rec failure  : %04x %d\n",tmps,tmps);
    208 
    209 		tmps = mopGetShort(pkt,&index);
    210 		(void)fprintf(fd,"Rec fail reas: %04x ",tmps);
    211 		if ((tmps &  1)) (void)fprintf(fd,"Block chk err  ");
    212 		if ((tmps &  2)) (void)fprintf(fd,"Framing err  ");
    213 		if ((tmps &  4)) (void)fprintf(fd,"Frm to long  ");
    214 		(void)fprintf(fd,"\n");
    215 
    216 		tmps = mopGetShort(pkt,&index);
    217 		(void)fprintf(fd,"Unrec frm dst: %04x %d\n",tmps,tmps);
    218 
    219 		tmps = mopGetShort(pkt,&index);
    220 		(void)fprintf(fd,"Data overrun : %04x %d\n",tmps,tmps);
    221 
    222 		tmps = mopGetShort(pkt,&index);
    223 		(void)fprintf(fd,"Sys Buf Unava: %04x %d\n",tmps,tmps);
    224 
    225 		tmps = mopGetShort(pkt,&index);
    226 		(void)fprintf(fd,"Usr Buf Unava: %04x %d\n",tmps,tmps);
    227 
    228 		break;
    229 	case MOP_K_CODE_RVC:
    230 
    231 		tmpl = mopGetLong(pkt,&index);
    232 		(void)fprintf(fd,"Verification : %08x\n",tmpl);
    233 
    234 		break;
    235 	case MOP_K_CODE_RLC:
    236 
    237 		/* Empty message */
    238 
    239 		break;
    240 	case MOP_K_CODE_CCP:
    241 
    242 		tmpc = mopGetChar(pkt,&index);
    243 		(void)fprintf(fd,
    244 			      "Control Flags: %02x Message %d ",tmpc,tmpc & 1);
    245 		if ((tmpc & 2))
    246 			(void)fprintf(fd,"Break");
    247 		(void)fprintf(fd,"\n");
    248 
    249 		if (moplen > 2) {
    250 #ifndef SHORT_PRINT
    251 			for (i = 0; i < (moplen - 2); i++) {
    252 		  		if ((i % 16) == 0) {
    253 					if ((i / 16) == 0) {
    254 						(void)fprintf(fd,
    255 							"Image Data   : %04x ",
    256 							      moplen-2);
    257 					} else {
    258 						(void)fprintf(fd,
    259 						       "                    ");
    260 				        }
    261 				}
    262 				(void)fprintf(fd,"%02x ",
    263 					      mopGetChar(pkt,&index));
    264 				if ((i % 16) == 15)
    265 					(void)fprintf(fd,"\n");
    266 			}
    267 			if ((i % 16) != 15)
    268 				(void)fprintf(fd,"\n");
    269 #else
    270 			index = index + moplen - 2;
    271 #endif
    272 		}
    273 
    274 		break;
    275 	case MOP_K_CODE_CRA:
    276 
    277 		tmpc = mopGetChar(pkt,&index);
    278 		(void)fprintf(fd,
    279 			      "Control Flags: %02x Message %d ",tmpc,tmpc & 1);
    280 		if ((tmpc & 2))
    281 			(void)fprintf(fd,"Cmd Data Lost ");
    282 		if ((tmpc & 4))
    283 			(void)fprintf(fd,"Resp Data Lost ");
    284 		(void)fprintf(fd,"\n");
    285 
    286 		if (moplen > 2) {
    287 #ifndef SHORT_PRINT
    288 			for (i = 0; i < (moplen - 2); i++) {
    289 				if ((i % 16) == 0) {
    290 					if ((i / 16) == 0) {
    291 						(void)fprintf(fd,
    292 							"Image Data   : %04x ",
    293 							      moplen-2);
    294 					} else {
    295 						(void)fprintf(fd,
    296 						       "                    ");
    297 					}
    298 				}
    299 				(void)fprintf(fd,"%02x ",
    300 					      mopGetChar(pkt,&index));
    301 				if ((i % 16) == 15)
    302 					(void)fprintf(fd,"\n");
    303 			}
    304 			if ((i % 16) != 15)
    305 				(void)fprintf(fd,"\n");
    306 #else
    307 			index = index + moplen - 2;
    308 #endif
    309 		}
    310 
    311 		break;
    312 	default:
    313 		break;
    314 	}
    315 }
    316 
    317