File: gensiodoc.py

package info (click to toggle)
gensio 2.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,776 kB
  • sloc: ansic: 45,195; python: 2,718; cpp: 1,129; sh: 586; makefile: 420
file content (1257 lines) | stat: -rw-r--r-- 45,838 bytes parent folder | download
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
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
#
#  gensio - A library for abstracting stream I/O
#  Copyright (C) 2018  Corey Minyard <minyard@acm.org>
#
#  SPDX-License-Identifier: LGPL-2.1-only
#

# This file documents the python interface to gensio via the normal
# python documentation method.  It is not functional.

class LogHandler:
    """A template class used by gensio_os_funcs to generate logs."""
    def gensio_log(self, level, log):
        """gensio has generated a log.

        level -- A log level string: "fatal", "error", "warning",
                "info", or "debug"
        log -- The log text
        """
        return

class gensio_os_funcs:
    """This class is used to provide OS handling functions, the same as
    "struct gensio_os_funcs" in the C interface.  If you need a custom
    one, you might have to provide a Python/C interface to allocate it.
    """

def alloc_gensio_selector(h):
    """Allocate a default gensio_os_funcs for your platform.

    h -- A LogHandler class for receiving logs.

    Returns a gensio_os_funcs object.
    """
    return gensio_os_funcs()

class EventHandler:
    """A template class for handling events from a gensio.  All the
    possible callback events are here, they are the same as the C
    interfce GENSIO_EVENT_xxx defines.
    """
    def read_callback(io, err, data, auxdata):
        """Read data from the gensio, or error reporting.  When data comes in
        for the gensio, it is sent here if read is enabled.  Also, if
        something happens like an error or the gensio closes, it is
        reported through this interface (again, if read is enabled).

        io -- The gensio object reporting the read data.
        err -- An error string. If no error, this will be None, otherwise
               it is a string.  Some are not really errors, for instance
               "Remote end closed connection" just means the other end
               did a close.
        data -- A byte string holding the read data.
        auxdata -- Auxiliary data describing the read.  This is a sequence
               of strings. Some interfaces will have an "oob" string for
               out-of-bounds data (TCP and SCTP).  SCTP can have a
               channel number.  See the gensio description for details.

        Return the number of bytes consumed.  THIS IS IMPORTANT.  If
        you return 0, it will assume you did not consume any of the data
        and give you the same data again immediately.
        """
        return 0

    def write_callback(self, io):
        """Data can be written on the gensio.  You should generally
        use this for writing your data.  You can directly call the
        write() method, but it may not take all the data and you need
        a way to get it the rest of the data.

        io -- The gensio object reporting write ready.
        """
        return

    def new_channel(self, old_io, new_io):
        """A new channel has been requested from the other end.

        old_io - an existing channel on a mux gensio
        new_io - a new channel for the mux gensio

        Return an integer. If you return 0, the new channel is
        accepted.  If you return non-zero, it is considered a gensio
        error and that error is reported as an open channel failure on
        the remote end.  If you return non-zero, the new_io is freed,
        you should not use it.
        """
        return

    def send_break(self, io):
        """The remote end has requested that a break be sent.  This
        is for a telnet server where the remote end sent a break.

        io -- The gensio that received the break.
        """
        return

    def auth_begin(self, io):
        """An authorization event has begun.  This is used by certauth server
        side to report that authorization has begun from the client.
        The service and username will be available via controls, but
        other information is not available.

        io -- The gensio starting authorization.

        Return GE_NOTSUP to continue authentication, GE_AUTHREJECT to
        terminate the authentication, and 0 to cause the
        authentication to succeed.

        """
        return gensio.GE_NOTSUP

    def precert_verify(self, io):
        """Called from ssl and certauth server after a certificate has
        been received but before it is verified.  This allows the
        certificate to be examined with GENSIO_CONTROL_GET_PEER_CERT_NAME.
        Possible actions are rejecting the authentication, causing it to
        succeed, or continuing the authentication.  The certificate authority
        file/directory can be set with GENSIO_CONTROL_CERT_AUTH.

        io -- The gensio owning the certificate.

        Return GE_NOSUP to continue authentication, GE_AUTHREJECT to
        terminate the authentication, or 0 to cause the authentication
        to succeed.
        """
        return gensio.GE_NOTSUP

    def postcert_verify(self, io, err, errstr):
        """Called from certauth server after a certificate has been
        verified.  The results of the verification are reported in
        err and errstr.

        io -- The gensio owning the certificate.
        err -- An integer error, one of 0 (success), GE_CERTREVOKED,
            GE_CERTEXPIRED, or GE_CERTINVALID.
        errstr - Either None if the error string was not available,
            or a string representing the error.

        Return GE_NOSUP to continue authentication, GE_AUTHREJECT to
        terminate the authentication, or 0 to cause the authentication
        to succeed.
        """
        return gensio.GE_NOTSUP

    def password_verify(self, io, password):
        """Called from certauth server to report a password verification
        request from the client.  The certauth code will not to it's own
        password verification, it relies on the code using it to do this.

        io -- The gensio requesting verification.
        password -- The password string to verify.

        Return GE_NOTSUP to continue authentication (causing it to
        reject the password, or 0 to cause the authentication to
        succeed.  GE_AUTHREJECT will also reject the password

        """
        return gensio.GE_NOTSUP

    def request_password(self, io):
        """Called from the certauth client to request a password from
        the user.

        io -- The gensio requesting the password.

        Return a password string.
        """
        return ""

    def signature(self, sio):
        """Called from the telnet server to report that the client has
        requested the RFC2217 signature.  Call sg_signature(signature,
        None) with the signature.

        sio -- The sergensio object requesting the signature.

        """
        return

    def flush(self, sio, val):
        """Called from telnet server or client to report that a flush has been
        requested.

        sio -- The sergensio object requesting the flush.
        val -- The flush type, one of SERGIO_FLUSH_RCV_BUFFER,
            SERGIO_FLUSH_XMIT_BUFFER, or SERGIO_FLUSH_RCV_XMIT_BUFFERS.
        """
        return

    def sync(self, sio):
        """Called from telnet server or client to report that a sync has been
        requested.

        sio -- The sergensio object requesting the sync.
        """
        return

    def flowcontrol_state(self, sio, disable):
        """Called from telnet server or client to report that a sync has been
        requested.  If this is received with a disable request, then the
        local end should not send any data or commands.

        sio -- The sergensio object requesting the flow control state change.
        disable -- A boolean, if true then disable transmission, if false then
            enable transmission
        """
        return

    def sbaud(self, sio, val):
        """Called from telnet server to report that a baud change has been
        requested.  sg_baud(val, None) should be called when the
        change is complete to report the actual baud rate set.

        sio -- The sergensio object requesting the change.
        val -- The baud rate as an integer.
        """
        return

    def sdatasize(self, sio, val):
        """Called from telnet server to report that a data size change has
        been requested.  sg_datasize(val, None) should be called when the
        change is complete to report the actual data size set.

        sio -- The sergensio object requesting the change.
        val -- The data size as an integer, 5, 6, 7, or 8.
        """
        return

    def sparity(self, sio, val):
        """Called from telnet server to report that a parity change has
        been requested.  sg_parity(val, None) should be called when the
        change is complete to report the actual parity set.

        sio -- The sergensio object requesting the change.
        val -- The parity, one of SERGENSIO_PARITY_NONE,
            SERGENSIO_PARITY_ODD, SERGENSIO_PARITY_EVEN,
            SERGENSIO_PARITY_MARK, SERGENSIO_PARITY_SPACE.
        """
        return

    def sstopbits(self, sio, val):
        """Called from telnet server to report that a stop bit change has
        been requested.  sg_stopbits(val, None) should be called when the
        change is complete to report the actual number of stop bits set.

        sio -- The sergensio object requesting the change.
        val -- The stop bits as an integer, 1 or 2.
        """
        return

    def sflowcontrol(self, sio, val):
        """Called from telnet server to report that a flow control change has
        been requested.  sg_flowcontrol(val, None) should be called when the
        change is complete to report the actual flow control set.

        sio -- The sergensio object requesting the change.
        val -- The flow control state, one of SERGENSIO_FLOWCONTROL_NONE,
            SERGENSIO_FLOWCONTROL_XON_XOFF, SERGENSIO_FLOWCONTROL_RTS_CTS.
        """
        return

    def siflowcontrol(self, sio, val):
        """Called from telnet server to report that a input flow control
        change has been requested.  sg_iflowcontrol(val, None) should
        be called when the change is complete to report the actual
        flow control set.

        sio -- The sergensio object requesting the change.
        val -- The input flow control state, one of
            SERGENSIO_FLOWCONTROL_DCD, SERGENSIO_FLOWCONTROL_DTR,
            SERGENSIO_FLOWCONTROL_DSR, SERGENSIO_FLOWCONTROL_NONE
        """
        return

    def sbreak(self, sio, val):
        """Called from telnet server to report that a break
        change has been requested.  sg_break(val, None) should
        be called when the change is complete to report the actual
        break value set.

        sio -- The sergensio object requesting the change.
        val -- The break setting, either SERGENSIO_BREAK_ON or
            SERGENSIO_BREAK_OFF.
        """
        return

    def sdtr(self, sio, val):
        """Called from telnet server to report that a DTR
        change has been requested.  sg_dtr(val, None) should
        be called when the change is complete to report the actual
        DTR set.

        sio -- The sergensio object requesting the change.
        val -- The DTR setting, either SERGENSIO_DTR_ON or
            SERGENSIO_DTR_OFF.
        """
        return

    def srts(self, sio, val):
        """Called from telnet server to report that a RTS
        change has been requested.  sg_rts(val, None) should
        be called when the change is complete to report the actual
        RTS set.

        sio -- The sergensio object requesting the change.
        val -- The RTS setting, either SERGENSIO_RTS_ON or
            SERGENSIO_RTS_OFF.
        """
        return

    def modemstate(self, modemstate):
        """Called from a sergensio object when a modemstate monitor is enabled
        and a modemstate value changes..

        modemstate -- A bitmask of SERGENSIO_MODEMSTATE_CTS,
            SERGENSIO_MODEMSTATE_DSR, SERGENSIO_MODEMSTATE_RI and
            SERGENSIO_MODEMSTATE_CD.  This is the current modemstate
            values.  If a value has changed, this is reported in the bits
            SERGENSIO_MODEMSTATE_CTS_CHANGED,
            SERGENSIO_MODEMSTATE_DSR_CHANGED,
            SERGENSIO_MODEMSTATE_RI_CHANGED, and
            SERGENSIO_MODEMSTATE_CD_CHANGED.
        """

    def linestate(self, modemstate):
        """Called from a sergensio object when a linestate monitor is enabled
        and a particular linestate event occurs.

        linesate -- A bitmask of
            SERGENSIO_LINESTATE_DATA_READY,
            SERGENSIO_LINESTATE_OVERRUN_ERR,
            SERGENSIO_LINESTATE_PARITY_ERR,
            SERGENSIO_LINESTATE_FRAMING_ERR,
            SERGENSIO_LINESTATE_BREAK,
            SERGENSIO_LINESTATE_XMIT_HOLD_EMPTY,
            SERGENSIO_LINESTATE_XMIT_SHIFT_EMPTY, and
            SERGENSIO_LINESTATE_TIMEOUT_ERR.
        """

class OpenDone:

        """A template for a class handling the finish of an open."""

    def open_done(self, io, err):
        """Called when the open operation completes.

        io -- The gensio that was opened.
        err -- An error string, None if no error.
        """
        return

class CloseDone:
    """A template for a class handling the finish of an close."""

    def close_done(self, io):
        """Called when the close operation completes.

        io -- The gensio that was closed.
        """
        return

class gensio:
    def __init__(o, gensiostr, handler):
        """Allocate a gensio.

        o -- The gensio_os_funcs object to use for this gensio.
        gensiostr -- A string describing the gensio stack.  See the gensio
            documentation for details.
        handler -- An EventHandler object to receive events
        """
        return

    def new_parent(self, o, gensiostr, handler):
        """Allocate a new gensio filter stacked on top of this gensio.
        This is the equivalent of str_to_gensio_child().

        o -- The gensio_os_funcs object to use
        gensiostr -- A string describing just the gensio filter.
        handler -- An EventHandler object to receive events.

        Returns a new gensio
        """
        return gensio()

    def set_cbs(self, handler):
        """Change the callback handler for the gensio.  This should
        only be done when all I/O is disabled.

        handler -- An EventHandler object to receive events.
        """
        return

    def remote_id(self):
        """Return the remote_id value for this gensio.  See the specific
        gensio for the meaning.

        Returns an integer value.
        """
        return

    def open(self, done_handler):
        """Start up operation on the gensio.  Calls done_handler.open_done
        when the open operation completes.

        done_handler -- A class (like OpenDone) that has an open_done()
        method to call when the operation completes.

        """
        return

    def open_nochild(self, done_handler):
        """Start up operation on the gensio, assuming that the child gensio is
        already open.  Useful with the new_parent() method above.  Calls
        done_handler.open_done when the open operation completes.

        done_handler -- A class (like OpenDone) that has an open_done()
        method to call when the operation completes.

        """
        return

    def open_s(self):
        """Like open(), but waits for the open to complete and raises an
        exception on an error.  The wait operation is a normal waiter,
        so gensio is fully operational during the wait.
        """
        return

    def open_nochild_s(self):
        """Like open_nochild(), but waits for the open to complete and raises
        an exception on an error.  The wait operation is a normal
        waiter, so gensio is fully operational during the wait.
        """
        return

    def open_channel(self, args, handler, done):
        """Create a new channel on the gensio.  This is gensio-specific, most
        gensios don't support channels.

        args -- A sequence of strings holding arguments for the channel.
        handler -- The EventHandler object to receive events for the channel.
        done -- An OpenDone type class whose open_done() method is called
            when the open is complete.
        """
        return

    def open_channel_s(self, args, handler):
        """Like open_channel(), but waits for the open to complete and raises
        an exception on an error.  The wait operation is a normal
        waiter, so gensio is fully operational during the wait.
        """
        return

    def get_type(self):
        """Return the type string for the gensio."""
        return

    def close(self, close_done):
        """Close the gensio.  If it is not open this will raise an exception.
        When the close_done() method is called, the gensio is closed.

        close_done -- A CloseDone type object whose close_done()
            method gets called when the close is complete.
        """
        return

    def close_s(self):
        """Like close(), but waits for the close to complete.  The wait
        operation is a normal waiter, so gensio is fully operational
        during the wait.
        """
        return

    def write(self, bytestr, auxdata):
        """Write the given byte string.

        bytestr -- The data to write.
        auxdata -- A sequence of strings holding gensio-specific auxiliary
            data.  May be None if it's not applicable.

        Returns the actual number of bytes written.  This may be less
        than the given bytes, so you must account for that when calling
        write().
        """
        return 0

    def read_cb_enable(self, enable):
        """Allow read events from the gensio.  When the gensio is opened read
        is disabled, you must call this to get read events to
        read_callback().  Note that some gensios, like UDP, don't
        perform well if read is disabled a lot.  You should generally
        leave this enabled as much as possible.  You should only
        disable it if you cannot handle new data.

        enable -- A boolean, whether to enable or disable read events

        """
        return

    def write_cb_enable(self, enable):
        """Allow write ready events from the gensio.  When the gensio is
        opened write callbacks are enabled.  You should generally leave
        them disabled until you have data to write, then enable it
        and write to the gensio in the write_callback() events.

        enable -- A boolean, whether to enable or disable callback events
        """
        return

    def set_sync(self):
        """Enable synchronous I/O on the gensio.  If you call this, then read
        and write events will not go the the event handler (though
        other events will).  You must call the read_s() and write_s()
        methods to do I/O.
        """
        return

    def clear_sync(self):
        """Disable synchronous I/O on the gensio.  If you call this, then read
        and write events will go the the event handler.  Read and
        write events will be disabled by this function, you must
        enable them to start event processing.
        """
        return

    def read_s(self, reqlen, timeout):
        """Read data from the gensio synchronously.  This will read up to
        reqlen bytes and may have a timeout.  Note that this will
        return as soon as it has any data, even if it is less than
        reqlen.

        reqlen -- The number of bytes to read.
        timeout -- The number of milliseconds to wait for the data.  If -1,
            the timeout is disabled.

        Returns a sequence with a bytestr as the first item and the
        number of milliseconds left on the timeout as the second item.
        If the returned timeout is 0, the operation timed out.
        """
        return { bytes(""), 0 }

    def read_s_intr(self, reqlen, timeout):
        """Like read_s, but raises an exception for GE_INTERRUPTED if a
        signal comes in while waiting.
        """
        return { bytes(""), 0 }

    def write_s(self, bytestr, timeout):
        """Attempt to write the given byte string to the gensio.  This
        will wait up to timeout milliseconds for the write to complete.

        bytestr -- The bytes to write.
        timeout -- The number of milliseconds to wait for the write to
            complete.  Use -1 to disable the timeout.

        Returns a sequence with two items: the number of bytes
        actually written and the number of milliseconds left on the
        timeout.
        """
        return { 0, 0 }

    def write_s_intr(self, bytestr, timeout):
        """Like write_s, but raises an exception for GE_INTERRUPTED if a
        signal comes in while waiting.
        """
        return { 0, 0 }

    def control(self, depth, get, option, data):
        """Do a gensio-specific control operation.  See the specific gensios
        and the C interface for specific gensio controls.

        depth -- The gensio in the stack to choose.  0 selects the top
            gensio, 1 the second from the top, etc.
            GENSIO_CONTROL_DEPTH_ALL will call the control on every gensio
            in the stack, GENSIO_CONTROL_DEPTH_FIRST will call the control
            down the stack until a control doesn't return GE_NOTSOP.
        get -- A boolean specifying if this is a get or a put operation.
        option -- The specific gensio control to call.
        data -- A string specifying the data for the control.

        Returns a string with the result data for the control.
        """
        return ""

    def is_client(self):
        """Return whether the gensio is a client or server."""
        return True

    def is_packet(self):
        """Return whether the gensio is a packet interface.  In a packet
        interface, each write on one end will result in a single read
        on the other end with the same amount of data.
        """
        return False

    def is_reliable(self):
        """Return whether the gensio provides reliable data transport.  With
        reliable data transport, bytes will not be dropped and data
        will be delivered in the same order it was sent.
        """
        return True

    def is_authenticated(self):
        """Return whether the gensio has been authenticated.  This is
        primarily for ssl and certauth, if they succeed in their
        authentication algorithms succeeded.
        """
        return False

    def is_encrypted(self):
        """Return whether the data is is encrypted."""
        return False

    def cast_to_sergensio(self):
        """Convert the gensio to a sergensio.

        Returns the sergensio object if the gensio is a sergensio, or
        None if it is not.
        """
        return None

class SergensioDone:
    """These are methods called when a sergensio request from a client
    completes.  Note that the base code may not honor the request or
    may choose a different value than requested.  Check the returned
    value to be sure.  Also, an error may occur, if the err value is
    not None, it is a string given the error.
    """

    def baud(self, sio, err, val):
        return

    def datasize(self, sio, err, val):
        return

    def parity(self, sio, err, val):
        return

    def stopbits(self, sio, err, val):
        return

    def flowcontrol(self, sio, err, val):
        return

    def iflowcontrol(self, sio, err, val):
        return

    def sbreak(self, sio, err, val):
        return

    def dtr(self, sio, err, val):
        return

    def rts(self, sio, err, val):
        return

    def signature(self, sio, err, sig):
        return

class sergensio:
    """A gensio that is capable of doing serial port operations like baud
    rate, stop bits, modem control, etc.

    Note that on all of these, if you pass in a 0, it will not set the
    value but will return the current value in the callback.

    On a telnet client, these request the operations from the other end.
    On a telnet server, these send the request values back to the client.
    """

    def cast_to_gensio(self):
        """Returns the gensio object for this sergensio.  This cannot fail."""
        return None;

    def sg_baud(self, baud, handler):
        """Set the baud rate to the given baud rate.

        val -- The baud rate as an integer.
        handler -- Call the baud() method on this class when done.
        """
        return

    def sg_datasize(self, datasize, handler):
        """Set the data size to then given value.

        datasize -- One of 5, 6, 7, or 8.
        handler -- Call the datasize() method on this class when done.
        """
        return

    def sg_parity(self, parity, handler):
        """Set the parity on the connection.

        party -- The parity, one of SERGENSIO_PARITY_NONE,
            SERGENSIO_PARITY_ODD, SERGENSIO_PARITY_EVEN,
            SERGENSIO_PARITY_MARK, SERGENSIO_PARITY_SPACE.
        handler -- Call the parity() method on this class when done.
        """
        return

    def sg_stopbits(self, stopbits, handler):
        """Set the number of stop bits.

        stop bits -- One of 1 or 2.
        handler -- Call the stopbits() method on this class when done.
        """
        return

    def sg_flowcontrol(self, flowcontrol, handler):
        """Set the flow control method on the port.

        flowcontrol -- The flow control state, one of
            SERGENSIO_FLOWCONTROL_NONE,
            SERGENSIO_FLOWCONTROL_XON_XOFF, SERGENSIO_FLOWCONTROL_RTS_CTS.
        handler -- Call the flowcontrol() method on this class when done.
        """
        return

    def sg_iflowcontrol(self, iflowcontrol, handler):
        """Set the input flow control method on the port.

        iflowcontrol -- The input flow control state, one of
            SERGENSIO_FLOWCONTROL_DCD, SERGENSIO_FLOWCONTROL_DTR,
            SERGENSIO_FLOWCONTROL_DSR, SERGENSIO_FLOWCONTROL_NONE
        handler -- Call the iflowcontrol() method on this class when done.
        """
        return

    def sg_break(self, sbreak, handler):
        """Set the break state on the port.

        sbreak -- The break setting, either SERGENSIO_BREAK_ON or
            SERGENSIO_BREAK_OFF.
        handler -- Call the sbreak() method on this class when done.
        """
        return

    def sg_dtr(self, dtr, handler):
        """Set the DTR state on the port.

        dtr -- The DTR setting, either SERGENSIO_DTR_ON or
            SERGENSIO_DTR_OFF.
        handler -- Call the dtr() method on this class when done.
        """
        return

    def srts(self, rts, handler):
        """Set the RTS state on the port

        rts -- The RTS setting, either SERGENSIO_RTS_ON or
            SERGENSIO_RTS_OFF.
        handler -- Call the rts() method on this class when done.
        """
        return

    def sg_modemstate(self, modemstate):
        """Set the particular modemstate values that are monitored.
        If the modemstate value is set and it changes, the change
        is reported via the modemstate() event.

        modemstate -- A bitmask of SERGENSIO_MODEMSTATE_CTS,
            SERGENSIO_MODEMSTATE_DSR,
            SERGENSIO_MODEMSTATE_RI, and
            SERGENSIO_MODEMSTATE_CD.
        """
        return

    def sg_linestate(self, linestate):
        """Set the particular linestate values that are monitored.
        If the linestate value is set and it changes, the change
        is reported via the linestate() event.

        linesate -- A bitmask of
            SERGENSIO_LINESTATE_DATA_READY,
            SERGENSIO_LINESTATE_OVERRUN_ERR,
            SERGENSIO_LINESTATE_PARITY_ERR,
            SERGENSIO_LINESTATE_FRAMING_ERR,
            SERGENSIO_LINESTATE_BREAK,
            SERGENSIO_LINESTATE_XMIT_HOLD_EMPTY,
            SERGENSIO_LINESTATE_XMIT_SHIFT_EMPTY, and
            SERGENSIO_LINESTATE_TIMEOUT_ERR.
        """
        return

    def sg_flush(self, val):
        """Request that the remote end do a data flush.

        val -- The flush type, one of SERGIO_FLUSH_RCV_BUFFER,
            SERGIO_FLUSH_XMIT_BUFFER, or SERGIO_FLUSH_RCV_XMIT_BUFFERS.
        """
        return

    def sg_signature(self, sig, handler):
        """On a client, sig should be None, the handler's signature() method
        is called with the signature.  On the server, the handler
        should be None and the sig value is sent to the remote end.
        """
        return

class AccEventHandler:
    """A template class showing which events are generated by a
    gensio_accepter object.
    """

    def log(self, acc, level, logval):
        """An internal error has occurred in the accepter that cannot be
        reported via another mechanism, like an incoming connection
        failed.

        acc -- The gensio_accepter.
        level -- The log level as a string, like "info", "debug", "warning",
            "error", and "fatal".
        logval -- The actual log string.
        """
        return

    def new_connection(self, acc, io):
        """A new connection has come in on the gensio.

        acc -- The gensio_accepter.
        io -- The new gensio.  This is open, but read and write are
            not enabled.
        """
        return

    def auth_begin(self, acc, io):
        """Authentication of the remote end has begun on the gensio.  The
        remote end has requested authentiation.  The service and
        username may be available via controls on the gensio.

        acc -- The gensio_accepter.
        io -- The gensio doing the authentication.  Note that this gensio
            has not been reported via new_connection and is not functional.
            You can do some control operations on it, but that's about it.

        See auth_begin() in EventHandler for more details and return
        values, this is functionally the same, it just occurs on the
        accepter before the gensio has been reported as operational.
        """
        return gensio.GE_NOTSUP

    def precert_verify(self, acc, io):
        """Called after a certificate has been received from the remote
        end but before verification.

        acc -- The gensio_accepter.
        io -- The gensio doing the authentication.  Note that this gensio
            has not been reported via new_connection and is not functional.
            You can do some control operations on it, but that's about it.

        See precert_verify() in EventHandler for more details and return
        values, this is functionally the same, it just occurs on the
        accepter before the gensio has been reported as operational.
        """
        return gensio.GE_NOTSUP

    def postcert_verify(self, acc, io, err, errstr):
        """Called after the certificate has been verified with the
        verification results.

        acc -- The gensio_accepter.
        io -- The gensio doing the authentication.  Note that this gensio
            has not been reported via new_connection and is not functional.
            You can do some control operations on it, but that's about it.
        err -- An integer error.
        errstr -- An error string

        See postcert_verify() in EventHandler for more details and return
        values, this is functionally the same, it just occurs on the
        accepter before the gensio has been reported as operational.
        """
        return gensio.GE_NOTSUP

    def password_verify(self, acc, io, password):
        """A password has been received and needs to be verified.

        acc -- The gensio_accepter.
        io -- The gensio doing the authentication.  Note that this gensio
            has not been reported via new_connection and is not functional.
            You can do some control operations on it, but that's about it.
        password -- the password string for verification.

        See password_verify() in EventHandler for more details and return
        values, this is functionally the same, it just occurs on the
        accepter before the gensio has been reported as operational.
        """
        return gensio.GE_NOTSUP

    def request_password(self, acc, io):
        """The remote authentication server has requested a password.

        acc -- The gensio_accepter.
        io -- The gensio doing the authentication.  Note that this gensio
            has not been reported via new_connection and is not functional.
            You can do some control operations on it, but that's about it.

        See password_verify() in EventHandler for more details and return
        values, this is functionally the same, it just occurs on the
        accepter before the gensio has been reported as operational.
        """
        return "password"

class ShutdownDone:
    """A class template for receiving shutdown done reports."""

    def shutdown_done(self, acc):
        """The shutdown operation has completed on the gensio_accepter.

        acc - The gensio_accepter
        """
        return

class gensio_accepter:
        """A class that receives incoming connections."""

        def __init__(o, gensiostr, handler):
            """Allocate a gensio_accepter.  The gensio_accepter is
            allocated in shutdown state.

            o -- The gensio_os_funcs object to use for this gensio accepter.
            gensiostr -- A string describing the gensio stack.  See the gensio
                documentation for details.
            handler -- An AccEventHandler object to receive events.
            """
            return

        def set_cbs(self, handler):
            """Set the handler object for the gensio_accepter.

            handler -- An AccEventHandler object to receive events.
            """
            return

        def str_to_gensio(self, gensiostr, handler):
            """Allocate a new gensio, coming from the address/port of the
            gensio_accepter, if possible.  This makes it possible to
            create outgoing UDP connections on the same port as the
            accepter receives connections, but is available for other
            gensios, too.

            gensiostr -- A string describing the gensio stack.  See the gensio
                documentation for details.
            handler -- An EventHandler object to receive events.

            Returns the new gensio, in an unopened state.
            """
            return None

        def startup(self):
            """Start accepting connections on the gensio accepter."""
            return

        def shutdown(self, shutdown_done):
            """Stop accepting connection on the gensio accepter.  The
            accepter will be stopped when the shutdown_done() method
            is called in the shutdown_done object.  This closes any
            underlying connections.

            shutdown_done - The object containing the shutdown_done()
                method to be called when the shutdown is complete.
            """
            return

        def shutdown_s(self):
            """Like shutdown, but blocks until the shutdown is complete."""
            return

        def set_accept_cb_enable(self, enable):
            """Enable or disabling reporting new connections on the gensio
            accepter.  This does not close the underlying connection,
            it just disables reporting any accepts.

            enable - If true, enable callbacks.  If false, disabled them.
            enable_done - The object containing the
                set_accept_callback_done() method to be called when
                the enable is complete.

            """
            return

        def set_accept_cb_enable_cb(self, enable, enable_done):
            """Like set_accept_cb_enable(), but the accepter reporting is
            guaranteed to be stopped when the
            set_accept_callback_done() method is called in the
            enabled_done object.

            enable - If true, enable callbacks.  If false, disabled them.
            enable_done - The object containing the
                set_accept_callback_done() method to be called when
                the enable is complete.

            """
            return

        def set_accept_cb_enable_s(self, enable):
            """Like set_accept_cb_enable(), but the accepter reporting is
            guaranteed to be stopped when the function returns.

            enable - If true, enable callbacks.  If false, disabled them.
            """
            return

        def set_sync(self):
            """Enable synchronous accepts on the accepter.  The accepter must not
            be started when this is called.  Once called, the accepter
            is in synchronous mode until it is shutdown"""
            return

        def accept_s(self, o, handler):
            """Wait for an incoming connection on the accepter.  Returns the
            new gensio.  The handler for the gensio is set if returned."""
            return

        def accept_s_timeout(self, o, handler, timeout):
            """Like accept_s, but takes a timeout in milliseconds.  Returns
            a tuple with the new gensio as the first item (or None if timed out)
            and the remaining time as the second item."""
            return

        def accept_s_intr(self, o, handler):
            """Wait for an incoming connection on the accepter.  Returns the
            new gensio.  If a signal comes in while waiting, raise an
            exception for GE_INTERRUPTED."""
            return

        def accept_s_intr_timeout(self, o, handler, timeout):
            """Like accept_s_intr, but takes a timeout in milliseconds.  Returns
            a tuple with the new gensio as the first item (or None if timed out)
            and the remaining time as the second item."""
            return

        def control(self, depth, get, option, data):
        """Do a gensio_accepter-specific control operation.  See the specific
        gensio and the C interface for specific gensio_accepter controls.

        depth -- The gensio_accepter in the stack to choose.  0 selects the
            top ond, 1 the second from the top, etc.
            GENSIO_CONTROL_DEPTH_ALL will call the control on every
            gensio_accepter in the stack, GENSIO_CONTROL_DEPTH_FIRST will
            call the control down the stack until a control doesn't
            return GE_NOTSOP.
        get -- A boolean specifying if this is a get or a put operation.
        option -- The specific gensio_accepter control to call.
        data -- A string specifying the data for the control.

        Returns a string with the result data for the control.
        """
        return ""

    def is_packet(self):
        """Return whether a gensio from this gensio_accepter is a packet
        interface.  In a packet interface, each write on one end will
        result in a single read on the other end with the same amount
        of data.
        """
        return False

    def is_reliable(self):
        """Return whether a gensio from this gensio_accepter provides reliable
        data transport.  With reliable data transport, bytes will not
        be dropped and data will be delivered in the same order it was
        sent.
        """
        return True

    def cast_to_sergensio(self):
        """Convert the gensio_accepter to a sergensio_accepter.

        Returns the sergensio_accepter object if the accepter is a
        sergensio_accepter, or None if it is not.

        """
        return None

class sergensio_accepter:
    """An accepter that will create a sergensio on accept.
    """
    def cast_to_gensio_accepter(self):
        """Returns the gensio_accepter object for this sergensio_accepter.
        This cannot fail."""
        return None;

class MdnsCloseDone:
    """A template for a class handling the finish of an mdns close."""

    def mdns_close_done(self):
        """Called when the close operation completes. """
        return

class MdnsCloseWatchDone:
    """A template for a class handling the finish of an mdns watch close."""

    def mdns_close_watch_done(self):
        """Called when the close operation completes. """
        return

class MdnsEvent:
    """A template for a class handling MDNS events."""

    def mdns_all_for_now(self):
        """Called when all the services currently known have been reported.
        This method is optional."""
        return

    def mdns_cb(self, is_add, interface, ipdomain, name, types, domain,
                host, addr, txt):
        """Called when a matching services is found or removed.

        is_add -- True if an add, False if removed.
        interface -- The interface the service was found on.
        ipdomain -- One of GENSIO_NETTYPE_UNSPEC, GENSIO_NETTYPE_IPV4,
            or GENSIO_NETTYPE_IPV6.  Unspec means IPv4 or IPv6.
        name -- The name of the service.
        types -- The type of the service.
        domain -- The domain of the service.
        host -- The host of the service.
        addr -- An address string in the form of "ipxx,hostname,port".
        txt -- An array of text values for the service.
        """
        return

class mdns:
    """An object used for interacting with the mDNS subsystem.  Add a
    service to advertise an mDNS service, and use a watch to find
    service(s). """

    def __init__(o):
        """Allocate an mdns.

        o -- The gensio_os_funcs object to use for this mdns."""

    def close(self, cb):
        """Close the watch.

        cb -- An object matching the MdnsCloseWatchDone template, the
              mdns_close_watch_done() method is called the the close
              finishes."""
        return

    def add_service(interface, ipdomain,
		    name, types, domain, host, port, txt):
        """Add an mDNS service based on the information given.

        interface - The network interface number to use, -1 mean all.
        ipdomain - One of GENSIO_NETTYPE_UNSPEC, GENSIO_NETTYPE_IPV4,
            or GENSIO_NETTYPE_IPV6.  Unspec means IPv4 or IPv6.
        name - The name for the service.
        types - The type for the service.
        domain - The domain for the service.  Use None, generally.
        host - The host for the service.  Use None, generally.
        port - The port number for the service.
        txt - An array of strings for the mDNS txt field.
        """
        return

    def add_watch(interface, ipdomain,
		  name, types, domain, host, cb):
        """Watch for mDNS service information matching the data given.

        interface - The network interface number to use, -1 mean all.
        ipdomain - One of GENSIO_NETTYPE_UNSPEC, GENSIO_NETTYPE_IPV4,
            or GENSIO_NETTYPE_IPV6.  Unspec means IPv4 or IPv6.
        name - Match the given name.
        types - Match the given type.
        domain - Match the given domain.
        host - Match the given host.
        cb - An object matching MdnsEvent.

        The name, types, domain, and host strings may use regular
        expressions or globs.  If the string starts with '%', then the
        data after it is treated as a regular expression and fields
        are matched against that.  If the string starts with '@', the
        the data after it is treated as a standard glob.  See the
        regex(7) and glob(7) man pages for details.

        If the string starts with '=', an exact comparison is done
        with the data after it.

        If the string starts with a-z0-9_ or a space, then an exact
        string comparison is done, including the first character.

        The behavior of matching for any other starting character is
        undefined.  In general, you should always use '@', '%', or '='
        as the starting character of all your query strings to be
        sure.
        """
        return

class mdns_service:
    def close(self):
        """Close the service."""
        return

class mdns_watch:
    def close(self, cb):
        """Close the watch.

        cb -- An object matching the MdnsCloseWatchDone template, the
              mdns_close_watch_done() method is called the the close
              finishes."""
        return

class waiter:
    """An object that can be used to wait for wakeups in gensios.  You
    should use this interface to wait for operations to finish, it
    will run the internal gensio code so that things will actually
    happen.  If you just sleep, nothing will happen with the gensios.
    """

    def __init__(o):
        """Allocate a waiter.

        o -- The gensio_os_funcs object to use for this waiter.
        """
        return

    def wait_timeout(self, count, timeout):
        """Wait for count wakeups to this object to be called, or
        for timeout (in milliseconds) to elapse.

        count -- The number of wakeups expected.
        timeout -- The time in milliseconds to wait.
        """
        return

    def wait(self, count):
        """Wait for count wakeups to this object to be called.

        count -- The number of wakeups expected.
        """
        return

    def wake(self):
        """Do a wakeup on this object."""
        return

    def service(self, timeout):
        """Run the gensio service routine for timeout milliseconds.

        timeout -- The time to wait, in milliseconds
        """
        return

def gensio_set_log_mask(mask):
    """Set the logs that are delivered by the gensio system.

    mask - A bitmask of the following values:  GENSIO_LOG_FATAL,
        GENSIO_LOG_ERR, GENSIO_LOG_WARNING, GENSIO_LOG_INFO,
        GENSIO_LOG_DEBUG.  GENSIO_LOG_MASK_ALL has all of these
        set.  The default is fatal and errors.
    """
    return

def gensio_get_log_mask():
    """Return the current log mask.  See gensio_set_log_mask() above
    for details."""
    return 0