Annotation of 43BSDReno/sys/netimp/raw_imp.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution is only permitted until one year after the first shipment
                      6:  * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
                      7:  * binary forms are permitted provided that: (1) source distributions retain
                      8:  * this entire copyright notice and comment, and (2) distributions including
                      9:  * binaries display the following acknowledgement:  This product includes
                     10:  * software developed by the University of California, Berkeley and its
                     11:  * contributors'' in the documentation or other materials provided with the
                     12:  * distribution and in all advertising materials mentioning features or use
                     13:  * of this software.  Neither the name of the University nor the names of
                     14:  * its contributors may be used to endorse or promote products derived from
                     15:  * this software without specific prior written permission.
                     16:  * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
                     17:  * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
                     18:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     19:  *
                     20:  *     @(#)raw_imp.c   7.6 (Berkeley) 6/28/90
                     21:  */
                     22: 
                     23: #include "param.h"
                     24: #include "mbuf.h"
                     25: #include "socket.h"
                     26: #include "protosw.h"
                     27: #include "socketvar.h"
                     28: #include "errno.h"
                     29: 
                     30: #include "../net/if.h"
                     31: #include "../net/route.h"
                     32: #include "../net/raw_cb.h"
                     33: 
                     34: #include "../netinet/in.h"
                     35: #include "../netinet/in_systm.h"
                     36: #include "../netinet/in_var.h"
                     37: #include "../netinet/in_pcb.h"
                     38: #include "if_imp.h"
                     39: 
                     40: /*
                     41:  * Raw interface to IMP.
                     42:  */
                     43: 
                     44: /*
                     45:  * Generate IMP leader and pass packet to impoutput.
                     46:  * The user must create a skeletal leader in order to
                     47:  * communicate message type, message subtype, etc.
                     48:  * We fill in holes where needed and verify parameters
                     49:  * supplied by user.
                     50:  */
                     51: rimp_output(m, so)
                     52:        register struct mbuf *m;
                     53:        struct socket *so;
                     54: {
                     55:        struct mbuf *n;
                     56:        int len, error = 0;
                     57:        register struct imp_leader *ip;
                     58:        register struct sockaddr_in *sin;
                     59:        register struct raw_inpcb *rp = sotorawinpcb(so);
                     60:        struct in_ifaddr *ia;
                     61:        struct control_leader *cp;
                     62: 
                     63:        /*
                     64:         * Verify user has supplied necessary space
                     65:         * for the leader and check parameters in it.
                     66:         */
                     67:        if ((m->m_len < sizeof(struct control_leader)) &&
                     68:            (m = m_pullup(m, sizeof(struct control_leader))) == 0) {
                     69:                error = EMSGSIZE;       /* XXX */
                     70:                goto bad;
                     71:        }
                     72:        cp = mtod(m, struct control_leader *);
                     73:        if (cp->dl_mtype == IMPTYPE_DATA)
                     74:                if (m->m_len < sizeof(struct imp_leader) &&
                     75:                    (m = m_pullup(m, sizeof(struct imp_leader))) == 0) {
                     76:                        error = EMSGSIZE;       /* XXX */
                     77:                        goto bad;
                     78:                }
                     79:        ip = mtod(m, struct imp_leader *);
                     80:        if (ip->il_format != IMP_NFF) {
                     81:                error = EMSGSIZE;               /* XXX */
                     82:                goto bad;
                     83:        }
                     84: #ifdef notdef
                     85:        if (ip->il_link != IMPLINK_IP &&
                     86:            (ip->il_link<IMPLINK_LOWEXPER || ip->il_link>IMPLINK_HIGHEXPER)) {
                     87:                error = EPERM;
                     88:                goto bad;
                     89:        }
                     90: #endif
                     91: 
                     92:        /*
                     93:         * Fill in IMP leader -- impoutput refrains from rebuilding
                     94:         * the leader when it sees the protocol family PF_IMPLINK.
                     95:         * (message size calculated by walking through mbuf's)
                     96:         */
                     97:        for (len = 0, n = m; n; n = n->m_next)
                     98:                len += n->m_len;
                     99:        ip->il_length = htons((u_short)(len << 3));
                    100:        sin = (struct sockaddr_in *)rp->rinp_rcb.rcb_faddr;
                    101:        imp_addr_to_leader((struct control_leader *)ip, sin->sin_addr.s_addr);
                    102:        /* no routing here */
                    103:        ia = in_iaonnetof(in_netof(sin->sin_addr));
                    104:        if (ia)
                    105:                return (impoutput(ia->ia_ifp, m, (struct sockaddr *)sin));
                    106:        error = ENETUNREACH;
                    107: bad:
                    108:        m_freem(m);
                    109:        return (error);
                    110: }

unix.superglobalmegacorp.com

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