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