| 1 | /* |
| 2 | * Copyright (c) 1982 Regents of the University of California. |
| 3 | * All rights reserved. The Berkeley software License Agreement |
| 4 | * specifies the terms and conditions for redistribution. |
| 5 | * |
| 6 | * @(#)uipc_pipe.c 6.3 (Berkeley) %G% |
| 7 | */ |
| 8 | |
| 9 | #include "param.h" |
| 10 | #include "mbuf.h" |
| 11 | #include "protosw.h" |
| 12 | #include "socket.h" |
| 13 | #include "socketvar.h" |
| 14 | #include "unpcb.h" |
| 15 | |
| 16 | #define PIPSIZ 4096 |
| 17 | |
| 18 | /* |
| 19 | * Sneakily connect a pipe from wso to rso. |
| 20 | * This will get cleaned up when socketpair is added. |
| 21 | */ |
| 22 | piconnect(wso, rso) |
| 23 | struct socket *wso, *rso; |
| 24 | { |
| 25 | |
| 26 | /* when we reserve memory this routine may fail */ |
| 27 | sotounpcb(wso)->unp_conn = sotounpcb(rso); |
| 28 | sotounpcb(rso)->unp_conn = sotounpcb(wso); |
| 29 | wso->so_snd.sb_hiwat = PIPSIZ; |
| 30 | wso->so_snd.sb_mbmax = 2*PIPSIZ; |
| 31 | wso->so_state |= SS_ISCONNECTED|SS_CANTRCVMORE; |
| 32 | rso->so_rcv.sb_hiwat = 0; |
| 33 | rso->so_rcv.sb_mbmax = 0; |
| 34 | rso->so_state |= SS_ISCONNECTED|SS_CANTSENDMORE; |
| 35 | return (1); |
| 36 | } |