|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2021 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // シリアルポートの TCP ドライバ
9: //
10:
11: #pragma once
12:
13: #include "comdriver.h"
14: #include "autofd.h"
15:
16: class COMDriverTCP : public COMDriver
17: {
18: using inherited = COMDriver;
19: public:
1.1.1.3 root 20: explicit COMDriverTCP(HostDevice *hostdev_);
1.1 root 21: ~COMDriverTCP() override;
22:
1.1.1.4 root 23: bool InitDriver(bool startup) override;
1.1 root 24: int Dispatch(int udata) override;
25: int Read() override;
26: void Write(uint32 data) override;
1.1.1.5 ! root 27: void MonitorScreenMD(TextScreen&, int y) override;
1.1 root 28:
29: private:
30: bool Accept();
31:
32: void WriteCmd(const std::vector<uint8>& cmd);
33: int Command(uint8 code);
34: void Close();
35:
1.1.1.4 root 36: int port {};
37:
1.1 root 38: autofd ls {};
39: autofd sock {};
40:
41: // TELNET コマンド受信バッファ
42: std::vector<uint8> recvcmd {};
43: // TELNET コマンド (ステート)
44: int cmdstate {};
45:
46: // ネゴシエーション中なら 1 以上。
47: // WILL, DO, WONT, DONT コマンドは、送信側がこの4種のコマンドを送信し、
48: // 受信側もこの4種で応答する。サーバ、クライアントどちらも送信側に
49: // なりうるため、これを受信しただけでは、対向が自発的に送信してきた
50: // ものか (こちらはそれに応答する必要がある)、こちらからのコマンドに
51: // 対向が応答したものか (こちらはそれ以上返答しない) の区別が出来ない。
52: // negotiation はこちらからコマンドを送った際に非 0 にして、受信した
53: // コマンドが応答であることを示すことにする。本来は bool でいいのだが
54: // 接続開始時にコマンドを複数投げる必要があるので、残りの応答数を
55: // 保持している。
56: int negotiation {};
57:
58: // コマンド名を返す
59: static std::string GetCommandName(uint8 code);
60: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.