?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  2. ;@                                                                            @
  3. ;@                 S Y M B O S   S Y S T E M   L I B R A R Y                  @
  4. ;@                        - NETWORK DAEMON FUNCTIONS -                        @
  5. ;@                                                                            @
  6. ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  7.  
  8. ;Author     Prodatron / SymbiosiS
  9. ;Date       11.07.2015
  10.  
  11. ;This library supports you in using all network daemon functions.
  12.  
  13. ;The existance of
  14. ;- "App_PrcID" (a byte, where the ID of the applications process is stored)
  15. ;- "App_MsgBuf" (the message buffer, 14 bytes, which are placed in the transfer
  16. ;  ram area)
  17. ;- "App_BnkNum" (a byte, where the number of the applications' ram bank (0-15)
  18. ;  is stored)
  19. ;is required.
  20.  
  21.  
  22. ;### SUMMARY ##################################################################
  23.  
  24. ;;   SyNet_NETINI                ;...
  25. ;use_SyNet_NETEVT        equ 0   ;check for network events
  26. ;use_SyNet_CFGGET        equ 0   ;Config get data
  27. ;use_SyNet_CFGSET        equ 0   ;Config set data
  28. ;use_SyNet_CFGSCK        equ 0   ;Config socket status
  29. ;use_SyNet_TCPOPN        equ 0   ;TCP open connection
  30. ;use_SyNet_TCPCLO        equ 0   ;TCP close connecton
  31. ;use_SyNet_TCPSTA        equ 0   ;TCP status of connection
  32. ;use_SyNet_TCPRCV        equ 0   ;TCP receive from connection
  33. ;use_SyNet_TCPSND        equ 0   ;TCP send to connection
  34. ;use_SyNet_TCPSKP        equ 0   ;TCP skip received data
  35. ;use_SyNet_TCPFLS        equ 0   ;TCP flush send buffer
  36. ;use_SyNet_TCPDIS        equ 0   ;TCP disconnect connection
  37. ;use_SyNet_TCPRLN        equ 0   ;TCP receive textline from connection
  38. ;use_SyNet_UDPOPN        equ 0   ;UDP open
  39. ;use_SyNet_UDPCLO        equ 0   ;UDP close
  40. ;use_SyNet_UDPSTA        equ 0   ;UDP status
  41. ;use_SyNet_UDPRCV        equ 0   ;UDP receive
  42. ;use_SyNet_UDPSND        equ 0   ;UDP send
  43. ;use_SyNet_UDPSKP        equ 0   ;UDP skip received data
  44. ;use_SyNet_DNSRSV        equ 0   ;DNS resolve
  45. ;use_SyNet_DNSVFY        equ 0   ;DNS verify
  46.  
  47.  
  48. ;### GLOBAL VARIABLES #########################################################
  49.  
  50. SyNet_PrcID db 0    ;network daemon process ID
  51.  
  52.  
  53. ;### GENERAL FUNCTIONS ########################################################
  54.  
  55. SyNet_NETINI
  56. ;******************************************************************************
  57. ;*** Name           Network_Init
  58. ;*** Input          -
  59. ;*** Output         CF   = Error state (0 = ok, 1 = Network daemon not running)
  60. ;***                - if CF is 0:
  61. ;***                (SyNet_PrcID) = Network daemon process ID
  62. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  63. ;*** Description    ...
  64. ;******************************************************************************
  65.         ld e,0
  66.         ld hl,snwdmnt
  67.         ld a,(App_BnkNum)
  68.         call SySystem_PRGSRV
  69.         or a
  70.         scf
  71.         ret nz
  72.         ld a,h
  73.         ld (SyNet_PrcID),a
  74.         or a
  75.         ret
  76. snwdmnt db "Network Daem"
  77.  
  78. if use_SyNet_NETEVT=1
  79. SyNet_NETEVT
  80. ;******************************************************************************
  81. ;*** Name           Network_Event
  82. ;*** Input          -
  83. ;*** Output         CF   = Flag, if network event occured (1=no)
  84. ;***                - if CF is 0:
  85. ;***                A    = Handle
  86. ;***                L    = Status (1=TCP opening, 2=TCP established, 3=TCP
  87. ;***                       close waiting, 4=TCP close,
  88. ;***                       16=UDP sending,
  89. ;***                       128=data received)
  90. ;***                IX,IY= Remote IP
  91. ;***                DE   = Remote port
  92. ;***                BC   = Received bytes
  93. ;*** Destroyed      F,HL
  94. ;*** Description    ...
  95. ;******************************************************************************
  96.         ld a,(App_PrcID)
  97.         db #dd:ld l,a
  98.         ld a,(SyNet_PrcID)
  99.         db #dd:ld h,a
  100.         ld iy,App_MsgBuf
  101.         rst #18                 ;check for message
  102.         db #dd:dec l
  103.         scf
  104.         ret nz                  ;no message available
  105.         ld a,(App_MsgBuf)
  106.         cp MSR_NET_TCPEVT
  107.         jp z,snwmsgo_afbcdehlixiy
  108.         cp MSR_NET_UDPEVT
  109.         jp z,snwmsgo_afbcdehlixiy
  110.         scf                     ;senseless message
  111.         ret
  112. endif
  113.  
  114.  
  115. ;### CONFIG FUNCTIONS #########################################################
  116.  
  117. if use_SyNet_CFGSET=1
  118. SyNet_CFGGET
  119. ;******************************************************************************
  120. ;*** ID             001 (CFGGET)
  121. ;*** Name           Config_GetData
  122. ;*** Input          A    = Type
  123. ;***                HL   = Config data buffer
  124. ;*** Output         CF   = status (CF=1 invalid type)
  125. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  126. ;*** Description    ...
  127. ;******************************************************************************
  128.         ld de,(App_BnkNum)
  129.         call snwmsgi_afdehl
  130.         db FNC_NET_CFGGET
  131.         jp snwmsgo_afhl
  132. endif
  133.  
  134. if use_SyNet_CFGGET=1
  135. SyNet_CFGSET
  136. ;******************************************************************************
  137. ;*** ID             002 (CFGSET)
  138. ;*** Name           Config_SetData
  139. ;*** Input          A    = Type
  140. ;***                HL   = New config data
  141. ;*** Output         CF   = status (CF=1 invalid type)
  142. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  143. ;*** Description    ...
  144. ;******************************************************************************
  145.         ld de,(App_BnkNum)
  146.         call snwmsgi_afdehl
  147.         db FNC_NET_CFGSET
  148.         jp snwmsgo_afhl
  149. endif
  150.  
  151. if use_SyNet_CFGSCK=1
  152. SyNet_CFGSCK
  153. ;******************************************************************************
  154. ;*** ID             003 (CFGSCK)
  155. ;*** Name           Config_SocketStatus
  156. ;*** Input          A    = first socket
  157. ;***                C    = number of sockets
  158. ;***                HL   = data buffer
  159. ;*** Output         CF   = status (CF=1 invalid range)
  160. ;*** Destroyed      AF,BC,DE,HL,IX,IY
  161. ;*** Description    ...
  162. ;******************************************************************************
  163.         ld de,(App_BnkNum)
  164.         call snwmsgi_afbcdehl
  165.         db FNC_NET_CFGSCK
  166.         jp snwmsgo_afhl
  167. endif
  168.  
  169.  
  170. ;### TCP FUNCTIONS ############################################################
  171.  
  172. if use_SyNet_TCPOPN=1
  173. ;******************************************************************************
  174. ;*** ID             016 (TCPOPN)
  175. ;*** Name           TCP_Open
  176. ;*** Input          A    = Type (0=active/client, 1=passive/server)
  177. ;***                HL   = Local port (-1=dynamic client port)
  178. ;***                - if A is 0:
  179. ;***                IX,IY= Remote IP
  180. ;***                DE   = Remote port
  181. ;*** Output         CF   = Error state (0 = ok, 1 = error; A = error code)
  182. ;***                - if CF is 0:
  183. ;***                A    = Handle
  184. ;*** Destroyed      F,BC,DE,HL,IX,IY
  185. ;*** Description    Opens a TCP connection as a client (active) or as a server
  186. ;***                (passive). If it's an active connection you have to specify
  187. ;***                the remote IP address and port number as well.
  188. ;***                The local port number always has to be set. For client
  189. ;***                network applications you should set HL to -1 (65535) to get
  190. ;***                a dynamic port number. This will automaticaly generated by
  191. ;***                the network daemon in the range of 49152-65535 (official
  192. ;***                range for dynamic ports).
  193. ;***                This function will fail, if there is no free socket left.
  194. ;***                It returns the connection handle if it was successful.
  195. ;******************************************************************************
  196. SyNet_TCPOPN
  197.         call snwmsgi_afbcdehlixiy
  198.         db FNC_NET_TCPOPN
  199.         jp snwmsgo_afhl
  200. endif
  201.  
  202. if use_SyNet_TCPCLO=1
  203. ;******************************************************************************
  204. ;*** ID             017 (TCPCLO)
  205. ;*** Name           TCP_Close
  206. ;*** Input          A    = Handle
  207. ;*** Output         CF   = Error state (0 = ok, 1 = error; A = error code)
  208. ;***                - if CF is 0:
  209. ;***                A    = Handle
  210. ;*** Destroyed      F,BC,DE,HL,IX,IY
  211. ;*** Description    Closes a TCP connection and releases the used socket. It
  212. ;***                will not send a disconnect signal to the remote host (see
  213. ;***                TCPDIS). Use this, after the remote host already
  214. ;***                closed the connection.
  215. ;******************************************************************************
  216. SyNet_TCPCLO
  217.         call snwmsgi_af
  218.         db FNC_NET_TCPCLO
  219.         jp snwmsgo_afhl
  220. endif
  221.  
  222. if use_SyNet_TCPSTA=1
  223. ;******************************************************************************
  224. ;*** ID             018 (TCPSTA)
  225. ;*** Name           TCP_Status
  226. ;*** Input          A    = Handle
  227. ;*** Output         CF   = Error state (0 = ok, 1 = error; A = error code)
  228. ;***                - if CF is 0:
  229. ;***                A    = Handle
  230. ;***                L    = Status (1=TCP opening, 2=TCP established, 3=TCP
  231. ;***                       close waiting, 4=TCP close; +128=data received)
  232. ;***                - if L is >1:
  233. ;***                IX,IY= Remote IP
  234. ;***                DE   = Remote port
  235. ;***                - if L is >=128:
  236. ;***                BC   = Received bytes (which are available in the RX
  237. ;***                       buffer)
  238. ;*** Destroyed      F,H
  239. ;*** Description    Returns the actual status of the TCP connection. Usually
  240. ;***                this is exactly the same as received in the last event
  241. ;***                message (see TCPEVT). The number of received bytes in BC
  242. ;***                may have been increased during the last event, if it was
  243. ;***                already larger than 0.
  244. ;******************************************************************************
  245. SyNet_TCPSTA
  246.         call snwmsgi_af
  247.         db FNC_NET_TCPSTA
  248.         jp snwmsgo_afbcdehlixiy
  249. endif
  250.  
  251. if use_SyNet_TCPRCV=1
  252. ;******************************************************************************
  253. ;*** ID             019 (TCPRCV)
  254. ;*** Name           TCP_Receive
  255. ;*** Input          A    = Handle
  256. ;***                E    = Destination bank
  257. ;***                HL   = Destination address
  258. ;***                BC   = Length (has to be >0)
  259. ;*** Output         CF   = Error state (0 = ok, 1 = error; A = error code)
  260. ;***                - if CF is 0:
  261. ;***                A    = Handle
  262. ;***                BC   = Number of transfered bytes (which have been copied
  263. ;***                       to the destination)
  264. ;***                HL   = Number of remaining bytes (which are still left in
  265. ;***                       the RX buffer)
  266. ;***                ZF   = 1 -> no remaining bytes (RX buffer is empty)
  267. ;*** Destroyed      F,DE,HL,IX,IY
  268. ;*** Description    Copies data, which has been received from the remote host,
  269. ;***                to a specified destination in memory. The length of the
  270. ;***                requested data is not limited, but this function will only
  271. ;***                receive the available one.
  272. ;***                Please note, that a new TCPEVT event only occurs on new
  273. ;***                incoming bytes, if this function returned HL=0 (no
  274. ;***                remaining bytes). It may happen, that during the last
  275. ;***                TCPEVT/TCPSTA status the number of remaining bytes has been
  276. ;***                increased, so you always have to check HL, even if you
  277. ;***                requested all incoming bytes known from the last status.
  278. ;******************************************************************************
  279. SyNet_TCPRCV
  280.         call snwmsgi_afbcdehl
  281.         db FNC_NET_TCPRCV
  282.         jp snwmsgo_afbchl
  283. endif
  284.  
  285. if use_SyNet_TCPSND=1
  286. ;******************************************************************************
  287. ;*** ID             020 (TCPSND)
  288. ;*** Name           TCP_Send
  289. ;*** Input          A    = Handle
  290. ;***                E    = Source bank
  291. ;***                HL   = Source address
  292. ;***                BC   = Length
  293. ;*** Output         CF   = Error state (0 = ok, 1 = error; A = error code)
  294. ;***                - if CF is 0:
  295. ;***                A    = Handle
  296. ;***                BC   = Number of transfered bytes
  297. ;***                HL   = Number of remaining bytes (which couldn't be
  298. ;***                       transfered, as the TX buffer is full at the moment)
  299. ;***                ZF   = 1 -> no remaining bytes
  300. ;*** Destroyed      F,DE,IX,IY
  301. ;*** Description    Sends data to the remote host. The length of the data is
  302. ;***                not limited, but this function may send only a part of it.
  303. ;***                In case that not all data have been send, the application
  304. ;***                should idle for a short time and send the remaining part
  305. ;***                at another attempt.
  306. ;******************************************************************************
  307. SyNet_TCPSND
  308.         call snwmsgi_afbcdehl
  309.         db FNC_NET_TCPSND
  310.         jp snwmsgo_afbchl
  311. endif
  312.  
  313. if use_SyNet_TCPSKP=1
  314. ;******************************************************************************
  315. ;*** ID             021 (TCPSKP)
  316. ;*** Name           TCP_Skip
  317. ;*** Input          A    = Handle
  318. ;***                BC   = Length
  319. ;*** Output         CF   = Error state (0 = ok, 1 = error; A = error code)
  320. ;***                - if CF is 0:
  321. ;***                A    = Handle
  322. ;*** Destroyed      F,BC,DE,HL,IX,IY
  323. ;*** Description    Skips data, which has been received from the remote host.
  324. ;***                This can be used if the application is sure, that the
  325. ;***                following bytes are not needed and the data transfer can be
  326. ;***                skipped to save resources. The amount of bytes must be
  327. ;***                equal or smaller than the total amount of received data.
  328. ;******************************************************************************
  329. SyNet_TCPSKP
  330.         call snwmsgi_afbcdehl
  331.         db FNC_NET_TCPSKP
  332.         jp snwmsgo_afhl
  333. endif
  334.  
  335. if use_SyNet_TCPFLS=1
  336. ;******************************************************************************
  337. ;*** ID             022 (TCPFLS)
  338. ;*** Name           TCP_Flush
  339. ;*** Input          A    = Handle
  340. ;*** Output         CF   = Error state (0 = ok, 1 = error; A = error code)
  341. ;***                - if CF is 0:
  342. ;***                A    = Handle
  343. ;*** Destroyed      F,BC,DE,HL,IX,IY
  344. ;*** Description    Flushes the send buffer. This maybe used to send data
  345. ;***                immediately, as some network hardware or software
  346. ;***                implementations may store it first in the send buffer for a
  347. ;***                while until it is full or a special amount of time has
  348. ;***                passed.
  349. ;******************************************************************************
  350. SyNet_TCPFLS
  351.         call snwmsgi_af
  352.         db FNC_NET_TCPFLS
  353.         jp snwmsgo_afhl
  354. endif
  355.  
  356. if use_SyNet_TCPDIS=1
  357. ;******************************************************************************
  358. ;*** ID             023 (TCPDIS)
  359. ;*** Name           TCP_Disconnect
  360. ;*** Input          A    = Handle
  361. ;*** Output         CF   = Error state (0 = ok, 1 = error; A = error code)
  362. ;***                - if CF is 0:
  363. ;***                A    = Handle
  364. ;*** Destroyed      F,BC,DE,HL,IX,IY
  365. ;*** Description    Sends a disconnect signal to the remote host, closes the
  366. ;***                TCP connection and releases the used socket. Use this, if
  367. ;***                you want to close the connection by yourself.
  368. ;******************************************************************************
  369. SyNet_TCPDIS
  370.         call snwmsgi_af
  371.         db FNC_NET_TCPDIS
  372.         jp snwmsgo_afhl
  373. endif
  374.  
  375. if use_SyNet_TCPRLN=1
  376. ;******************************************************************************
  377. ;*** ID             024 (TCPRLN)
  378. ;*** Name           TCP_ReceiveLine
  379. ;*** Input          A    = Handle
  380. ;***                E    = Destination bank
  381. ;***                HL   = Destination address
  382. ;*** Output         CF   = Error state (0 = ok, 1 = error; A = error code)
  383. ;***                - if CF is 0:
  384. ;***                A    = Handle
  385. ;***                D    = Line length (-1=no complete line received, ZF=1)
  386. ;***                ZF   = 1 -> no complete line received
  387. ;*** Destroyed      AF,E,HL,IX,IY
  388. ;*** Description    ...
  389. ;******************************************************************************
  390. SyNet_TCPRLN_Buffer ds 256      ;buffer
  391. SyNet_TCPRLN_Length db 0        ;length (always <255)
  392. SyNet_TCPRLN
  393.         ld (snwrln3+1),a
  394.         ld a,e
  395.         add a:add a:add a:add a
  396.         ld (snwrlnb+1),a
  397.         ld (snwrlna+1),hl
  398.         call snwrln0
  399.         ld a,d
  400.         inc a
  401.         jr z,snwrln8
  402. snwrln9 ld a,d
  403.         inc a
  404.         or a
  405. snwrlnc ld a,(snwrln3+1)
  406.         ret
  407. snwrln8 ld a,(SyNet_TCPRLN_Length)
  408.         ld c,a
  409.         ld b,0
  410.         cpl                     ;A=255-buflen
  411.         ld hl,SyNet_TCPRLN_Buffer
  412.         add hl,bc
  413.         ld c,a
  414. snwrln3 ld a,0
  415.         ld de,(App_BnkNum)
  416.         call snwmsgi_afbcdehl   ;receive data
  417.         db FNC_NET_TCPRCV
  418.         call snwmsgo_afbchl
  419.         ret c
  420.         ld hl,SyNet_TCPRLN_Length
  421.         ld a,(hl)
  422.         add c
  423.         ld (hl),a               ;update buffer length
  424.         call snwrln0
  425.         jr snwrln9
  426.  
  427. snwrln0 ld a,(SyNet_TCPRLN_Length)
  428.         cp 255
  429.         ccf
  430.         sbc 0
  431.         ld d,-1
  432.         ret z
  433.         ld e,a                  ;e,bc=search length (max 254)
  434.         ld c,a
  435.         ld b,0
  436.         ld hl,SyNet_TCPRLN_Buffer
  437.         ld a,13
  438.         cpir
  439.         jr z,snwrln5
  440.         ld a,e
  441.         cp 254
  442.         ret c                   ;** not found and <254 chars -> no complete line received
  443.         inc d
  444. snwrln4 call snwrln7            ;** not found and =254 chars -> send line anyway
  445.         ld d,254
  446.         ret
  447. snwrln5 ld a,c                  ;** found -> HL=behind 13-char, BC=remaining length
  448.         or b
  449.         ld d,-1
  450.         ret z                   ;found at the last position -> no complete line received
  451.         ld d,1
  452.         ld a,10
  453.         cp (hl)
  454.         jr nz,snwrln6
  455.         inc d
  456. snwrln6 ld bc,SyNet_TCPRLN_Buffer+1
  457.         or a
  458.         sbc hl,bc
  459.         ld e,l
  460.         push de
  461.         call snwrln7
  462.         pop de
  463.         ld d,e
  464.         ret
  465.  
  466. ;e=line length, d=bytes to skip -> copy line to destination and remove it from the buffer
  467. snwrln7 push de
  468.         ld d,0
  469.         ld hl,SyNet_TCPRLN_Buffer
  470.         push hl
  471.         add hl,de
  472.         ld (hl),0
  473.         pop hl
  474.         ld c,e
  475.         inc c
  476.         ld b,0
  477.         ld a,(App_BnkNum)
  478. snwrlnb add 0
  479. snwrlna ld de,0
  480.         rst #20:dw jmp_bnkcop
  481.         pop de
  482.         ld hl,SyNet_TCPRLN_Length
  483.         ld a,(hl)
  484.         sub e
  485.         sub d
  486.         ld (hl),a
  487.         ret z
  488.         ld c,a
  489.         ld b,0
  490.         ld a,e
  491.         add d
  492.         ld e,a
  493.         ld d,0
  494.         ld hl,SyNet_TCPRLN_Buffer
  495.         add hl,de
  496.         ld de,SyNet_TCPRLN_Buffer
  497.         ldir
  498.         ret
  499. endif
  500.  
  501. ;### UDP FUNCTIONS ############################################################
  502.  
  503. if use_SyNet_UDPOPN=1
  504. ;******************************************************************************
  505. ;*** ID             032 (UDPOPN)
  506. ;*** Name           UDP_Open
  507. ;*** Input          A    = Type
  508. ;***                HL   = Local port
  509. ;***                E    = Source/destination bank for receive/send
  510. ;*** Output         CF   = Error state (0 = ok, 1 = error; A = error code)
  511. ;***                - if CF is 0:
  512. ;***                A    = Handle
  513. ;*** Destroyed      F,BC,DE,HL,IX,IY
  514. ;*** Description    Opens an UDP session. Already with this functions you have
  515. ;***                to specify the ram bank number of the source and
  516. ;***                destination memory areas for upcoming data transfer.
  517. ;***                This function will fail, if there is no free socket left.
  518. ;***                It returns the session handle if it was successful.
  519. ;******************************************************************************
  520. SyNet_UDPOPN
  521.         call snwmsgi_afdehl
  522.         db FNC_NET_UDPOPN
  523.         jp snwmsgo_afhl
  524. endif
  525.  
  526. if use_SyNet_UDPCLO=1
  527. ;******************************************************************************
  528. ;*** ID             033 (UDPCLO)
  529. ;*** Name           UDP_Close
  530. ;*** Input          A    = Handle
  531. ;*** Output         CF   = Error state (0 = ok, 1 = error; A = error code)
  532. ;***                - if CF is 0:
  533. ;***                A    = Handle
  534. ;*** Destroyed      F,BC,DE,HL,IX,IY
  535. ;*** Description    Closes an UDP session and releases the used socket.
  536. ;******************************************************************************
  537. SyNet_UDPCLO
  538.         call snwmsgi_af
  539.         db FNC_NET_UDPCLO
  540.         jp snwmsgo_afhl
  541. endif
  542.  
  543. if use_SyNet_UDPSTA=1
  544. ;******************************************************************************
  545. ;*** ID             034 (UDPSTA)
  546. ;*** Name           UDP_Status
  547. ;*** Input          A    = Handle
  548. ;*** Output         CF   = Error state (0 = ok, 1 = error; A = error code)
  549. ;***                - if CF is 0:
  550. ;***                A    = Handle
  551. ;***                L    = Status
  552. ;***                - if L is ???:
  553. ;***                BC   = Received bytes
  554. ;***                IX,IY= Remote IP
  555. ;***                DE   = Remote port
  556. ;*** Destroyed      F,BC,DE,HL,IX,IY
  557. ;*** Description    Returns the actual status of the UDP session. This is
  558. ;***                always exactly the same as received in the last event
  559. ;***                message (see UDPEVT).
  560. ;******************************************************************************
  561. SyNet_UDPSTA
  562.         call snwmsgi_af
  563.         db FNC_NET_UDPSTA
  564.         jp snwmsgo_afbcdehlixiy
  565. endif
  566.  
  567. if use_SyNet_UDPRCV=1
  568. ;******************************************************************************
  569. ;*** ID             035 (UDPRCV)
  570. ;*** Name           UDP_Receive
  571. ;*** Input          A    = Handle
  572. ;***                HL   = Destination address
  573. ;***                       (bank has been specified by the UDPOPN function)
  574. ;*** Output         CF   = Error state (0 = ok, 1 = error; A = error code)
  575. ;***                - if CF is 0:
  576. ;***                A    = Handle
  577. ;*** Destroyed      F,BC,DE,HL,IX,IY
  578. ;*** Description    Copies the package data, which has been received from a
  579. ;***                remote host, to a specified destination in memory. Please
  580. ;***                note, that this function will always transfer the whole
  581. ;***                data at once, so there should be enough place at the
  582. ;***                destination address. The destination ram bank number has
  583. ;***                already been specified with the UDPOPN function.
  584. ;******************************************************************************
  585. SyNet_UDPRCV
  586.         call snwmsgi_afhl
  587.         db FNC_NET_UDPRCV
  588.         jp snwmsgo_afhl
  589. endif
  590.  
  591. if use_SyNet_UDPSND=1
  592. ;******************************************************************************
  593. ;*** ID             036 (UDPSND)
  594. ;*** Name           UDP_Send
  595. ;*** Input          A    = Handle
  596. ;***                HL   = Source address
  597. ;***                       (bank has been specified by the UDPOPN function)
  598. ;***                BC   = Length
  599. ;***                IX,IY= Remote IP
  600. ;***                DE   = Remote port
  601. ;*** Output         CF   = Error state (0 = ok, 1 = error; A = error code)
  602. ;***                - if CF is 0:
  603. ;***                A    = Handle
  604. ;*** Destroyed      F,BC,DE,HL,IX,IY
  605. ;*** Description    Sends a data package to a remote host. It may happen, that
  606. ;***                the send buffer is currently full, and this function will
  607. ;***                the return the appropriate error code. In this case the
  608. ;***                application should idle for a short time and try to send
  609. ;***                the package again at another attempt.
  610. ;******************************************************************************
  611. SyNet_UDPSND
  612.         call snwmsgi_afbcdehlixiy
  613.         db FNC_NET_UDPSND
  614.         jp snwmsgo_afhl
  615. endif
  616.  
  617. if use_SyNet_UDPSKP=1
  618. ;******************************************************************************
  619. ;*** ID             037 (UDPSKP)
  620. ;*** Name           UDP_Skip
  621. ;*** Input          A    = Handle
  622. ;*** Output         CF   = Error state (0 = ok, 1 = error; A = error code)
  623. ;***                - if CF is 0:
  624. ;***                A    = Handle
  625. ;*** Destroyed      F,BC,DE,HL,IX,IY
  626. ;*** Description    Skips a received data package. This can be used if the
  627. ;***                application is sure, that the data is not needed or has
  628. ;***                sent from the wrong remote host, so the data transfer can
  629. ;***                be skipped to save resources.
  630. ;******************************************************************************
  631. SyNet_UDPSKP
  632.         call snwmsgi_af
  633.         db FNC_NET_UDPSKP
  634.         jp snwmsgo_afhl
  635. endif
  636.  
  637.  
  638. ;### DNS FUNCTIONS ############################################################
  639.  
  640. if use_SyNet_DNSRSV=1
  641. ;******************************************************************************
  642. ;*** ID             112 (DNSRSV)
  643. ;*** Name           DNS_Resolve
  644. ;*** Input          HL = string address (0-terminated)
  645. ;*** Output         CF   = Error state (0 = ok, 1 = error; A = error code)
  646. ;***                - if CF is 0:
  647. ;***                IX,IY= IP
  648. ;*** Destroyed      AF,BC,DE,HL
  649. ;*** Description    ...
  650. ;******************************************************************************
  651. SyNet_DNSRSV
  652.         ld de,(App_BnkNum)
  653.         call snwmsgi_afdehl
  654.         db FNC_NET_DNSRSV
  655.         jp snwmsgo_afbcdehlixiy
  656. endif
  657.  
  658. if use_SyNet_DNSVFY=1
  659. ;******************************************************************************
  660. ;*** ID             113 (DNSVFY)
  661. ;*** Name           DNS_Verify
  662. ;*** Input          HL = string address (0-terminated)
  663. ;*** Output         L    = type of address (0=no valid address, 1=IP address,
  664. ;***                                        2=domain address)
  665. ;***                - if L is 1:
  666. ;***                IX,IY= IP
  667. ;*** Destroyed      F,BC,DE,HL
  668. ;*** Description    ...
  669. ;******************************************************************************
  670. SyNet_DNSVFY
  671.         ld de,(App_BnkNum)
  672.         call snwmsgi_afdehl
  673.         db FNC_NET_DNSVFY
  674.         jp snwmsgo_afbcdehlixiy
  675. endif
  676.  
  677.  
  678. ;### SUB ROUTINES #############################################################
  679.  
  680. snwmsgi_afbcdehlixiy
  681.         ld (App_MsgBuf+10),ix   ;store registers to message buffer
  682.         ld (App_MsgBuf+12),iy
  683. snwmsgi_afbcdehl
  684.         ld (App_MsgBuf+04),bc
  685. snwmsgi_afdehl
  686.         ld (App_MsgBuf+06),de
  687. snwmsgi_afhl
  688.         ld (App_MsgBuf+08),hl
  689. snwmsgi_af
  690.         push af:pop hl
  691.         ld (App_MsgBuf+02),hl
  692.         pop hl
  693.         ld a,(hl)               ;set command
  694.         inc hl
  695.         push hl
  696.         ld (App_MsgBuf+0),a
  697.         ld (snwmsg2+1),a
  698.         ld iy,App_MsgBuf
  699.         ld a,(App_PrcID)
  700.         db #dd:ld l,a
  701.         ld a,(SyNet_PrcID)
  702.         db #dd:ld h,a
  703.         ld (snwmsg1+2),ix
  704.         rst #10                 ;send message
  705. snwmsg1 ld ix,0                 ;wait for response
  706.         rst #08
  707.         db #dd:dec l
  708.         jr nz,snwmsg1
  709.         ld a,(App_MsgBuf)
  710.         sub 128
  711. snwmsg2 cp 0
  712.         ret z
  713.         ld a,(App_PrcID)        ;wrong response code -> re-send and wait for correct one
  714.         db #dd:ld h,a
  715.         ld a,(SyNet_PrcID)
  716.         db #dd:ld l,a
  717.         rst #10
  718.         rst #30
  719.         jr snwmsg1
  720. snwmsgo_afbcdehlixiy
  721.         ld ix,(App_MsgBuf+10)   ;get registers from the message buffer
  722.         ld iy,(App_MsgBuf+12)
  723.         ld de,(App_MsgBuf+06)
  724. snwmsgo_afbchl
  725.         ld bc,(App_MsgBuf+04)
  726. snwmsgo_afhl
  727.         ld hl,(App_MsgBuf+02)
  728.         push hl
  729.         pop af
  730.         ld hl,(App_MsgBuf+08)
  731.         ret
  732.