dl.c revision 1.4
1/* $NetBSD: dl.c,v 1.4 1999/08/17 12:38:09 simonb 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: dl.c,v 1.4 1999/08/17 12:38:09 simonb Exp $"); 35#endif 36 37#include "os.h" 38#include "dl.h" 39#include "get.h" 40#include "mopdef.h" 41#include "print.h" 42 43void 44mopDumpDL(fd, pkt, trans) 45 FILE *fd; 46 u_char *pkt; 47 int trans; 48{ 49 int i,index = 0; 50 u_int32_t tmpl; 51 u_char tmpc,c,program[257],code,*ucp; 52 u_short len,tmps,moplen; 53 54 len = mopGetLength(pkt, trans); 55 56 switch (trans) { 57 case TRANS_8023: 58 index = 22; 59 moplen = len - 8; 60 break; 61 default: 62 index = 16; 63 moplen = len; 64 } 65 code = mopGetChar(pkt,&index); 66 67 switch (code) { 68 case MOP_K_CODE_MLT: 69 70 tmpc = mopGetChar(pkt,&index); /* Load Number */ 71 (void)fprintf(fd,"Load Number : %02x\n",tmpc); 72 73 if (moplen > 6) { 74 tmpl = mopGetLong(pkt,&index);/* Load Address */ 75 (void)fprintf(fd,"Load Address : %08x\n", tmpl); 76 } 77 78 if (moplen > 10) { 79#ifndef SHORT_PRINT 80 for (i = 0; i < (moplen - 10); i++) { 81 if ((i % 16) == 0) { 82 if ((i / 16) == 0) { 83 (void)fprintf(fd, 84 "Image Data : %04x ", 85 moplen-10); 86 } else { 87 (void)fprintf(fd, 88 " "); 89 } 90 } 91 92 (void)fprintf(fd, "%02x ", 93 mopGetChar(pkt,&index)); 94 if ((i % 16) == 15) 95 (void)fprintf(fd,"\n"); 96 } 97 98 if ((i % 16) != 15) 99 (void)fprintf(fd,"\n"); 100#else 101 index = index + moplen - 10; 102#endif 103 } 104 105 tmpl = mopGetLong(pkt,&index); /* Load Address */ 106 (void)fprintf(fd,"Xfer Address : %08x\n", tmpl); 107 108 break; 109 case MOP_K_CODE_DCM: 110 111 /* Empty Message */ 112 113 break; 114 case MOP_K_CODE_MLD: 115 116 tmpc = mopGetChar(pkt,&index); /* Load Number */ 117 (void)fprintf(fd,"Load Number : %02x\n",tmpc); 118 119 tmpl = mopGetLong(pkt,&index); /* Load Address */ 120 (void)fprintf(fd,"Load Address : %08x\n", tmpl); 121 122 if (moplen > 6) { 123#ifndef SHORT_PRINT 124 for (i = 0; i < (moplen - 6); i++) { 125 if ((i % 16) == 0) { 126 if ((i / 16) == 0) { 127 (void)fprintf(fd, 128 "Image Data : %04x ", 129 moplen-6); 130 } else { 131 (void)fprintf(fd, 132 " "); 133 } 134 } 135 (void)fprintf(fd,"%02x ", 136 mopGetChar(pkt,&index)); 137 if ((i % 16) == 15) 138 (void)fprintf(fd,"\n"); 139 } 140 141 if ((i % 16) != 15) 142 (void)fprintf(fd,"\n"); 143#else 144 index = index + moplen - 6; 145#endif 146 } 147 148 break; 149 case MOP_K_CODE_ASV: 150 151 /* Empty Message */ 152 153 break; 154 case MOP_K_CODE_RMD: 155 156 tmpl = mopGetLong(pkt,&index); /* Memory Address */ 157 (void)fprintf(fd,"Mem Address : %08x\n", tmpl); 158 159 tmps = mopGetShort(pkt,&index); /* Count */ 160 (void)fprintf(fd,"Count : %04x (%d)\n",tmps,tmps); 161 162 break; 163 case MOP_K_CODE_RPR: 164 165 tmpc = mopGetChar(pkt,&index); /* Device Type */ 166 (void)fprintf(fd, "Device Type : %02x ",tmpc); 167 mopPrintDevice(fd, tmpc); (void)fprintf(fd, "\n"); 168 169 tmpc = mopGetChar(pkt,&index); /* Format Version */ 170 (void)fprintf(fd,"Format : %02x\n",tmpc); 171 172 tmpc = mopGetChar(pkt,&index); /* Program Type */ 173 (void)fprintf(fd,"Program Type : %02x ",tmpc); 174 mopPrintPGTY(fd, tmpc); (void)fprintf(fd, "\n"); 175 176 program[0] = 0; 177 tmpc = mopGetChar(pkt,&index); /* Software ID Len */ 178 for (i = 0; i < tmpc; i++) { 179 program[i] = mopGetChar(pkt,&index); 180 program[i+1] = '\0'; 181 } 182 183 (void)fprintf(fd,"Software : %02x '%s'\n",tmpc,program); 184 185 tmpc = mopGetChar(pkt,&index); /* Processor */ 186 (void)fprintf(fd,"Processor : %02x ",tmpc); 187 mopPrintBPTY(fd, tmpc); (void)fprintf(fd, "\n"); 188 189 mopPrintInfo(fd, pkt, &index, moplen, code, trans); 190 191 break; 192 case MOP_K_CODE_RML: 193 194 tmpc = mopGetChar(pkt,&index); /* Load Number */ 195 (void)fprintf(fd,"Load Number : %02x\n",tmpc); 196 197 tmpc = mopGetChar(pkt,&index); /* Error */ 198 (void)fprintf(fd,"Error : %02x (",tmpc); 199 if ((tmpc == 0)) { 200 (void)fprintf(fd,"no error)\n"); 201 } else { 202 (void)fprintf(fd,"error)\n"); 203 } 204 205 break; 206 case MOP_K_CODE_RDS: 207 208 tmpc = mopGetChar(pkt,&index); /* Device Type */ 209 (void)fprintf(fd, "Device Type : %02x ",tmpc); 210 mopPrintDevice(fd, tmpc); (void)fprintf(fd, "\n"); 211 212 tmpc = mopGetChar(pkt,&index); /* Format Version */ 213 (void)fprintf(fd,"Format : %02x\n",tmpc); 214 215 tmpl = mopGetLong(pkt,&index); /* Memory Size */ 216 (void)fprintf(fd,"Memory Size : %08x\n", tmpl); 217 218 tmpc = mopGetChar(pkt,&index); /* Bits */ 219 (void)fprintf(fd,"Bits : %02x\n",tmpc); 220 221 mopPrintInfo(fd, pkt, &index, moplen, code, trans); 222 223 break; 224 case MOP_K_CODE_MDD: 225 226 tmpl = mopGetLong(pkt,&index); /* Memory Address */ 227 (void)fprintf(fd,"Mem Address : %08x\n", tmpl); 228 229 if (moplen > 5) { 230#ifndef SHORT_PRINT 231 for (i = 0; i < (moplen - 5); i++) { 232 if ((i % 16) == 0) { 233 if ((i / 16) == 0) { 234 (void)fprintf(fd, 235 "Image Data : %04x ", 236 moplen-5); 237 } else { 238 (void)fprintf(fd, 239 " "); 240 } 241 } 242 (void)fprintf(fd,"%02x ", 243 mopGetChar(pkt,&index)); 244 if ((i % 16) == 15) 245 (void)fprintf(fd,"\n"); 246 } 247 if ((i % 16) != 15) 248 (void)fprintf(fd,"\n"); 249#else 250 index = index + moplen - 5; 251#endif 252 } 253 254 break; 255 case MOP_K_CODE_PLT: 256 257 tmpc = mopGetChar(pkt,&index); /* Load Number */ 258 (void)fprintf(fd,"Load Number : %02x\n",tmpc); 259 260 tmpc = mopGetChar(pkt,&index); /* Parameter Type */ 261 while (tmpc != MOP_K_PLTP_END) { 262 c = mopGetChar(pkt,&index); /* Parameter Length */ 263 switch(tmpc) { 264 case MOP_K_PLTP_TSN: /* Target Name */ 265 (void)fprintf(fd,"Target Name : %02x '", 266 tmpc); 267 for (i = 0; i < ((int) c); i++) { 268 (void)fprintf(fd,"%c", 269 mopGetChar(pkt,&index)); 270 } 271 (void)fprintf(fd,"'\n"); 272 break; 273 case MOP_K_PLTP_TSA: /* Target Address */ 274 (void)fprintf(fd,"Target Addr : %02x ",c); 275 for (i = 0; i < ((int) c); i++) { 276 (void)fprintf(fd,"%02x ", 277 mopGetChar(pkt,&index)); 278 } 279 (void)fprintf(fd,"\n"); 280 break; 281 case MOP_K_PLTP_HSN: /* Host Name */ 282 (void)fprintf(fd,"Host Name : %02x '", 283 tmpc); 284 for (i = 0; i < ((int) c); i++) { 285 (void)fprintf(fd,"%c", 286 mopGetChar(pkt,&index)); 287 } 288 (void)fprintf(fd,"'\n"); 289 break; 290 case MOP_K_PLTP_HSA: /* Host Address */ 291 (void)fprintf(fd,"Host Addr : %02x ",c); 292 for (i = 0; i < ((int) c); i++) { 293 (void)fprintf(fd,"%02x ", 294 mopGetChar(pkt,&index)); 295 } 296 (void)fprintf(fd,"\n"); 297 break; 298 case MOP_K_PLTP_HST: /* Host Time */ 299 ucp = pkt + index; index = index + 10; 300 (void)fprintf(fd,"Host Time : "); 301 mopPrintTime(fd, ucp); 302 (void)fprintf(fd,"\n"); 303 break; 304 default: 305 break; 306 } 307 tmpc = mopGetChar(pkt,&index);/* Parameter Type */ 308 } 309 310 tmpl = mopGetLong(pkt,&index); /* Transfer Address */ 311 (void)fprintf(fd,"Transfer Addr: %08x\n", tmpl); 312 313 break; 314 default: 315 break; 316 } 317} 318 319 320