Annotation of researchv8dc/sys/inet/udp_ld.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * udp line discipline; only one, to be pushed on /dev/ip17.
                      3:  */
                      4: 
                      5: #include "udp.h"
                      6: #if NUDP > 0
                      7: #include "../h/param.h"
                      8: #include "../h/systm.h"
                      9: #include "../h/stream.h"
                     10: #include "../h/ioctl.h"
                     11: #include "../h/ttyld.h"
                     12: #include "../h/map.h"
                     13: #include "../h/buf.h"
                     14: #include "../h/ubavar.h"
                     15: #include "../h/conf.h"
                     16: 
                     17: #include "../h/inet/in.h"
                     18: #include "../h/inet/ip.h"
                     19: #include "../h/inet/ip_var.h"
                     20: #include "../h/inet/udp.h"
                     21: #include "../h/inet/udp_var.h"
                     22: 
                     23: struct queue *udpqueue;
                     24: 
                     25: int    udpopen(), udpiput(), udpisrv(), udpclose();
                     26: int    udposrv(), udpoput();
                     27: static struct qinit udprinit = { udpiput, udpisrv, udpopen, udpclose, 
                     28:                                  UDP_MSG_LIMIT, 512 };
                     29: static struct qinit udpwinit = { putq, udposrv, udpopen, udpclose, 
                     30:                                  UDP_MSG_LIMIT, 64 };
                     31: struct streamtab udpinfo = { &udprinit, &udpwinit };
                     32: 
                     33: udpopen(q, dev)
                     34: register struct queue *q;
                     35: {
                     36:        if (q->ptr)
                     37:                return(0);
                     38:        udpqueue = q;   /* RD queue */
                     39:        q->flag |= QDELIM;
                     40:        WR(q)->flag |= QDELIM;
                     41:        q->ptr = (caddr_t)1;
                     42:        WR(q)->ptr = (caddr_t)1;
                     43:        q->flag |= QNOENB;      /* ipiput calls qenable() */
                     44:        return(1);
                     45: }
                     46: 
                     47: udpclose(q)
                     48: register struct queue *q;
                     49: {
                     50:        if(udpqueue == q)
                     51:                udpqueue = 0;
                     52: }
                     53: 
                     54: udpisrv(q)
                     55: register struct queue *q;
                     56: {
                     57:        register struct block *bp, *head, *tail;
                     58: 
                     59:        /* there is now a whole packet waiting
                     60:         * on this queue; strip it off and pass to udp_input().
                     61:         * things other than data or delims are forwarded directly
                     62:         * by udpiput().
                     63:         */
                     64:        head = tail = (struct block *) 0;
                     65:        while(bp = getq(q)){
                     66:                if(bp->type == M_DELIM){
                     67:                        freeb(bp);
                     68:                        if(head){
                     69:                                udp_input(head);
                     70:                        } else {
                     71:                                printf("udpisrv: delim, no data\n");
                     72:                        }
                     73:                        head = tail = (struct block *) 0;
                     74:                } else if(bp->type == M_DATA){
                     75:                        bp->next = (struct block *) 0;
                     76:                        if(head == (struct block *) 0){
                     77:                                head = bp;
                     78:                        } else {
                     79:                                tail->next = bp;
                     80:                        }
                     81:                        tail = bp;
                     82:                } else {
                     83:                        printf("weird type 0%o in udpisrv\n", bp->type);
                     84:                        (*q->next->qinfo->putp)(q->next, bp);
                     85:                }       
                     86:        }
                     87:        if(head || tail){
                     88:                printf("udpisrv: data & no dELIM\n");
                     89:        }
                     90: }
                     91: 
                     92: 
                     93: udpiput(q, bp)
                     94: register struct queue *q;
                     95: register struct block *bp;
                     96: {
                     97:        switch(bp->type){
                     98:        case M_DATA:
                     99:                putq(q, bp);    /* putq does compression into blocks */
                    100:                break;
                    101:        case M_DELIM:
                    102:                putq(q, bp);
                    103:                qenable(q);
                    104:                break;
                    105:        default:
                    106:                (*q->next->qinfo->putp)(q->next, bp);
                    107:                break;
                    108:        }
                    109:                
                    110: }
                    111: 
                    112: udposrv(q)
                    113: register struct queue *q;
                    114: {
                    115:        register union stmsg *sp;
                    116:        register struct block *bp;
                    117: 
                    118:        while(bp = getq(q)){
                    119:                if(bp->type == M_IOCTL){
                    120:                        sp = (union stmsg *)bp->rptr;
                    121:                        switch(sp->ioc0.com){
                    122:                        default:
                    123:                                (*q->next->qinfo->putp)(q->next, bp);
                    124:                                break;
                    125:                        }
                    126:                } else {
                    127:                        (*q->next->qinfo->putp)(q->next, bp);
                    128:                }
                    129:        }
                    130: }
                    131: 
                    132: udp_ldout(bp)
                    133: register struct block *bp;
                    134: {
                    135:        register struct block *bp1;
                    136:        register struct queue *q;
                    137: 
                    138:        if(udpqueue == 0){
                    139:                bp_free(bp);
                    140:                return(1);
                    141:        }
                    142:        q = WR(udpqueue);
                    143:        if(q->next->flag&QFULL){
                    144:                printf("udp_ldout: QFULL\n");
                    145:                bp_free(bp);
                    146:                return(1);
                    147:        }
                    148:        while(bp){
                    149:                bp1 = bp->next;
                    150:                (*q->next->qinfo->putp)(q->next, bp);
                    151:                bp = bp1;
                    152:        }
                    153: /*
                    154:  * send delim
                    155:  */
                    156: 
                    157:        putctl(q->next, M_DELIM);
                    158: }
                    159: #endif

unix.superglobalmegacorp.com

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