omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / aienux / allen / net.om
| 1 | note Native bounded single HTTPS client. RFC826/791/768/2131/2132/1035/9293/6298. |
| 2 | note Caller provides Ethernet frames without FCS, checked monotonic milliseconds, |
| 3 | note six-byte unicast Nmac before netinit, and 32 fresh EFI entropy bytes in |
| 4 | note Nrand before every netconnect. netconnect consumes and wipes Nrand: DHCP xid, |
| 5 | note IPv4 id, DNS id/port, TCP port and ISN are never reused across connections. |
| 6 | note netwrite true transfers a copy, not a peer ACK. netsent is firmware acceptance. |
| 7 | note Public state 0idle 1DHCP 2DNS 3SYN 4open 5EOF/closed 6error. |
| 8 | note Errors: 1clock 2MAC/entropy 3DHCPtimeout 4DHCPnak 5config 6conflict |
| 9 | note 7ARPtimeout 8DNStimeout 9DNSrefused/truncated 10DNSinvalid/empty |
| 10 | note 11TCPtimeout 12peerreset 13unsupportedTCP 14leaseexpired 15transmit |
| 11 | note 16establishdeadline 17callerbounds. Invalid unrelated packets are ignored. |
| 12 | note Limits: untagged Ethernet MTU1500, IPv4 without options/fragments, |
| 13 | note DHCP lease without renewal, 120s establishment, DNS A/CNAME <=8 links, |
| 14 | note 64 DNS records/UDP message, one stop-and-wait TCP segment, receive64KiB. |
| 15 | note No DNS-over-TCP or EDNS: truncation fails; lease expiry fails explicitly. |
| 16 | note A bound lease is reused by later netconnect calls; anything else restarts DHCP. |
| 17 | note Internal Ncfg slots: now,dhcp,ip,mask,router,dns,server,offer,xid,leaseMS, |
| 18 | note leaseAt,initAt,dhcpDue,dhcpTries,probeCount,want,connectAt,generation, |
| 19 | note ipid,dnsid,dnsport,tcpport,dnsDue,dnsTries,cnameHops,qnameLen, |
| 20 | note arpWanted,arpCached,arpDue,arpTries,arpAt,initialized. |
| 21 | global Nrx uchar 2048 |
| 22 | global Ntx uchar 2048 |
| 23 | global Ntxlen ulong 1 |
| 24 | global Nmac uchar 6 |
| 25 | global Nrand uchar 32 |
| 26 | global Tcpin uchar 65536 |
| 27 | global Tcpout uchar 65536 |
| 28 | global Tcpn ulong 1 |
| 29 | global Tcpstate ulong 8 |
| 30 | global Ncfg ulong 32 |
| 31 | note Nct: una,next,rcvnxt,ringHead,peerwin,wl1,wl2,mss,ackPending, |
| 32 | note flightLen,flightKind(1syn2data3fin),flightSent,flightSeq,sentAt,rto, |
| 33 | note retries,sendTotal,sendOffset,closeWanted,finAcked,peerFin,finPending, |
| 34 | note finSeq,activity,timewaitAt,iss,srtt,rttvar,rttValid,zeroAt,synRetried. |
| 35 | global Nct ulong 32 |
| 36 | global Nsbuf uchar 65536 |
| 37 | global Nrbuf uchar 65536 |
| 38 | global Nrmap uchar 65536 |
| 39 | global Nhop uchar 6 |
| 40 | global Narp uchar 6 |
| 41 | global Napip ulong 1 |
| 42 | note Queue kind 1DHCP 2ARPquery 3ARPreply 4DNS 5TCPflight 6TCPack 7courierUDP. |
| 43 | note Kind 7 (look-chat.om, netudpsend) is fire-and-forget: netsent only clears it, |
| 44 | note no retry bookkeeping; the courier scheduler resends on its own clock. |
| 45 | note Q1 failures Q2 queuedAt Q3 DHCP/ARP phase Q4 seq Q5 ack Q6 window Q7 generation. |
| 46 | global Nq ulong 8 |
| 47 | note Parsed packet: frameLen,ipHlen,ipLen,src,dst,l4off,l4len,seq,ack, |
| 48 | note flags,dataOff,dataLen,window,tcpHlen. |
| 49 | global Npk ulong 16 |
| 50 | note Ndrop: reason code of the last segment refused before the payload path. Diagnosis only. |
| 51 | global Ndrop ulong 1 |
| 52 | note Ndropt/Ndropd/Ndropw: length, start offset and window of the last accepted segment. |
| 53 | global Ndropt ulong 1 |
| 54 | global Ndropd ulong 1 |
| 55 | global Ndropw ulong 1 |
| 56 | global Nopt ulong 8 |
| 57 | note DNS decoder base,end,next,nameLen,answerStart,answerCount,rrNext,rrData. |
| 58 | global Nd ulong 8 |
| 59 | global Nname uchar 256 |
| 60 | global Nwant uchar 256 |
| 61 | global Nrr ulong 4 |
| 62 | note Courier UDP hooks (look-chat.om): one datagram body out in Chtx, one in |
| 63 | note Chrx/Chrxn (0 = empty slot); a second arrival before chstep consumed the |
| 64 | note slot is dropped and counted in Chdrop. Port 47033 both ways, like the C |
| 65 | note kernel (x86/courier_udp.h CK_COURIER_PORT); source 0.0.0.0 before a lease. |
| 66 | global Chtx uchar 1600 |
| 67 | global Chrx uchar 1600 |
| 68 | global Chrxn ulong 1 |
| 69 | global Chdrop ulong 1 |
| 70 | text Nhost "api.github.com" |
| 71 | fn nr16 p ulong to ulong |
| 72 | ret add shl ulong get Nrx p 8 ulong get Nrx add p 1 |
| 73 | end |
| 74 | fn nr32 p ulong to ulong |
| 75 | ret add shl nr16 p 16 nr16 add p 2 |
| 76 | end |
| 77 | fn nt16 p ulong v ulong to void |
| 78 | put Ntx p uchar and shr v 8 255 |
| 79 | put Ntx add p 1 uchar and v 255 |
| 80 | end |
| 81 | fn nt32 p ulong v ulong to void |
| 82 | nt16 p shr v 16 |
| 83 | nt16 add p 2 and v 65535 |
| 84 | end |
| 85 | fn nadd a ulong b ulong to ulong |
| 86 | ret and add a b 4294967295 |
| 87 | end |
| 88 | fn ndiff a ulong b ulong to ulong |
| 89 | ret and sub add a 4294967296 b 4294967295 |
| 90 | end |
| 91 | fn nlt a ulong b ulong to bool |
| 92 | ret gt ndiff a b 2147483647 |
| 93 | end |
| 94 | fn nfold s ulong to ulong |
| 95 | while gt s 65535 bound 8 |
| 96 | s = add and s 65535 shr s 16 |
| 97 | end |
| 98 | ret xor s 65535 |
| 99 | end |
| 100 | fn nrsum p ulong n ulong to ulong |
| 101 | s = ulong 0 |
| 102 | while ge n 2 bound 1024 |
| 103 | s = add s nr16 p |
| 104 | p = add p 2 |
| 105 | n = sub n 2 |
| 106 | end |
| 107 | if eq n 1 |
| 108 | s = add s shl ulong get Nrx p 8 |
| 109 | end |
| 110 | ret s |
| 111 | end |
| 112 | fn ntsum p ulong n ulong to ulong |
| 113 | s = ulong 0 |
| 114 | while ge n 2 bound 1024 |
| 115 | s = add s shl ulong get Ntx p 8 |
| 116 | s = add s ulong get Ntx add p 1 |
| 117 | p = add p 2 |
| 118 | n = sub n 2 |
| 119 | end |
| 120 | if eq n 1 |
| 121 | s = add s shl ulong get Ntx p 8 |
| 122 | end |
| 123 | ret s |
| 124 | end |
| 125 | fn npssum a ulong b ulong proto ulong n ulong to ulong |
| 126 | s = add shr a 16 and a 65535 |
| 127 | s = add s shr b 16 |
| 128 | s = add s and b 65535 |
| 129 | ret add add s proto n |
| 130 | end |
| 131 | fn nipok ip ulong to bool |
| 132 | if or eq ip 0 eq ip 4294967295 |
| 133 | ret false |
| 134 | end |
| 135 | x = shr ip 24 |
| 136 | ret and ne x 0 and ne x 127 lt x 224 |
| 137 | end |
| 138 | fn nmacrx p ulong to bool |
| 139 | v = uchar 0 |
| 140 | for i ulong 6 |
| 141 | v = or v get Nrx add p i |
| 142 | end |
| 143 | ret and ne v 0 eq and get Nrx p 1 0 |
| 144 | end |
| 145 | fn nmaceq p ulong to bool |
| 146 | for i ulong 6 |
| 147 | if ne get Nrx add p i get Nmac i |
| 148 | ret false |
| 149 | end |
| 150 | end |
| 151 | ret true |
| 152 | end |
| 153 | fn nwipe to void |
| 154 | for i ulong 65536 |
| 155 | put Tcpin i uchar 0 |
| 156 | put Tcpout i uchar 0 |
| 157 | put Nsbuf i uchar 0 |
| 158 | put Nrbuf i uchar 0 |
| 159 | put Nrmap i uchar 0 |
| 160 | end |
| 161 | put Tcpn 0 0 |
| 162 | end |
| 163 | fn nfail code ulong to void |
| 164 | put Tcpstate 0 6 |
| 165 | put Tcpstate 1 code |
| 166 | put Ntxlen 0 0 |
| 167 | for i ulong 2048 |
| 168 | put Ntx i uchar 0 |
| 169 | end |
| 170 | for i ulong 32 |
| 171 | put Nrand i uchar 0 |
| 172 | put Nct i 0 |
| 173 | end |
| 174 | nwipe |
| 175 | end |
| 176 | fn nclock now ulong to bool |
| 177 | if or lt now get Ncfg 0 gt now 1000000000000000000 |
| 178 | nfail 1 |
| 179 | ret false |
| 180 | end |
| 181 | put Ncfg 0 now |
| 182 | ret true |
| 183 | end |
| 184 | fn ntxzero to void |
| 185 | for i ulong 1514 |
| 186 | put Ntx i uchar 0 |
| 187 | end |
| 188 | end |
| 189 | fn neth typ ulong broad bool to void |
| 190 | for i ulong 6 |
| 191 | if broad |
| 192 | put Ntx i uchar 255 |
| 193 | else |
| 194 | put Ntx i get Nhop i |
| 195 | end |
| 196 | put Ntx add i 6 get Nmac i |
| 197 | end |
| 198 | nt16 12 typ |
| 199 | end |
| 200 | fn nqueue kind ulong n ulong to void |
| 201 | if lt n 60 |
| 202 | n = 60 |
| 203 | end |
| 204 | put Ntxlen 0 n |
| 205 | put Nq 0 kind |
| 206 | put Nq 1 0 |
| 207 | put Nq 2 get Ncfg 0 |
| 208 | put Nq 7 get Ncfg 17 |
| 209 | end |
| 210 | fn nipbuild dest ulong proto ulong n ulong broad bool to void |
| 211 | neth 2048 broad |
| 212 | put Ntx 14 uchar 69 |
| 213 | nt16 16 add n 20 |
| 214 | nt16 18 get Ncfg 18 |
| 215 | put Ncfg 18 and add get Ncfg 18 1 65535 |
| 216 | nt16 20 16384 |
| 217 | put Ntx 22 uchar 64 |
| 218 | put Ntx 23 uchar proto |
| 219 | nt32 26 get Ncfg 2 |
| 220 | nt32 30 dest |
| 221 | nt16 24 nfold ntsum 14 20 |
| 222 | end |
| 223 | fn nudp dest ulong srcp ulong dstp ulong n ulong broad bool to void |
| 224 | nt16 34 srcp |
| 225 | nt16 36 dstp |
| 226 | nt16 38 add n 8 |
| 227 | s = npssum get Ncfg 2 dest 17 add n 8 |
| 228 | s = nfold add s ntsum 34 add n 8 |
| 229 | if eq s 0 |
| 230 | s = 65535 |
| 231 | end |
| 232 | nt16 40 s |
| 233 | nipbuild dest 17 add n 8 broad |
| 234 | end |
| 235 | note Courier datagram out: Chtx[0..n) to 255.255.255.255:47033 from Ncfg2:47033 |
| 236 | note in a broadcast frame, queued as kind 7 only when nothing else is in flight. |
| 237 | note Error state 6 does not refuse it: the courier has no TCP, DHCP or DNS |
| 238 | note dependency, so Allen keeps answering after a failed repository session. |
| 239 | note false: not queued, the courier scheduler offers the same datagram again on |
| 240 | note its own clock. |
| 241 | fn netudpsend n ulong to bool |
| 242 | if ne get Ntxlen 0 0 |
| 243 | ret false |
| 244 | end |
| 245 | if or eq n 0 gt n 1472 |
| 246 | ret false |
| 247 | end |
| 248 | ntxzero |
| 249 | for i ulong n |
| 250 | put Ntx add 42 i get Chtx i |
| 251 | end |
| 252 | nudp 4294967295 47033 47033 n true |
| 253 | nqueue 7 add 42 n |
| 254 | ret true |
| 255 | end |
| 256 | fn narpout target ulong probe bool to void |
| 257 | ntxzero |
| 258 | neth 2054 true |
| 259 | nt16 14 1 |
| 260 | nt16 16 2048 |
| 261 | put Ntx 18 uchar 6 |
| 262 | put Ntx 19 uchar 4 |
| 263 | nt16 20 1 |
| 264 | for i ulong 6 |
| 265 | put Ntx add i 22 get Nmac i |
| 266 | end |
| 267 | if not probe |
| 268 | nt32 28 get Ncfg 2 |
| 269 | end |
| 270 | nt32 38 target |
| 271 | put Nq 3 get Ncfg 1 |
| 272 | nqueue 2 42 |
| 273 | end |
| 274 | fn narprepl to void |
| 275 | ntxzero |
| 276 | neth 2054 false |
| 277 | for i ulong 6 |
| 278 | put Ntx i get Narp i |
| 279 | put Ntx add i 32 get Narp i |
| 280 | put Ntx add i 22 get Nmac i |
| 281 | end |
| 282 | nt16 14 1 |
| 283 | nt16 16 2048 |
| 284 | put Ntx 18 uchar 6 |
| 285 | put Ntx 19 uchar 4 |
| 286 | nt16 20 2 |
| 287 | nt32 28 get Ncfg 2 |
| 288 | nt32 38 get Napip 0 |
| 289 | put Napip 0 0 |
| 290 | nqueue 3 42 |
| 291 | end |
| 292 | fn nroute dest ulong to bool |
| 293 | if ne and dest get Ncfg 3 and get Ncfg 2 get Ncfg 3 |
| 294 | dest = get Ncfg 4 |
| 295 | end |
| 296 | if eq dest 0 |
| 297 | nfail 5 |
| 298 | ret false |
| 299 | end |
| 300 | if eq get Ncfg 27 dest |
| 301 | if lt sub get Ncfg 0 get Ncfg 30 60000 |
| 302 | ret true |
| 303 | end |
| 304 | put Ncfg 27 0 |
| 305 | end |
| 306 | if ne get Ncfg 26 dest |
| 307 | put Ncfg 26 dest |
| 308 | put Ncfg 29 0 |
| 309 | put Ncfg 28 get Ncfg 0 |
| 310 | end |
| 311 | if ge get Ncfg 0 get Ncfg 28 |
| 312 | if ge get Ncfg 29 5 |
| 313 | nfail 7 |
| 314 | ret false |
| 315 | end |
| 316 | narpout dest false |
| 317 | end |
| 318 | ret false |
| 319 | end |
| 320 | fn ndhcpout to void |
| 321 | ntxzero |
| 322 | put Ntx 42 uchar 1 |
| 323 | put Ntx 43 uchar 1 |
| 324 | put Ntx 44 uchar 6 |
| 325 | nt32 46 get Ncfg 8 |
| 326 | nt16 50 div sub get Ncfg 0 get Ncfg 11 1000 |
| 327 | nt16 52 32768 |
| 328 | for i ulong 6 |
| 329 | put Ntx add i 70 get Nmac i |
| 330 | end |
| 331 | nt32 278 1669485411 |
| 332 | put Ntx 282 uchar 53 |
| 333 | put Ntx 283 uchar 1 |
| 334 | mt = uchar 1 |
| 335 | if eq get Ncfg 1 2 |
| 336 | mt = 3 |
| 337 | end |
| 338 | if eq get Ncfg 1 5 |
| 339 | mt = 4 |
| 340 | end |
| 341 | put Ntx 284 mt |
| 342 | p = ulong 285 |
| 343 | if ne mt 1 |
| 344 | put Ntx p uchar 50 |
| 345 | put Ntx add p 1 uchar 4 |
| 346 | nt32 add p 2 get Ncfg 7 |
| 347 | put Ntx add p 6 uchar 54 |
| 348 | put Ntx add p 7 uchar 4 |
| 349 | nt32 add p 8 get Ncfg 6 |
| 350 | p = add p 12 |
| 351 | end |
| 352 | put Ntx p uchar 61 |
| 353 | put Ntx add p 1 uchar 7 |
| 354 | put Ntx add p 2 uchar 1 |
| 355 | for i ulong 6 |
| 356 | put Ntx add add p 3 i get Nmac i |
| 357 | end |
| 358 | p = add p 9 |
| 359 | note RFC2131 table 5: DHCPDECLINE carries no parameter list or size option. |
| 360 | if ne mt 4 |
| 361 | put Ntx p uchar 55 |
| 362 | put Ntx add p 1 uchar 6 |
| 363 | put Ntx add p 2 uchar 1 |
| 364 | put Ntx add p 3 uchar 3 |
| 365 | put Ntx add p 4 uchar 6 |
| 366 | put Ntx add p 5 uchar 51 |
| 367 | put Ntx add p 6 uchar 58 |
| 368 | put Ntx add p 7 uchar 59 |
| 369 | put Ntx add p 8 uchar 57 |
| 370 | put Ntx add p 9 uchar 2 |
| 371 | nt16 add p 10 1472 |
| 372 | p = add p 12 |
| 373 | end |
| 374 | put Ntx p uchar 255 |
| 375 | p = add p 1 |
| 376 | if lt p 342 |
| 377 | p = 342 |
| 378 | end |
| 379 | nudp 4294967295 68 67 sub p 42 true |
| 380 | put Nq 3 get Ncfg 1 |
| 381 | nqueue 1 p |
| 382 | end |
| 383 | fn ndnsout to void |
| 384 | ntxzero |
| 385 | nt16 42 get Ncfg 19 |
| 386 | nt16 44 256 |
| 387 | nt16 46 1 |
| 388 | for i ulong get Ncfg 25 |
| 389 | put Ntx add i 54 get Nwant i |
| 390 | end |
| 391 | p = add 54 get Ncfg 25 |
| 392 | nt16 p 1 |
| 393 | nt16 add p 2 1 |
| 394 | nudp get Ncfg 5 get Ncfg 20 53 sub add p 4 42 false |
| 395 | nqueue 4 add p 4 |
| 396 | end |
| 397 | fn nwindow to ulong |
| 398 | ret sub 65535 get Tcpn 0 |
| 399 | end |
| 400 | fn ntcpout flight bool to void |
| 401 | ntxzero |
| 402 | nt16 34 get Ncfg 21 |
| 403 | nt16 36 443 |
| 404 | nt32 38 get Nct 1 |
| 405 | nt32 42 get Nct 2 |
| 406 | put Ntx 46 uchar 80 |
| 407 | put Ntx 47 uchar 16 |
| 408 | nt16 48 nwindow |
| 409 | n = ulong 20 |
| 410 | if flight |
| 411 | nt32 38 get Nct 12 |
| 412 | if eq get Nct 10 1 |
| 413 | put Ntx 46 uchar 96 |
| 414 | put Ntx 47 uchar 2 |
| 415 | nt32 42 0 |
| 416 | put Ntx 54 uchar 2 |
| 417 | put Ntx 55 uchar 4 |
| 418 | nt16 56 1460 |
| 419 | n = 24 |
| 420 | else |
| 421 | if eq get Nct 10 3 |
| 422 | put Ntx 47 uchar 17 |
| 423 | else |
| 424 | put Ntx 47 uchar 24 |
| 425 | n = add n get Nct 9 |
| 426 | for i ulong get Nct 9 |
| 427 | put Ntx add i 54 get Nsbuf add get Nct 17 i |
| 428 | end |
| 429 | end |
| 430 | end |
| 431 | end |
| 432 | s = npssum get Ncfg 2 get Tcpstate 2 6 n |
| 433 | nt16 50 nfold add s ntsum 34 n |
| 434 | nipbuild get Tcpstate 2 6 n false |
| 435 | put Nq 4 get Nct 12 |
| 436 | put Nq 5 get Nct 2 |
| 437 | put Nq 6 nwindow |
| 438 | if flight |
| 439 | nqueue 5 add n 34 |
| 440 | else |
| 441 | nqueue 6 add n 34 |
| 442 | end |
| 443 | end |
| 444 | note DHCP option fields are parsed atomically before changing lease state. |
| 445 | fn ndopt code ulong p ulong n ulong to bool |
| 446 | slot = ulong 8 |
| 447 | if eq code 53 |
| 448 | slot = 0 |
| 449 | end |
| 450 | if eq code 54 |
| 451 | slot = 1 |
| 452 | end |
| 453 | if eq code 1 |
| 454 | slot = 2 |
| 455 | end |
| 456 | if eq code 3 |
| 457 | slot = 3 |
| 458 | end |
| 459 | if eq code 6 |
| 460 | slot = 4 |
| 461 | end |
| 462 | if eq code 51 |
| 463 | slot = 5 |
| 464 | end |
| 465 | if eq code 52 |
| 466 | slot = 7 |
| 467 | end |
| 468 | if eq slot 8 |
| 469 | ret true |
| 470 | end |
| 471 | if ne and get Nopt 6 shl ulong 1 slot 0 |
| 472 | ret false |
| 473 | end |
| 474 | put Nopt 6 or get Nopt 6 shl ulong 1 slot |
| 475 | if or eq slot 0 eq slot 7 |
| 476 | if ne n 1 |
| 477 | ret false |
| 478 | end |
| 479 | put Nopt slot ulong get Nrx p |
| 480 | ret true |
| 481 | end |
| 482 | if or eq slot 3 eq slot 4 |
| 483 | if or lt n 4 ne rem n 4 0 |
| 484 | ret false |
| 485 | end |
| 486 | else |
| 487 | if ne n 4 |
| 488 | ret false |
| 489 | end |
| 490 | end |
| 491 | put Nopt slot nr32 p |
| 492 | ret true |
| 493 | end |
| 494 | fn ndopts p ulong stop ulong to bool |
| 495 | while lt p stop bound 2048 |
| 496 | code = ulong get Nrx p |
| 497 | p = add p 1 |
| 498 | if eq code 255 |
| 499 | ret true |
| 500 | end |
| 501 | if ne code 0 |
| 502 | if ge p stop |
| 503 | ret false |
| 504 | end |
| 505 | n = ulong get Nrx p |
| 506 | p = add p 1 |
| 507 | if gt n sub stop p |
| 508 | ret false |
| 509 | end |
| 510 | if not ndopt code p n |
| 511 | ret false |
| 512 | end |
| 513 | p = add p n |
| 514 | end |
| 515 | end |
| 516 | ret false |
| 517 | end |
| 518 | fn ndconf to bool |
| 519 | m = get Ncfg 3 |
| 520 | if or eq m 0 eq m 4294967295 |
| 521 | ret false |
| 522 | end |
| 523 | v = xor m 4294967295 |
| 524 | if ne and v add v 1 0 |
| 525 | ret false |
| 526 | end |
| 527 | v = and get Ncfg 7 xor m 4294967295 |
| 528 | if or eq v 0 eq v xor m 4294967295 |
| 529 | ret false |
| 530 | end |
| 531 | if not nipok get Ncfg 4 |
| 532 | ret false |
| 533 | end |
| 534 | if ne and get Ncfg 4 m and get Ncfg 7 m |
| 535 | ret false |
| 536 | end |
| 537 | if not nipok get Ncfg 5 |
| 538 | ret false |
| 539 | end |
| 540 | ret ge get Ncfg 9 10000 |
| 541 | end |
| 542 | fn ndcopy to void |
| 543 | if ne get Nopt 2 0 |
| 544 | put Ncfg 3 get Nopt 2 |
| 545 | end |
| 546 | if ne get Nopt 3 0 |
| 547 | put Ncfg 4 get Nopt 3 |
| 548 | end |
| 549 | if ne get Nopt 4 0 |
| 550 | put Ncfg 5 get Nopt 4 |
| 551 | end |
| 552 | if ne get Nopt 5 0 |
| 553 | put Ncfg 9 mul get Nopt 5 1000 |
| 554 | end |
| 555 | end |
| 556 | fn ndhcpin to void |
| 557 | p = add get Npk 5 8 |
| 558 | n = sub get Npk 6 8 |
| 559 | if lt n 240 |
| 560 | ret |
| 561 | end |
| 562 | if or ne get Nrx p 2 ne get Nrx add p 1 1 |
| 563 | ret |
| 564 | end |
| 565 | if ne get Nrx add p 2 6 |
| 566 | ret |
| 567 | end |
| 568 | if ne nr32 add p 4 get Ncfg 8 |
| 569 | ret |
| 570 | end |
| 571 | if not nmaceq add p 28 |
| 572 | ret |
| 573 | end |
| 574 | if ne nr32 add p 236 1669485411 |
| 575 | ret |
| 576 | end |
| 577 | for i ulong 8 |
| 578 | put Nopt i 0 |
| 579 | end |
| 580 | if not ndopts add p 240 add p n |
| 581 | ret |
| 582 | end |
| 583 | if gt get Nopt 7 3 |
| 584 | ret |
| 585 | end |
| 586 | if ne and get Nopt 7 1 0 |
| 587 | if not ndopts add p 108 add p 236 |
| 588 | ret |
| 589 | end |
| 590 | end |
| 591 | if ne and get Nopt 7 2 0 |
| 592 | if not ndopts add p 44 add p 108 |
| 593 | ret |
| 594 | end |
| 595 | end |
| 596 | if not nipok get Nopt 1 |
| 597 | ret |
| 598 | end |
| 599 | if eq get Ncfg 1 1 |
| 600 | if ne get Nopt 0 2 |
| 601 | ret |
| 602 | end |
| 603 | if not nipok nr32 add p 16 |
| 604 | ret |
| 605 | end |
| 606 | put Ncfg 7 nr32 add p 16 |
| 607 | put Ncfg 6 get Nopt 1 |
| 608 | ndcopy |
| 609 | put Ncfg 1 2 |
| 610 | put Ncfg 13 0 |
| 611 | put Ncfg 12 get Ncfg 0 |
| 612 | ret |
| 613 | end |
| 614 | if ne get Ncfg 1 2 |
| 615 | ret |
| 616 | end |
| 617 | if ne get Nopt 1 get Ncfg 6 |
| 618 | ret |
| 619 | end |
| 620 | if eq get Nopt 0 6 |
| 621 | nfail 4 |
| 622 | ret |
| 623 | end |
| 624 | if ne get Nopt 0 5 |
| 625 | ret |
| 626 | end |
| 627 | if ne nr32 add p 16 get Ncfg 7 |
| 628 | ret |
| 629 | end |
| 630 | ndcopy |
| 631 | if not ndconf |
| 632 | nfail 5 |
| 633 | ret |
| 634 | end |
| 635 | put Ncfg 10 get Ncfg 0 |
| 636 | put Ncfg 1 3 |
| 637 | put Ncfg 14 0 |
| 638 | put Ncfg 12 add get Ncfg 0 rem get Ncfg 8 1000 |
| 639 | end |
| 640 | fn narpin to void |
| 641 | if lt get Npk 0 42 |
| 642 | ret |
| 643 | end |
| 644 | if or ne nr16 14 1 ne nr16 16 2048 |
| 645 | ret |
| 646 | end |
| 647 | if or ne get Nrx 18 6 ne get Nrx 19 4 |
| 648 | ret |
| 649 | end |
| 650 | if or lt nr16 20 1 gt nr16 20 2 |
| 651 | ret |
| 652 | end |
| 653 | if not nmacrx 22 |
| 654 | ret |
| 655 | end |
| 656 | for i ulong 6 |
| 657 | if ne get Nrx add i 6 get Nrx add i 22 |
| 658 | ret |
| 659 | end |
| 660 | end |
| 661 | if nmaceq 22 |
| 662 | ret |
| 663 | end |
| 664 | if eq get Ncfg 1 3 |
| 665 | if or eq nr32 28 get Ncfg 7 and eq nr32 28 0 eq nr32 38 get Ncfg 7 |
| 666 | put Ncfg 1 5 |
| 667 | put Ncfg 12 get Ncfg 0 |
| 668 | end |
| 669 | ret |
| 670 | end |
| 671 | if ne get Ncfg 1 4 |
| 672 | ret |
| 673 | end |
| 674 | if eq nr32 28 get Ncfg 2 |
| 675 | nfail 6 |
| 676 | ret |
| 677 | end |
| 678 | if ne nr32 38 get Ncfg 2 |
| 679 | ret |
| 680 | end |
| 681 | if eq nr16 20 2 |
| 682 | if not nmaceq 32 |
| 683 | ret |
| 684 | end |
| 685 | if or eq get Ncfg 26 0 ne nr32 28 get Ncfg 26 |
| 686 | ret |
| 687 | end |
| 688 | for i ulong 6 |
| 689 | put Nhop i get Nrx add i 22 |
| 690 | end |
| 691 | put Ncfg 27 get Ncfg 26 |
| 692 | put Ncfg 26 0 |
| 693 | put Ncfg 30 get Ncfg 0 |
| 694 | ret |
| 695 | end |
| 696 | if nipok nr32 28 |
| 697 | if eq get Napip 0 0 |
| 698 | for i ulong 6 |
| 699 | put Narp i get Nrx add i 22 |
| 700 | end |
| 701 | put Napip 0 nr32 28 |
| 702 | end |
| 703 | end |
| 704 | end |
| 705 | note DNS names expand to lowercase wire labels, never textual pointer arithmetic. |
| 706 | note Compression pointers must point backward into this message, with <=128 hops. |
| 707 | fn ndname p ulong to bool |
| 708 | used = ulong 0 |
| 709 | next = ulong 0 |
| 710 | for hop ulong 256 |
| 711 | if ge p get Nd 1 |
| 712 | ret false |
| 713 | end |
| 714 | c = ulong get Nrx p |
| 715 | if eq and c 192 192 |
| 716 | if ge add p 1 get Nd 1 |
| 717 | ret false |
| 718 | end |
| 719 | q = add get Nd 0 and nr16 p 16383 |
| 720 | if or ge q p lt q add get Nd 0 12 |
| 721 | ret false |
| 722 | end |
| 723 | if eq next 0 |
| 724 | next = add p 2 |
| 725 | end |
| 726 | p = q |
| 727 | else |
| 728 | if ne and c 192 0 |
| 729 | ret false |
| 730 | end |
| 731 | p = add p 1 |
| 732 | if or gt add used add c 1 255 gt c sub get Nd 1 p |
| 733 | ret false |
| 734 | end |
| 735 | put Nname used uchar c |
| 736 | used = add used 1 |
| 737 | if eq c 0 |
| 738 | if eq next 0 |
| 739 | next = p |
| 740 | end |
| 741 | put Nd 2 next |
| 742 | put Nd 3 used |
| 743 | ret true |
| 744 | end |
| 745 | for i ulong c |
| 746 | v = get Nrx add p i |
| 747 | if and ge v 65 le v 90 |
| 748 | v = add v 32 |
| 749 | end |
| 750 | put Nname used v |
| 751 | used = add used 1 |
| 752 | end |
| 753 | p = add p c |
| 754 | end |
| 755 | end |
| 756 | ret false |
| 757 | end |
| 758 | fn ndmatch to bool |
| 759 | if ne get Nd 3 get Ncfg 25 |
| 760 | ret false |
| 761 | end |
| 762 | for i ulong get Nd 3 |
| 763 | if ne get Nname i get Nwant i |
| 764 | ret false |
| 765 | end |
| 766 | end |
| 767 | ret true |
| 768 | end |
| 769 | fn ndrr p ulong to bool |
| 770 | if not ndname p |
| 771 | ret false |
| 772 | end |
| 773 | p = get Nd 2 |
| 774 | if gt add p 10 get Nd 1 |
| 775 | ret false |
| 776 | end |
| 777 | put Nrr 0 nr16 p |
| 778 | put Nrr 1 nr16 add p 2 |
| 779 | put Nrr 2 nr16 add p 8 |
| 780 | put Nrr 3 nr32 add p 4 |
| 781 | p = add p 10 |
| 782 | if gt get Nrr 2 sub get Nd 1 p |
| 783 | ret false |
| 784 | end |
| 785 | put Nd 7 p |
| 786 | put Nd 6 add p get Nrr 2 |
| 787 | ret true |
| 788 | end |
| 789 | fn ndtarget to void |
| 790 | for i ulong get Nd 3 |
| 791 | put Nwant i get Nname i |
| 792 | end |
| 793 | put Ncfg 25 get Nd 3 |
| 794 | put Ncfg 24 add get Ncfg 24 1 |
| 795 | end |
| 796 | fn ndanswer to void |
| 797 | for pass ulong 9 |
| 798 | p = get Nd 4 |
| 799 | changed = false |
| 800 | for i ulong get Nd 5 |
| 801 | if not ndrr p |
| 802 | nfail 10 |
| 803 | ret |
| 804 | end |
| 805 | p = get Nd 6 |
| 806 | if and eq get Nrr 1 1 ndmatch |
| 807 | if eq get Nrr 0 1 |
| 808 | if ne get Nrr 2 4 |
| 809 | nfail 10 |
| 810 | ret |
| 811 | end |
| 812 | if not nipok nr32 get Nd 7 |
| 813 | nfail 10 |
| 814 | ret |
| 815 | end |
| 816 | put Tcpstate 2 nr32 get Nd 7 |
| 817 | put Tcpstate 0 3 |
| 818 | put Nct 9 1 |
| 819 | put Nct 10 1 |
| 820 | put Nct 11 0 |
| 821 | put Nct 12 get Nct 25 |
| 822 | put Nct 0 get Nct 25 |
| 823 | put Nct 1 get Nct 25 |
| 824 | put Nct 14 1000 |
| 825 | put Nct 15 0 |
| 826 | ret |
| 827 | end |
| 828 | if eq get Nrr 0 5 |
| 829 | if ge get Ncfg 24 8 |
| 830 | nfail 10 |
| 831 | ret |
| 832 | end |
| 833 | if not ndname get Nd 7 |
| 834 | nfail 10 |
| 835 | ret |
| 836 | end |
| 837 | if ne get Nd 2 p |
| 838 | nfail 10 |
| 839 | ret |
| 840 | end |
| 841 | if ndmatch |
| 842 | nfail 10 |
| 843 | ret |
| 844 | end |
| 845 | ndtarget |
| 846 | changed = true |
| 847 | break |
| 848 | end |
| 849 | end |
| 850 | end |
| 851 | if not changed |
| 852 | if eq pass 0 |
| 853 | nfail 10 |
| 854 | ret |
| 855 | end |
| 856 | put Ncfg 19 and add get Ncfg 19 1 65535 |
| 857 | put Ncfg 22 get Ncfg 0 |
| 858 | put Ncfg 23 0 |
| 859 | ret |
| 860 | end |
| 861 | end |
| 862 | nfail 10 |
| 863 | end |
| 864 | fn ndnsin to void |
| 865 | p = add get Npk 5 8 |
| 866 | if lt get Npk 6 20 |
| 867 | ret |
| 868 | end |
| 869 | if ne nr16 p get Ncfg 19 |
| 870 | ret |
| 871 | end |
| 872 | if ne and nr16 add p 2 63488 32768 |
| 873 | ret |
| 874 | end |
| 875 | if ne nr16 add p 4 1 |
| 876 | ret |
| 877 | end |
| 878 | put Nd 0 p |
| 879 | put Nd 1 add get Npk 5 get Npk 6 |
| 880 | if not ndname add p 12 |
| 881 | ret |
| 882 | end |
| 883 | if not ndmatch |
| 884 | ret |
| 885 | end |
| 886 | q = get Nd 2 |
| 887 | if gt add q 4 get Nd 1 |
| 888 | ret |
| 889 | end |
| 890 | if or ne nr16 q 1 ne nr16 add q 2 1 |
| 891 | ret |
| 892 | end |
| 893 | if ne and nr16 add p 2 527 0 |
| 894 | nfail 9 |
| 895 | ret |
| 896 | end |
| 897 | put Nd 4 add q 4 |
| 898 | put Nd 5 nr16 add p 6 |
| 899 | n = add get Nd 5 nr16 add p 8 |
| 900 | n = add n nr16 add p 10 |
| 901 | if gt n 64 |
| 902 | nfail 10 |
| 903 | ret |
| 904 | end |
| 905 | q = get Nd 4 |
| 906 | for i ulong n |
| 907 | if not ndrr q |
| 908 | nfail 10 |
| 909 | ret |
| 910 | end |
| 911 | q = get Nd 6 |
| 912 | end |
| 913 | if ne q get Nd 1 |
| 914 | nfail 10 |
| 915 | ret |
| 916 | end |
| 917 | ndanswer |
| 918 | end |
| 919 | fn nrtt to void |
| 920 | if ne get Nct 15 0 |
| 921 | ret |
| 922 | end |
| 923 | r = sub get Ncfg 0 get Nct 13 |
| 924 | if eq r 0 |
| 925 | r = 1 |
| 926 | end |
| 927 | if eq get Nct 28 0 |
| 928 | put Nct 26 r |
| 929 | put Nct 27 div r 2 |
| 930 | put Nct 28 1 |
| 931 | else |
| 932 | d = get Nct 26 |
| 933 | if ge d r |
| 934 | d = sub d r |
| 935 | else |
| 936 | d = sub r d |
| 937 | end |
| 938 | put Nct 27 div add mul get Nct 27 3 d 4 |
| 939 | put Nct 26 div add mul get Nct 26 7 r 8 |
| 940 | end |
| 941 | r = add get Nct 26 mul get Nct 27 4 |
| 942 | if lt r 1000 |
| 943 | r = 1000 |
| 944 | end |
| 945 | if gt r 60000 |
| 946 | r = 60000 |
| 947 | end |
| 948 | if and ne get Nct 30 0 lt r 3000 |
| 949 | r = 3000 |
| 950 | end |
| 951 | put Nct 14 r |
| 952 | end |
| 953 | fn ntopts p ulong stop ulong to bool |
| 954 | while lt p stop bound 40 |
| 955 | kind = ulong get Nrx p |
| 956 | if eq kind 0 |
| 957 | ret true |
| 958 | end |
| 959 | if eq kind 1 |
| 960 | p = add p 1 |
| 961 | else |
| 962 | if ge add p 1 stop |
| 963 | ret false |
| 964 | end |
| 965 | n = ulong get Nrx add p 1 |
| 966 | if or lt n 2 gt n sub stop p |
| 967 | ret false |
| 968 | end |
| 969 | if eq kind 2 |
| 970 | if ne n 4 |
| 971 | ret false |
| 972 | end |
| 973 | n = nr16 add p 2 |
| 974 | if eq n 0 |
| 975 | ret false |
| 976 | end |
| 977 | if gt n 1460 |
| 978 | n = 1460 |
| 979 | end |
| 980 | put Nct 7 n |
| 981 | n = 4 |
| 982 | end |
| 983 | p = add p n |
| 984 | end |
| 985 | end |
| 986 | ret true |
| 987 | end |
| 988 | fn ntaccept to bool |
| 989 | n = get Npk 11 |
| 990 | if ne and get Npk 9 1 0 |
| 991 | n = add n 1 |
| 992 | end |
| 993 | w = nwindow |
| 994 | if eq n 0 |
| 995 | if eq w 0 |
| 996 | ret eq get Npk 7 get Nct 2 |
| 997 | end |
| 998 | ret lt ndiff get Npk 7 get Nct 2 w |
| 999 | end |
| 1000 | if eq w 0 |
| 1001 | ret false |
| 1002 | end |
| 1003 | if lt ndiff get Npk 7 get Nct 2 w |
| 1004 | ret true |
| 1005 | end |
| 1006 | ret lt ndiff nadd get Npk 7 sub n 1 get Nct 2 w |
| 1007 | end |
| 1008 | fn ntack to bool |
| 1009 | a = get Npk 8 |
| 1010 | if nlt get Nct 1 a |
| 1011 | put Nct 8 1 |
| 1012 | ret false |
| 1013 | end |
| 1014 | if nlt a get Nct 0 |
| 1015 | ret true |
| 1016 | end |
| 1017 | if or nlt get Nct 5 get Npk 7 and eq get Nct 5 get Npk 7 not nlt a get Nct 6 |
| 1018 | put Nct 4 get Npk 12 |
| 1019 | put Nct 5 get Npk 7 |
| 1020 | put Nct 6 a |
| 1021 | end |
| 1022 | if eq a get Nct 0 |
| 1023 | ret true |
| 1024 | end |
| 1025 | if or eq get Nct 9 0 eq get Nct 11 0 |
| 1026 | ret false |
| 1027 | end |
| 1028 | n = ndiff a get Nct 0 |
| 1029 | if gt n get Nct 9 |
| 1030 | ret false |
| 1031 | end |
| 1032 | if eq n get Nct 9 |
| 1033 | nrtt |
| 1034 | end |
| 1035 | if eq get Nct 10 2 |
| 1036 | for i ulong n |
| 1037 | put Nsbuf add get Nct 17 i uchar 0 |
| 1038 | end |
| 1039 | put Nct 17 add get Nct 17 n |
| 1040 | end |
| 1041 | put Nct 0 a |
| 1042 | put Nct 12 a |
| 1043 | put Nct 9 sub get Nct 9 n |
| 1044 | put Nct 13 get Ncfg 0 |
| 1045 | if ne get Nct 9 0 |
| 1046 | note Partial ACK retains Karn ambiguity for the remaining bytes. |
| 1047 | put Nct 15 1 |
| 1048 | ret true |
| 1049 | end |
| 1050 | if eq get Nct 10 3 |
| 1051 | put Nct 19 1 |
| 1052 | end |
| 1053 | put Nct 10 0 |
| 1054 | put Nct 11 0 |
| 1055 | put Nct 15 0 |
| 1056 | if eq get Nct 17 get Nct 16 |
| 1057 | put Nct 17 0 |
| 1058 | put Nct 16 0 |
| 1059 | end |
| 1060 | ret true |
| 1061 | end |
| 1062 | fn ntfinish to void |
| 1063 | if and ne get Nct 19 0 ne get Nct 20 0 |
| 1064 | if eq get Nct 24 0 |
| 1065 | put Nct 24 add get Ncfg 0 1 |
| 1066 | end |
| 1067 | put Tcpstate 0 5 |
| 1068 | end |
| 1069 | end |
| 1070 | fn ntdrain to void |
| 1071 | while ne get Nrmap get Nct 3 0 bound 65536 |
| 1072 | if ge get Tcpn 0 65535 |
| 1073 | break |
| 1074 | end |
| 1075 | if ne get Nct 20 0 |
| 1076 | break |
| 1077 | end |
| 1078 | if and ne get Nct 21 0 eq get Nct 22 get Nct 2 |
| 1079 | break |
| 1080 | end |
| 1081 | put Tcpin get Tcpn 0 get Nrbuf get Nct 3 |
| 1082 | put Tcpn 0 add get Tcpn 0 1 |
| 1083 | put Nrmap get Nct 3 uchar 0 |
| 1084 | put Nrbuf get Nct 3 uchar 0 |
| 1085 | put Nct 3 and add get Nct 3 1 65535 |
| 1086 | put Nct 2 nadd get Nct 2 1 |
| 1087 | end |
| 1088 | if and ne get Nct 21 0 eq get Nct 22 get Nct 2 |
| 1089 | put Nct 2 nadd get Nct 2 1 |
| 1090 | put Nct 21 0 |
| 1091 | put Nct 20 1 |
| 1092 | put Nct 18 1 |
| 1093 | put Nct 8 1 |
| 1094 | put Tcpstate 0 5 |
| 1095 | end |
| 1096 | ntfinish |
| 1097 | end |
| 1098 | fn ntdata to void |
| 1099 | if ne get Nct 20 0 |
| 1100 | put Nct 8 1 |
| 1101 | ret |
| 1102 | end |
| 1103 | note Out-of-order bytes are stored directly in the ring and drained once the gap fills. |
| 1104 | note This deliberately does not borrow Nct 21/22, which hold the peer FIN state: doing so |
| 1105 | note made a retransmitted in-order segment look like a FIN and stalled the stream. |
| 1106 | for i ulong get Npk 11 |
| 1107 | s = nadd get Npk 7 i |
| 1108 | d = ndiff s get Nct 2 |
| 1109 | if lt d nwindow |
| 1110 | p = and add get Nct 3 d 65535 |
| 1111 | v = get Nrx add get Npk 10 i |
| 1112 | if eq get Nrmap p 0 |
| 1113 | put Nrbuf p v |
| 1114 | put Nrmap p uchar 1 |
| 1115 | else |
| 1116 | if ne get Nrbuf p v |
| 1117 | nfail 13 |
| 1118 | ret |
| 1119 | end |
| 1120 | end |
| 1121 | end |
| 1122 | end |
| 1123 | if or ne get Npk 11 0 ne and get Npk 9 1 0 |
| 1124 | put Nct 8 1 |
| 1125 | end |
| 1126 | ntdrain |
| 1127 | end |
| 1128 | fn ntsynin to void |
| 1129 | if eq get Nct 11 0 |
| 1130 | ret |
| 1131 | end |
| 1132 | if ne get Npk 8 nadd get Nct 25 1 |
| 1133 | ret |
| 1134 | end |
| 1135 | if eq and get Npk 9 20 20 |
| 1136 | nfail 12 |
| 1137 | ret |
| 1138 | end |
| 1139 | if ne and get Npk 9 23 18 |
| 1140 | ret |
| 1141 | end |
| 1142 | if ne get Npk 11 0 |
| 1143 | nfail 13 |
| 1144 | ret |
| 1145 | end |
| 1146 | if not ntopts add get Npk 5 20 get Npk 10 |
| 1147 | ret |
| 1148 | end |
| 1149 | nrtt |
| 1150 | put Nct 0 get Npk 8 |
| 1151 | put Nct 1 get Npk 8 |
| 1152 | put Nct 2 nadd get Npk 7 1 |
| 1153 | put Nct 4 get Npk 12 |
| 1154 | put Nct 5 get Npk 7 |
| 1155 | put Nct 6 get Npk 8 |
| 1156 | put Nct 9 0 |
| 1157 | put Nct 10 0 |
| 1158 | put Nct 11 0 |
| 1159 | put Nct 15 0 |
| 1160 | put Nct 8 1 |
| 1161 | put Nct 23 get Ncfg 0 |
| 1162 | put Tcpstate 0 4 |
| 1163 | end |
| 1164 | fn ntcpin to void |
| 1165 | p = get Npk 5 |
| 1166 | if lt get Npk 6 20 |
| 1167 | ret |
| 1168 | end |
| 1169 | if or ne nr16 p 443 ne nr16 add p 2 get Ncfg 21 |
| 1170 | ret |
| 1171 | end |
| 1172 | if ne get Npk 3 get Tcpstate 2 |
| 1173 | put Ndrop 0 12 |
| 1174 | ret |
| 1175 | end |
| 1176 | s = npssum get Npk 3 get Npk 4 6 get Npk 6 |
| 1177 | if ne nfold add s nrsum p get Npk 6 0 |
| 1178 | put Ndrop 0 13 |
| 1179 | ret |
| 1180 | end |
| 1181 | put Npk 13 mul ulong shr get Nrx add p 12 4 4 |
| 1182 | if or lt get Npk 13 20 gt get Npk 13 get Npk 6 |
| 1183 | put Ndrop 0 14 |
| 1184 | ret |
| 1185 | end |
| 1186 | note RFC9293: the four reserved header bits are ignored on receipt. |
| 1187 | put Npk 7 nr32 add p 4 |
| 1188 | put Npk 8 nr32 add p 8 |
| 1189 | put Npk 9 ulong get Nrx add p 13 |
| 1190 | put Npk 10 add p get Npk 13 |
| 1191 | put Npk 11 sub get Npk 6 get Npk 13 |
| 1192 | put Npk 12 nr16 add p 14 |
| 1193 | if eq get Tcpstate 0 3 |
| 1194 | ntsynin |
| 1195 | ret |
| 1196 | end |
| 1197 | if or lt get Tcpstate 0 4 gt get Tcpstate 0 5 |
| 1198 | put Ndrop 0 15 |
| 1199 | ret |
| 1200 | end |
| 1201 | if ne get Nct 31 0 |
| 1202 | put Ndrop 0 16 |
| 1203 | ret |
| 1204 | end |
| 1205 | if ne and get Npk 9 4 0 |
| 1206 | if eq get Npk 7 get Nct 2 |
| 1207 | nfail 12 |
| 1208 | else |
| 1209 | if ntaccept |
| 1210 | put Nct 8 1 |
| 1211 | end |
| 1212 | end |
| 1213 | ret |
| 1214 | end |
| 1215 | if not ntaccept |
| 1216 | put Nct 8 1 |
| 1217 | if and ne get Nct 24 0 ne and get Npk 9 1 0 |
| 1218 | if eq nadd get Npk 7 add get Npk 11 1 get Nct 2 |
| 1219 | put Nct 24 add get Ncfg 0 1 |
| 1220 | end |
| 1221 | end |
| 1222 | ret |
| 1223 | end |
| 1224 | if ne and get Npk 9 2 0 |
| 1225 | put Nct 8 1 |
| 1226 | ret |
| 1227 | end |
| 1228 | if eq and get Npk 9 16 0 |
| 1229 | ret |
| 1230 | end |
| 1231 | note CWR/ECE are ignored (ECN was not offered); urgent data is refused. |
| 1232 | if ne and get Npk 9 32 0 |
| 1233 | nfail 13 |
| 1234 | ret |
| 1235 | end |
| 1236 | if not ntack |
| 1237 | put Ndrop 0 1 |
| 1238 | ret |
| 1239 | end |
| 1240 | put Ndropt 0 get Npk 11 |
| 1241 | put Ndropd 0 ndiff get Npk 7 get Nct 2 |
| 1242 | put Ndropw 0 nwindow |
| 1243 | put Nct 23 get Ncfg 0 |
| 1244 | ntdata |
| 1245 | if ne and get Npk 9 1 0 |
| 1246 | note FIN occupies one sequence number after the payload. Latch it; ntdrain completes it when |
| 1247 | note the stream reaches it, in order or after the gap fills. |
| 1248 | put Nct 21 1 |
| 1249 | put Nct 22 nadd get Npk 7 get Npk 11 |
| 1250 | ntdrain |
| 1251 | end |
| 1252 | end |
| 1253 | note Courier datagram in (UDP to port 47033, checksum already verified). Like |
| 1254 | note the C kernel (courier_udp_x86.c pump) the frame is ours by its Ethernet |
| 1255 | note destination (netinput: our MAC or ff:ff:ff:ff:ff:ff) and the port alone: |
| 1256 | note any IPv4 destination is taken, so the relay's --udp-answer 192.168.1.255 |
| 1257 | note reaches a kernel that has no lease yet. Copied into Chrx when the slot is |
| 1258 | note free, else dropped and counted. Any source port. |
| 1259 | fn netudpin p ulong to void |
| 1260 | n = sub get Npk 6 8 |
| 1261 | if or eq n 0 gt n len Chrx |
| 1262 | ret |
| 1263 | end |
| 1264 | if ne get Chrxn 0 0 |
| 1265 | put Chdrop 0 add get Chdrop 0 1 |
| 1266 | ret |
| 1267 | end |
| 1268 | for i ulong n |
| 1269 | put Chrx i get Nrx add add p 8 i |
| 1270 | end |
| 1271 | put Chrxn 0 n |
| 1272 | end |
| 1273 | fn nipin to void |
| 1274 | if lt get Npk 0 34 |
| 1275 | ret |
| 1276 | end |
| 1277 | if ne shr get Nrx 14 4 4 |
| 1278 | ret |
| 1279 | end |
| 1280 | put Npk 1 mul ulong and get Nrx 14 15 4 |
| 1281 | if lt get Npk 1 20 |
| 1282 | ret |
| 1283 | end |
| 1284 | put Npk 2 nr16 16 |
| 1285 | if or lt get Npk 2 get Npk 1 gt add get Npk 2 14 get Npk 0 |
| 1286 | ret |
| 1287 | end |
| 1288 | if ne and nr16 20 49151 0 |
| 1289 | ret |
| 1290 | end |
| 1291 | if eq get Nrx 22 0 |
| 1292 | ret |
| 1293 | end |
| 1294 | if ne nfold nrsum 14 get Npk 1 0 |
| 1295 | ret |
| 1296 | end |
| 1297 | note All IPv4 options are refused; no source-route or hidden forwarding path. |
| 1298 | if ne get Npk 1 20 |
| 1299 | ret |
| 1300 | end |
| 1301 | put Npk 3 nr32 26 |
| 1302 | put Npk 4 nr32 30 |
| 1303 | if not nipok get Npk 3 |
| 1304 | ret |
| 1305 | end |
| 1306 | put Npk 5 add 14 get Npk 1 |
| 1307 | put Npk 6 sub get Npk 2 get Npk 1 |
| 1308 | if eq get Nrx 23 6 |
| 1309 | if ne get Tcpstate 0 6 |
| 1310 | if and eq get Ncfg 1 4 eq get Npk 4 get Ncfg 2 |
| 1311 | ntcpin |
| 1312 | end |
| 1313 | end |
| 1314 | ret |
| 1315 | end |
| 1316 | if ne get Nrx 23 17 |
| 1317 | ret |
| 1318 | end |
| 1319 | p = get Npk 5 |
| 1320 | if lt get Npk 6 8 |
| 1321 | ret |
| 1322 | end |
| 1323 | if ne nr16 add p 4 get Npk 6 |
| 1324 | ret |
| 1325 | end |
| 1326 | if ne nr16 add p 6 0 |
| 1327 | s = npssum get Npk 3 get Npk 4 17 get Npk 6 |
| 1328 | if ne nfold add s nrsum p get Npk 6 0 |
| 1329 | ret |
| 1330 | end |
| 1331 | end |
| 1332 | if and eq nr16 p 67 eq nr16 add p 2 68 |
| 1333 | if ne get Tcpstate 0 6 |
| 1334 | if or eq get Ncfg 1 1 eq get Ncfg 1 2 |
| 1335 | note Any destination: chaddr, random xid and server-id gate acceptance. |
| 1336 | ndhcpin |
| 1337 | end |
| 1338 | end |
| 1339 | ret |
| 1340 | end |
| 1341 | if eq nr16 add p 2 47033 |
| 1342 | netudpin p |
| 1343 | ret |
| 1344 | end |
| 1345 | if ne get Tcpstate 0 2 |
| 1346 | ret |
| 1347 | end |
| 1348 | if or ne get Npk 4 get Ncfg 2 ne get Npk 3 get Ncfg 5 |
| 1349 | ret |
| 1350 | end |
| 1351 | if or ne nr16 p 53 ne nr16 add p 2 get Ncfg 20 |
| 1352 | ret |
| 1353 | end |
| 1354 | ndnsin |
| 1355 | end |
| 1356 | fn nrnd32 p ulong to ulong |
| 1357 | v = ulong 0 |
| 1358 | for i ulong 4 |
| 1359 | v = add shl v 8 ulong get Nrand add p i |
| 1360 | end |
| 1361 | ret v |
| 1362 | end |
| 1363 | fn nqhost to void |
| 1364 | put Nwant 0 uchar 3 |
| 1365 | put Nwant 4 uchar 6 |
| 1366 | put Nwant 11 uchar 3 |
| 1367 | put Nwant 15 uchar 0 |
| 1368 | for i ulong 3 |
| 1369 | put Nwant add i 1 get Nhost i |
| 1370 | put Nwant add i 12 get Nhost add i 11 |
| 1371 | end |
| 1372 | for i ulong 6 |
| 1373 | put Nwant add i 5 get Nhost add i 4 |
| 1374 | end |
| 1375 | put Ncfg 25 16 |
| 1376 | end |
| 1377 | fn netinit now ulong to void |
| 1378 | put Ntxlen 0 0 |
| 1379 | nwipe |
| 1380 | for i ulong 32 |
| 1381 | put Ncfg i 0 |
| 1382 | put Nct i 0 |
| 1383 | put Nrand i uchar 0 |
| 1384 | end |
| 1385 | for i ulong 8 |
| 1386 | put Tcpstate i 0 |
| 1387 | put Nq i 0 |
| 1388 | end |
| 1389 | put Napip 0 0 |
| 1390 | for i ulong 6 |
| 1391 | put Nhop i uchar 0 |
| 1392 | put Narp i uchar 0 |
| 1393 | end |
| 1394 | if not nclock now |
| 1395 | ret |
| 1396 | end |
| 1397 | v = uchar 0 |
| 1398 | for i ulong 6 |
| 1399 | v = or v get Nmac i |
| 1400 | end |
| 1401 | if or eq v 0 ne and get Nmac 0 1 0 |
| 1402 | nfail 2 |
| 1403 | ret |
| 1404 | end |
| 1405 | put Ncfg 31 1 |
| 1406 | end |
| 1407 | fn nbound to bool |
| 1408 | if or ne get Ncfg 1 4 lt get Ncfg 14 5 |
| 1409 | ret false |
| 1410 | end |
| 1411 | ret lt sub get Ncfg 0 get Ncfg 10 get Ncfg 9 |
| 1412 | end |
| 1413 | fn ndhcpnew to void |
| 1414 | for i ulong 14 |
| 1415 | put Ncfg add i 1 0 |
| 1416 | end |
| 1417 | for i ulong 5 |
| 1418 | put Ncfg add i 26 0 |
| 1419 | end |
| 1420 | put Ncfg 8 nrnd32 0 |
| 1421 | put Ncfg 1 1 |
| 1422 | put Ncfg 11 get Ncfg 0 |
| 1423 | put Ncfg 12 get Ncfg 0 |
| 1424 | end |
| 1425 | fn netconnect now ulong to void |
| 1426 | if not nclock now |
| 1427 | ret |
| 1428 | end |
| 1429 | if eq get Ncfg 31 0 |
| 1430 | nfail 17 |
| 1431 | ret |
| 1432 | end |
| 1433 | if and ge get Tcpstate 0 1 le get Tcpstate 0 4 |
| 1434 | ret |
| 1435 | end |
| 1436 | v = uchar 0 |
| 1437 | for i ulong 32 |
| 1438 | v = or v get Nrand i |
| 1439 | end |
| 1440 | if eq v 0 |
| 1441 | nfail 2 |
| 1442 | ret |
| 1443 | end |
| 1444 | note A queued frame from an older generation is completed, never reinterpreted. |
| 1445 | g = add get Ncfg 17 1 |
| 1446 | nwipe |
| 1447 | for i ulong 32 |
| 1448 | put Nct i 0 |
| 1449 | end |
| 1450 | for i ulong 8 |
| 1451 | put Tcpstate i 0 |
| 1452 | end |
| 1453 | for i ulong 10 |
| 1454 | put Ncfg add i 15 0 |
| 1455 | end |
| 1456 | put Napip 0 0 |
| 1457 | put Ncfg 17 g |
| 1458 | put Ncfg 18 and nrnd32 20 65535 |
| 1459 | put Ncfg 19 and nrnd32 4 65535 |
| 1460 | put Ncfg 20 add 49152 rem nrnd32 8 16384 |
| 1461 | put Ncfg 21 add 49152 rem nrnd32 16 16384 |
| 1462 | put Nct 25 nrnd32 12 |
| 1463 | put Nct 7 536 |
| 1464 | put Nct 14 1000 |
| 1465 | if nbound |
| 1466 | put Tcpstate 0 2 |
| 1467 | put Ncfg 22 now |
| 1468 | else |
| 1469 | ndhcpnew |
| 1470 | put Tcpstate 0 1 |
| 1471 | end |
| 1472 | for i ulong 32 |
| 1473 | put Nrand i uchar 0 |
| 1474 | end |
| 1475 | put Ncfg 15 1 |
| 1476 | put Ncfg 16 now |
| 1477 | nqhost |
| 1478 | end |
| 1479 | note Error state 6 freezes DHCP, DNS and TCP until the next netconnect. Courier |
| 1480 | note datagrams on port 47033 still arrive, and ARP for a bound lease is still |
| 1481 | note answered so a relay's unicast answer to the leased address can reach us. |
| 1482 | fn netinput n ulong now ulong to void |
| 1483 | if not nclock now |
| 1484 | ret |
| 1485 | end |
| 1486 | if or lt n 14 gt n 1514 |
| 1487 | ret |
| 1488 | end |
| 1489 | if not nmacrx 6 |
| 1490 | ret |
| 1491 | end |
| 1492 | if nmaceq 6 |
| 1493 | ret |
| 1494 | end |
| 1495 | note Any frame for us counts as activity: the mode-3 idle check in netstep must not be a |
| 1496 | note connection-lifetime cap, or a long transfer dies mid-body with failure 14. |
| 1497 | put Ncfg 10 now |
| 1498 | if not nmaceq 0 |
| 1499 | for i ulong 6 |
| 1500 | if ne get Nrx i 255 |
| 1501 | ret |
| 1502 | end |
| 1503 | end |
| 1504 | end |
| 1505 | put Npk 0 n |
| 1506 | if eq nr16 12 2054 |
| 1507 | if or ne get Tcpstate 0 6 eq get Ncfg 1 4 |
| 1508 | narpin |
| 1509 | end |
| 1510 | end |
| 1511 | if eq nr16 12 2048 |
| 1512 | nipin |
| 1513 | end |
| 1514 | end |
| 1515 | fn netwrite n ulong now ulong to bool |
| 1516 | if not nclock now |
| 1517 | ret false |
| 1518 | end |
| 1519 | if gt n 65536 |
| 1520 | nfail 17 |
| 1521 | ret false |
| 1522 | end |
| 1523 | if or ne get Tcpstate 0 4 ne get Nct 18 0 |
| 1524 | ret false |
| 1525 | end |
| 1526 | if ne get Nct 16 0 |
| 1527 | ret false |
| 1528 | end |
| 1529 | if eq n 0 |
| 1530 | ret true |
| 1531 | end |
| 1532 | for i ulong n |
| 1533 | put Nsbuf i get Tcpout i |
| 1534 | end |
| 1535 | put Nct 16 n |
| 1536 | put Nct 17 0 |
| 1537 | put Nct 29 now |
| 1538 | ret true |
| 1539 | end |
| 1540 | fn netconsume n ulong to void |
| 1541 | if gt n get Tcpn 0 |
| 1542 | nfail 17 |
| 1543 | ret |
| 1544 | end |
| 1545 | if eq n 0 |
| 1546 | ret |
| 1547 | end |
| 1548 | left = sub get Tcpn 0 n |
| 1549 | for i ulong left |
| 1550 | put Tcpin i get Tcpin add i n |
| 1551 | end |
| 1552 | for i ulong n |
| 1553 | put Tcpin add left i uchar 0 |
| 1554 | end |
| 1555 | put Tcpn 0 left |
| 1556 | put Nct 8 1 |
| 1557 | ntdrain |
| 1558 | end |
| 1559 | fn netclose now ulong to void |
| 1560 | if not nclock now |
| 1561 | ret |
| 1562 | end |
| 1563 | if eq get Tcpstate 0 6 |
| 1564 | ret |
| 1565 | end |
| 1566 | if lt get Tcpstate 0 4 |
| 1567 | put Tcpstate 0 5 |
| 1568 | put Nct 31 1 |
| 1569 | nwipe |
| 1570 | ret |
| 1571 | end |
| 1572 | put Nct 18 1 |
| 1573 | put Tcpstate 0 5 |
| 1574 | end |
| 1575 | fn nstepset to void |
| 1576 | if eq get Ncfg 1 5 |
| 1577 | ndhcpout |
| 1578 | ret |
| 1579 | end |
| 1580 | if or eq get Ncfg 1 1 eq get Ncfg 1 2 |
| 1581 | if ge sub get Ncfg 0 get Ncfg 11 60000 |
| 1582 | nfail 3 |
| 1583 | ret |
| 1584 | end |
| 1585 | if ge get Ncfg 0 get Ncfg 12 |
| 1586 | if ge get Ncfg 13 5 |
| 1587 | nfail 3 |
| 1588 | else |
| 1589 | ndhcpout |
| 1590 | end |
| 1591 | end |
| 1592 | ret |
| 1593 | end |
| 1594 | if eq get Ncfg 1 3 |
| 1595 | if lt get Ncfg 0 get Ncfg 12 |
| 1596 | ret |
| 1597 | end |
| 1598 | if lt get Ncfg 14 3 |
| 1599 | narpout get Ncfg 7 true |
| 1600 | ret |
| 1601 | end |
| 1602 | put Ncfg 2 get Ncfg 7 |
| 1603 | put Ncfg 1 4 |
| 1604 | end |
| 1605 | if ne get Ncfg 1 4 |
| 1606 | ret |
| 1607 | end |
| 1608 | if lt get Ncfg 14 5 |
| 1609 | if ge get Ncfg 0 get Ncfg 12 |
| 1610 | narpout get Ncfg 2 false |
| 1611 | put Nq 3 6 |
| 1612 | end |
| 1613 | ret |
| 1614 | end |
| 1615 | if eq get Tcpstate 0 1 |
| 1616 | put Tcpstate 0 2 |
| 1617 | put Ncfg 22 get Ncfg 0 |
| 1618 | end |
| 1619 | end |
| 1620 | fn nstepdns to void |
| 1621 | if lt get Ncfg 0 get Ncfg 22 |
| 1622 | ret |
| 1623 | end |
| 1624 | if ge get Ncfg 23 4 |
| 1625 | nfail 8 |
| 1626 | ret |
| 1627 | end |
| 1628 | if nroute get Ncfg 5 |
| 1629 | ndnsout |
| 1630 | end |
| 1631 | end |
| 1632 | fn nflight kind ulong n ulong to void |
| 1633 | put Nct 9 n |
| 1634 | put Nct 10 kind |
| 1635 | put Nct 11 0 |
| 1636 | put Nct 12 get Nct 1 |
| 1637 | put Nct 15 0 |
| 1638 | end |
| 1639 | fn nsteptcp to void |
| 1640 | if ne get Nct 24 0 |
| 1641 | if ge sub add get Ncfg 0 1 get Nct 24 120000 |
| 1642 | put Nct 31 1 |
| 1643 | put Nct 8 0 |
| 1644 | ret |
| 1645 | end |
| 1646 | end |
| 1647 | if ne get Nct 31 0 |
| 1648 | ret |
| 1649 | end |
| 1650 | note FIN-WAIT-2 is bounded: our FIN is acknowledged, the peer stays silent. |
| 1651 | if and ne get Nct 19 0 eq get Nct 20 0 |
| 1652 | if ge sub get Ncfg 0 get Nct 23 60000 |
| 1653 | put Nct 31 1 |
| 1654 | ret |
| 1655 | end |
| 1656 | end |
| 1657 | if ne get Nct 8 0 |
| 1658 | if nroute get Tcpstate 2 |
| 1659 | ntcpout false |
| 1660 | end |
| 1661 | ret |
| 1662 | end |
| 1663 | if ne get Nct 9 0 |
| 1664 | if ne get Nct 11 0 |
| 1665 | if lt sub get Ncfg 0 get Nct 13 get Nct 14 |
| 1666 | ret |
| 1667 | end |
| 1668 | if ge get Nct 15 6 |
| 1669 | nfail 11 |
| 1670 | ret |
| 1671 | end |
| 1672 | end |
| 1673 | if nroute get Tcpstate 2 |
| 1674 | ntcpout true |
| 1675 | end |
| 1676 | ret |
| 1677 | end |
| 1678 | if eq get Tcpstate 0 3 |
| 1679 | ret |
| 1680 | end |
| 1681 | if ne get Nct 16 0 |
| 1682 | n = sub get Nct 16 get Nct 17 |
| 1683 | if gt n get Nct 7 |
| 1684 | n = get Nct 7 |
| 1685 | end |
| 1686 | if gt n get Nct 4 |
| 1687 | n = get Nct 4 |
| 1688 | end |
| 1689 | if eq n 0 |
| 1690 | if lt sub get Ncfg 0 get Nct 29 1000 |
| 1691 | ret |
| 1692 | end |
| 1693 | note A one-byte persist probe is retained and retransmitted, never discarded. |
| 1694 | n = 1 |
| 1695 | end |
| 1696 | nflight 2 n |
| 1697 | else |
| 1698 | if and ne get Nct 18 0 eq get Nct 19 0 |
| 1699 | nflight 3 1 |
| 1700 | else |
| 1701 | ret |
| 1702 | end |
| 1703 | end |
| 1704 | if nroute get Tcpstate 2 |
| 1705 | ntcpout true |
| 1706 | end |
| 1707 | end |
| 1708 | fn netstep now ulong to void |
| 1709 | if not nclock now |
| 1710 | ret |
| 1711 | end |
| 1712 | if or eq get Tcpstate 0 6 ne get Nct 31 0 |
| 1713 | ret |
| 1714 | end |
| 1715 | if ge get Ncfg 1 3 |
| 1716 | if and ne get Ncfg 9 0 ge sub now get Ncfg 10 get Ncfg 9 |
| 1717 | nfail 14 |
| 1718 | ret |
| 1719 | end |
| 1720 | end |
| 1721 | if and ne get Ncfg 15 0 lt get Tcpstate 0 4 |
| 1722 | if ge sub now get Ncfg 16 120000 |
| 1723 | nfail 16 |
| 1724 | ret |
| 1725 | end |
| 1726 | end |
| 1727 | if ne get Ntxlen 0 0 |
| 1728 | if ge sub now get Nq 2 10000 |
| 1729 | nfail 15 |
| 1730 | end |
| 1731 | ret |
| 1732 | end |
| 1733 | nstepset |
| 1734 | if or eq get Tcpstate 0 6 ne get Ntxlen 0 0 |
| 1735 | ret |
| 1736 | end |
| 1737 | if lt get Ncfg 14 5 |
| 1738 | ret |
| 1739 | end |
| 1740 | if ne get Napip 0 0 |
| 1741 | narprepl |
| 1742 | ret |
| 1743 | end |
| 1744 | if eq get Tcpstate 0 2 |
| 1745 | nstepdns |
| 1746 | end |
| 1747 | if and ge get Tcpstate 0 3 le get Tcpstate 0 5 |
| 1748 | nsteptcp |
| 1749 | end |
| 1750 | end |
| 1751 | fn nqdhcp to void |
| 1752 | if ne get Nq 3 get Ncfg 1 |
| 1753 | ret |
| 1754 | end |
| 1755 | if eq get Ncfg 1 5 |
| 1756 | nfail 6 |
| 1757 | ret |
| 1758 | end |
| 1759 | d = add 3000 rem get Ncfg 8 2001 |
| 1760 | d = mul d shl ulong 1 get Ncfg 13 |
| 1761 | if gt d 16000 |
| 1762 | d = 16000 |
| 1763 | end |
| 1764 | put Ncfg 13 add get Ncfg 13 1 |
| 1765 | put Ncfg 12 add get Ncfg 0 d |
| 1766 | end |
| 1767 | fn nqarp to void |
| 1768 | if eq get Nq 3 3 |
| 1769 | if ne get Ncfg 1 3 |
| 1770 | ret |
| 1771 | end |
| 1772 | put Ncfg 14 add get Ncfg 14 1 |
| 1773 | d = add 1000 rem get Ncfg 8 1001 |
| 1774 | if eq get Ncfg 14 3 |
| 1775 | d = 2000 |
| 1776 | end |
| 1777 | put Ncfg 12 add get Ncfg 0 d |
| 1778 | ret |
| 1779 | end |
| 1780 | if eq get Nq 3 6 |
| 1781 | put Ncfg 14 add get Ncfg 14 1 |
| 1782 | put Ncfg 12 add get Ncfg 0 2000 |
| 1783 | ret |
| 1784 | end |
| 1785 | put Ncfg 28 add get Ncfg 0 mul 1000 shl ulong 1 get Ncfg 29 |
| 1786 | put Ncfg 29 add get Ncfg 29 1 |
| 1787 | end |
| 1788 | fn nqflight to void |
| 1789 | if or eq get Nct 9 0 ne get Nq 4 get Nct 12 |
| 1790 | ret |
| 1791 | end |
| 1792 | if ne get Nct 11 0 |
| 1793 | put Nct 15 add get Nct 15 1 |
| 1794 | r = mul get Nct 14 2 |
| 1795 | if gt r 60000 |
| 1796 | r = 60000 |
| 1797 | end |
| 1798 | put Nct 14 r |
| 1799 | if eq get Nct 10 1 |
| 1800 | put Nct 30 1 |
| 1801 | end |
| 1802 | end |
| 1803 | put Nct 11 1 |
| 1804 | put Nct 13 get Ncfg 0 |
| 1805 | put Nct 1 nadd get Nct 12 get Nct 9 |
| 1806 | end |
| 1807 | fn netsent ok bool now ulong to void |
| 1808 | if not nclock now |
| 1809 | ret |
| 1810 | end |
| 1811 | if eq get Ntxlen 0 0 |
| 1812 | ret |
| 1813 | end |
| 1814 | if not ok |
| 1815 | put Nq 1 add get Nq 1 1 |
| 1816 | if ge get Nq 1 8 |
| 1817 | nfail 15 |
| 1818 | end |
| 1819 | ret |
| 1820 | end |
| 1821 | put Ntxlen 0 0 |
| 1822 | note Kind 7 (courier UDP) ends here: nothing to retry or acknowledge. |
| 1823 | if ne get Nq 7 get Ncfg 17 |
| 1824 | ret |
| 1825 | end |
| 1826 | if eq get Nq 0 1 |
| 1827 | nqdhcp |
| 1828 | end |
| 1829 | if eq get Nq 0 2 |
| 1830 | nqarp |
| 1831 | end |
| 1832 | if eq get Nq 0 4 |
| 1833 | d = mul 2000 shl ulong 1 get Ncfg 23 |
| 1834 | put Ncfg 23 add get Ncfg 23 1 |
| 1835 | put Ncfg 22 add now d |
| 1836 | end |
| 1837 | if eq get Nq 0 5 |
| 1838 | nqflight |
| 1839 | end |
| 1840 | if or eq get Nq 0 5 eq get Nq 0 6 |
| 1841 | if and eq get Nq 5 get Nct 2 eq get Nq 6 nwindow |
| 1842 | put Nct 8 0 |
| 1843 | end |
| 1844 | end |
| 1845 | end |