Annotation of xinu/sys/arp_in.c, revision 1.1

1.1     ! root        1: /* arp_in.c - arp_in */
        !             2: 
        !             3: #include <conf.h>
        !             4: #include <kernel.h>
        !             5: #include <proc.h>
        !             6: #include <network.h>
        !             7: 
        !             8: /*------------------------------------------------------------------------
        !             9:  *  arp_in  -  handle ARP packet coming in from Ethernet network
        !            10:  *------------------------------------------------------------------------
        !            11:  */
        !            12: arp_in(packet, device)
        !            13: struct epacket *packet;
        !            14: int    device;
        !            15: {
        !            16:        PStype  ps;
        !            17:        int     arop;
        !            18:        int     pid;
        !            19:        struct  arppak  *apacptr;
        !            20:        struct  arpent  *atabptr;
        !            21:        struct  etblk   *etptr; 
        !            22:        
        !            23:        etptr = (struct etblk *) devtab[device].dvioblk;
        !            24:        apacptr = (struct arppak *) packet->ep_data;
        !            25:        atabptr = &Arp.arptab[arpfind(apacptr->ar_spa)];
        !            26:        if (atabptr->arp_state != AR_RSLVD) {
        !            27:                blkcopy(atabptr->arp_Ead, apacptr->ar_sha, EPADLEN);
        !            28:                atabptr->arp_dev = device;
        !            29:                atabptr->arp_state = AR_RSLVD;
        !            30:        }
        !            31:        arop = net2hs(apacptr->ar_op) & LOW16;
        !            32:        switch (arop) {
        !            33: 
        !            34:            case AR_REQ:        /* request - answer if for me */
        !            35:                if (! blkequ(Net.myaddr, apacptr->ar_tpa, IPLEN)) {
        !            36:                        freebuf(packet);
        !            37:                        return(OK);
        !            38:                }
        !            39:                apacptr->ar_op = hs2net(AR_RPLY);
        !            40:                blkcopy(apacptr->ar_tpa, apacptr->ar_spa, IPLEN);
        !            41:                blkcopy(apacptr->ar_tha, packet->ep_hdr.e_src, EPADLEN);
        !            42:                blkcopy(packet->ep_hdr.e_dest, apacptr->ar_tha, EPADLEN);
        !            43:                blkcopy(apacptr->ar_sha, etptr->etpaddr, EPADLEN);
        !            44:                blkcopy(apacptr->ar_spa, Net.myaddr, IPLEN);
        !            45:                write(device, packet, EMINPAK);
        !            46:                return(OK);
        !            47: 
        !            48:            case AR_RPLY:       /* reply - awaken requestor if any */
        !            49:                disable(ps);
        !            50:                pid = Arp.arppid;
        !            51:                if (!isbadpid(pid)
        !            52:                    && blkequ(Arp.arpwant, apacptr->ar_spa, IPLEN)) {
        !            53:                        Arp.arppid = BADPID;
        !            54:                        send(pid, OK);
        !            55:                }
        !            56:                freebuf(packet);
        !            57:                restore(ps);
        !            58:                return(OK);
        !            59: 
        !            60:            default:
        !            61:                Net.ndrop++;
        !            62:                freebuf(packet);
        !            63:                return(SYSERR);
        !            64:        }
        !            65: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.