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

1.1     ! root        1: /* ip_in.c - ip_in */
        !             2: 
        !             3: #include <conf.h>
        !             4: #include <kernel.h>
        !             5: #include <proc.h>
        !             6: #include <network.h>
        !             7: 
        !             8: /*------------------------------------------------------------------------
        !             9:  *  ip_in  -  handle IP packet coming in from the network
        !            10:  *------------------------------------------------------------------------
        !            11:  */
        !            12: ip_in(packet, icmpp, lim)
        !            13: struct epacket *packet;
        !            14: int    icmpp;
        !            15: int    lim;
        !            16: {
        !            17:        struct  udp     *udpptr;
        !            18:        struct  ip      *ipptr;
        !            19:        struct  netq    *nqptr;
        !            20:        int     dport;
        !            21:        int     i;
        !            22:        int     to;
        !            23:        PStype  ps;
        !            24: 
        !            25:        ipptr = (struct ip *)packet->ep_data;
        !            26:        switch (ipptr->i_proto) {
        !            27: 
        !            28:        case IPRO_ICMP:         /* ICMP: pass to icmp input routine */
        !            29:                return(icmp_in(packet, icmpp, lim));
        !            30: 
        !            31:        case IPRO_UDP:          /* UDP: demultiplex based on UDP "port" */
        !            32:                udpptr = (struct udp *) ipptr->i_data;
        !            33:                dport = net2hs(udpptr->u_dport)&LOW16;
        !            34:                for (i=0 ; i<NETQS ; i++) {
        !            35:                        nqptr = &Net.netqs[i];
        !            36:                        if (nqptr->uport == dport) {
        !            37:                                /* drop instead of blocking on psend */ 
        !            38:                                if (pcount(nqptr->xport) >= NETQLEN) {
        !            39:                                        Net.ndrop++;
        !            40:                                        Net.nover++;
        !            41:                                        freebuf(packet);
        !            42:                                        return(SYSERR);
        !            43:                                }
        !            44:                                psend(nqptr->xport, packet);
        !            45:                                disable(ps);
        !            46:                                to = nqptr->pid;
        !            47:                                if ( !isbadpid(to) ) {
        !            48:                                    nqptr->pid = BADPID;
        !            49:                                    send(to, OK);
        !            50:                                }
        !            51:                                restore(ps);
        !            52:                                return(OK);
        !            53:                        }
        !            54:                }
        !            55:                break;
        !            56: 
        !            57:        default:
        !            58:                break;          
        !            59:        }
        !            60:        Net.ndrop++;
        !            61:        freebuf(packet);
        !            62:        return(OK);
        !            63: }

unix.superglobalmegacorp.com

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