include direct connect on outgoing mail if the pathname is "[IPC]" --
[unix-history] / usr / src / sys / deprecated / netpup / raw_pup.c
CommitLineData
31c2345c 1/* raw_pup.c 4.4 82/03/03 */
c2461425
SL
2
3#include "../h/param.h"
4#include "../h/mbuf.h"
5#include "../h/socket.h"
6#include "../h/protosw.h"
7#include "../h/socketvar.h"
8#include "../net/in.h"
9#include "../net/in_systm.h"
10#include "../net/pup.h"
11#include "../net/raw_cb.h"
12#include "/usr/include/errno.h"
13
14/*
15 * Raw PUP protocol interface.
16 */
17
c2461425 18/*ARGSUSED*/
8e999b50 19rpup_ctlinput(m)
c2461425
SL
20 struct mbuf *m;
21{
8e999b50 22COUNT(RPUP_CTLINPUT);
c2461425
SL
23}
24
25/*
26 * Encapsulate packet in PUP header which is supplied by the
27 * user. This is done to allow user to specify PUP identifier.
28 */
8e999b50 29rpup_output(m0, so)
c2461425
SL
30 struct mbuf *m0;
31 struct socket *so;
32{
33 register struct rawcb *rp = sotorawcb(so);
34 register struct pup_header *pup;
35 int len;
36 struct mbuf *n;
37 struct sockaddr_pup *spup;
31c2345c 38 struct ifnet *ifp;
c2461425 39
8e999b50 40COUNT(RPUP_OUTPUT);
c2461425
SL
41 /*
42 * Verify user has supplied necessary space
43 * for the header and check parameters in it.
44 */
45 if ((m->m_off > MMAXOFF || m->m_len < sizeof(struct pup_header)) &&
46 (m = m_pullup(m, sizeof(struct pup_header)) == 0) {
47 goto bad;
48 pup = mtod(m, struct pup_header *);
49 if (pup->pup_type == 0)
50 goto bad;
51 if (pup->pup_tcontrol && (pup->pup_tcontrol & ~PUP_TRACE))
52 goto bad;
53 for (len = 0, n = m; n; n = n->m_next)
54 len += n->m_len;
55 pup->pup_length = len;
56 spup = (struct sockaddr_pup *)&rp->rcb_addr;
57 pup->pup_dport = spup->spup_addr;
58
59 /*
60 * Insure proper source address is included.
61 */
62 spup = (struct sockadrr_pup *)rp->rcb_socket->so_addr;
63 pup->pup_sport = spup->spup_addr;
64 /* for now, assume user generates PUP checksum. */
65
31c2345c
SL
66 ifp = if_ifonnetof(&rp->rcb_addr);
67 if (ifp == 0) {
68 ifp = if_gatewayfor(&rp->rcb_addr);
69 if (ifp == 0)
70 goto bad;
71 }
c2461425
SL
72 return (enoutput((struct ifnet *)rp->rcb_pcb, m, PF_PUP));
73
74bad:
75 m_freem(m);
76 return (0);
77}