File: states.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 (780 lines) | stat: -rw-r--r-- 28,159 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
/* NBD client library in userspace
 * WARNING: THIS FILE IS GENERATED FROM
 * generator/generator generator/states*.c
 * 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
 */

enum state {
  /* START: Handle after being initially created */
  STATE_START,

  /* CONNECT.START: Initial call to connect(2) on the socket */
  STATE_CONNECT_START,

  /* CONNECT.CONNECTING: Connecting to the remote server */
  STATE_CONNECT_CONNECTING,

  /* CONNECT_TCP.START: Connect to a remote TCP server */
  STATE_CONNECT_TCP_START,

  /* CONNECT_TCP.CONNECT: Initial call to connect(2) on a TCP socket */
  STATE_CONNECT_TCP_CONNECT,

  /* CONNECT_TCP.CONNECTING: Connecting to the remote server over a TCP socket
   */
  STATE_CONNECT_TCP_CONNECTING,

  /* CONNECT_TCP.NEXT_ADDRESS: Connecting to the next address over a TCP socket
   */
  STATE_CONNECT_TCP_NEXT_ADDRESS,

  /* CONNECT_COMMAND.START: Connect to a subprocess */
  STATE_CONNECT_COMMAND_START,

  /* CONNECT_SA.START: Connect to a subprocess with systemd socket activation */
  STATE_CONNECT_SA_START,

  /* MAGIC.START: Prepare to receive the magic identification from remote */
  STATE_MAGIC_START,

  /* MAGIC.RECV_MAGIC: Receive initial magic identification from remote */
  STATE_MAGIC_RECV_MAGIC,

  /* MAGIC.CHECK_MAGIC: Check magic and version sent by remote */
  STATE_MAGIC_CHECK_MAGIC,

  /* OLDSTYLE.START: Prepare to receive remainder of oldstyle header */
  STATE_OLDSTYLE_START,

  /* OLDSTYLE.RECV_REMAINING: Receive remainder of oldstyle header */
  STATE_OLDSTYLE_RECV_REMAINING,

  /* OLDSTYLE.CHECK: Check oldstyle header */
  STATE_OLDSTYLE_CHECK,

  /* NEWSTYLE.START: Prepare to receive newstyle gflags from remote */
  STATE_NEWSTYLE_START,

  /* NEWSTYLE.RECV_GFLAGS: Receive newstyle gflags from remote */
  STATE_NEWSTYLE_RECV_GFLAGS,

  /* NEWSTYLE.CHECK_GFLAGS: Check global flags sent by remote */
  STATE_NEWSTYLE_CHECK_GFLAGS,

  /* NEWSTYLE.SEND_CFLAGS: Send newstyle client flags to remote */
  STATE_NEWSTYLE_SEND_CFLAGS,

  /* NEWSTYLE.OPT_STARTTLS.START: Try to send newstyle NBD_OPT_STARTTLS to
   * upgrade to TLS
   */
  STATE_NEWSTYLE_OPT_STARTTLS_START,

  /* NEWSTYLE.OPT_STARTTLS.SEND: Send newstyle NBD_OPT_STARTTLS to upgrade to
   * TLS
   */
  STATE_NEWSTYLE_OPT_STARTTLS_SEND,

  /* NEWSTYLE.OPT_STARTTLS.RECV_REPLY: Receive newstyle NBD_OPT_STARTTLS reply
   */
  STATE_NEWSTYLE_OPT_STARTTLS_RECV_REPLY,

  /* NEWSTYLE.OPT_STARTTLS.RECV_REPLY_PAYLOAD: Receive any newstyle
   * NBD_OPT_STARTTLS reply payload
   */
  STATE_NEWSTYLE_OPT_STARTTLS_RECV_REPLY_PAYLOAD,

  /* NEWSTYLE.OPT_STARTTLS.CHECK_REPLY: Check newstyle NBD_OPT_STARTTLS reply */
  STATE_NEWSTYLE_OPT_STARTTLS_CHECK_REPLY,

  /* NEWSTYLE.OPT_STARTTLS.TLS_HANDSHAKE_READ: TLS handshake (reading) */
  STATE_NEWSTYLE_OPT_STARTTLS_TLS_HANDSHAKE_READ,

  /* NEWSTYLE.OPT_STARTTLS.TLS_HANDSHAKE_WRITE: TLS handshake (writing) */
  STATE_NEWSTYLE_OPT_STARTTLS_TLS_HANDSHAKE_WRITE,

  /* NEWSTYLE.OPT_STARTTLS.TLS_HANDSHAKE_DONE: TLS handshake complete */
  STATE_NEWSTYLE_OPT_STARTTLS_TLS_HANDSHAKE_DONE,

  /* NEWSTYLE.OPT_EXTENDED_HEADERS.START: Try to negotiate newstyle
   * NBD_OPT_EXTENDED_HEADERS
   */
  STATE_NEWSTYLE_OPT_EXTENDED_HEADERS_START,

  /* NEWSTYLE.OPT_EXTENDED_HEADERS.SEND: Send newstyle NBD_OPT_EXTENDED_HEADERS
   * negotiation request
   */
  STATE_NEWSTYLE_OPT_EXTENDED_HEADERS_SEND,

  /* NEWSTYLE.OPT_EXTENDED_HEADERS.RECV_REPLY: Receive newstyle
   * NBD_OPT_EXTENDED_HEADERS option reply
   */
  STATE_NEWSTYLE_OPT_EXTENDED_HEADERS_RECV_REPLY,

  /* NEWSTYLE.OPT_EXTENDED_HEADERS.RECV_REPLY_PAYLOAD: Receive any newstyle
   * NBD_OPT_EXTENDED_HEADERS reply payload
   */
  STATE_NEWSTYLE_OPT_EXTENDED_HEADERS_RECV_REPLY_PAYLOAD,

  /* NEWSTYLE.OPT_EXTENDED_HEADERS.CHECK_REPLY: Check newstyle
   * NBD_OPT_EXTENDED_HEADERS option reply
   */
  STATE_NEWSTYLE_OPT_EXTENDED_HEADERS_CHECK_REPLY,

  /* NEWSTYLE.OPT_STRUCTURED_REPLY.START: Try to negotiate newstyle
   * NBD_OPT_STRUCTURED_REPLY
   */
  STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_START,

  /* NEWSTYLE.OPT_STRUCTURED_REPLY.SEND: Send newstyle NBD_OPT_STRUCTURED_REPLY
   * negotiation request
   */
  STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_SEND,

  /* NEWSTYLE.OPT_STRUCTURED_REPLY.RECV_REPLY: Receive newstyle
   * NBD_OPT_STRUCTURED_REPLY option reply
   */
  STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_RECV_REPLY,

  /* NEWSTYLE.OPT_STRUCTURED_REPLY.RECV_REPLY_PAYLOAD: Receive any newstyle
   * NBD_OPT_STRUCTURED_REPLY reply payload
   */
  STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_RECV_REPLY_PAYLOAD,

  /* NEWSTYLE.OPT_STRUCTURED_REPLY.CHECK_REPLY: Check newstyle
   * NBD_OPT_STRUCTURED_REPLY option reply
   */
  STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_CHECK_REPLY,

  /* NEWSTYLE.OPT_META_CONTEXT.START: Try to negotiate newstyle
   * NBD_OPT_SET_META_CONTEXT
   */
  STATE_NEWSTYLE_OPT_META_CONTEXT_START,

  /* NEWSTYLE.OPT_META_CONTEXT.SEND: Send newstyle NBD_OPT_SET_META_CONTEXT */
  STATE_NEWSTYLE_OPT_META_CONTEXT_SEND,

  /* NEWSTYLE.OPT_META_CONTEXT.SEND_EXPORTNAMELEN: Send newstyle
   * NBD_OPT_SET_META_CONTEXT export name length
   */
  STATE_NEWSTYLE_OPT_META_CONTEXT_SEND_EXPORTNAMELEN,

  /* NEWSTYLE.OPT_META_CONTEXT.SEND_EXPORTNAME: Send newstyle
   * NBD_OPT_SET_META_CONTEXT export name
   */
  STATE_NEWSTYLE_OPT_META_CONTEXT_SEND_EXPORTNAME,

  /* NEWSTYLE.OPT_META_CONTEXT.SEND_NRQUERIES: Send newstyle
   * NBD_OPT_SET_META_CONTEXT number of queries
   */
  STATE_NEWSTYLE_OPT_META_CONTEXT_SEND_NRQUERIES,

  /* NEWSTYLE.OPT_META_CONTEXT.PREPARE_NEXT_QUERY: Prepare to send newstyle
   * NBD_OPT_SET_META_CONTEXT query
   */
  STATE_NEWSTYLE_OPT_META_CONTEXT_PREPARE_NEXT_QUERY,

  /* NEWSTYLE.OPT_META_CONTEXT.SEND_QUERYLEN: Send newstyle
   * NBD_OPT_SET_META_CONTEXT query length
   */
  STATE_NEWSTYLE_OPT_META_CONTEXT_SEND_QUERYLEN,

  /* NEWSTYLE.OPT_META_CONTEXT.SEND_QUERY: Send newstyle
   * NBD_OPT_SET_META_CONTEXT query
   */
  STATE_NEWSTYLE_OPT_META_CONTEXT_SEND_QUERY,

  /* NEWSTYLE.OPT_META_CONTEXT.PREPARE_FOR_REPLY: Prepare to receive newstyle
   * NBD_OPT_SET_META_CONTEXT option reply
   */
  STATE_NEWSTYLE_OPT_META_CONTEXT_PREPARE_FOR_REPLY,

  /* NEWSTYLE.OPT_META_CONTEXT.RECV_REPLY: Receive newstyle
   * NBD_OPT_SET_META_CONTEXT option reply
   */
  STATE_NEWSTYLE_OPT_META_CONTEXT_RECV_REPLY,

  /* NEWSTYLE.OPT_META_CONTEXT.RECV_REPLY_PAYLOAD: Receive newstyle
   * NBD_OPT_SET_META_CONTEXT option reply payload
   */
  STATE_NEWSTYLE_OPT_META_CONTEXT_RECV_REPLY_PAYLOAD,

  /* NEWSTYLE.OPT_META_CONTEXT.CHECK_REPLY: Check newstyle
   * NBD_OPT_SET_META_CONTEXT option reply
   */
  STATE_NEWSTYLE_OPT_META_CONTEXT_CHECK_REPLY,

  /* NEWSTYLE.OPT_GO.START: Try to send newstyle NBD_OPT_GO to end handshake */
  STATE_NEWSTYLE_OPT_GO_START,

  /* NEWSTYLE.OPT_GO.SEND: Send newstyle NBD_OPT_GO to end handshake */
  STATE_NEWSTYLE_OPT_GO_SEND,

  /* NEWSTYLE.OPT_GO.SEND_EXPORTNAMELEN: Send newstyle NBD_OPT_GO export name
   * length
   */
  STATE_NEWSTYLE_OPT_GO_SEND_EXPORTNAMELEN,

  /* NEWSTYLE.OPT_GO.SEND_EXPORT: Send newstyle NBD_OPT_GO export name */
  STATE_NEWSTYLE_OPT_GO_SEND_EXPORT,

  /* NEWSTYLE.OPT_GO.SEND_NRINFOS: Send newstyle NBD_OPT_GO number of infos */
  STATE_NEWSTYLE_OPT_GO_SEND_NRINFOS,

  /* NEWSTYLE.OPT_GO.SEND_INFO: Send newstyle NBD_OPT_GO request for
   * NBD_INFO_BLOCK_SIZE
   */
  STATE_NEWSTYLE_OPT_GO_SEND_INFO,

  /* NEWSTYLE.OPT_GO.RECV_REPLY: Receive newstyle NBD_OPT_GO reply */
  STATE_NEWSTYLE_OPT_GO_RECV_REPLY,

  /* NEWSTYLE.OPT_GO.RECV_REPLY_PAYLOAD: Receive newstyle NBD_OPT_GO reply
   * payload
   */
  STATE_NEWSTYLE_OPT_GO_RECV_REPLY_PAYLOAD,

  /* NEWSTYLE.OPT_GO.CHECK_REPLY: Check newstyle NBD_OPT_GO reply */
  STATE_NEWSTYLE_OPT_GO_CHECK_REPLY,

  /* NEWSTYLE.OPT_EXPORT_NAME.START: Try to send newstyle NBD_OPT_EXPORT_NAME to
   * end handshake
   */
  STATE_NEWSTYLE_OPT_EXPORT_NAME_START,

  /* NEWSTYLE.OPT_EXPORT_NAME.SEND: Send newstyle NBD_OPT_EXPORT_NAME to end
   * handshake
   */
  STATE_NEWSTYLE_OPT_EXPORT_NAME_SEND,

  /* NEWSTYLE.OPT_EXPORT_NAME.SEND_EXPORT: Send newstyle NBD_OPT_EXPORT_NAME
   * export name
   */
  STATE_NEWSTYLE_OPT_EXPORT_NAME_SEND_EXPORT,

  /* NEWSTYLE.OPT_EXPORT_NAME.RECV_REPLY: Receive newstyle NBD_OPT_EXPORT_NAME
   * reply
   */
  STATE_NEWSTYLE_OPT_EXPORT_NAME_RECV_REPLY,

  /* NEWSTYLE.OPT_EXPORT_NAME.CHECK_REPLY: Check newstyle NBD_OPT_EXPORT_NAME
   * reply
   */
  STATE_NEWSTYLE_OPT_EXPORT_NAME_CHECK_REPLY,

  /* NEWSTYLE.OPT_LIST.START: Start listing exports if in list mode. */
  STATE_NEWSTYLE_OPT_LIST_START,

  /* NEWSTYLE.OPT_LIST.SEND: Send newstyle NBD_OPT_LIST to begin listing exports
   */
  STATE_NEWSTYLE_OPT_LIST_SEND,

  /* NEWSTYLE.OPT_LIST.RECV_REPLY: Receive NBD_REP_SERVER reply */
  STATE_NEWSTYLE_OPT_LIST_RECV_REPLY,

  /* NEWSTYLE.OPT_LIST.RECV_REPLY_PAYLOAD: Receive NBD_REP_SERVER reply payload
   */
  STATE_NEWSTYLE_OPT_LIST_RECV_REPLY_PAYLOAD,

  /* NEWSTYLE.OPT_LIST.CHECK_REPLY: Check NBD_REP_SERVER reply */
  STATE_NEWSTYLE_OPT_LIST_CHECK_REPLY,

  /* NEWSTYLE.PREPARE_OPT_ABORT: Prepare to send NBD_OPT_ABORT */
  STATE_NEWSTYLE_PREPARE_OPT_ABORT,

  /* NEWSTYLE.SEND_OPT_ABORT: Send NBD_OPT_ABORT to end negotiation */
  STATE_NEWSTYLE_SEND_OPT_ABORT,

  /* NEWSTYLE.SEND_OPTION_SHUTDOWN: Sending write shutdown notification to the
   * remote server
   */
  STATE_NEWSTYLE_SEND_OPTION_SHUTDOWN,

  /* NEWSTYLE.FINISHED: Finish off newstyle negotiation */
  STATE_NEWSTYLE_FINISHED,

  /* NEGOTIATING: Connection is ready to negotiate an NBD option */
  STATE_NEGOTIATING,

  /* READY: Connection is ready to process NBD commands */
  STATE_READY,

  /* ISSUE_COMMAND.START: Begin issuing a command to the remote server */
  STATE_ISSUE_COMMAND_START,

  /* ISSUE_COMMAND.SEND_REQUEST: Sending a request to the remote server */
  STATE_ISSUE_COMMAND_SEND_REQUEST,

  /* ISSUE_COMMAND.PAUSE_SEND_REQUEST: Interrupt send request to receive an
   * earlier command's reply
   */
  STATE_ISSUE_COMMAND_PAUSE_SEND_REQUEST,

  /* ISSUE_COMMAND.PREPARE_WRITE_PAYLOAD: Prepare the write payload to send to
   * the remote server
   */
  STATE_ISSUE_COMMAND_PREPARE_WRITE_PAYLOAD,

  /* ISSUE_COMMAND.SEND_WRITE_PAYLOAD: Sending the write payload to the remote
   * server
   */
  STATE_ISSUE_COMMAND_SEND_WRITE_PAYLOAD,

  /* ISSUE_COMMAND.PAUSE_WRITE_PAYLOAD: Interrupt write payload to receive an
   * earlier command's reply
   */
  STATE_ISSUE_COMMAND_PAUSE_WRITE_PAYLOAD,

  /* ISSUE_COMMAND.SEND_WRITE_SHUTDOWN: Sending write shutdown notification to
   * the remote server
   */
  STATE_ISSUE_COMMAND_SEND_WRITE_SHUTDOWN,

  /* ISSUE_COMMAND.PAUSE_WRITE_SHUTDOWN: Interrupt write shutdown to receive an
   * earlier command's reply
   */
  STATE_ISSUE_COMMAND_PAUSE_WRITE_SHUTDOWN,

  /* ISSUE_COMMAND.FINISH: Finish issuing a command */
  STATE_ISSUE_COMMAND_FINISH,

  /* REPLY.START: Prepare to receive a reply from the remote server */
  STATE_REPLY_START,

  /* REPLY.RECV_REPLY: Receive a reply from the remote server */
  STATE_REPLY_RECV_REPLY,

  /* REPLY.CHECK_REPLY_MAGIC: Check if the reply has expected magic */
  STATE_REPLY_CHECK_REPLY_MAGIC,

  /* REPLY.RECV_STRUCTURED_REMAINING: Receiving the remaining part of a
   * structured reply header
   */
  STATE_REPLY_RECV_STRUCTURED_REMAINING,

  /* REPLY.SIMPLE_REPLY.START: Parse a simple reply from the server */
  STATE_REPLY_SIMPLE_REPLY_START,

  /* REPLY.SIMPLE_REPLY.RECV_READ_PAYLOAD: Receiving the read payload for a
   * simple reply
   */
  STATE_REPLY_SIMPLE_REPLY_RECV_READ_PAYLOAD,

  /* REPLY.CHUNK_REPLY.START: Start parsing a chunk reply payload from the
   * server
   */
  STATE_REPLY_CHUNK_REPLY_START,

  /* REPLY.CHUNK_REPLY.RECV_ERROR: Receive a chunk reply error header */
  STATE_REPLY_CHUNK_REPLY_RECV_ERROR,

  /* REPLY.CHUNK_REPLY.RECV_ERROR_MESSAGE: Receive a chunk reply error message
   */
  STATE_REPLY_CHUNK_REPLY_RECV_ERROR_MESSAGE,

  /* REPLY.CHUNK_REPLY.RECV_ERROR_TAIL: Receive a chunk reply error tail */
  STATE_REPLY_CHUNK_REPLY_RECV_ERROR_TAIL,

  /* REPLY.CHUNK_REPLY.RECV_OFFSET_DATA: Receive a chunk reply offset-data
   * header
   */
  STATE_REPLY_CHUNK_REPLY_RECV_OFFSET_DATA,

  /* REPLY.CHUNK_REPLY.RECV_OFFSET_DATA_DATA: Receive a chunk reply offset-data
   * block of data
   */
  STATE_REPLY_CHUNK_REPLY_RECV_OFFSET_DATA_DATA,

  /* REPLY.CHUNK_REPLY.RECV_OFFSET_HOLE: Receive a chunk reply offset-hole
   * header
   */
  STATE_REPLY_CHUNK_REPLY_RECV_OFFSET_HOLE,

  /* REPLY.CHUNK_REPLY.RECV_BS_HEADER: Receive header of a chunk reply
   * block-status payload
   */
  STATE_REPLY_CHUNK_REPLY_RECV_BS_HEADER,

  /* REPLY.CHUNK_REPLY.RECV_BS_ENTRIES: Receive entries array of chunk reply
   * block-status payload
   */
  STATE_REPLY_CHUNK_REPLY_RECV_BS_ENTRIES,

  /* REPLY.CHUNK_REPLY.RESYNC: Ignore payload of an unexpected chunk reply */
  STATE_REPLY_CHUNK_REPLY_RESYNC,

  /* REPLY.CHUNK_REPLY.FINISH: Finish receiving a chunk reply */
  STATE_REPLY_CHUNK_REPLY_FINISH,

  /* REPLY.FINISH_COMMAND: Finish receiving a command */
  STATE_REPLY_FINISH_COMMAND,

  /* DEAD: Connection is in an unrecoverable error state, can only be closed */
  STATE_DEAD,

  /* CLOSED: Connection is closed */
  STATE_CLOSED,

};

/* These correspond to the external events in generator/generator. */
enum external_event {
  notify_read,
  notify_write,
  cmd_create,
  cmd_connect_sockaddr,
  cmd_connect_tcp,
  cmd_connect_command,
  cmd_connect_sa,
  cmd_connect_socket,
  cmd_issue,
};

/* State groups. */
enum state_group {
  GROUP_TOP,
  GROUP_CONNECT,
  GROUP_CONNECT_TCP,
  GROUP_CONNECT_COMMAND,
  GROUP_CONNECT_SA,
  GROUP_MAGIC,
  GROUP_OLDSTYLE,
  GROUP_NEWSTYLE,
  GROUP_NEWSTYLE_OPT_STARTTLS,
  GROUP_NEWSTYLE_OPT_EXTENDED_HEADERS,
  GROUP_NEWSTYLE_OPT_STRUCTURED_REPLY,
  GROUP_NEWSTYLE_OPT_META_CONTEXT,
  GROUP_NEWSTYLE_OPT_GO,
  GROUP_NEWSTYLE_OPT_EXPORT_NAME,
  GROUP_NEWSTYLE_OPT_LIST,
  GROUP_ISSUE_COMMAND,
  GROUP_REPLY,
  GROUP_REPLY_SIMPLE_REPLY,
  GROUP_REPLY_CHUNK_REPLY,
};

/* State transitions defined in states.c. */
extern int nbd_internal_enter_STATE_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_CONNECT_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_CONNECT_CONNECTING (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_CONNECT_TCP_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_CONNECT_TCP_CONNECT (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_CONNECT_TCP_CONNECTING (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_CONNECT_TCP_NEXT_ADDRESS (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_CONNECT_COMMAND_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_CONNECT_SA_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_MAGIC_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_MAGIC_RECV_MAGIC (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_MAGIC_CHECK_MAGIC (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_OLDSTYLE_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_OLDSTYLE_RECV_REMAINING (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_OLDSTYLE_CHECK (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_RECV_GFLAGS (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_CHECK_GFLAGS (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_SEND_CFLAGS (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_STARTTLS_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_STARTTLS_SEND (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_STARTTLS_RECV_REPLY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_STARTTLS_RECV_REPLY_PAYLOAD (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_STARTTLS_CHECK_REPLY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_STARTTLS_TLS_HANDSHAKE_READ (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_STARTTLS_TLS_HANDSHAKE_WRITE (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_STARTTLS_TLS_HANDSHAKE_DONE (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_EXTENDED_HEADERS_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_EXTENDED_HEADERS_SEND (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_EXTENDED_HEADERS_RECV_REPLY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_EXTENDED_HEADERS_RECV_REPLY_PAYLOAD (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_EXTENDED_HEADERS_CHECK_REPLY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_SEND (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_RECV_REPLY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_RECV_REPLY_PAYLOAD (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_STRUCTURED_REPLY_CHECK_REPLY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_META_CONTEXT_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_META_CONTEXT_SEND (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_META_CONTEXT_SEND_EXPORTNAMELEN (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_META_CONTEXT_SEND_EXPORTNAME (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_META_CONTEXT_SEND_NRQUERIES (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_META_CONTEXT_PREPARE_NEXT_QUERY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_META_CONTEXT_SEND_QUERYLEN (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_META_CONTEXT_SEND_QUERY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_META_CONTEXT_PREPARE_FOR_REPLY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_META_CONTEXT_RECV_REPLY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_META_CONTEXT_RECV_REPLY_PAYLOAD (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_META_CONTEXT_CHECK_REPLY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_GO_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_GO_SEND (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_GO_SEND_EXPORTNAMELEN (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_GO_SEND_EXPORT (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_GO_SEND_NRINFOS (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_GO_SEND_INFO (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_GO_RECV_REPLY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_GO_RECV_REPLY_PAYLOAD (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_GO_CHECK_REPLY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_EXPORT_NAME_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_EXPORT_NAME_SEND (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_EXPORT_NAME_SEND_EXPORT (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_EXPORT_NAME_RECV_REPLY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_EXPORT_NAME_CHECK_REPLY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_LIST_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_LIST_SEND (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_LIST_RECV_REPLY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_LIST_RECV_REPLY_PAYLOAD (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_OPT_LIST_CHECK_REPLY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_PREPARE_OPT_ABORT (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_SEND_OPT_ABORT (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_SEND_OPTION_SHUTDOWN (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEWSTYLE_FINISHED (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_NEGOTIATING (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_READY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_ISSUE_COMMAND_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_ISSUE_COMMAND_SEND_REQUEST (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_ISSUE_COMMAND_PAUSE_SEND_REQUEST (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_ISSUE_COMMAND_PREPARE_WRITE_PAYLOAD (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_ISSUE_COMMAND_SEND_WRITE_PAYLOAD (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_ISSUE_COMMAND_PAUSE_WRITE_PAYLOAD (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_ISSUE_COMMAND_SEND_WRITE_SHUTDOWN (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_ISSUE_COMMAND_PAUSE_WRITE_SHUTDOWN (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_ISSUE_COMMAND_FINISH (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_RECV_REPLY (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_CHECK_REPLY_MAGIC (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_RECV_STRUCTURED_REMAINING (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_SIMPLE_REPLY_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_SIMPLE_REPLY_RECV_READ_PAYLOAD (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_CHUNK_REPLY_START (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_CHUNK_REPLY_RECV_ERROR (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_CHUNK_REPLY_RECV_ERROR_MESSAGE (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_CHUNK_REPLY_RECV_ERROR_TAIL (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_CHUNK_REPLY_RECV_OFFSET_DATA (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_CHUNK_REPLY_RECV_OFFSET_DATA_DATA (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_CHUNK_REPLY_RECV_OFFSET_HOLE (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_CHUNK_REPLY_RECV_BS_HEADER (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_CHUNK_REPLY_RECV_BS_ENTRIES (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_CHUNK_REPLY_RESYNC (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_CHUNK_REPLY_FINISH (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_REPLY_FINISH_COMMAND (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_DEAD (
             struct nbd_handle *h, bool *blocked
           );
extern int nbd_internal_enter_STATE_CLOSED (
             struct nbd_handle *h, bool *blocked
           );