summaryrefslogtreecommitdiff
path: root/pflocal
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1995-07-02 00:28:48 +0000
committerMiles Bader <miles@gnu.org>1995-07-02 00:28:48 +0000
commit882b2ecaf14d2797b4c3a3f8d046df386577e7d3 (patch)
tree25905f6a73d3889cafba759de62c5ba13936c17d /pflocal
parent9535e9ae6099f334632d38ded1d0aca3a303fa33 (diff)
Formerly pf.c.~2~
Diffstat (limited to 'pflocal')
-rw-r--r--pflocal/pf.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/pflocal/pf.c b/pflocal/pf.c
index 30e42afd..fd23d028 100644
--- a/pflocal/pf.c
+++ b/pflocal/pf.c
@@ -22,23 +22,29 @@ S_socket_create (struct trivfs_protid *cred,
int sock_type, int protocol,
mach_port_t *port, mach_msg_type_name_t *port_type)
{
- struct socket_user *user;
+ error_t err;
+ struct pipe_ops *pipe_ops;
+ struct sock *sock;
+ struct sock_user *user;
if (!cred)
return EOPNOTSUPP;
- if (sock_type != SOCK_DGRAM && sock_type != SOCK_STREAM)
- return ESOCKTNOSUPPORT;
if (protocol != 0)
return EPROTONOSUPPORT;
+ switch (sock_type)
+ {
+ case SOCK_STREAM:
+ pipe_ops = stream_pipe_ops; break;
+ case SOCK_DGRAM:
+ pipe_ops = dgram_pipe_ops; break;
+ default:
+ return ESOCKTNOSUPPORT;
+ }
- user =
- port_allocate_port (socket_user_bucket,
- sizeof (struct socket_user),
- socket_user_class);
- user->socket = socket;
-
- *port = ports_get_right (user);
- *port_type = MACH_MSG_TYPE_MAKE_SEND;
- return 0;
+ err = sock_create (pipe_ops, &sock);
+ if (!err)
+ err = sock_create_port (sock, port, port_type);
+
+ return err;
}