interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / native / omega / allen / tests / https-live.om

186 lines · 2813 bytes Raw Blame History
1note SPDX-License-Identifier: MIT
2note Qualification only: real Omega TLS/HTTP client on Linux AArch64.
3note Argument1 is a DNS-resolved IPv4 address supplied by the external test orchestrator.
4note Production firmware build uses net.om DNS instead; this harness is not the deployed network provider.
5global Laddr uchar 16
6global Lip uchar 32
7global Lfd int 1
8global Lstate ulong 4
9text Lpath "/repos/aien-dev/allen"
10fn laddress to bool
11n = argread 1 Lip 0 len Lip
12if or le n 0 gt n 15
13ret false
14end
15put Laddr 0 2
16put Laddr 2 1
17put Laddr 3 187
18part = ulong 0
19value = ulong 0
20digits = ulong 0
21for i ulong add ulong n 1
22c = uchar 46
23if lt i ulong n
24c = get Lip i
25end
26if eq c 46
27if or or eq digits 0 gt value 255 ge part 4
28ret false
29end
30put Laddr add 4 part uchar value
31part = add part 1
32value = 0
33digits = 0
34else
35if or lt c 48 gt c 57
36ret false
37end
38digits = add digits 1
39if gt digits 3
40ret false
41end
42value = add mul value 10 sub ulong c 48
43end
44end
45ret eq part 4
46end
47fn lflush to bool
48off = ulong 0
49while lt off get Tlsoutn 0
50n = send get Lfd 0 Tlsout off sub get Tlsoutn 0 off 0
51if gt n 0
52off = add off ulong n
53else
54if ne n -11
55ret false
56end
57r = waitio get Lfd 0 4 10000000000
58if le r 0
59ret false
60end
61end
62end
63tlssent
64ret true
65end
66fn lhttp to bool
67while gt get Tlsappn 0 0
68n = get Tlsappn 0
69if gt n len Hchunk
70n = len Hchunk
71end
72for i ulong n
73put Hchunk i get Tlsapp i
74end
75if not httpfeed n
76ret false
77end
78tlsconsume n
79end
80ret true
81end
82fn ldrive to int
83start = monons
84sent = false
85while eq get Hstate 0 1
86if gt sub monons start 120000000000
87ret 71
88end
89if eq get Tlsstate 0 4
90ret 72
91end
92if gt get Tlsoutn 0 0
93if not lflush
94ret 73
95end
96end
97if and eq get Tlsstate 0 2 not sent
98for i ulong get Httpreqn 0
99put Tlsplain i get Httpreq i
100end
101if tlswrite get Httpreqn 0
102sent = true
103end
104end
105if not lhttp
106ret 74
107end
108if eq get Hstate 0 2
109break
110end
111if eq get Tlsstate 0 3
112if not httpend eq get Tlsstate 2 1
113ret 75
114end
115break
116end
117if eq get Tlsoutn 0 0
118r = waitio get Lfd 0 1 1000000000
119if lt r 0
120ret 76
121end
122if gt r 0
123n = recv get Lfd 0 Tlsin 0 len Tlsin 0
124if gt n 0
125tlsinput ulong n
126else
127if eq n 0
128ret 77
129end
130if ne n -11
131ret 78
132end
133end
134end
135end
136end
137if ne get Hstate 1 200
138ret 79
139end
140n = write 1 Ghbody 0 get Hstate 2
141if ne n long get Hstate 2
142ret 80
143end
144ret 0
145end
146fn main to int
147if ne argcnt 2
148ret 64
149end
150if not laddress
151ret 65
152end
153for i ulong len Lpath
154put Ghpath i get Lpath i
155end
156if not httpstart 1 1 0 65536 len Lpath
157ret 66
158end
159off = ulong 0
160while lt off len Tlsrand
161n = random Tlsrand off sub len Tlsrand off 0
162if le n 0
163ret 67
164end
165off = add off ulong n
166end
167now = realns
168if le now 0
169ret 68
170end
171tlsinit ulong div now 1000000000
172fd = socknew 2 526337 0
173if lt fd 0
174ret 69
175end
176put Lfd 0 int fd
177r = connect int fd Laddr 0 len Laddr
178if and ne r 0 ne r -115
179r = fclose int fd
180ret 70
181end
182rc = ldrive
183r = fclose int fd
184tcwipe
185ret rc
186end