File: libnbd.h

package info (click to toggle)
libnbd 1.22.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,636 kB
  • sloc: ansic: 53,855; ml: 12,311; sh: 8,499; python: 4,595; makefile: 2,902; perl: 165; cpp: 24
file content (1213 lines) | stat: -rw-r--r-- 37,463 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
/* NBD client library in userspace
 * WARNING: THIS FILE IS GENERATED FROM
 * generator/generator
 * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
 *
 * Copyright Red Hat
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#ifndef LIBNBD_H
#define LIBNBD_H

/* This is the public interface to libnbd, a client library for
 * accessing Network Block Device (NBD) servers.
 *
 * Please read the libnbd(3) manual page to
 * find out how to use this library.
 */

#include <stdbool.h>
#include <stdint.h>
#include <sys/socket.h>

#ifdef __cplusplus
extern "C" {
#endif

#if defined (__GNUC__)
#define LIBNBD_GCC_VERSION \
    (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif

#ifndef LIBNBD_ATTRIBUTE_NONNULL
#if defined (__GNUC__) && LIBNBD_GCC_VERSION >= 120000 /* gcc >= 12.0 */
#define LIBNBD_ATTRIBUTE_NONNULL(...) \
  __attribute__ ((__nonnull__ (__VA_ARGS__)))
#else
#define LIBNBD_ATTRIBUTE_NONNULL(...)
#endif
#endif /* ! defined LIBNBD_ATTRIBUTE_NONNULL */

#if defined (__GNUC__) && LIBNBD_GCC_VERSION >= 120000 /* gcc >= 12.0 */
#define LIBNBD_ATTRIBUTE_ALLOC_DEALLOC(fn) \
  __attribute__ ((__malloc__, __malloc__ (fn, 1)))
#else
#define LIBNBD_ATTRIBUTE_ALLOC_DEALLOC(fn)
#endif

struct nbd_handle;

#define LIBNBD_TLS_DISABLE                       0
#define LIBNBD_TLS_ALLOW                         1
#define LIBNBD_TLS_REQUIRE                       2

#define LIBNBD_SIZE_MINIMUM                      0
#define LIBNBD_SIZE_PREFERRED                    1
#define LIBNBD_SIZE_MAXIMUM                      2
#define LIBNBD_SIZE_PAYLOAD                      3

#define LIBNBD_CMD_FLAG_FUA                      0x01U
#define LIBNBD_CMD_FLAG_NO_HOLE                  0x02U
#define LIBNBD_CMD_FLAG_DF                       0x04U
#define LIBNBD_CMD_FLAG_REQ_ONE                  0x08U
#define LIBNBD_CMD_FLAG_FAST_ZERO                0x10U
#define LIBNBD_CMD_FLAG_PAYLOAD_LEN              0x20U
#define LIBNBD_CMD_FLAG_MASK                     0x3fU

#define LIBNBD_HANDSHAKE_FLAG_FIXED_NEWSTYLE     0x01U
#define LIBNBD_HANDSHAKE_FLAG_NO_ZEROES          0x02U
#define LIBNBD_HANDSHAKE_FLAG_MASK               0x03U

#define LIBNBD_STRICT_COMMANDS                   0x01U
#define LIBNBD_STRICT_FLAGS                      0x02U
#define LIBNBD_STRICT_BOUNDS                     0x04U
#define LIBNBD_STRICT_ZERO_SIZE                  0x08U
#define LIBNBD_STRICT_ALIGN                      0x10U
#define LIBNBD_STRICT_PAYLOAD                    0x20U
#define LIBNBD_STRICT_AUTO_FLAG                  0x40U
#define LIBNBD_STRICT_MASK                       0x7fU

#define LIBNBD_ALLOW_TRANSPORT_TCP               0x01U
#define LIBNBD_ALLOW_TRANSPORT_UNIX              0x02U
#define LIBNBD_ALLOW_TRANSPORT_VSOCK             0x04U
#define LIBNBD_ALLOW_TRANSPORT_SSH               0x08U
#define LIBNBD_ALLOW_TRANSPORT_MASK              0x0fU

#define LIBNBD_SHUTDOWN_ABANDON_PENDING          0x10000U
#define LIBNBD_SHUTDOWN_MASK                     0x10000U

#define LIBNBD_AIO_DIRECTION_READ                1
#define LIBNBD_AIO_DIRECTION_WRITE               2
#define LIBNBD_AIO_DIRECTION_BOTH                3
#define LIBNBD_READ_DATA                         1
#define LIBNBD_READ_HOLE                         2
#define LIBNBD_READ_ERROR                        3

extern void nbd_close (struct nbd_handle *h); /* h can be NULL */
#define LIBNBD_HAVE_NBD_CLOSE 1

extern struct nbd_handle *nbd_create (void)
    LIBNBD_ATTRIBUTE_ALLOC_DEALLOC (nbd_close);
#define LIBNBD_HAVE_NBD_CREATE 1

extern const char *nbd_get_error (void);
#define LIBNBD_HAVE_NBD_GET_ERROR 1

extern int nbd_get_errno (void);
#define LIBNBD_HAVE_NBD_GET_ERRNO 1

/* This is used in the callback for nbd_block_status_64.
 */
typedef struct {
  uint64_t length;  /* Will not exceed INT64_MAX */
  uint64_t flags;
} nbd_extent;

/* These are used for callback parameters.  They are passed
 * by value not by reference.  See CALLBACKS in libnbd(3).
 */
typedef struct {
  int (*callback) (void *user_data, const void *subbuf, size_t count,
                   uint64_t offset, unsigned status, int *error);
  void *user_data;
  void (*free) (void *user_data);
} nbd_chunk_callback;
#define LIBNBD_HAVE_NBD_CHUNK_CALLBACK 1

typedef struct {
  int (*callback) (void *user_data, int *error);
  void *user_data;
  void (*free) (void *user_data);
} nbd_completion_callback;
#define LIBNBD_HAVE_NBD_COMPLETION_CALLBACK 1

typedef struct {
  int (*callback) (void *user_data, const char *context, const char *msg);
  void *user_data;
  void (*free) (void *user_data);
} nbd_debug_callback;
#define LIBNBD_HAVE_NBD_DEBUG_CALLBACK 1

typedef struct {
  int (*callback) (void *user_data, const char *metacontext,
                   uint64_t offset, uint32_t *entries, size_t nr_entries,
                   int *error);
  void *user_data;
  void (*free) (void *user_data);
} nbd_extent_callback;
#define LIBNBD_HAVE_NBD_EXTENT_CALLBACK 1

typedef struct {
  int (*callback) (void *user_data, const char *metacontext,
                   uint64_t offset, nbd_extent *entries, size_t nr_entries,
                   int *error);
  void *user_data;
  void (*free) (void *user_data);
} nbd_extent64_callback;
#define LIBNBD_HAVE_NBD_EXTENT64_CALLBACK 1

typedef struct {
  int (*callback) (void *user_data, const char *name,
                   const char *description);
  void *user_data;
  void (*free) (void *user_data);
} nbd_list_callback;
#define LIBNBD_HAVE_NBD_LIST_CALLBACK 1

typedef struct {
  int (*callback) (void *user_data, const char *name);
  void *user_data;
  void (*free) (void *user_data);
} nbd_context_callback;
#define LIBNBD_HAVE_NBD_CONTEXT_CALLBACK 1

/* Note NBD_NULL_* are only generated for callbacks which are
 * optional.  (See OClosure in the generator).
 */
#define NBD_NULL_COMPLETION ((nbd_completion_callback) { .callback = NULL })

extern int nbd_set_debug (
             struct nbd_handle *h, bool debug
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_DEBUG 1

extern int nbd_get_debug (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_DEBUG 1

extern int nbd_set_debug_callback (
             struct nbd_handle *h, nbd_debug_callback debug_callback
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_DEBUG_CALLBACK 1

extern int nbd_clear_debug_callback (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_CLEAR_DEBUG_CALLBACK 1

extern uint64_t nbd_stats_bytes_sent (
                  struct nbd_handle *h
                )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_STATS_BYTES_SENT 1

extern uint64_t nbd_stats_chunks_sent (
                  struct nbd_handle *h
                )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_STATS_CHUNKS_SENT 1

extern uint64_t nbd_stats_bytes_received (
                  struct nbd_handle *h
                )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_STATS_BYTES_RECEIVED 1

extern uint64_t nbd_stats_chunks_received (
                  struct nbd_handle *h
                )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_STATS_CHUNKS_RECEIVED 1

extern int nbd_set_handle_name (
             struct nbd_handle *h, const char *handle_name
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_SET_HANDLE_NAME 1

extern char * nbd_get_handle_name (
                struct nbd_handle *h
              )
    LIBNBD_ATTRIBUTE_ALLOC_DEALLOC (__builtin_free)
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_HANDLE_NAME 1

extern uintptr_t nbd_set_private_data (
                   struct nbd_handle *h, uintptr_t private_data
                 )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_PRIVATE_DATA 1

extern uintptr_t nbd_get_private_data (
                   struct nbd_handle *h
                 )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_PRIVATE_DATA 1

extern int nbd_set_export_name (
             struct nbd_handle *h, const char *export_name
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_SET_EXPORT_NAME 1

extern char * nbd_get_export_name (
                struct nbd_handle *h
              )
    LIBNBD_ATTRIBUTE_ALLOC_DEALLOC (__builtin_free)
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_EXPORT_NAME 1

extern int nbd_set_request_block_size (
             struct nbd_handle *h, bool request
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_REQUEST_BLOCK_SIZE 1

extern int nbd_get_request_block_size (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_REQUEST_BLOCK_SIZE 1

extern int nbd_set_full_info (
             struct nbd_handle *h, bool request
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_FULL_INFO 1

extern int nbd_get_full_info (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_FULL_INFO 1

extern char * nbd_get_canonical_export_name (
                struct nbd_handle *h
              )
    LIBNBD_ATTRIBUTE_ALLOC_DEALLOC (__builtin_free)
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_CANONICAL_EXPORT_NAME 1

extern char * nbd_get_export_description (
                struct nbd_handle *h
              )
    LIBNBD_ATTRIBUTE_ALLOC_DEALLOC (__builtin_free)
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_EXPORT_DESCRIPTION 1

extern int nbd_set_tls (
             struct nbd_handle *h, int tls
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_TLS 1

extern int nbd_get_tls (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_TLS 1

extern int nbd_get_tls_negotiated (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_TLS_NEGOTIATED 1

extern int nbd_set_tls_certificates (
             struct nbd_handle *h, const char *dir
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_SET_TLS_CERTIFICATES 1

extern int nbd_set_tls_verify_peer (
             struct nbd_handle *h, bool verify
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_TLS_VERIFY_PEER 1

extern int nbd_get_tls_verify_peer (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_TLS_VERIFY_PEER 1

extern int nbd_set_tls_username (
             struct nbd_handle *h, const char *username
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_SET_TLS_USERNAME 1

extern char * nbd_get_tls_username (
                struct nbd_handle *h
              )
    LIBNBD_ATTRIBUTE_ALLOC_DEALLOC (__builtin_free)
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_TLS_USERNAME 1

extern int nbd_set_tls_hostname (
             struct nbd_handle *h, const char *hostname
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_SET_TLS_HOSTNAME 1

extern char * nbd_get_tls_hostname (
                struct nbd_handle *h
              )
    LIBNBD_ATTRIBUTE_ALLOC_DEALLOC (__builtin_free)
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_TLS_HOSTNAME 1

extern int nbd_set_tls_psk_file (
             struct nbd_handle *h, const char *filename
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_SET_TLS_PSK_FILE 1

extern int nbd_set_request_extended_headers (
             struct nbd_handle *h, bool request
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_REQUEST_EXTENDED_HEADERS 1

extern int nbd_get_request_extended_headers (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_REQUEST_EXTENDED_HEADERS 1

extern int nbd_get_extended_headers_negotiated (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_EXTENDED_HEADERS_NEGOTIATED 1

extern int nbd_set_request_structured_replies (
             struct nbd_handle *h, bool request
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_REQUEST_STRUCTURED_REPLIES 1

extern int nbd_get_request_structured_replies (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_REQUEST_STRUCTURED_REPLIES 1

extern int nbd_get_structured_replies_negotiated (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_STRUCTURED_REPLIES_NEGOTIATED 1

extern int nbd_set_request_meta_context (
             struct nbd_handle *h, bool request
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_REQUEST_META_CONTEXT 1

extern int nbd_get_request_meta_context (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_REQUEST_META_CONTEXT 1

extern int nbd_set_handshake_flags (
             struct nbd_handle *h, uint32_t flags
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_HANDSHAKE_FLAGS 1

extern uint32_t nbd_get_handshake_flags (
                  struct nbd_handle *h
                )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_HANDSHAKE_FLAGS 1

extern int nbd_set_pread_initialize (
             struct nbd_handle *h, bool request
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_PREAD_INITIALIZE 1

extern int nbd_get_pread_initialize (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_PREAD_INITIALIZE 1

extern int nbd_set_strict_mode (
             struct nbd_handle *h, uint32_t flags
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_STRICT_MODE 1

extern uint32_t nbd_get_strict_mode (
                  struct nbd_handle *h
                )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_STRICT_MODE 1

extern int nbd_set_opt_mode (
             struct nbd_handle *h, bool enable
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_OPT_MODE 1

extern int nbd_get_opt_mode (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_OPT_MODE 1

extern int nbd_opt_go (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_OPT_GO 1

extern int nbd_opt_abort (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_OPT_ABORT 1

extern int nbd_opt_starttls (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_OPT_STARTTLS 1

extern int nbd_opt_extended_headers (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_OPT_EXTENDED_HEADERS 1

extern int nbd_opt_structured_reply (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_OPT_STRUCTURED_REPLY 1

extern int nbd_opt_list (
             struct nbd_handle *h, nbd_list_callback list_callback
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_OPT_LIST 1

extern int nbd_opt_info (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_OPT_INFO 1

extern int nbd_opt_list_meta_context (
             struct nbd_handle *h, nbd_context_callback context_callback
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_OPT_LIST_META_CONTEXT 1

extern int nbd_opt_list_meta_context_queries (
             struct nbd_handle *h, char **queries,
             nbd_context_callback context_callback
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_OPT_LIST_META_CONTEXT_QUERIES 1

extern int nbd_opt_set_meta_context (
             struct nbd_handle *h, nbd_context_callback context_callback
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_OPT_SET_META_CONTEXT 1

extern int nbd_opt_set_meta_context_queries (
             struct nbd_handle *h, char **queries,
             nbd_context_callback context_callback
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_OPT_SET_META_CONTEXT_QUERIES 1

extern int nbd_add_meta_context (
             struct nbd_handle *h, const char *name
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_ADD_META_CONTEXT 1

extern ssize_t nbd_get_nr_meta_contexts (
                 struct nbd_handle *h
               )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_NR_META_CONTEXTS 1

extern char * nbd_get_meta_context (
                struct nbd_handle *h, size_t i
              )
    LIBNBD_ATTRIBUTE_ALLOC_DEALLOC (__builtin_free)
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_META_CONTEXT 1

extern int nbd_clear_meta_contexts (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_CLEAR_META_CONTEXTS 1

extern int nbd_set_uri_allow_transports (
             struct nbd_handle *h, uint32_t mask
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_URI_ALLOW_TRANSPORTS 1

extern int nbd_set_uri_allow_tls (
             struct nbd_handle *h, int tls
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_URI_ALLOW_TLS 1

extern int nbd_set_uri_allow_local_file (
             struct nbd_handle *h, bool allow
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SET_URI_ALLOW_LOCAL_FILE 1

extern int nbd_connect_uri (
             struct nbd_handle *h, const char *uri
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_CONNECT_URI 1

extern int nbd_connect_unix (
             struct nbd_handle *h, const char *unixsocket
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_CONNECT_UNIX 1

extern int nbd_connect_vsock (
             struct nbd_handle *h, uint32_t cid, uint32_t port
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_CONNECT_VSOCK 1

extern int nbd_connect_tcp (
             struct nbd_handle *h, const char *hostname, const char *port
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2, 3);
#define LIBNBD_HAVE_NBD_CONNECT_TCP 1

extern int nbd_connect_socket (
             struct nbd_handle *h, int sock
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_CONNECT_SOCKET 1

extern int nbd_connect_command (
             struct nbd_handle *h, char **argv
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_CONNECT_COMMAND 1

extern int nbd_connect_systemd_socket_activation (
             struct nbd_handle *h, char **argv
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_CONNECT_SYSTEMD_SOCKET_ACTIVATION 1

extern int nbd_set_socket_activation_name (
             struct nbd_handle *h, const char *socket_name
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_SET_SOCKET_ACTIVATION_NAME 1

extern char * nbd_get_socket_activation_name (
                struct nbd_handle *h
              )
    LIBNBD_ATTRIBUTE_ALLOC_DEALLOC (__builtin_free)
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_SOCKET_ACTIVATION_NAME 1

extern int nbd_is_read_only (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_IS_READ_ONLY 1

extern int nbd_can_flush (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_CAN_FLUSH 1

extern int nbd_can_fua (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_CAN_FUA 1

extern int nbd_is_rotational (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_IS_ROTATIONAL 1

extern int nbd_can_trim (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_CAN_TRIM 1

extern int nbd_can_zero (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_CAN_ZERO 1

extern int nbd_can_fast_zero (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_CAN_FAST_ZERO 1

extern int nbd_can_block_status_payload (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_CAN_BLOCK_STATUS_PAYLOAD 1

extern int nbd_can_df (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_CAN_DF 1

extern int nbd_can_multi_conn (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_CAN_MULTI_CONN 1

extern int nbd_can_cache (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_CAN_CACHE 1

extern int nbd_can_meta_context (
             struct nbd_handle *h, const char *metacontext
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_CAN_META_CONTEXT 1

extern const char * nbd_get_protocol (
                      struct nbd_handle *h
                    )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_PROTOCOL 1

extern int64_t nbd_get_size (
                 struct nbd_handle *h
               )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_SIZE 1

extern int64_t nbd_get_block_size (
                 struct nbd_handle *h, int size_type
               )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_BLOCK_SIZE 1

extern int nbd_pread (
             struct nbd_handle *h, void *buf, size_t count, uint64_t offset,
             uint32_t flags
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_PREAD 1

extern int nbd_pread_structured (
             struct nbd_handle *h, void *buf, size_t count, uint64_t offset,
             nbd_chunk_callback chunk_callback, uint32_t flags
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_PREAD_STRUCTURED 1

extern int nbd_pwrite (
             struct nbd_handle *h, const void *buf, size_t count,
             uint64_t offset, uint32_t flags
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_PWRITE 1

extern int nbd_shutdown (
             struct nbd_handle *h, uint32_t flags
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SHUTDOWN 1

extern int nbd_flush (
             struct nbd_handle *h, uint32_t flags
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_FLUSH 1

extern int nbd_trim (
             struct nbd_handle *h, uint64_t count, uint64_t offset,
             uint32_t flags
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_TRIM 1

extern int nbd_cache (
             struct nbd_handle *h, uint64_t count, uint64_t offset,
             uint32_t flags
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_CACHE 1

extern int nbd_zero (
             struct nbd_handle *h, uint64_t count, uint64_t offset,
             uint32_t flags
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_ZERO 1

extern int nbd_block_status (
             struct nbd_handle *h, uint64_t count, uint64_t offset,
             nbd_extent_callback extent_callback, uint32_t flags
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_BLOCK_STATUS 1

extern int nbd_block_status_64 (
             struct nbd_handle *h, uint64_t count, uint64_t offset,
             nbd_extent64_callback extent64_callback, uint32_t flags
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_BLOCK_STATUS_64 1

extern int nbd_block_status_filter (
             struct nbd_handle *h, uint64_t count, uint64_t offset,
             char **contexts, nbd_extent64_callback extent64_callback,
             uint32_t flags
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 4);
#define LIBNBD_HAVE_NBD_BLOCK_STATUS_FILTER 1

extern int nbd_poll (
             struct nbd_handle *h, int timeout
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_POLL 1

extern int nbd_poll2 (
             struct nbd_handle *h, int fd, int timeout
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_POLL2 1

extern int nbd_aio_connect (
             struct nbd_handle *h, const struct sockaddr *addr,
             socklen_t addrlen
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_AIO_CONNECT 1

extern int nbd_aio_connect_uri (
             struct nbd_handle *h, const char *uri
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_AIO_CONNECT_URI 1

extern int nbd_aio_connect_unix (
             struct nbd_handle *h, const char *unixsocket
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_AIO_CONNECT_UNIX 1

extern int nbd_aio_connect_vsock (
             struct nbd_handle *h, uint32_t cid, uint32_t port
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_CONNECT_VSOCK 1

extern int nbd_aio_connect_tcp (
             struct nbd_handle *h, const char *hostname, const char *port
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2, 3);
#define LIBNBD_HAVE_NBD_AIO_CONNECT_TCP 1

extern int nbd_aio_connect_socket (
             struct nbd_handle *h, int sock
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_CONNECT_SOCKET 1

extern int nbd_aio_connect_command (
             struct nbd_handle *h, char **argv
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_AIO_CONNECT_COMMAND 1

extern int nbd_aio_connect_systemd_socket_activation (
             struct nbd_handle *h, char **argv
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_AIO_CONNECT_SYSTEMD_SOCKET_ACTIVATION 1

extern int nbd_aio_opt_go (
             struct nbd_handle *h,
             nbd_completion_callback completion_callback
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_OPT_GO 1

extern int nbd_aio_opt_abort (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_OPT_ABORT 1

extern int nbd_aio_opt_starttls (
             struct nbd_handle *h,
             nbd_completion_callback completion_callback
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_OPT_STARTTLS 1

extern int nbd_aio_opt_extended_headers (
             struct nbd_handle *h,
             nbd_completion_callback completion_callback
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_OPT_EXTENDED_HEADERS 1

extern int nbd_aio_opt_structured_reply (
             struct nbd_handle *h,
             nbd_completion_callback completion_callback
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_OPT_STRUCTURED_REPLY 1

extern int nbd_aio_opt_list (
             struct nbd_handle *h, nbd_list_callback list_callback,
             nbd_completion_callback completion_callback
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_OPT_LIST 1

extern int nbd_aio_opt_info (
             struct nbd_handle *h,
             nbd_completion_callback completion_callback
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_OPT_INFO 1

extern int nbd_aio_opt_list_meta_context (
             struct nbd_handle *h, nbd_context_callback context_callback,
             nbd_completion_callback completion_callback
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_OPT_LIST_META_CONTEXT 1

extern int nbd_aio_opt_list_meta_context_queries (
             struct nbd_handle *h, char **queries,
             nbd_context_callback context_callback,
             nbd_completion_callback completion_callback
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_AIO_OPT_LIST_META_CONTEXT_QUERIES 1

extern int nbd_aio_opt_set_meta_context (
             struct nbd_handle *h, nbd_context_callback context_callback,
             nbd_completion_callback completion_callback
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_OPT_SET_META_CONTEXT 1

extern int nbd_aio_opt_set_meta_context_queries (
             struct nbd_handle *h, char **queries,
             nbd_context_callback context_callback,
             nbd_completion_callback completion_callback
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_AIO_OPT_SET_META_CONTEXT_QUERIES 1

extern int64_t nbd_aio_pread (
                 struct nbd_handle *h, void *buf, size_t count,
                 uint64_t offset,
                 nbd_completion_callback completion_callback,
                 uint32_t flags
               )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_AIO_PREAD 1

extern int64_t nbd_aio_pread_structured (
                 struct nbd_handle *h, void *buf, size_t count,
                 uint64_t offset, nbd_chunk_callback chunk_callback,
                 nbd_completion_callback completion_callback,
                 uint32_t flags
               )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_AIO_PREAD_STRUCTURED 1

extern int64_t nbd_aio_pwrite (
                 struct nbd_handle *h, const void *buf, size_t count,
                 uint64_t offset,
                 nbd_completion_callback completion_callback,
                 uint32_t flags
               )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_AIO_PWRITE 1

extern int nbd_aio_disconnect (
             struct nbd_handle *h, uint32_t flags
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_DISCONNECT 1

extern int64_t nbd_aio_flush (
                 struct nbd_handle *h,
                 nbd_completion_callback completion_callback,
                 uint32_t flags
               )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_FLUSH 1

extern int64_t nbd_aio_trim (
                 struct nbd_handle *h, uint64_t count, uint64_t offset,
                 nbd_completion_callback completion_callback,
                 uint32_t flags
               )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_TRIM 1

extern int64_t nbd_aio_cache (
                 struct nbd_handle *h, uint64_t count, uint64_t offset,
                 nbd_completion_callback completion_callback,
                 uint32_t flags
               )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_CACHE 1

extern int64_t nbd_aio_zero (
                 struct nbd_handle *h, uint64_t count, uint64_t offset,
                 nbd_completion_callback completion_callback,
                 uint32_t flags
               )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_ZERO 1

extern int64_t nbd_aio_block_status (
                 struct nbd_handle *h, uint64_t count, uint64_t offset,
                 nbd_extent_callback extent_callback,
                 nbd_completion_callback completion_callback,
                 uint32_t flags
               )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_BLOCK_STATUS 1

extern int64_t nbd_aio_block_status_64 (
                 struct nbd_handle *h, uint64_t count, uint64_t offset,
                 nbd_extent64_callback extent64_callback,
                 nbd_completion_callback completion_callback,
                 uint32_t flags
               )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_BLOCK_STATUS_64 1

extern int64_t nbd_aio_block_status_filter (
                 struct nbd_handle *h, uint64_t count, uint64_t offset,
                 char **contexts, nbd_extent64_callback extent64_callback,
                 nbd_completion_callback completion_callback,
                 uint32_t flags
               )
    LIBNBD_ATTRIBUTE_NONNULL (1, 4);
#define LIBNBD_HAVE_NBD_AIO_BLOCK_STATUS_FILTER 1

extern int nbd_aio_get_fd (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_GET_FD 1

extern unsigned nbd_aio_get_direction (
                  struct nbd_handle *h
                )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_GET_DIRECTION 1

extern int nbd_aio_notify_read (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_NOTIFY_READ 1

extern int nbd_aio_notify_write (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_NOTIFY_WRITE 1

extern int nbd_aio_is_created (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_IS_CREATED 1

extern int nbd_aio_is_connecting (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_IS_CONNECTING 1

extern int nbd_aio_is_negotiating (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_IS_NEGOTIATING 1

extern int nbd_aio_is_ready (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_IS_READY 1

extern int nbd_aio_is_processing (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_IS_PROCESSING 1

extern int nbd_aio_is_dead (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_IS_DEAD 1

extern int nbd_aio_is_closed (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_IS_CLOSED 1

extern int nbd_aio_command_completed (
             struct nbd_handle *h, uint64_t cookie
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_COMMAND_COMPLETED 1

extern int64_t nbd_aio_peek_command_completed (
                 struct nbd_handle *h
               )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_PEEK_COMMAND_COMPLETED 1

extern int nbd_aio_in_flight (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_AIO_IN_FLIGHT 1

extern const char * nbd_connection_state (
                      struct nbd_handle *h
                    )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_CONNECTION_STATE 1

extern const char * nbd_get_package_name (
                      struct nbd_handle *h
                    )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_PACKAGE_NAME 1

extern const char * nbd_get_version (
                      struct nbd_handle *h
                    )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_VERSION 1

extern int nbd_kill_subprocess (
             struct nbd_handle *h, int signum
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_KILL_SUBPROCESS 1

extern int64_t nbd_get_subprocess_pid (
                 struct nbd_handle *h
               )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_SUBPROCESS_PID 1

extern int nbd_supports_tls (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SUPPORTS_TLS 1

extern int nbd_supports_vsock (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SUPPORTS_VSOCK 1

extern int nbd_supports_uri (
             struct nbd_handle *h
           )
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_SUPPORTS_URI 1

extern char * nbd_get_uri (
                struct nbd_handle *h
              )
    LIBNBD_ATTRIBUTE_ALLOC_DEALLOC (__builtin_free)
    LIBNBD_ATTRIBUTE_NONNULL (1);
#define LIBNBD_HAVE_NBD_GET_URI 1

extern int nbd_is_uri (
             struct nbd_handle *h, const char *uri
           )
    LIBNBD_ATTRIBUTE_NONNULL (1, 2);
#define LIBNBD_HAVE_NBD_IS_URI 1

/* "base" namespace */
#define LIBNBD_NAMESPACE_BASE "base:"

/* "base" namespace contexts */
#define LIBNBD_CONTEXT_BASE_ALLOCATION "base:allocation"

/* "base:allocation" context related constants */
#define LIBNBD_STATE_HOLE                     1
#define LIBNBD_STATE_ZERO                     2

/* "qemu" namespace */
#define LIBNBD_NAMESPACE_QEMU "qemu:"

/* "qemu" namespace contexts */
#define LIBNBD_CONTEXT_QEMU_DIRTY_BITMAP "qemu:dirty-bitmap:"
#define LIBNBD_CONTEXT_QEMU_ALLOCATION_DEPTH "qemu:allocation-depth"

/* "qemu:dirty-bitmap:" context related constants */
#define LIBNBD_STATE_DIRTY                    1

#ifdef __cplusplus
}
#endif

#endif /* LIBNBD_H */