|
Network Block Device
@PACKAGE_VERSION@
|
#include "lfs.h"#include <glib.h>#include <stdbool.h>#include <stdint.h>#include <sys/socket.h>#include <sys/types.h>Go to the source code of this file.
Data Structures | |
| struct | SERVER |
| Variables associated with a server. More... | |
| struct | CLIENT |
| Variables associated with a client connection. More... | |
Macros | |
| #define | NBDS_ERR g_quark_from_static_string("server-error-quark") |
| Error domain common for all NBD server errors. More... | |
| #define | msg(prio, ...) g_log(G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __VA_ARGS__) |
| Logging macros. More... | |
| #define | MY_NAME "nbd_server" |
Enumerations | |
| enum | VIRT_STYLE { VIRT_NONE =0, VIRT_IPLIT, VIRT_IPHASH, VIRT_CIDR } |
| Types of virtuatlization. More... | |
| enum | NBDS_ERRS { NBDS_ERR_CFILE_NOTFOUND, NBDS_ERR_CFILE_MISSING_GENERIC, NBDS_ERR_CFILE_KEY_MISSING, NBDS_ERR_CFILE_VALUE_INVALID, NBDS_ERR_CFILE_VALUE_UNSUPPORTED, NBDS_ERR_CFILE_NO_EXPORTS, NBDS_ERR_CFILE_INCORRECT_PORT, NBDS_ERR_CFILE_DIR_UNKNOWN, NBDS_ERR_CFILE_READDIR_ERR, NBDS_ERR_SO_LINGER, NBDS_ERR_SO_REUSEADDR, NBDS_ERR_SO_KEEPALIVE, NBDS_ERR_GAI, NBDS_ERR_SOCKET, NBDS_ERR_BIND, NBDS_ERR_LISTEN, NBDS_ERR_SYS } |
| NBD server error codes. More... | |
Functions | |
| bool | address_matches (const char *mask, const struct sockaddr *addr, GError **err) |
| Check whether a given address matches a given netmask. More... | |
| uint8_t | getmaskbyte (int masklen) G_GNUC_PURE |
| Gets a byte to allow for address masking. More... | |
| int | authorized_client (CLIENT *opts) |
| Check whether a client is allowed to connect. More... | |
| SERVER * | dup_serve (const SERVER *const s) |
| duplicate server More... | |
| int | append_serve (const SERVER *const s, GArray *const a) |
| append new server to array More... | |
| uint64_t | size_autodetect (int fhandle) |
| Detect the size of a file. More... | |
| #define msg | ( | prio, | |
| ... | |||
| ) | g_log(G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __VA_ARGS__) |
Logging macros.
Definition at line 117 of file nbdsrv.h.
Referenced by authorized_client(), copyonwrite_prepare(), handle_modern_connection(), handle_oldstyle_connection(), mainloop(), serveloop(), set_peername(), setup_servers(), setupexport(), and spawn_child().
| #define NBDS_ERR g_quark_from_static_string("server-error-quark") |
Error domain common for all NBD server errors.
Definition at line 81 of file nbdsrv.h.
Referenced by do_cfile_dir(), dosockopts(), main(), open_modern(), open_unix(), parse_cfile(), and setup_serve().
| enum NBDS_ERRS |
NBD server error codes.
| enum VIRT_STYLE |
| bool address_matches | ( | const char * | mask, |
| const struct sockaddr * | addr, | ||
| GError ** | err | ||
| ) |
Check whether a given address matches a given netmask.
| mask | the address or netmask to check against, in ASCII representation |
| addr | the address to check |
Definition at line 25 of file nbdsrv.c.
Referenced by authorized_client().
| int append_serve | ( | const SERVER *const | s, |
| GArray *const | a | ||
| ) |
append new server to array
| s | server |
| a | server array |
Definition at line 192 of file nbdsrv.c.
Referenced by append_new_servers(), main(), and parse_cfile().
| int authorized_client | ( | CLIENT * | opts | ) |
Check whether a client is allowed to connect.
Works with an authorization file which contains one line per machine or network, with CIDR-style netmasks.
| opts | The client who's trying to connect. |
Definition at line 105 of file nbdsrv.c.
References address_matches(), SERVER::authname, CLIENT::clientaddr, dup_serve(), LINELEN, msg, and CLIENT::server.
Referenced by getmaskbyte(), handle_modern_connection(), and handle_oldstyle_connection().
duplicate server
| s | the old server we want to duplicate |
Definition at line 149 of file nbdsrv.c.
Referenced by authorized_client().
| uint8_t getmaskbyte | ( | int | masklen | ) |
Gets a byte to allow for address masking.
| masklen | the length of the requested mask. |
Definition at line 93 of file nbdsrv.c.
References authorized_client().
Referenced by set_peername().
| uint64_t size_autodetect | ( | int | fhandle | ) |
Detect the size of a file.
| fhandle | An open filedescriptor |
Definition at line 252 of file nbdsrv.c.
Referenced by setupexport().
1.8.11