|
AquilaOS documentation
How it works, and its code
|
Go to the source code of this file.
Data Structures | |
| struct | socket |
| A socket. More... | |
| struct | sock_ops |
| A domain's socket operations. More... | |
Macros | |
| #define | FILE_SOCKET 0x80000000 |
Functions | |
| 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_bind (struct file *file, const struct sockaddr *addr, socklen_t len) |
| Gives a socket its local address, for bind(). | |
| 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_connect (struct file *file, const struct sockaddr *addr, socklen_t len) |
| Connects a socket to a peer, for connect(). | |
| int | socket_listen (struct file *file, int backlog) |
| Makes a socket listen for connections, for listen(). | |
| 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(). | |
| 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(). | |
| int | socket_getsockopt (struct file *file, int level, int name, void *val, socklen_t *len) |
| Reads a socket option, for getsockopt(). | |
| int | socket_setsockopt (struct file *file, int level, int name, const void *val, socklen_t len) |
| Sets a socket option, for setsockopt(). | |
| int | socket_ioctl (struct file *file, int request, void *argp) |
| Handles an ioctl() on a socket, by passing it to the protocol. | |
| int | socket_can_read (struct file *file, size_t len) |
| Says whether a socket has something to read, for select() and poll(). | |
| int | socket_can_write (struct file *file, size_t len) |
| Says whether a socket has room to write, 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 register. | |
| int | socket_shutdown (struct file *file, int how) |
| Releases a socket when its open file is closed (its last descriptor went). | |
| int | socket_shutdown_dir (struct file *file, int how) |
| Shuts down reading, writing or both on a socket, for shutdown(). | |
| int | socket_unix_create (struct file *file, int domain, int type, int protocol) |
| Makes an AF_UNIX socket, for socket(). | |
| 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_tcp_create (struct file *file, int domain, int type, int protocol) |
| Makes a TCP socket, with its connection, CLOSED. | |
| #define FILE_SOCKET 0x80000000 |
Definition at line 70 of file socket.h.
Referenced by at_uio(), fd_vnode(), socket_accept(), socket_bind(), socket_can_read(), socket_can_write(), socket_connect(), socket_getname(), socket_getsockopt(), socket_inet_create(), socket_ioctl(), socket_listen(), socket_recv(), socket_send(), socket_setsockopt(), socket_shutdown(), socket_shutdown_dir(), socket_tcp_accept(), socket_tcp_create(), socket_unix_accept(), socket_unix_create(), sys_fchdir(), sys_fcntl(), sys_fstat(), sys_ioctl(), sys_isatty(), sys_lseek(), sys_mmap(), sys_readdir(), vfs_file_can_read(), vfs_file_can_write(), vfs_file_close(), vfs_file_flock(), vfs_file_read(), vfs_file_trunc(), vfs_file_wait_queue(), and vfs_file_write().
| 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().
| file | the listening socket |
| conn | the open file that becomes the connection's socket |
| addr | where to put the peer's address, in user memory, or NULL |
| len | its size, in user memory |
Definition at line 59 of file socket.c.
References FILE_SOCKET, file::flags, and socket_accept().
Referenced by socket_accept(), and sys_accept().
| int socket_bind | ( | struct file * | file, |
| const struct sockaddr * | addr, | ||
| socklen_t | len ) |
Gives a socket its local address, for bind().
| file | the socket |
| addr | the address, in the kernel's memory |
| len | its size |
Definition at line 83 of file socket.c.
References FILE_SOCKET, file::flags, and socket_bind().
Referenced by socket_bind(), and sys_bind().
Says whether a socket has something to read, for select() and poll().
| file | the socket |
| len | how much a read would want |
Definition at line 189 of file socket.c.
References FILE_SOCKET, file::flags, and socket_can_read().
Referenced by socket_can_read(), and vfs_file_can_read().
Says whether a socket has room to write, for select() and poll().
| file | the socket |
| len | how much a write would want |
Definition at line 225 of file socket.c.
References FILE_SOCKET, file::flags, and socket_can_write().
Referenced by socket_can_write(), and vfs_file_can_write().
| int socket_connect | ( | struct file * | file, |
| const struct sockaddr * | addr, | ||
| socklen_t | len ) |
Connects a socket to a peer, for connect().
| file | the socket |
| addr | the peer's address, in the kernel's memory |
| len | its size |
Definition at line 102 of file socket.c.
References FILE_SOCKET, file::flags, and socket_connect().
Referenced by socket_connect(), and sys_connect().
| int socket_create | ( | struct file * | file, |
| int | domain, | ||
| int | type, | ||
| int | protocol ) |
Makes a socket of a domain in an open file, for socket().
| file | the open file that becomes the socket |
| domain | AF_UNIX or AF_INET |
| type | the socket's type (SOCK_STREAM, SOCK_DGRAM) |
| protocol | the protocol, or 0 for the type's default |
Definition at line 27 of file socket.c.
References file::flags, socket_create(), socket_inet_create(), and socket_unix_create().
Referenced by socket_create(), and sys_socket().
| 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().
| file | the socket |
| addr | where to put the address, in the kernel's memory |
| len | its size, set to the address's |
| peer | 0 for the local address, 1 for the peer's |
Definition at line 289 of file socket.c.
References FILE_SOCKET, file::flags, and socket_getname().
Referenced by socket_getname(), and socket_name().
| int socket_getsockopt | ( | struct file * | file, |
| int | level, | ||
| int | name, | ||
| void * | val, | ||
| socklen_t * | len ) |
Reads a socket option, for getsockopt().
The protocol is asked first; SO_TYPE, and SO_ERROR for a protocol that keeps no errors, are answered here.
| file | the socket |
| level | SOL_SOCKET, or a protocol's level |
| name | the option |
| val | where to put its value, in the kernel's memory |
| len | its size, set to the value's |
Definition at line 325 of file socket.c.
References FILE_SOCKET, file::flags, sock_ops::getsockopt, socket_getsockopt(), and sockopt_int().
Referenced by socket_getsockopt(), and sys_getsockopt().
| int socket_inet_create | ( | struct file * | file, |
| int | domain, | ||
| int | type, | ||
| int | protocol ) |
Makes an AF_INET socket: a TCP, UDP or ping socket.
| file | the open file that becomes the socket |
| domain | AF_INET |
| type | SOCK_STREAM or SOCK_DGRAM |
| protocol | 0, IPPROTO_TCP, IPPROTO_UDP or IPPROTO_ICMP |
Definition at line 230 of file socket.c.
References socket::domain, FILE_SOCKET, file::flags, IP_PROTO_ICMP, IP_PROTO_UDP, kfree(), kmalloc(), M_ZERO, socket::ops, socket::p, inet_sock::proto, socket::protocol, socket_inet_create(), socket_inet_ops, socket_tcp_create(), and socket::type.
Referenced by socket_create(), and socket_inet_create().
| int socket_ioctl | ( | struct file * | file, |
| int | request, | ||
| void * | argp ) |
Handles an ioctl() on a socket, by passing it to the protocol.
| file | the socket |
| request | the request |
| argp | its argument, in user memory |
Definition at line 399 of file socket.c.
References FILE_SOCKET, file::flags, and socket_ioctl().
Referenced by socket_ioctl(), and sys_ioctl().
| int socket_listen | ( | struct file * | file, |
| int | backlog ) |
Makes a socket listen for connections, for listen().
| file | the socket |
| backlog | how many connections may wait to be accepted |
Definition at line 120 of file socket.c.
References FILE_SOCKET, file::flags, and socket_listen().
Referenced by socket_listen(), and sys_listen().
| 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().
| file | the socket |
| io | where to put the data, in user memory |
| flags | MSG_* flags |
| from | where to put the sender's address, or NULL |
| fromlen | its size |
Definition at line 169 of file socket.c.
References FILE_SOCKET, file::flags, and socket_recv().
Referenced by socket_recv(), sys_recv(), and vfs_file_read().
| 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().
| file | the socket |
| io | the data, in user memory |
| flags | MSG_* flags |
| to | the destination, for a datagram socket, or NULL |
| tolen | its size |
Definition at line 141 of file socket.c.
References FILE_SOCKET, file::flags, and socket_send().
Referenced by socket_send(), sys_send(), and vfs_file_write().
| int socket_setsockopt | ( | struct file * | file, |
| int | level, | ||
| int | name, | ||
| const void * | val, | ||
| socklen_t | len ) |
Sets a socket option, for setsockopt().
The protocol is asked first; a few common SOL_SOCKET options are accepted here without effect.
| file | the socket |
| level | SOL_SOCKET, or a protocol's level |
| name | the option |
| val | its value, in the kernel's memory |
| len | its size |
Definition at line 361 of file socket.c.
References FILE_SOCKET, file::flags, sock_ops::setsockopt, and socket_setsockopt().
Referenced by socket_setsockopt(), and sys_setsockopt().
| int socket_shutdown | ( | struct file * | file, |
| int | how ) |
Releases a socket when its open file is closed (its last descriptor went).
| file | the socket |
| how | passed on to the protocol |
Definition at line 267 of file socket.c.
References FILE_SOCKET, file::flags, and socket_shutdown().
Referenced by socket_shutdown(), and vfs_file_close().
| int socket_shutdown_dir | ( | struct file * | file, |
| int | how ) |
Shuts down reading, writing or both on a socket, for shutdown().
The socket stays open.
| file | the socket |
| how | SHUT_RD, SHUT_WR or SHUT_RDWR |
Definition at line 245 of file socket.c.
References FILE_SOCKET, file::flags, and socket_shutdown_dir().
Referenced by socket_shutdown_dir(), and sys_shutdown().
| int socket_tcp_create | ( | struct file * | file, |
| int | domain, | ||
| int | type, | ||
| int | protocol ) |
Makes a TCP socket, with its connection, CLOSED.
| file | the open file that becomes the socket |
| domain | AF_INET |
| type | SOCK_STREAM |
| protocol | 0 or IPPROTO_TCP |
Definition at line 490 of file tcp_socket.c.
References socket::domain, FILE_SOCKET, file::flags, kfree(), kmalloc(), M_ZERO, socket::ops, socket::p, socket::protocol, socket_tcp_create(), socket_tcp_ops, tcp_pcb_free(), tcp_pcb_new(), and socket::type.
Referenced by socket_inet_create(), and socket_tcp_create().
| int socket_unix_create | ( | struct file * | file, |
| int | domain, | ||
| int | type, | ||
| int | protocol ) |
Makes an AF_UNIX socket, for socket().
It is neither bound nor connected yet.
| file | the open file that becomes the socket |
| domain | AF_UNIX |
| type | SOCK_STREAM (the only one supported) |
| protocol | 0 |
Definition at line 68 of file unix.c.
References socket::domain, FILE_SOCKET, file::flags, kmalloc(), M_ZERO, NULL, socket::ops, socket::p, socket::protocol, socket_unix_create(), socket_unix_ops, and socket::type.
Referenced by socket_create(), and socket_unix_create().
Finds the wait queue that a socket's readers (or writers) sleep on, for select() and poll() to register.
| file | the socket |
| write | 0 for readers, 1 for writers |
Definition at line 209 of file socket.c.
References NULL, and socket_wait_queue().
Referenced by socket_wait_queue(), and vfs_file_wait_queue().