[BACK]Return to process.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / usr.sbin / mopd / mopd

Annotation of src/usr.sbin/mopd/mopd/process.c, Revision 1.14

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

CVSweb <webmaster@jp.NetBSD.org>