8#include <aquila/socket.h>
31 int (*
bind) (
struct file *
socket,
const struct sockaddr *addr, socklen_t len);
39 struct sockaddr *from, socklen_t *fromlen);
41 const struct sockaddr *to, socklen_t tolen);
70#define FILE_SOCKET 0x80000000
int socket_listen(struct file *file, int backlog)
Makes a socket listen for connections, for listen().
int socket_inet_create(struct file *file, int domain, int type, int protocol)
Makes an AF_INET socket: a TCP, UDP or ping socket.
int socket_shutdown_dir(struct file *file, int how)
Shuts down reading, writing or both on a socket, for shutdown().
int socket_can_write(struct file *file, size_t len)
Says whether a socket has room to write, for select() and poll().
int socket_getsockopt(struct file *file, int level, int name, void *val, socklen_t *len)
Reads a socket option, for getsockopt().
int socket_connect(struct file *file, const struct sockaddr *addr, socklen_t len)
Connects a socket to a peer, for connect().
int socket_setsockopt(struct file *file, int level, int name, const void *val, socklen_t len)
Sets a socket option, for setsockopt().
int socket_can_read(struct file *file, size_t len)
Says whether a socket has something to read, for select() and poll().
struct waitq * socket_wait_queue(struct file *file, int write)
Finds the wait queue that a socket's readers (or writers) sleep on, for select() and poll() to regist...
int socket_create(struct file *file, int domain, int type, int protocol)
Makes a socket of a domain in an open file, for socket().
int socket_tcp_create(struct file *file, int domain, int type, int protocol)
Makes a TCP socket, with its connection, CLOSED.
int socket_unix_create(struct file *file, int domain, int type, int protocol)
Makes an AF_UNIX socket, for socket().
int socket_accept(struct file *file, struct file *conn, const struct sockaddr *addr, socklen_t *len)
Accepts a connection on a listening socket, for accept().
int socket_ioctl(struct file *file, int request, void *argp)
Handles an ioctl() on a socket, by passing it to the protocol.
int socket_shutdown(struct file *file, int how)
Releases a socket when its open file is closed (its last descriptor went).
ssize_t socket_recv(struct file *file, struct iobuf *io, int flags, struct sockaddr *from, socklen_t *fromlen)
Receives data from a socket, for recv(), recvfrom() and read().
int socket_getname(struct file *file, struct sockaddr *addr, socklen_t *len, int peer)
Gets a socket's local address, or its peer's, for getsockname() and getpeername().
ssize_t socket_send(struct file *file, struct iobuf *io, int flags, const struct sockaddr *to, socklen_t tolen)
Sends data on a socket, for send(), sendto() and write().
int socket_bind(struct file *file, const struct sockaddr *addr, socklen_t len)
Gives a socket its local address, for bind().
An open file (POSIX's "open file description", fs/file.c).
A domain's socket operations.
int(*) connect(struct file *socket, const struct sockaddr *addr, socklen_t len)
int(*) getname(struct file *socket, struct sockaddr *addr, socklen_t *len, int peer)
int(*) bind(struct file *socket, const struct sockaddr *addr, socklen_t len)
int(*) shutdown(struct file *socket, int how)
ssize_t(*) send(struct file *socket, struct iobuf *io, int flags, const struct sockaddr *to, socklen_t tolen)
int(*) shut(struct file *socket, int how)
int(*) can_write(struct file *socket, size_t len)
int(*) accept(struct file *socket, struct file *conn, const struct sockaddr *addr, socklen_t *len)
int(*) listen(struct file *socket, int backlog)
int(*) setsockopt(struct file *socket, int level, int name, const void *val, socklen_t len)
int(*) can_read(struct file *socket, size_t len)
ssize_t(*) recv(struct file *socket, struct iobuf *io, int flags, struct sockaddr *from, socklen_t *fromlen)
int(*) getsockopt(struct file *socket, int level, int name, void *val, socklen_t *len)
int(*) ioctl(struct file *socket, int request, void *argp)