1 /* tp_usrreq.c 1.4 82/12/18 */ 2 3 #include "../h/param.h" 4 #include "../h/systm.h" 5 #include "../h/mbuf.h" 6 #include "../h/socket.h" 7 #include "../h/socketvar.h" 8 #include "../h/protosw.h" 9 #include "../netdecnet/dn_systm.h" 10 #include "../netdecnet/tp.h" 11 #include "../netdecnet/tp_var.h" 12 13 /* 14 * Transport protocol interface to socket abstraction. 15 * Used ONLY to initialize the Transport layer. May be 16 * used for routing control in the future. 17 */ 18 19 /* 20 * Process a Transport user request. Only allowed 21 * operation is PRU_ATTACH to initialize the Transport 22 * layer. 23 */ 24 tp_usrreq(so, req, m, addr) 25 struct socket *so; 26 int req; 27 struct mbuf *m; 28 caddr_t addr; 29 { 30 int s = splimp(); 31 int error = 0; 32 33 /* 34 */ 35 if (so->so_pcb != 0 || req != PRU_ATTACH) { 36 splx(s); 37 return (EINVAL); /* XXX */ 38 } 39 if (tpstate != TPS_HALT) { 40 splx(s); 41 return (0); 42 } 43 if (tp_linit() == 0) { 44 splx(s); 45 return (EIO); 46 } 47 sleep((caddr_t)&tpstate, PZERO+1); 48 splx(s); 49 return (0); 50 } 51 52 /* 53 * Perform transport initialization for a line 54 */ 55 tp_linit() 56 { 57 register struct mbuf *m; 58 register struct tpin *t; 59 register int n; 60 61 m = m_get(MT_CANTWAIT, MT_HEADER); 62 if (m == 0) 63 return (0); 64 m->m_off = MMINOFF; 65 m->m_len = sizeof (struct tpin); 66 t = mtod(m, struct tpin *); 67 t->tpin_ctlflg = TP_INIT; 68 AD_SHORT(t->tpin_srcnode, tp_host); 69 t->tpin_tiinfo = TPINNT_NRT; 70 AD_SHORT(t->tpin_blksize, 1024); 71 t->tpin_ver[0] = 1; 72 t->tpin_ver[1] = 3; 73 t->tpin_ver[2] = 0; 74 t->tpin_res = 0; 75 n = (*tpifp->if_output)(tpifp, m, PF_DECNET); 76 tpstate = TPS_TIS; 77 m_freem(m); 78 return (n); 79 } 80