+static void
+sock_setupcalls_common(socket_t sock, sock_upcall rcallback, void *rcontext,
+ sock_upcall wcallback, void *wcontext)
+{
+ if (rcallback != NULL) {
+ sock->so_rcv.sb_flags |= SB_UPCALL;
+ sock->so_rcv.sb_upcall = rcallback;
+ sock->so_rcv.sb_upcallarg = rcontext;
+ } else {
+ sock->so_rcv.sb_flags &= ~SB_UPCALL;
+ sock->so_rcv.sb_upcall = NULL;
+ sock->so_rcv.sb_upcallarg = NULL;
+ }
+
+ if (wcallback != NULL) {
+ sock->so_snd.sb_flags |= SB_UPCALL;
+ sock->so_snd.sb_upcall = wcallback;
+ sock->so_snd.sb_upcallarg = wcontext;
+ } else {
+ sock->so_snd.sb_flags &= ~SB_UPCALL;
+ sock->so_snd.sb_upcall = NULL;
+ sock->so_snd.sb_upcallarg = NULL;
+ }
+}
+