|
|
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:
23: bool InitDriver() override;
24: int Dispatch(int udata) override;
25: int Read() override;
26: void Write(uint32 data) override;
1.1.1.2 root 27: void MonitorUpdateMD(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:
36: autofd ls {};
37: autofd sock {};
38:
39: // TELNET コマンド受信バッファ
40: std::vector<uint8> recvcmd {};
41: // TELNET コマンド (ステート)
42: int cmdstate {};
43:
44: // ネゴシエーション中なら 1 以上。
45: // WILL, DO, WONT, DONT コマンドは、送信側がこの4種のコマンドを送信し、
46: // 受信側もこの4種で応答する。サーバ、クライアントどちらも送信側に
47: // なりうるため、これを受信しただけでは、対向が自発的に送信してきた
48: // ものか (こちらはそれに応答する必要がある)、こちらからのコマンドに
49: // 対向が応答したものか (こちらはそれ以上返答しない) の区別が出来ない。
50: // negotiation はこちらからコマンドを送った際に非 0 にして、受信した
51: // コマンドが応答であることを示すことにする。本来は bool でいいのだが
52: // 接続開始時にコマンドを複数投げる必要があるので、残りの応答数を
53: // 保持している。
54: int negotiation {};
55:
56: // コマンド名を返す
57: static std::string GetCommandName(uint8 code);
58: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.