Network Block Device  @PACKAGE_VERSION@
Macros | Functions | Variables
cliserv.h File Reference
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <netinet/tcp.h>
#include <netinet/in.h>
#include <stdlib.h>
#include "nbd.h"

Go to the source code of this file.

Macros

#define __be32   u32
 
#define __be64   u64
 
#define fdatasync(arg)   fsync(arg)
 
#define G_GNUC_NORETURN
 
#define G_GNUC_UNUSED
 
#define INIT_PASSWD   "NBDMAGIC"
 
#define INFO(a)   do { } while(0)
 
#define htonll   ntohll
 
#define NBD_DEFAULT_PORT
 
#define NBD_OPT_EXPORT_NAME   (1) /** Client wants to select a named export (is followed by name of export) */
 
#define NBD_OPT_ABORT   (2) /** Client wishes to abort negotiation */
 
#define NBD_OPT_LIST   (3) /** Client request list of supported exports (not followed by data) */
 
#define NBD_REP_ACK   (1) /** ACK a request. Data: option number to be acked */
 
#define NBD_REP_SERVER   (2) /** Reply to NBD_OPT_LIST (one of these per server; must be followed by NBD_REP_ACK to signal the end of the list */
 
#define NBD_REP_FLAG_ERROR   (1 << 31) /** If the high bit is set, the reply is an error */
 
#define NBD_REP_ERR_UNSUP   (1 | NBD_REP_FLAG_ERROR) /** Client requested an option not understood by this version of the server */
 
#define NBD_REP_ERR_POLICY   (2 | NBD_REP_FLAG_ERROR) /** Client requested an option not allowed by server configuration. (e.g., the option was disabled) */
 
#define NBD_REP_ERR_INVALID   (3 | NBD_REP_FLAG_ERROR) /** Client issued an invalid request */
 
#define NBD_REP_ERR_PLATFORM   (4 | NBD_REP_FLAG_ERROR) /** Option not supported on this platform */
 
#define NBD_FLAG_FIXED_NEWSTYLE   (1 << 0) /* new-style export that actually supports extending */
 
#define NBD_FLAG_NO_ZEROES   (1 << 1) /* we won't send the 128 bits of zeroes if the client sends NBD_FLAG_C_NO_ZEROES */
 
#define NBD_FLAG_C_FIXED_NEWSTYLE   NBD_FLAG_FIXED_NEWSTYLE
 
#define NBD_FLAG_C_NO_ZEROES   NBD_FLAG_NO_ZEROES
 

Functions

void setmysockopt (int sock)
 
void err_nonfatal (const char *s)
 
void err (const char *s) G_GNUC_NORETURN
 
void logging (const char *name)
 
uint64_t ntohll (uint64_t a)
 

Variables

const u64 cliserv_magic
 
const u64 opts_magic
 
const u64 rep_magic
 

Macro Definition Documentation

#define __be32   u32

Definition at line 39 of file cliserv.h.

#define __be64   u64

Definition at line 40 of file cliserv.h.

#define fdatasync (   arg)    fsync(arg)

Definition at line 44 of file cliserv.h.

Referenced by expwrite(), and rawexpwrite().

#define G_GNUC_NORETURN

Definition at line 62 of file cliserv.h.

Referenced by serveloop().

#define G_GNUC_UNUSED

Definition at line 63 of file cliserv.h.

Referenced by main().

#define htonll   ntohll

Definition at line 83 of file cliserv.h.

Referenced by ask_list(), main(), negotiate(), send_export_info(), and send_reply().

#define INFO (   a)    do { } while(0)

Definition at line 73 of file cliserv.h.

Referenced by setmysockopt().

#define INIT_PASSWD   "NBDMAGIC"

Definition at line 71 of file cliserv.h.

Referenced by negotiate().

#define NBD_DEFAULT_PORT
Value:
"10809" /* Port on which named exports are
* served */

Definition at line 85 of file cliserv.h.

Referenced by main(), and open_modern().

#define NBD_FLAG_C_FIXED_NEWSTYLE   NBD_FLAG_FIXED_NEWSTYLE

Definition at line 106 of file cliserv.h.

Referenced by main().

#define NBD_FLAG_C_NO_ZEROES   NBD_FLAG_NO_ZEROES

Definition at line 107 of file cliserv.h.

Referenced by negotiate().

#define NBD_FLAG_FIXED_NEWSTYLE   (1 << 0) /* new-style export that actually supports extending */

Definition at line 103 of file cliserv.h.

Referenced by main(), and negotiate().

#define NBD_FLAG_NO_ZEROES   (1 << 1) /* we won't send the 128 bits of zeroes if the client sends NBD_FLAG_C_NO_ZEROES */

Definition at line 104 of file cliserv.h.

Referenced by negotiate().

#define NBD_OPT_ABORT   (2) /** Client wishes to abort negotiation */

Definition at line 90 of file cliserv.h.

Referenced by ask_list(), and negotiate().

#define NBD_OPT_EXPORT_NAME   (1) /** Client wants to select a named export (is followed by name of export) */

Definition at line 89 of file cliserv.h.

Referenced by negotiate().

#define NBD_OPT_LIST   (3) /** Client request list of supported exports (not followed by data) */

Definition at line 91 of file cliserv.h.

Referenced by ask_list(), and negotiate().

#define NBD_REP_ACK   (1) /** ACK a request. Data: option number to be acked */

Definition at line 94 of file cliserv.h.

Referenced by ask_list(), and handle_list().

#define NBD_REP_ERR_INVALID   (3 | NBD_REP_FLAG_ERROR) /** Client issued an invalid request */

Definition at line 99 of file cliserv.h.

Referenced by handle_list().

#define NBD_REP_ERR_PLATFORM   (4 | NBD_REP_FLAG_ERROR) /** Option not supported on this platform */

Definition at line 100 of file cliserv.h.

#define NBD_REP_ERR_POLICY   (2 | NBD_REP_FLAG_ERROR) /** Client requested an option not allowed by server configuration. (e.g., the option was disabled) */

Definition at line 98 of file cliserv.h.

Referenced by ask_list(), and handle_list().

#define NBD_REP_ERR_UNSUP   (1 | NBD_REP_FLAG_ERROR) /** Client requested an option not understood by this version of the server */

Definition at line 97 of file cliserv.h.

Referenced by negotiate().

#define NBD_REP_FLAG_ERROR   (1 << 31) /** If the high bit is set, the reply is an error */

Definition at line 96 of file cliserv.h.

Referenced by ask_list().

#define NBD_REP_SERVER   (2) /** Reply to NBD_OPT_LIST (one of these per server; must be followed by NBD_REP_ACK to signal the end of the list */

Definition at line 95 of file cliserv.h.

Referenced by ask_list(), and handle_list().

Function Documentation

void err ( const char *  s)
void err_nonfatal ( const char *  s)

Definition at line 30 of file cliserv.c.

Referenced by err(), handle_list(), negotiate(), opennet(), openunix(), and socket_accept().

void logging ( const char *  name)

Definition at line 61 of file cliserv.c.

References ntohll().

Referenced by main().

uint64_t ntohll ( uint64_t  a)
void setmysockopt ( int  sock)

Definition at line 12 of file cliserv.c.

References INFO.

Referenced by opennet(), and serveconnection().

Variable Documentation

const u64 cliserv_magic

Definition at line 8 of file cliserv.c.

Referenced by negotiate().

const u64 opts_magic

Definition at line 9 of file cliserv.c.

Referenced by ask_list(), and negotiate().

const u64 rep_magic

Definition at line 10 of file cliserv.c.

Referenced by ask_list().