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