This source file includes following definitions.
- fnpInputRetryDue
- fnpScheduleInputRetry
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <uv.h>
21 #include "libtelnet.h"
22
23 #define encodeline(fnp,line) ((fnp) * MAX_LINES + (line))
24 #define decodefnp(coded) ((coded) / MAX_LINES)
25 #define decodeline(coded) ((coded) % MAX_LINES)
26 #define noassoc -1
27
28 extern UNIT fnp_unit [N_FNP_UNITS_MAX];
29 extern DEVICE fnp_dev;
30
31 #define MAX_LINES 96
32
33
34
35
36
37
38 enum service_types {service_undefined = 0, service_login, service_3270, service_autocall, service_slave};
39
40 typedef struct t_MState
41 {
42 t_bool accept_calls;
43
44
45
46
47
48
49 word16 configRegA;
50 struct t_line
51 {
52
53 enum service_types service;
54
55
56
57
58 uv_tcp_t * line_client;
59
60
61 bool was_CR;
62
63
64 t_bool listen;
65 uint inputBufferSize;
66 uint ctrlStrIdx;
67 t_bool breakAll;
68 t_bool handleQuit;
69 t_bool fullDuplex;
70 t_bool echoPlex;
71 t_bool crecho;
72 t_bool lfecho;
73 t_bool tabecho;
74 t_bool replay;
75 t_bool polite;
76 t_bool prefixnl;
77 t_bool eight_bit_out;
78 t_bool eight_bit_in;
79 t_bool odd_parity;
80 t_bool output_flow_control;
81 t_bool input_flow_control;
82 uint block_xfer_in_frame_sz, block_xfer_out_frame_sz;
83 uint delay_table [6];
84 #define FC_STR_SZ 4
85 uint inputSuspendLen;
86 unsigned char inputSuspendStr [4];
87 uint inputResumeLen;
88 unsigned char inputResumeStr [4];
89 uint outputSuspendLen;
90 unsigned char outputSuspendStr [4];
91 uint outputResumeLen;
92 unsigned char outputResumeStr [4];
93 uint frame_begin;
94 uint frame_end;
95
96
97 bool echnego_break_table [256];
98 word18 echnego_sync_ctr;
99 word18 echnego_screen_left;
100 uint echnego_unechoed_cnt;
101 bool echnego_on;
102 bool echnego_synced;
103
104 uint sync_msg_size;
105
106 bool line_break;
107 #if defined(FNPDBG)
108 # define SEND_OUTPUT_DELAY 100
109 #else
110 # define SEND_OUTPUT_DELAY 2
111 #endif
112 uint send_output;
113 bool accept_new_terminal;
114 #if defined(DISC_DELAY)
115 uint line_disconnected;
116 #else
117 bool line_disconnected;
118 #endif
119 bool ack_echnego_init;
120 bool ack_echnego_stop;
121 bool acu_dial_failure;
122 bool sendLineStatus;
123 bool wru_timeout;
124 uint accept_input;
125
126
127
128
129 uint64_t input_retry_at_ns;
130
131 bool force_accept_input;
132
133 bool waitForMbxDone;
134
135
136
137
138 bool input_reply_pending;
139
140
141 bool input_in_mailbox_pending;
142
143
144
145 bool input_cancelled;
146
147 bool input_break;
148
149
150 unsigned char buffer[1024];
151 uint nPos;
152
153
154 unsigned char * inBuffer;
155 uint inSize;
156 uint inUsed;
157
158
159 uv_connect_t doConnect;
160
161
162 uv_tcp_t server;
163 int port;
164
165 #if defined(TUN)
166
167 bool is_tun;
168 int tun_fd;
169 bool in_frame;
170 uint8_t frame [2+1500];
171 uint frameLen;
172 #endif
173
174 word9 lineType;
175 word36 lineStatus0, lineStatus1;
176 bool sendEOT;
177 } line [MAX_LINES];
178 } t_MState;
179
180
181
182 #define FNP_INPUT_RETRY_NS UINT64_C(1000000000)
183 static inline bool fnpInputRetryDue (const struct t_line * linep, uint64_t now_ns)
184 {
185 return linep->input_retry_at_ns == 0 || now_ns >= linep->input_retry_at_ns;
186 }
187 static inline void fnpScheduleInputRetry (struct t_line * linep)
188 {
189 if ((!linep->input_reply_pending && !linep->input_in_mailbox_pending) ||
190 linep->input_cancelled)
191 return;
192 linep->accept_input = 1;
193 linep->input_retry_at_ns = uv_hrtime () + FNP_INPUT_RETRY_NS;
194 }
195
196
197
198 #define IBM3270_CONTROLLERS_MAX 1
199 #define IBM3270_STATIONS_MAX 32
200
201 struct ibm3270ctlr_s
202 {
203 bool configured;
204 uint fnpno;
205 uint lineno;
206
207
208 unsigned char pollCtlrChar;
209 unsigned char pollDevChar;
210 unsigned char selCtlrChar;
211 unsigned char selDevChar;
212 bool sending_stn_in_buffer;
213 uint stn_no;
214 struct station_s
215 {
216 uv_tcp_t * client;
217 bool EORReceived;
218 bool hdr_sent;
219 unsigned char * stn_in_buffer;
220 uint stn_in_size;
221 uint stn_in_used;
222
223 } stations [IBM3270_STATIONS_MAX];
224
225
226
227
228
229 bool write_complete;
230 };
231
232 #define MAX_DEV_NAME_LEN 64
233
234
235 struct fnpUnitData_s
236 {
237 char device_name [MAX_DEV_NAME_LEN];
238 word24 mailboxAddress;
239 bool fnpIsRunning;
240 bool fnpMBXinUse [4];
241 bool lineWaiting [4];
242 int fnpMBXlineno [4];
243 char ipcName [MAX_DEV_NAME_LEN];
244
245 t_MState MState;
246 };
247
248 typedef struct s_fnpData
249 {
250 struct fnpUnitData_s fnpUnitData [N_FNP_UNITS_MAX];
251 struct ibm3270ctlr_s ibm3270ctlr [IBM3270_CONTROLLERS_MAX];
252 char * telnet_address;
253 int telnet_port;
254 int telnet3270_port;
255 uv_loop_t * loop;
256 uv_tcp_t du_server;
257 bool du_server_inited;
258 uv_tcp_t du3270_server;
259 bool du3270_server_inited;
260 int du3270_poll;
261 } t_fnpData;
262
263 extern t_fnpData fnpData;
264
265
266
267
268
269
270
271
272
273
274
275
276
277 struct dn355_submailbox
278 {
279 word36 word1;
280 word36 word2;
281 word36 command_data [3];
282 word36 word6;
283 word36 pad3 [2];
284 };
285
286 struct fnp_submailbox
287 {
288
289 word36 word1;
290 word36 word2;
291 word36 mystery [26];
292 };
293
294 struct input_sub_mbx
295 {
296 word36 word1;
297 word36 word2;
298 word36 n_buffers;
299 word36 dcws [24];
300 word36 command_data;
301 };
302
303 struct mailbox
304 {
305 word36 dia_pcw;
306 word36 mailbox_requests;
307 word36 term_inpt_mpx_wd;
308 word36 last_mbx_req_count;
309 word36 num_in_use;
310 word36 mbx_used_flags;
311 word36 crash_data [2];
312 struct dn355_submailbox dn355_sub_mbxes [8];
313 struct fnp_submailbox fnp_sub_mbxes [4];
314 };
315
316 #define MAILBOX_WORDS (sizeof (struct mailbox) / sizeof (word36))
317
318 #define DIA_PCW (offsetof (struct mailbox, dia_pcw) / sizeof (word36))
319 #define TERM_INPT_MPX_WD (offsetof (struct mailbox, term_inpt_mpx_wd) / sizeof (word36))
320 #define CRASH_DATA (offsetof (struct mailbox, crash_data) / sizeof (word36))
321 #define DN355_SUB_MBXES (offsetof (struct mailbox, dn355_sub_mbxes) / sizeof (word36))
322 #define FNP_SUB_MBXES (offsetof (struct mailbox, fnp_sub_mbxes) / sizeof (word36))
323
324 #define FNP_SUB_MBX_SIZE (sizeof (struct fnp_submailbox) / sizeof (word36))
325 #define DN355_SUB_MBX_SIZE (sizeof (struct dn355_submailbox) / sizeof (word36))
326
327 #define WORD1 0
328 #define WORD2 1
329 #define COMMAND_DATA 2
330 #define MYSTERY 2
331 #define WORD6 5
332 #define N_BUFFERS 2
333 #define DCWS 3
334 #define N_DCWS 24
335 #define INP_COMMAND_DATA 27
336
337 extern const unsigned char a2e [256];
338 extern const unsigned char e2a [256];
339 #define ADDR_MAP_ENTRIES 32
340
341
342 extern const unsigned char addr_map [ADDR_MAP_ENTRIES];
343
344 #define N_FW_ENTRIES 1024
345 extern int n_fw_entries;
346 struct fw_entry_s
347 {
348 uint line_0, line_1;
349 uint32_t ipaddr;
350 uint cidr;
351 uint32_t cidr_mask;
352 bool accept;
353 };
354 extern struct fw_entry_s fw_entries [N_FW_ENTRIES];
355
356 void fnpInit(void);
357 void fnpExit (void);
358 int lookupFnpsIomUnitNumber (int fnpUnitNum);
359 int lookupFnpLink (int fnpUnitNum);
360 void fnpProcessEvent (void);
361 t_stat diaCommand (int fnpUnitNum, char *arg3);
362 void fnpToCpuQueueMsg (int fnpUnitNum, char * msg);
363 iom_cmd_rc_t fnp_iom_cmd (uint iomUnitIdx, uint chan);
364 t_stat set_fnp_server_port (int32 arg, const char * buf);
365 t_stat set_fnp_server_address (int32 arg, const char * buf);
366 t_stat set_fnp_3270_server_port (int32 arg, const char * buf);
367 t_stat fnp_start (UNUSED int32 arg, UNUSED const char * buf);
368 void fnpConnectPrompt (uv_tcp_t * client);
369 void fnp3270ConnectPrompt (uv_tcp_t * client);
370 void processUserInput (uv_tcp_t * client, unsigned char * buf, ssize_t nread);
371 void processLineInput (uv_tcp_t * client, unsigned char * buf, ssize_t nread);
372 void fnpRecvEOR (uv_tcp_t * client);
373 void process3270Input (uv_tcp_t * client, unsigned char * buf, ssize_t nread);
374 void set_3270_write_complete (uv_tcp_t * client);
375 void startFNPListener (void);
376 void setTIMW (uint iom_unit_idx, uint chan, word24 mailboxAddress, int mbx);