Annotation of 42BSD/etc/routed/af.c, revision 1.1.1.1

1.1       root        1: #ifndef lint
                      2: static char sccsid[] = "@(#)af.c       4.11 (Berkeley) 5/25/83";
                      3: #endif
                      4: 
                      5: #include "defs.h"
                      6: 
                      7: /*
                      8:  * Address family support routines
                      9:  */
                     10: int    null_hash(), null_netmatch(), null_output(),
                     11:        null_portmatch(), null_portcheck(),
                     12:        null_checkhost(), null_canon();
                     13: int    inet_hash(), inet_netmatch(), inet_output(),
                     14:        inet_portmatch(), inet_portcheck(),
                     15:        inet_checkhost(), inet_canon();
                     16: #define NIL \
                     17:        { null_hash,            null_netmatch,          null_output, \
                     18:          null_portmatch,       null_portcheck,         null_checkhost, \
                     19:          null_canon }
                     20: #define        INET \
                     21:        { inet_hash,            inet_netmatch,          inet_output, \
                     22:          inet_portmatch,       inet_portcheck,         inet_checkhost, \
                     23:          inet_canon }
                     24: 
                     25: struct afswitch afswitch[AF_MAX] =
                     26:        { NIL, NIL, INET, INET, NIL, NIL, NIL, NIL, NIL, NIL, NIL };
                     27: 
                     28: inet_hash(sin, hp)
                     29:        register struct sockaddr_in *sin;
                     30:        struct afhash *hp;
                     31: {
                     32: 
                     33:        hp->afh_nethash = inet_netof(sin->sin_addr);
                     34:        hp->afh_hosthash = ntohl(sin->sin_addr.s_addr);
                     35:        hp->afh_hosthash &= 0x7fffffff;
                     36: }
                     37: 
                     38: inet_netmatch(sin1, sin2)
                     39:        struct sockaddr_in *sin1, *sin2;
                     40: {
                     41: 
                     42:        return (inet_netof(sin1->sin_addr) == inet_netof(sin2->sin_addr));
                     43: }
                     44: 
                     45: /*
                     46:  * Verify the message is from the right port.
                     47:  */
                     48: inet_portmatch(sin)
                     49:        register struct sockaddr_in *sin;
                     50: {
                     51:        
                     52: #ifdef COMPAT
                     53:        if (ntohs(sin->sin_port) == ntohs(sp->s_port) + 1)
                     54:                return (1);
                     55: #endif
                     56:        return (sin->sin_port == sp->s_port);
                     57: }
                     58: 
                     59: /*
                     60:  * Verify the message is from a "trusted" port.
                     61:  */
                     62: inet_portcheck(sin)
                     63:        struct sockaddr_in *sin;
                     64: {
                     65: 
                     66:        return (ntohs(sin->sin_port) <= IPPORT_RESERVED);
                     67: }
                     68: 
                     69: /*
                     70:  * Internet output routine.
                     71:  */
                     72: inet_output(s, flags, sin, size)
                     73:        int s, flags;
                     74:        struct sockaddr_in *sin;
                     75:        int size;
                     76: {
                     77:        struct sockaddr_in dst;
                     78: 
                     79:        dst = *sin;
                     80:        sin = &dst;
                     81:        if (sin->sin_port == 0)
                     82:                sin->sin_port = sp->s_port;
                     83:        if (sendto(s, packet, size, flags, sin, sizeof (*sin)) < 0)
                     84:                perror("sendto");
                     85: }
                     86: 
                     87: /*
                     88:  * Return 1 if the address is believed
                     89:  * for an Internet host -- THIS IS A KLUDGE.
                     90:  */
                     91: inet_checkhost(sin)
                     92:        struct sockaddr_in *sin;
                     93: {
                     94: 
                     95:        return (inet_lnaof(sin->sin_addr) != 0);
                     96: }
                     97: 
                     98: inet_canon(sin)
                     99:        struct sockaddr_in *sin;
                    100: {
                    101: 
                    102:        sin->sin_port = 0;
                    103: }
                    104: 
                    105: /*ARGSUSED*/
                    106: null_hash(addr, hp)
                    107:        struct sockaddr *addr;
                    108:        struct afhash *hp;
                    109: {
                    110: 
                    111:        hp->afh_nethash = hp->afh_hosthash = 0;
                    112: }
                    113: 
                    114: /*ARGSUSED*/
                    115: null_netmatch(a1, a2)
                    116:        struct sockaddr *a1, *a2;
                    117: {
                    118: 
                    119:        return (0);
                    120: }
                    121: 
                    122: /*ARGSUSED*/
                    123: null_output(s, f, a1, n)
                    124:        int s, f;
                    125:        struct sockaddr *a1;
                    126:        int n;
                    127: {
                    128: 
                    129:        ;
                    130: }
                    131: 
                    132: /*ARGSUSED*/
                    133: null_portmatch(a1)
                    134:        struct sockaddr *a1;
                    135: {
                    136: 
                    137:        return (0);
                    138: }
                    139: 
                    140: /*ARGSUSED*/
                    141: null_portcheck(a1)
                    142:        struct sockaddr *a1;
                    143: {
                    144: 
                    145:        return (0);
                    146: }
                    147: 
                    148: /*ARGSUSED*/
                    149: null_checkhost(a1)
                    150:        struct sockaddr *a1;
                    151: {
                    152: 
                    153:        return (0);
                    154: }
                    155: 
                    156: /*ARGSUSED*/
                    157: null_canon(a1)
                    158:        struct sockaddr *a1;
                    159: {
                    160: 
                    161:        ;
                    162: }

unix.superglobalmegacorp.com

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