2474
|
1 ********************************************************************
|
|
2 * net - network routines
|
|
3 *
|
|
4 * $Id$
|
|
5 *
|
|
6 * Edt/Rev YYYY/MM/DD Modified by
|
|
7 * Comment
|
|
8 * ------------------------------------------------------------------
|
|
9 * 1 2010/01/08 Boisy G. Pitre
|
|
10 * Started.
|
|
11
|
|
12 nam net.a
|
|
13 ttl network routines
|
|
14
|
|
15 psect net_a,0,0,0,0,0
|
|
16
|
|
17 vsect
|
|
18 nbufferl equ 128
|
|
19 nbuffer rmb nbufferl
|
|
20 endsect
|
|
21
|
|
22 space fcb C$SPAC
|
|
23
|
|
24 devnam fcs "/N"
|
|
25
|
|
26
|
|
27 getopts leax nbuffer,u
|
|
28 ldb #SS.Opt
|
|
29 os9 I$GetStt
|
|
30 rts
|
|
31
|
|
32 setopts leax nbuffer,u
|
|
33 ldb #SS.Opt
|
|
34 os9 I$SetStt
|
|
35 rts
|
|
36
|
|
37 * Set Echo
|
|
38 *
|
|
39 * Entry: A = path to network device
|
|
40 * Exit:
|
|
41 * Success: CC carry clear
|
|
42 * Failure: CC carry set, B = error code
|
|
43 SetEcho: pshs a,x
|
|
44 bsr getopts
|
|
45 bcs rawex
|
|
46 ldb #1
|
|
47 stb PD.EKO-PD.OPT,x
|
|
48 bsr setopts
|
|
49 puls a,x,pc
|
|
50
|
|
51
|
|
52 * Set Auto Linefeed
|
|
53 *
|
|
54 * Entry: A = path to network device
|
|
55 * Exit:
|
|
56 * Success: CC carry clear
|
|
57 * Failure: CC carry set, B = error code
|
|
58 SetAutoLF: pshs a,x
|
|
59 bsr getopts
|
|
60 bcs rawex
|
|
61 ldb #1
|
|
62 stb PD.ALF-PD.OPT,x
|
|
63 bsr setopts
|
|
64 puls a,x,pc
|
|
65
|
|
66
|
|
67 * Put the path passed in A in raw mode
|
|
68 *
|
|
69 * Entry: A = path to network device
|
|
70 *
|
|
71 * Exit:
|
|
72 * Success: CC carry clear
|
|
73 * Failure: CC carry set, B = error code
|
|
74 RawPath: pshs a,x
|
|
75 bsr getopts
|
|
76 bcs rawex
|
|
77 leax PD.UPC-PD.OPT,x
|
|
78 ldb #PD.QUT-PD.UPC
|
|
79 rawloop clr ,x+
|
|
80 decb
|
|
81 bpl rawloop
|
|
82 bsr setopts
|
|
83 rawex puls a,x,pc
|
|
84
|
|
85
|
|
86 * Attempts to open and setup a path to the TCP server
|
|
87 *
|
|
88 * Exit:
|
|
89 * Success: A = path to network device, CC carry clear
|
|
90 * Failure: B = error code, CC carry set
|
|
91 TCPOpen: pshs x,y
|
|
92 lda #UPDAT.
|
|
93 leax devnam,pcr
|
|
94 os9 I$Open
|
|
95 puls x,y,pc
|
|
96
|
|
97
|
|
98 * Informs the server that we are killing a session
|
|
99 *
|
|
100 * Entry: A = path to network device
|
|
101 * Y = pointer to token string (nul terminated)
|
|
102 *
|
|
103 * Exit:
|
|
104 * Success: CC carry clear
|
|
105 * Failure: CC carry set, B = error code
|
|
106 TCPKill: pshs a,x,y
|
|
107 leax tcpkill,pcr
|
|
108 ldy #tcpkilll
|
|
109 os9 I$Write
|
|
110 lbcs connectex
|
|
111 bra writeport
|
|
112
|
|
113 * Informs the server that we are joining a session
|
|
114 *
|
|
115 * Entry: A = path to network device
|
|
116 * Y = pointer to token string (nul terminated)
|
|
117 *
|
|
118 * Exit:
|
|
119 * Success: CC carry clear
|
|
120 * Failure: CC carry set, B = error code
|
|
121 TCPJoin: pshs a,x,y
|
|
122 leax tcpjoin,pcr
|
|
123 ldy #tcpjoinl
|
|
124 os9 I$Write
|
|
125 lbcs connectex
|
|
126 bra writeport
|
|
127
|
|
128 * Attempts to connect to a TCP/IP host via the server
|
|
129 *
|
|
130 * Entry: A = path to network device
|
|
131 * X = pointer to host name string (nul terminated)
|
|
132 * Y = pointer to port string (nul terminated)
|
|
133 *
|
|
134 * Exit:
|
|
135 * Success: CC carry clear
|
|
136 * Failure: CC carry set, B = error code
|
|
137 TCPConnectToHost:
|
|
138 pshs a,x,y
|
|
139 leax tcpconnect,pcr
|
|
140 ldy #tcpconnectl
|
|
141 os9 I$Write
|
|
142 bcs connectex
|
|
143 ldx 1,s
|
|
144 lbsr STRLEN
|
|
145 tfr d,y
|
|
146 lda ,s
|
|
147 os9 I$Write
|
|
148 * write space
|
|
149 leax space,pcr
|
|
150 ldy #1
|
|
151 os9 I$Write
|
|
152 * write port (we worry about response later)
|
|
153 writeport ldx 3,s get original Y on stack
|
|
154 pshs a
|
|
155 lbsr STRLEN
|
|
156 tfr d,y
|
|
157 puls a
|
|
158 os9 I$Write
|
|
159 leax acr,pcr
|
|
160 ldy #1
|
|
161 os9 I$WritLn
|
|
162
|
|
163 * read response from server
|
|
164 * Entry: A = path
|
|
165 readresponse
|
|
166 leax nbuffer,u
|
|
167 ldy #nbufferl
|
|
168 os9 I$ReadLn
|
|
169 bcs connectex
|
|
170 lda ,x
|
|
171 cmpa #'F
|
|
172 bne connectex
|
|
173 * failure case: read number and return it with carry set
|
|
174 leax 5,x skip over "FAIL "
|
|
175 lbsr DEC_BIN error will fit in B
|
|
176 coma set carry
|
|
177 connectex puls a,x,y,pc
|
|
178
|
|
179 acr fcb C$CR
|
|
180
|
|
181 * Requests to listen on a port
|
|
182 *
|
|
183 * Entry: A = path to network device
|
|
184 * X = pointer to parameter string (nul terminated)
|
|
185 *
|
|
186 * Exit:
|
|
187 * Success: CC carry clear
|
|
188 * Failure: CC carry set, B = error code
|
|
189 TCPListen: pshs a,x,y
|
|
190 leax tcplisten,pcr
|
|
191 ldy #tcplistenl
|
|
192 os9 I$Write
|
|
193 bcs connectex
|
|
194 ldx 1,s
|
|
195 lbsr STRLEN
|
|
196 tfr d,y
|
|
197 lda ,s
|
|
198 os9 I$Write
|
|
199 leax acr,pcr
|
|
200 ldy #1
|
|
201 os9 I$WritLn
|
|
202 bra readresponse
|
|
203
|
|
204 * Disconnects the TCP/IP host via the server
|
|
205 *
|
|
206 * Entry: A = path to network device
|
|
207 *
|
|
208 * Exit:
|
|
209 * Success: CC carry clear
|
|
210 * Failure: B = error code, CC carry set
|
|
211 TCPDisconnect: os9 I$Close
|
|
212 rts
|
|
213
|
|
214 tcpconnect fcc 'tcp connect '
|
|
215 tcpconnectl equ *-tcpconnect
|
|
216
|
|
217 tcplisten fcc 'tcp listen '
|
|
218 tcplistenl equ *-tcplisten
|
|
219
|
|
220 tcpjoin fcc 'tcp join '
|
|
221 tcpjoinl equ *-tcpjoin
|
|
222
|
|
223 tcpkill fcc 'tcp kill '
|
|
224 tcpkilll equ *-tcpkill
|
|
225
|
|
226 endsect
|