dl.c revision 1.6
1/* $NetBSD: dl.c,v 1.6 2009/10/20 00:51:13 snj 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 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27#include <sys/cdefs.h> 28#ifndef lint 29__RCSID("$NetBSD: dl.c,v 1.6 2009/10/20 00:51:13 snj Exp $"); 30#endif 31 32#include "os.h" 33#include "dl.h" 34#include "get.h" 35#include "mopdef.h" 36#include "print.h" 37 38void 39mopDumpDL(fd, pkt, trans) 40 FILE *fd; 41 u_char *pkt; 42 int trans; 43{ 44 int i,idx = 0; 45 u_int32_t tmpl; 46 u_char tmpc,c,program[257],code,*ucp; 47 u_short len,tmps,moplen; 48 49 len = mopGetLength(pkt, trans); 50 51 switch (trans) { 52 case TRANS_8023: 53 idx = 22; 54 moplen = len - 8; 55 break; 56 default: 57 idx = 16; 58 moplen = len; 59 } 60 code = mopGetChar(pkt,&idx); 61 62 switch (code) { 63 case MOP_K_CODE_MLT: 64 65 tmpc = mopGetChar(pkt,&idx); /* Load Number */ 66 (void)fprintf(fd,"Load Number : %02x\n",tmpc); 67 68 if (moplen > 6) { 69 tmpl = mopGetLong(pkt,&idx);/* Load Address */ 70 (void)fprintf(fd,"Load Address : %08x\n", tmpl); 71 } 72 73 if (moplen > 10) { 74#ifndef SHORT_PRINT 75 for (i = 0; i < (moplen - 10); i++) { 76 if ((i % 16) == 0) { 77 if ((i / 16) == 0) { 78 (void)fprintf(fd, 79 "Image Data : %04x ", 80 moplen-10); 81 } else { 82 (void)fprintf(fd, 83 " "); 84 } 85 } 86 87 (void)fprintf(fd, "%02x ", 88 mopGetChar(pkt,&idx)); 89 if ((i % 16) == 15) 90 (void)fprintf(fd,"\n"); 91 } 92 93 if ((i % 16) != 15) 94 (void)fprintf(fd,"\n"); 95#else 96 idx = idx + moplen - 10; 97#endif 98 } 99 100 tmpl = mopGetLong(pkt,&idx); /* Load Address */ 101 (void)fprintf(fd,"Xfer Address : %08x\n", tmpl); 102 103 break; 104 case MOP_K_CODE_DCM: 105 106 /* Empty Message */ 107 108 break; 109 case MOP_K_CODE_MLD: 110 111 tmpc = mopGetChar(pkt,&idx); /* Load Number */ 112 (void)fprintf(fd,"Load Number : %02x\n",tmpc); 113 114 tmpl = mopGetLong(pkt,&idx); /* Load Address */ 115 (void)fprintf(fd,"Load Address : %08x\n", tmpl); 116 117 if (moplen > 6) { 118#ifndef SHORT_PRINT 119 for (i = 0; i < (moplen - 6); i++) { 120 if ((i % 16) == 0) { 121 if ((i / 16) == 0) { 122 (void)fprintf(fd, 123 "Image Data : %04x ", 124 moplen-6); 125 } else { 126 (void)fprintf(fd, 127 " "); 128 } 129 } 130 (void)fprintf(fd,"%02x ", 131 mopGetChar(pkt,&idx)); 132 if ((i % 16) == 15) 133 (void)fprintf(fd,"\n"); 134 } 135 136 if ((i % 16) != 15) 137 (void)fprintf(fd,"\n"); 138#else 139 idx = idx + moplen - 6; 140#endif 141 } 142 143 break; 144 case MOP_K_CODE_ASV: 145 146 /* Empty Message */ 147 148 break; 149 case MOP_K_CODE_RMD: 150 151 tmpl = mopGetLong(pkt,&idx); /* Memory Address */ 152 (void)fprintf(fd,"Mem Address : %08x\n", tmpl); 153 154 tmps = mopGetShort(pkt,&idx); /* Count */ 155 (void)fprintf(fd,"Count : %04x (%d)\n",tmps,tmps); 156 157 break; 158 case MOP_K_CODE_RPR: 159 160 tmpc = mopGetChar(pkt,&idx); /* Device Type */ 161 (void)fprintf(fd, "Device Type : %02x ",tmpc); 162 mopPrintDevice(fd, tmpc); (void)fprintf(fd, "\n"); 163 164 tmpc = mopGetChar(pkt,&idx); /* Format Version */ 165 (void)fprintf(fd,"Format : %02x\n",tmpc); 166 167 tmpc = mopGetChar(pkt,&idx); /* Program Type */ 168 (void)fprintf(fd,"Program Type : %02x ",tmpc); 169 mopPrintPGTY(fd, tmpc); (void)fprintf(fd, "\n"); 170 171 program[0] = 0; 172 tmpc = mopGetChar(pkt,&idx); /* Software ID Len */ 173 for (i = 0; i < tmpc; i++) { 174 program[i] = mopGetChar(pkt,&idx); 175 program[i+1] = '\0'; 176 } 177 178 (void)fprintf(fd,"Software : %02x '%s'\n",tmpc,program); 179 180 tmpc = mopGetChar(pkt,&idx); /* Processor */ 181 (void)fprintf(fd,"Processor : %02x ",tmpc); 182 mopPrintBPTY(fd, tmpc); (void)fprintf(fd, "\n"); 183 184 mopPrintInfo(fd, pkt, &idx, moplen, code, trans); 185 186 break; 187 case MOP_K_CODE_RML: 188 189 tmpc = mopGetChar(pkt,&idx); /* Load Number */ 190 (void)fprintf(fd,"Load Number : %02x\n",tmpc); 191 192 tmpc = mopGetChar(pkt,&idx); /* Error */ 193 (void)fprintf(fd,"Error : %02x (",tmpc); 194 if ((tmpc == 0)) { 195 (void)fprintf(fd,"no error)\n"); 196 } else { 197 (void)fprintf(fd,"error)\n"); 198 } 199 200 break; 201 case MOP_K_CODE_RDS: 202 203 tmpc = mopGetChar(pkt,&idx); /* Device Type */ 204 (void)fprintf(fd, "Device Type : %02x ",tmpc); 205 mopPrintDevice(fd, tmpc); (void)fprintf(fd, "\n"); 206 207 tmpc = mopGetChar(pkt,&idx); /* Format Version */ 208 (void)fprintf(fd,"Format : %02x\n",tmpc); 209 210 tmpl = mopGetLong(pkt,&idx); /* Memory Size */ 211 (void)fprintf(fd,"Memory Size : %08x\n", tmpl); 212 213 tmpc = mopGetChar(pkt,&idx); /* Bits */ 214 (void)fprintf(fd,"Bits : %02x\n",tmpc); 215 216 mopPrintInfo(fd, pkt, &idx, moplen, code, trans); 217 218 break; 219 case MOP_K_CODE_MDD: 220 221 tmpl = mopGetLong(pkt,&idx); /* Memory Address */ 222 (void)fprintf(fd,"Mem Address : %08x\n", tmpl); 223 224 if (moplen > 5) { 225#ifndef SHORT_PRINT 226 for (i = 0; i < (moplen - 5); i++) { 227 if ((i % 16) == 0) { 228 if ((i / 16) == 0) { 229 (void)fprintf(fd, 230 "Image Data : %04x ", 231 moplen-5); 232 } else { 233 (void)fprintf(fd, 234 " "); 235 } 236 } 237 (void)fprintf(fd,"%02x ", 238 mopGetChar(pkt,&idx)); 239 if ((i % 16) == 15) 240 (void)fprintf(fd,"\n"); 241 } 242 if ((i % 16) != 15) 243 (void)fprintf(fd,"\n"); 244#else 245 idx = idx + moplen - 5; 246#endif 247 } 248 249 break; 250 case MOP_K_CODE_PLT: 251 252 tmpc = mopGetChar(pkt,&idx); /* Load Number */ 253 (void)fprintf(fd,"Load Number : %02x\n",tmpc); 254 255 tmpc = mopGetChar(pkt,&idx); /* Parameter Type */ 256 while (tmpc != MOP_K_PLTP_END) { 257 c = mopGetChar(pkt,&idx); /* Parameter Length */ 258 switch(tmpc) { 259 case MOP_K_PLTP_TSN: /* Target Name */ 260 (void)fprintf(fd,"Target Name : %02x '", 261 tmpc); 262 for (i = 0; i < ((int) c); i++) { 263 (void)fprintf(fd,"%c", 264 mopGetChar(pkt,&idx)); 265 } 266 (void)fprintf(fd,"'\n"); 267 break; 268 case MOP_K_PLTP_TSA: /* Target Address */ 269 (void)fprintf(fd,"Target Addr : %02x ",c); 270 for (i = 0; i < ((int) c); i++) { 271 (void)fprintf(fd,"%02x ", 272 mopGetChar(pkt,&idx)); 273 } 274 (void)fprintf(fd,"\n"); 275 break; 276 case MOP_K_PLTP_HSN: /* Host Name */ 277 (void)fprintf(fd,"Host Name : %02x '", 278 tmpc); 279 for (i = 0; i < ((int) c); i++) { 280 (void)fprintf(fd,"%c", 281 mopGetChar(pkt,&idx)); 282 } 283 (void)fprintf(fd,"'\n"); 284 break; 285 case MOP_K_PLTP_HSA: /* Host Address */ 286 (void)fprintf(fd,"Host Addr : %02x ",c); 287 for (i = 0; i < ((int) c); i++) { 288 (void)fprintf(fd,"%02x ", 289 mopGetChar(pkt,&idx)); 290 } 291 (void)fprintf(fd,"\n"); 292 break; 293 case MOP_K_PLTP_HST: /* Host Time */ 294 ucp = pkt + idx; idx = idx + 10; 295 (void)fprintf(fd,"Host Time : "); 296 mopPrintTime(fd, ucp); 297 (void)fprintf(fd,"\n"); 298 break; 299 default: 300 break; 301 } 302 tmpc = mopGetChar(pkt,&idx);/* Parameter Type */ 303 } 304 305 tmpl = mopGetLong(pkt,&idx); /* Transfer Address */ 306 (void)fprintf(fd,"Transfer Addr: %08x\n", tmpl); 307 308 break; 309 default: 310 break; 311 } 312} 313 314 315