Home | History | Annotate | Line # | Download | only in mopd
process.c revision 1.10
      1 /*	$NetBSD: process.c,v 1.10 2000/11/19 16:40:16 bouyer 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: process.c,v 1.10 2000/11/19 16:40:16 bouyer Exp $");
     35 #endif
     36 
     37 #include "os.h"
     38 #include "cmp.h"
     39 #include "common.h"
     40 #include "dl.h"
     41 #include "file.h"
     42 #include "get.h"
     43 #include "mopdef.h"
     44 #include "nmadef.h"
     45 #include "pf.h"
     46 #include "print.h"
     47 #include "put.h"
     48 #include "rc.h"
     49 
     50 extern u_char	buf[];
     51 extern int	DebugFlag;
     52 
     53 struct dllist dllist[MAXDL];		/* dump/load list		*/
     54 extern char	dl_mcst[];		/* Dump/Load Multicast		*/
     55 extern char	rc_mcst[];		/* Remote Console Multicast	*/
     56 
     57 void	mopNextLoad __P((u_char *, u_char *, u_char, int));
     58 void	mopProcessDL __P((FILE *, struct if_info *, u_char *, int *,
     59 	    u_char *, u_char *, int, u_short));
     60 void	mopProcessRC __P((FILE *, struct if_info *, u_char *, int *,
     61 	    u_char *, u_char *, int, u_short));
     62 void	mopProcessInfo __P((u_char *, int *, u_short, struct dllist *, int));
     63 void	mopSendASV __P((u_char *, u_char *, struct if_info *, int));
     64 void	mopStartLoad __P((u_char *, u_char *, struct dllist *, int));
     65 
     66 void
     67 mopProcessInfo(pkt, index, moplen, dl_rpr, trans)
     68 	u_char  *pkt;
     69 	int     *index;
     70 	u_short moplen;
     71 	struct  dllist  *dl_rpr;
     72 	int	trans;
     73 {
     74         u_short itype,tmps;
     75 	u_char  ilen ,tmpc,device;
     76 	u_char  uc1,uc2,uc3,*ucp;
     77 
     78 	device = 0;
     79 
     80 	switch(trans) {
     81 	case TRANS_ETHER:
     82 		moplen = moplen + 16;
     83 		break;
     84 	case TRANS_8023:
     85 		moplen = moplen + 14;
     86 		break;
     87 	}
     88 
     89 	itype = mopGetShort(pkt,index);
     90 
     91 	while (*index < (int)(moplen)) {
     92 		ilen  = mopGetChar(pkt,index);
     93 		switch (itype) {
     94 		case 0:
     95 			tmpc  = mopGetChar(pkt,index);
     96 			*index = *index + tmpc;
     97 			break;
     98 		case MOP_K_INFO_VER:
     99 			uc1 = mopGetChar(pkt,index);
    100 			uc2 = mopGetChar(pkt,index);
    101 			uc3 = mopGetChar(pkt,index);
    102 			break;
    103 		case MOP_K_INFO_MFCT:
    104 			tmps = mopGetShort(pkt,index);
    105 			break;
    106 		case MOP_K_INFO_CNU:
    107 			ucp = pkt + *index; *index = *index + 6;
    108 			break;
    109 		case MOP_K_INFO_RTM:
    110 			tmps = mopGetShort(pkt,index);
    111 			break;
    112 		case MOP_K_INFO_CSZ:
    113 			tmps = mopGetShort(pkt,index);
    114 			break;
    115 		case MOP_K_INFO_RSZ:
    116 			tmps = mopGetShort(pkt,index);
    117 			break;
    118 		case MOP_K_INFO_HWA:
    119 			ucp = pkt + *index; *index = *index + 6;
    120 			break;
    121 		case MOP_K_INFO_TIME:
    122 			ucp = pkt + *index; *index = *index + 10;
    123 			break;
    124 		case MOP_K_INFO_SOFD:
    125 			device = mopGetChar(pkt,index);
    126 			break;
    127 		case MOP_K_INFO_SFID:
    128 			tmpc = mopGetChar(pkt,index);
    129 			ucp = pkt + *index; *index = *index + tmpc;
    130 			break;
    131 		case MOP_K_INFO_PRTY:
    132 			tmpc = mopGetChar(pkt,index);
    133 			break;
    134 		case MOP_K_INFO_DLTY:
    135 			tmpc = mopGetChar(pkt,index);
    136 			break;
    137 		case MOP_K_INFO_DLBSZ:
    138 			tmps = mopGetShort(pkt,index);
    139 			dl_rpr->dl_bsz = tmps;
    140 			break;
    141 		default:
    142 			if (((device = NMA_C_SOFD_LCS) ||   /* DECserver 100 */
    143 			     (device = NMA_C_SOFD_DS2) ||   /* DECserver 200 */
    144 			     (device = NMA_C_SOFD_DP2) ||   /* DECserver 250 */
    145 			     (device = NMA_C_SOFD_DS3)) &&  /* DECserver 300 */
    146 			    ((itype > 101) && (itype < 107)))
    147 			{
    148 				switch (itype) {
    149 				case 102:
    150 					ucp = pkt + *index;
    151 					*index = *index + ilen;
    152 					break;
    153 				case 103:
    154 					ucp = pkt + *index;
    155 					*index = *index + ilen;
    156 					break;
    157 				case 104:
    158 					tmps = mopGetShort(pkt,index);
    159 					break;
    160 				case 105:
    161 					ucp = pkt + *index;
    162 					*index = *index + ilen;
    163 					break;
    164 				case 106:
    165 					ucp = pkt + *index;
    166 					*index = *index + ilen;
    167 					break;
    168 				};
    169 			} else {
    170 				ucp = pkt + *index; *index = *index + ilen;
    171 			};
    172 		}
    173 		itype = mopGetShort(pkt,index);
    174         }
    175 }
    176 
    177 void
    178 mopSendASV(dst, src, ii, trans)
    179 	u_char	*dst,*src;
    180 	struct if_info *ii;
    181 	int	 trans;
    182 {
    183         u_char	 pkt[200], *p;
    184 	int	 index;
    185 	u_char	 mopcode = MOP_K_CODE_ASV;
    186 	u_short	 newlen = 0,ptype = MOP_K_PROTO_DL;
    187 
    188 	index = 0;
    189 	mopPutHeader(pkt, &index, dst, src, ptype, trans);
    190 
    191 	p = &pkt[index];
    192 	mopPutChar(pkt,&index,mopcode);
    193 
    194 	mopPutLength(pkt, trans, index);
    195 	newlen = mopGetLength(pkt, trans);
    196 
    197 	if ((DebugFlag == DEBUG_ONELINE)) {
    198 		mopPrintOneline(stdout, pkt, trans);
    199 	}
    200 
    201 	if ((DebugFlag >= DEBUG_HEADER)) {
    202 		mopPrintHeader(stdout, pkt, trans);
    203 		mopPrintMopHeader(stdout, pkt, trans);
    204 	}
    205 
    206 	if ((DebugFlag >= DEBUG_INFO)) {
    207 		mopDumpDL(stdout, pkt, trans);
    208 	}
    209 
    210 	if (pfWrite(ii->fd, pkt, index, trans) != index) {
    211 		if (DebugFlag) {
    212 			(void)fprintf(stderr, "error pfWrite()\n");
    213 		}
    214 	}
    215 }
    216 
    217 #define MAX_ETH_PAYLOAD 1492
    218 
    219 void
    220 mopStartLoad(dst, src, dl_rpr, trans)
    221 	u_char	*dst,*src;
    222 	struct dllist *dl_rpr;
    223 	int	 trans;
    224 {
    225 	int	 len;
    226 	int	 i, slot;
    227 	u_char	 pkt[BUFSIZE], *p;
    228 	int	 index;
    229 	u_char	 mopcode = MOP_K_CODE_MLD;
    230 	u_short	 newlen,ptype = MOP_K_PROTO_DL;
    231 	struct dllist *dle;
    232 
    233 	slot = -1;
    234 
    235 	/* Look if we have a non terminated load, if so, use it's slot */
    236 
    237 	for (i = 0, dle = dllist; i < MAXDL; i++, dle++) {
    238 		if (dle->status != DL_STATUS_FREE) {
    239 			if (mopCmpEAddr(dle->eaddr, dst) == 0) {
    240 				slot = i;
    241 			}
    242 		}
    243 	}
    244 
    245 	/* If no slot yet, then find first free */
    246 
    247 	if (slot == -1) {
    248 		for (i = 0, dle = dllist; i < MAXDL; i++, dle++) {
    249 			if (dle->status == DL_STATUS_FREE) {
    250 				if (slot == -1) {
    251 					slot = i;
    252 					memmove((char *)dle->eaddr,
    253 					    (char *)dst, 6);
    254 				}
    255 			}
    256 		}
    257 	}
    258 
    259 	/* If no slot yet, then return. No slot is free */
    260 
    261 	if (slot == -1)
    262 		return;
    263 
    264 	/* Ok, save info from RPR */
    265 
    266 	dllist[slot] = *dl_rpr;
    267 	dle = &dllist[slot];
    268 	dle->status = DL_STATUS_READ_IMGHDR;
    269 
    270 	/* Get Load and Transfer Address. */
    271 
    272 	GetFileInfo(dle->ldfd,
    273 		    &dle->loadaddr,
    274 		    &dle->xferaddr,
    275 		    &dle->aout,
    276 		    &dle->a_text, &dle->a_text_fill,
    277 		    &dle->a_data, &dle->a_data_fill,
    278 		    &dle->a_bss,  &dle->a_bss_fill);
    279 
    280 	dle->nloadaddr = dle->loadaddr;
    281 	dle->lseek     = lseek(dle->ldfd, 0L, SEEK_CUR);
    282 	dle->a_lseek   = 0;
    283 
    284 	dle->count     = 0;
    285 	if (dle->dl_bsz >= MAX_ETH_PAYLOAD || dle->dl_bsz == 0)
    286 		dle->dl_bsz = MAX_ETH_PAYLOAD;
    287 	if (dle->dl_bsz == 1030)	/* VS/uVAX 2000 needs this */
    288 		dle->dl_bsz = 1000;
    289 	if (dle->dl_bsz == 0)		/* Needed by "big" VAXen */
    290 		dle->dl_bsz = MAX_ETH_PAYLOAD;
    291 	if (trans == TRANS_8023)
    292 		dle->dl_bsz = dle->dl_bsz - 8;
    293 
    294 	index = 0;
    295 	mopPutHeader(pkt, &index, dst, src, ptype, trans);
    296 	p = &pkt[index];
    297 	mopPutChar (pkt, &index, mopcode);
    298 
    299 	mopPutChar (pkt, &index, dle->count);
    300 	mopPutLong (pkt, &index, dle->loadaddr);
    301 
    302 	len = mopFileRead(dle, &pkt[index]);
    303 
    304 	dle->nloadaddr = dle->loadaddr + len;
    305 	index = index + len;
    306 
    307 	mopPutLength(pkt, trans, index);
    308 	newlen = mopGetLength(pkt, trans);
    309 
    310 	if ((DebugFlag == DEBUG_ONELINE)) {
    311 		mopPrintOneline(stdout, pkt, trans);
    312 	}
    313 
    314 	if ((DebugFlag >= DEBUG_HEADER)) {
    315 		mopPrintHeader(stdout, pkt, trans);
    316 		mopPrintMopHeader(stdout, pkt, trans);
    317 	}
    318 
    319 	if ((DebugFlag >= DEBUG_INFO)) {
    320 		mopDumpDL(stdout, pkt, trans);
    321 	}
    322 
    323 	if (pfWrite(dle->ii->fd, pkt, index, trans) != index) {
    324 		if (DebugFlag) {
    325 			(void)fprintf(stderr, "error pfWrite()\n");
    326 		}
    327 	}
    328 
    329 	dle->status = DL_STATUS_SENT_MLD;
    330 }
    331 
    332 void
    333 mopNextLoad(dst, src, new_count, trans)
    334 	u_char	*dst, *src, new_count;
    335 	int	 trans;
    336 {
    337 	int	 len;
    338 	int	 i, slot;
    339 	u_char	 pkt[BUFSIZE], *p;
    340 	int	 index, pindex;
    341 	char	 line[100];
    342 	u_short  newlen = 0,ptype = MOP_K_PROTO_DL;
    343 	u_char	 mopcode;
    344 	struct dllist *dle;
    345 
    346 	slot = -1;
    347 
    348 	for (i = 0, dle = dllist; i < MAXDL; i++, dle++) {
    349 		if (dle->status != DL_STATUS_FREE) {
    350 			if (mopCmpEAddr(dst, dle->eaddr) == 0)
    351 				slot = i;
    352 		}
    353 	}
    354 
    355 	/* If no slot yet, then return. No slot is free */
    356 
    357 	if (slot == -1)
    358 		return;
    359 
    360 	dle = &dllist[slot];
    361 
    362 	if ((new_count == ((dle->count+1) % 256))) {
    363 		dle->loadaddr = dllist[slot].nloadaddr;
    364 		dle->count    = new_count;
    365 	} else if (new_count != (dle->count % 256)) {
    366 		return;
    367 	}
    368 
    369 	if (dle->status == DL_STATUS_SENT_PLT) {
    370 		close(dle->ldfd);
    371 		dle->ldfd = -1;
    372 		dle->status = DL_STATUS_FREE;
    373 		sprintf(line,
    374 			"%x:%x:%x:%x:%x:%x Load completed",
    375 			dst[0],dst[1],dst[2],dst[3],dst[4],dst[5]);
    376 		syslog(LOG_INFO, "%s", line);
    377 		return;
    378 	}
    379 
    380 	dle->lseek     = lseek(dle->ldfd, 0L, SEEK_CUR);
    381 
    382 	if (dle->dl_bsz >= MAX_ETH_PAYLOAD)
    383 		dle->dl_bsz = MAX_ETH_PAYLOAD;
    384 
    385 	index = 0;
    386 	mopPutHeader(pkt, &index, dst, src, ptype, trans);
    387 	p = &pkt[index];
    388 	mopcode = MOP_K_CODE_MLD;
    389 	pindex = index;
    390 	mopPutChar (pkt,&index, mopcode);
    391 	mopPutChar (pkt,&index, dle->count);
    392 	mopPutLong (pkt,&index, dle->loadaddr);
    393 
    394 	len = mopFileRead(dle, &pkt[index]);
    395 
    396 	if (len > 0 ) {
    397 
    398 		dle->nloadaddr = dle->loadaddr + len;
    399 		index = index + len;
    400 
    401 		mopPutLength(pkt, trans, index);
    402 		newlen = mopGetLength(pkt, trans);
    403 
    404 	} else {
    405 		if (len == 0) {
    406 			index = pindex;
    407 			mopcode = MOP_K_CODE_PLT;
    408 			mopPutChar (pkt, &index, mopcode);
    409 			mopPutChar (pkt, &index, dle->count);
    410 			mopPutChar (pkt, &index, MOP_K_PLTP_HSN);
    411  			mopPutChar (pkt, &index, 3);
    412 			mopPutMulti(pkt, &index, "ipc", 3);
    413 			mopPutChar (pkt, &index, MOP_K_PLTP_HSA);
    414 			mopPutChar (pkt, &index, 6);
    415 			mopPutMulti(pkt, &index, src, 6);
    416 			mopPutChar (pkt, &index, MOP_K_PLTP_HST);
    417 			mopPutTime (pkt, &index, 0);
    418 			mopPutChar (pkt, &index, 0);
    419 			mopPutLong (pkt, &index, dle->xferaddr);
    420 
    421 			mopPutLength(pkt, trans, index);
    422 			newlen = mopGetLength(pkt, trans);
    423 
    424 			dle->status = DL_STATUS_SENT_PLT;
    425 		} else {
    426 			dle->status = DL_STATUS_FREE;
    427 			return;
    428 		}
    429 	}
    430 
    431 	if ((DebugFlag == DEBUG_ONELINE)) {
    432 		mopPrintOneline(stdout, pkt, trans);
    433 	}
    434 
    435 	if ((DebugFlag >= DEBUG_HEADER)) {
    436 		mopPrintHeader(stdout, pkt, trans);
    437 		mopPrintMopHeader(stdout, pkt, trans);
    438 	}
    439 
    440 	if ((DebugFlag >= DEBUG_INFO)) {
    441 		mopDumpDL(stdout, pkt, trans);
    442 	}
    443 
    444 	if (pfWrite(dle->ii->fd, pkt, index, trans) != index) {
    445 		if (DebugFlag) {
    446 			(void)fprintf(stderr, "error pfWrite()\n");
    447 		}
    448 	}
    449 }
    450 
    451 void
    452 mopProcessDL(fd, ii, pkt, index, dst, src, trans, len)
    453 	FILE	*fd;
    454 	struct if_info *ii;
    455 	u_char	*pkt;
    456 	int	*index;
    457 	u_char	*dst, *src;
    458 	int	 trans;
    459 	u_short	 len;
    460 {
    461 	u_char  tmpc;
    462 	u_short moplen;
    463 	u_char  pfile[129], mopcode;
    464 	char    filename[FILENAME_MAX];
    465 	char    line[100];
    466 	int     i,nfd,iindex;
    467 	struct dllist dl,*dl_rpr;
    468 	u_char  rpr_pgty,load;
    469 
    470 	if ((DebugFlag == DEBUG_ONELINE)) {
    471 		mopPrintOneline(stdout, pkt, trans);
    472 	}
    473 
    474 	if ((DebugFlag >= DEBUG_HEADER)) {
    475 		mopPrintHeader(stdout, pkt, trans);
    476 		mopPrintMopHeader(stdout, pkt, trans);
    477 	}
    478 
    479 	if ((DebugFlag >= DEBUG_INFO)) {
    480 		mopDumpDL(stdout, pkt, trans);
    481 	}
    482 
    483 	moplen  = mopGetLength(pkt, trans);
    484 	mopcode = mopGetChar(pkt,index);
    485 
    486 	switch (mopcode) {
    487 	case MOP_K_CODE_MLT:
    488 		break;
    489 	case MOP_K_CODE_DCM:
    490 		break;
    491 	case MOP_K_CODE_MLD:
    492 		break;
    493 	case MOP_K_CODE_ASV:
    494 		break;
    495 	case MOP_K_CODE_RMD:
    496 		break;
    497 	case MOP_K_CODE_RPR:
    498 
    499 		tmpc = mopGetChar(pkt,index);		/* Device Type */
    500 
    501 		tmpc = mopGetChar(pkt,index);		/* Format Version */
    502 		if ((tmpc != MOP_K_RPR_FORMAT) &&
    503 		    (tmpc != MOP_K_RPR_FORMAT_V3)) {
    504 			(void)fprintf(stderr,"mopd: Unknown RPR Format (%d) from ",tmpc);
    505 			mopPrintHWA(stderr,src);
    506 			(void)fprintf(stderr,"\n");
    507 		}
    508 
    509 		rpr_pgty = mopGetChar(pkt,index);	/* Program Type */
    510 
    511 		tmpc = mopGetChar(pkt,index);		/* Software ID Len */
    512 		if (tmpc > sizeof(pfile) - 1)
    513 			return;
    514 		for (i = 0; i < tmpc; i++) {
    515 			pfile[i] = mopGetChar(pkt,index);
    516 			pfile[i+1] = '\0';
    517 		}
    518 
    519 		if (tmpc == 0) {
    520 			/* In a normal implementation of a MOP Loader this */
    521 			/* would cause a question to NML (DECnet) if this  */
    522 			/* node is known and if so what image to load. But */
    523 			/* we don't have DECnet so we don't have anybody   */
    524 			/* to ask. My solution is to use the ethernet addr */
    525 			/* as filename. Implementing a database would be   */
    526 			/* overkill.					   */
    527 			sprintf(pfile,"%02x%02x%02x%02x%02x%02x%c",
    528 				src[0],src[1],src[2],src[3],src[4],src[5],0);
    529 		}
    530 
    531 		tmpc = mopGetChar(pkt,index);		/* Processor */
    532 
    533 		iindex = *index;
    534 		dl_rpr = &dl;
    535 		memset(dl_rpr, 0, sizeof(*dl_rpr));
    536 		dl_rpr->ii = ii;
    537 		memmove((char *)(dl_rpr->eaddr), (char *)src, 6);
    538 		mopProcessInfo(pkt,index,moplen,dl_rpr,trans);
    539 
    540 		sprintf(filename,"%s/%s.SYS", MOP_FILE_PATH, pfile);
    541 		if ((mopCmpEAddr(dst,dl_mcst) == 0)) {
    542 			if ((nfd = open(filename, O_RDONLY, 0)) != -1) {
    543 				close(nfd);
    544 				mopSendASV(src, ii->eaddr, ii, trans);
    545 				sprintf(line,
    546 					"%x:%x:%x:%x:%x:%x (%d) Do you have %s? (Yes)",
    547 					src[0],src[1],src[2],
    548 					src[3],src[4],src[5],trans,pfile);
    549 			} else {
    550 				sprintf(line,
    551 					"%x:%x:%x:%x:%x:%x (%d) Do you have %s? (No)",
    552 					src[0],src[1],src[2],
    553 					src[3],src[4],src[5],trans,pfile);
    554 			}
    555 			syslog(LOG_INFO, "%s", line);
    556 		} else {
    557 			if ((mopCmpEAddr(dst,ii->eaddr) == 0)) {
    558 				dl_rpr->ldfd = open(filename, O_RDONLY, 0);
    559 				mopStartLoad(src, ii->eaddr, dl_rpr, trans);
    560 				sprintf(line,
    561 					"%x:%x:%x:%x:%x:%x Send me %s",
    562 					src[0],src[1],src[2],
    563 					src[3],src[4],src[5],pfile);
    564 				syslog(LOG_INFO, "%s", line);
    565 			}
    566 		}
    567 
    568 		break;
    569 	case MOP_K_CODE_RML:
    570 
    571 		load = mopGetChar(pkt,index);		/* Load Number	*/
    572 
    573 		tmpc = mopGetChar(pkt,index);		/* Error	*/
    574 
    575 		if ((mopCmpEAddr(dst,ii->eaddr) == 0)) {
    576 			mopNextLoad(src, ii->eaddr, load, trans);
    577 		}
    578 
    579 		break;
    580 	case MOP_K_CODE_RDS:
    581 		break;
    582 	case MOP_K_CODE_MDD:
    583 		break;
    584 	case MOP_K_CODE_CCP:
    585 		break;
    586 	case MOP_K_CODE_PLT:
    587 		break;
    588 	default:
    589 		break;
    590 	}
    591 }
    592 
    593 void
    594 mopProcessRC(fd, ii, pkt, index, dst, src, trans, len)
    595 	FILE	*fd;
    596 	struct if_info *ii;
    597 	u_char	*pkt;
    598 	int	*index;
    599 	u_char	*dst, *src;
    600 	int	 trans;
    601 	u_short	 len;
    602 {
    603 	u_char	 tmpc;
    604 	u_short	 tmps, moplen = 0;
    605 	u_char   mopcode;
    606 	struct dllist dl,*dl_rpr;
    607 
    608 	if ((DebugFlag == DEBUG_ONELINE)) {
    609 		mopPrintOneline(stdout, pkt, trans);
    610 	}
    611 
    612 	if ((DebugFlag >= DEBUG_HEADER)) {
    613 		mopPrintHeader(stdout, pkt, trans);
    614 		mopPrintMopHeader(stdout, pkt, trans);
    615 	}
    616 
    617 	if ((DebugFlag >= DEBUG_INFO)) {
    618 		mopDumpRC(stdout, pkt, trans);
    619 	}
    620 
    621 	moplen  = mopGetLength(pkt, trans);
    622 	mopcode = mopGetChar(pkt,index);
    623 
    624 	switch (mopcode) {
    625 	case MOP_K_CODE_RID:
    626 		break;
    627 	case MOP_K_CODE_BOT:
    628 		break;
    629 	case MOP_K_CODE_SID:
    630 
    631 		tmpc = mopGetChar(pkt,index);		/* Reserved */
    632 
    633 		if ((DebugFlag >= DEBUG_INFO)) {
    634 			(void)fprintf(stderr, "Reserved     :   %02x\n",tmpc);
    635 		}
    636 
    637 		tmps = mopGetShort(pkt,index);		/* Receipt # */
    638 		if ((DebugFlag >= DEBUG_INFO)) {
    639 			(void)fprintf(stderr, "Receipt Nbr  : %04x\n",tmpc);
    640 		}
    641 
    642 		dl_rpr = &dl;
    643 		memset(dl_rpr, 0, sizeof(*dl_rpr));
    644 		dl_rpr->ii = ii;
    645 		memmove((char *)(dl_rpr->eaddr), (char *)src, 6);
    646 		mopProcessInfo(pkt,index,moplen,dl_rpr,trans);
    647 
    648 		break;
    649 	case MOP_K_CODE_RQC:
    650 		break;
    651 	case MOP_K_CODE_CNT:
    652 		break;
    653 	case MOP_K_CODE_RVC:
    654 		break;
    655 	case MOP_K_CODE_RLC:
    656 		break;
    657 	case MOP_K_CODE_CCP:
    658 		break;
    659 	case MOP_K_CODE_CRA:
    660 		break;
    661 	default:
    662 		break;
    663 	}
    664 }
    665 
    666