Network Block Device @PACKAGE_VERSION@
Defines | 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.

Defines

#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   "10809"
#define NBD_OPT_EXPORT_NAME   (1)
#define NBD_OPT_ABORT   (2)
#define NBD_OPT_LIST   (3)
#define NBD_REP_ACK   (1)
#define NBD_REP_SERVER   (2)
#define NBD_REP_FLAG_ERROR   (1 << 31)
#define NBD_REP_ERR_UNSUP   (1 | NBD_REP_FLAG_ERROR)
#define NBD_REP_ERR_POLICY   (2 | NBD_REP_FLAG_ERROR)
#define NBD_REP_ERR_INVALID   (3 | NBD_REP_FLAG_ERROR)
#define NBD_REP_ERR_PLATFORM   (4 | NBD_REP_FLAG_ERROR)
#define NBD_FLAG_FIXED_NEWSTYLE   (1 << 0)
#define NBD_FLAG_NO_ZEROES   (1 << 1)
#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)
void readit (int f, void *buf, size_t len)
 Read data from a file descriptor into a buffer.

Variables

const u64 cliserv_magic
const u64 opts_magic
const u64 rep_magic

Define 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.

#define G_GNUC_UNUSED

Definition at line 63 of file cliserv.h.

Referenced by main().

#define htonll   ntohll

Definition at line 86 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   "10809"

Definition at line 91 of file cliserv.h.

Referenced by main(), and open_modern().

#define NBD_FLAG_C_FIXED_NEWSTYLE   NBD_FLAG_FIXED_NEWSTYLE

Definition at line 112 of file cliserv.h.

Referenced by main().

#define NBD_FLAG_C_NO_ZEROES   NBD_FLAG_NO_ZEROES

Definition at line 113 of file cliserv.h.

Referenced by negotiate().

#define NBD_FLAG_FIXED_NEWSTYLE   (1 << 0)

Definition at line 109 of file cliserv.h.

Referenced by main(), and negotiate().

#define NBD_FLAG_NO_ZEROES   (1 << 1)

Definition at line 110 of file cliserv.h.

Referenced by negotiate().

#define NBD_OPT_ABORT   (2)

Definition at line 96 of file cliserv.h.

Referenced by ask_list(), and negotiate().

#define NBD_OPT_EXPORT_NAME   (1)

Definition at line 95 of file cliserv.h.

Referenced by negotiate().

#define NBD_OPT_LIST   (3)

Definition at line 97 of file cliserv.h.

Referenced by ask_list(), and negotiate().

#define NBD_REP_ACK   (1)

Definition at line 100 of file cliserv.h.

Referenced by ask_list(), and handle_list().

#define NBD_REP_ERR_INVALID   (3 | NBD_REP_FLAG_ERROR)

Definition at line 105 of file cliserv.h.

Referenced by handle_list().

#define NBD_REP_ERR_PLATFORM   (4 | NBD_REP_FLAG_ERROR)

Definition at line 106 of file cliserv.h.

#define NBD_REP_ERR_POLICY   (2 | NBD_REP_FLAG_ERROR)

Definition at line 104 of file cliserv.h.

Referenced by ask_list(), and handle_list().

#define NBD_REP_ERR_UNSUP   (1 | NBD_REP_FLAG_ERROR)

Definition at line 103 of file cliserv.h.

Referenced by negotiate().

#define NBD_REP_FLAG_ERROR   (1 << 31)

Definition at line 102 of file cliserv.h.

Referenced by ask_list().

#define NBD_REP_SERVER   (2)

Definition at line 101 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 33 of file cliserv.c.

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

void logging ( const char *  name)

Definition at line 64 of file cliserv.c.

Referenced by main().

uint64_t ntohll ( uint64_t  a)

Definition at line 78 of file cliserv.c.

Referenced by ask_list(), main(), mainloop(), mainloop_threaded(), and negotiate().

void readit ( int  f,
void *  buf,
size_t  len 
)

Read data from a file descriptor into a buffer.

Parameters:
fa file descriptor
bufa buffer
lenthe number of bytes to be read

Definition at line 95 of file cliserv.c.

References DEBUG, and err().

Referenced by consume(), mainloop(), mainloop_threaded(), and negotiate().

void setmysockopt ( int  sock)

Definition at line 15 of file cliserv.c.

References INFO.

Referenced by opennet(), and serveconnection().


Variable Documentation

const u64 cliserv_magic

Definition at line 11 of file cliserv.c.

Referenced by negotiate().

const u64 opts_magic

Definition at line 12 of file cliserv.c.

Referenced by ask_list(), and negotiate().

const u64 rep_magic

Definition at line 13 of file cliserv.c.

Referenced by ask_list().