Compare commits

...

7 Commits

Author SHA1 Message Date
John Bintz 882ee8cba2 Starting on test suite, fixing some bugs found via it 2024-04-26 08:32:52 -04:00
John Bintz e4711f1783 Change up documentation structure 2024-04-26 07:10:14 -04:00
John Bintz b25f08cdae 1.1.3 works 2024-04-25 17:03:25 -04:00
John Bintz 771d40fab7 1.1.2 applied 2024-04-25 16:18:31 -04:00
John Bintz 53c73d8888 1.1.1 applied and working 2024-04-25 14:53:17 -04:00
John Bintz fdab7b432e 1.1.0 applied and working 2024-04-25 14:40:47 -04:00
John Bintz ade45f63b8 why is this working 2024-04-25 13:54:01 -04:00
10 changed files with 636 additions and 78 deletions

6
.gitignore vendored
View File

@ -4,3 +4,9 @@ dist/
build/
aminet/
Disk.info
private-test/
stuff/
patches/
.vamosrc
activate
test/report.txt

92
API.md
View File

@ -3,7 +3,9 @@
Most functions will return -2 if the bsdsocket.library is
not open.
### Setup
---
## Setup
#### ADDR=Socket Library Open
@ -16,11 +18,15 @@ Try to open bsdsocket.library version 4.
* If needed, you'll be able to directly access library functions
using this address.
---
#### Socket Library Close
Close bsdsocket.library. This is safe to call if the library
is not open
---
#### RESULT=Socket Set Nonblocking(Socket, IsNonblocking BOOL)
Make a socket blocking (False, default), or nonblocking (True).
@ -29,6 +35,8 @@ Make a socket blocking (False, default), or nonblocking (True).
* Result of IoctlSocket call.
---
#### RESULT=Socket Reuse Addr(Socket)
Make a listening socket reuse the address it's trying to bind to.
@ -38,9 +46,9 @@ You probably want to call this right before Socket Listen.
* Result of setsockopt call.
---
### Connections
## Connections
#### SOCKET=Socket Create Inet Socket
@ -51,6 +59,8 @@ Create a new Internet socket for reading or writing.
* Socket number on success
* -1 on failure
---
#### RESULT=Socket Connect(Socket to IPAddress$, Port)
Attempt to connect to a remote host. Currently doesn't
@ -65,6 +75,8 @@ support DNS lookups.
to see if the connection succeeded
* -11 port out of range
---
#### RESULT=Socket Reuse Addr(Socket)
Set a server socket to reuse an interface and port that had
@ -77,6 +89,8 @@ setsockopt() for you.
The result of calling setsockopt() while setting your socket
to reuse addresses.
---
#### RESULT=Socket Bind(Socket to IPAddress, Port)
Attempt to bind a socket to a network interface. Use
@ -89,6 +103,8 @@ interfaces.
* -1 on other error
* -11 port out of range
---
#### RESULT=Socket Listen(Socket)
Start listening for connections.
@ -98,6 +114,8 @@ Start listening for connections.
* 0 on success
* -1 on failure
---
#### NEW_SOCKET=Socket Accept(Socket)
Get the socket that connected to this one. Wait for a connect
@ -115,11 +133,13 @@ socket non-blocking and use Fdsets and Select!
* The remote socket number on success
* -1 on failure
#### RESULT=Socket Async Wait Reading(Socket, Wait_ms)
---
#### RESULT=Socket Wait Async Reading(Socket, Wait_ms)
Wait the given number of milliseconds for the nonblocking socket to be ready for reading.
Use this when you're waiting for a client to connect to you, or if you're waiting for
a remote socket to send you data.
Use on a listen socket to await new connections, or on a connected socket to await
incoming data packets.
##### Returns
@ -127,7 +147,9 @@ a remote socket to send you data.
* -1 on error. Use `Socket Errno` for more detail.
* 1 on success.
#### RESULT=Socket Async Wait Writing(Socket, Wait_ms)
---
#### RESULT=Socket Wait Async Writing(Socket, Wait_ms)
Wait the given number of milliseconds for the nonblocking socket to be ready for writing.
Use this when you're connecting to a remote server and want to know if the connection
@ -143,6 +165,8 @@ has been completed.
checks will return 1.
* 1 on success.
---
#### RESULT=Socket Set Timeout(Socket, Wait_ms)
Set a socket to timeout after Wait_ms milliseconds if reading or writing doesn't complete.
@ -152,7 +176,9 @@ Set a socket to timeout after Wait_ms milliseconds if reading or writing doesn't
* 0 on success
* -1 on error
#### RESULT=Socket Close(Socket)
---
#### RESULT=Socket Close Socket(Socket)
Close a socket.
@ -161,9 +187,9 @@ Close a socket.
* 0 on success
* -1 on error
---
### Data Transfers
## Data Transfers
#### SENT=Socket Send$(Socket, String$)
@ -194,6 +220,8 @@ End Proc
* Number of characters sent
* -1 on other error
---
#### SENT=Socket Send(Socket, Data Pointer, Length)
Send a block of data to a connected socket.
@ -203,6 +231,8 @@ Send a block of data to a connected socket.
* Number of characters sent
* -1 on other error
---
#### DATA$=Socket Recv$(Socket, MaxLength)
Retrieve at most MaxLength bytes from Socket, and put them into a string.
@ -212,7 +242,9 @@ If Len(DATA$) < MaxLength, you've read the last bit of data from the socket.
* String of data, which is blank if there is no more data.
### LENGTH=Socket Recv(Socket to Dataptr, MaxLength)
---
#### LENGTH=Socket Recv(Socket to Dataptr, MaxLength)
Retrieve at most MaxLength bytes from Socket, and put them into the memory
address at Dataptr.
@ -222,9 +254,9 @@ address at Dataptr.
* Count of bytes read
* -1 on error
---
### Informational
## Informational
#### HOST=Socket Get Host(Socket)
@ -234,6 +266,8 @@ Get the IPv4 (Long) host value the given socket is using.
* Host as a long value
---
#### PORT=Socket Get Port(Socket)
Get the 16-bit port (Word) value the given socket is using.
@ -242,6 +276,8 @@ Get the 16-bit port (Word) value the given socket is using.
* Port as a word value
---
#### RESULT$=Socket Inet Ntoa$(Host)
Turn a long Host address into a string.
@ -250,6 +286,8 @@ Turn a long Host address into a string.
* IP address as string
---
#### RESULT=Socket Errno
Get the error from the last command. Note that this is
@ -260,6 +298,18 @@ not cleared on a successful command!
Error number from last call. Look in <sys/error.h> for more
details.
---
#### RESULT=Socket Herrno
Get the error from the last DNS resolver command.
##### Returns
Resolver error number (`h_errno`) from last call.
---
#### RESULT$=Dns Get Address By Name$(Domain Name$)
Look up the first IP address associated with this hostname.
@ -274,6 +324,8 @@ out. There's no way to set this timeout, or cancel or override it via AMOS.
String with IP address, or blank string on error.
---
#### RESULT=Socket Status(Socket)
Returns basic connection information about a socket.
@ -297,9 +349,9 @@ Status of socket:
* 6 = Connecting
* 7 = Connected
---
### Low Level
## Low Level
#### RESULT=Socket Setsockopt Int(Socket, Option, Value)
@ -311,6 +363,8 @@ Socket Reuse Addr().
* Result of setsockopt call
---
#### RESULT=Socket Getsockopt Int(Socket, Option)
Get a socket option. You probably want SO_ERROR,
@ -321,6 +375,8 @@ attempt a connection with a non-blocking socket.
* Result of getsockopt call
---
#### ADDR=Socket Fdset Zero(fd_set)
Clear out the specified fd_set.
@ -330,6 +386,8 @@ Clear out the specified fd_set.
* Address to that particular fd_set
* -1 if fd_set out of range. You get 16 of them.
---
#### ADDR=Socket Fdset Set(fd_set, Socket to Value BOOL)
Set or clear a socket bit in an fd_set.
@ -339,6 +397,8 @@ Set or clear a socket bit in an fd_set.
* Address to that particular fd_set
* -1 if fd_set is out of range or socket is out of range.
---
#### RESULT=Socket Fdset Is Set(fd_set, Socket)
See if the particular socket remained after a Socket Select call.
@ -347,6 +407,8 @@ See if the particular socket remained after a Socket Select call.
* True or False if the socket is set or not
---
#### RESULT=Socket Select(Max Socket, Read fd_set, Write fd_set, Error fd_set, TimeoutMS)
Wait for the specified number of milliseconds. If any of the sockets

BIN
src/AMOSPro_BSDSocket.Lib Normal file

Binary file not shown.

View File

@ -7,7 +7,7 @@
; extension number 18
ExtNb equ 18-1
Version MACRO
dc.b "1.0.1-20230403"
dc.b "1.1.3-20240417"
ENDM
VerNumber equ $1
@ -15,12 +15,12 @@ VerNumber equ $1
; Include the files automatically calculated by
; Library_Digest.AMOS
;---------------------------------------------------------------------
Incdir "Stuff:development/amos-professional-official-mas/"
Incdir "Stuff:development/amos-professional-official-mas/includes/"
Incdir "AMOSPro_Sources:"
Incdir "AMOSPro_Sources:includes/"
Include "BSDSocket_Size.s"
Include "BSDSocket_Labels.s"
Include "+AMOS_Includes.s"
Include "socket_lvo.i"
Include "bsdsocket_lvo.i"
; get the effective address of something in extension memory
Dlea MACRO
@ -56,7 +56,6 @@ SO_REUSEADDR EQU $4
MAX_SOCKETS EQU 64
len_sockaddr_in EQU 16
sockaddr_in_sin_len EQU 0
sockaddr_in_sin_family EQU 1
sockaddr_in_sin_port EQU 2
sockaddr_in_sin_addr EQU 4
@ -68,6 +67,20 @@ Error_PortOutOfRange EQU -11
Error_FdsetOutOfRange EQU -11
Error_UnableToBind EQU -12
; socket herrno and tag lists
; built from:
; * https://wiki.amigaos.net/amiga/autodocs/bsdsocket.doc.txt
; * https://github.com/deplinenoise/amiga-sdk/blob/master/netinclude/amitcp/socketbasetags.h
; * http://amigadev.elowar.com/read/ADCD_2.1/Includes_and_Autodocs_2._guide/node012E.html
TAG_USER EQU (1<<31)
SBTF_REF EQU $8000
SBTB_CODE EQU 1
SBTS_CODE EQU $3FFF
SBTC_HERRNO EQU 6
HerrnoTag EQU (TAG_USER|SBTF_REF|((SBTC_HERRNO&SBTS_CODE)<<SBTB_CODE))
; wrap code that doesn't take arguments with these
PreserveStackInstruction MACRO
MOVEM.L A2-A6/D6-D7,-(SP)
@ -128,19 +141,20 @@ LeaFdset MACRO
; LeaFdsetForBit fd_set reg,target address,target bit in address
LeaFdsetForBit MACRO
LeaFdset \1,\2 ; get fdset base address in \2
MOVE.L D3,-(SP)
MOVEM.L D3-D4,-(SP)
MOVE.L \3,D3 ; Put target bit into D3
ROR.L #5,D3 ; lop off the first 5 bits
AND.L #$7,D3 ; only keep the top three
ROL.L #2,D3 ; multiply by 4
ADD.L D3,\2 ; add that value to the fdset address
AND.L #$1F,\3 ; only keep 0-31 in \3
MOVE.L \3,D4
AND.L #$1F,D4 ; only keep 0-31 in \3
MOVEQ #1,D3
ROL.L \3,D3 ; shift that bit left as many as target
ROL.L D4,D3 ; shift that bit left as many as target
MOVE.L D3,\3 ; put that in the target
MOVE.L (SP)+,D3
MOVEM.L (SP)+,D3-D4
ENDM
@ -330,6 +344,9 @@ C_Tk dc.w 1,0
AddTokenFunction SocketCloseSocket
dc.b "socket close socke","t"+$80,"00",-1
AddTokenFunction SocketHerrno
dc.b "socket herrn","0"+$80,"0",-1
; TOKEN_END
dc.w 0
dc.l 0 ; Important!
@ -386,6 +403,8 @@ getsockopt_len ds.l 1
MaxSocketSeen dc.w 0
sockaddr_ram ds.l 1
; also used for errno tags
AcceptScratchArea ds.b 16
SelectScratchArea ds.l 2
@ -493,7 +512,7 @@ _SocketLibraryOpen_Finish:
;
; Turn an IP address and port into a sockaddr_in strucure
;
; d0 - 0 on success, -1 on failure
; d0 - address of sockaddr_in on success, -1 on failure
; - - - - - - - -
Lib_Def SocketIPAddressPortToSockaddr
@ -514,14 +533,26 @@ _ToSockaddr_PortOK:
MOVE.L sockaddr_ram-MB(A3),A0
ADD.L D3,A0 ; A0 contains our offset in ram
MOVE.B #len_sockaddr_in,sockaddr_in_sin_len(A0)
MOVE.B #AF_INET,sockaddr_in_sin_family(A0)
MOVE.W D2,sockaddr_in_sin_port(A0)
MOVEM.L A0-A3/D3,-(SP)
MOVE.L D1,A1 ; ip string address
MOVE.W (A1)+,D3 ; string length
MOVE.L D1,A0 ; ip address
ADDQ #2,A0 ; string data starts 2 bytes in
BNE _ToSockaddr_StringHasLength
MOVEM.L (SP)+,A0-A3/D3
MOVEM.L (SP)+,A0/A3/D3
MOVE.L #-14,D0
RTS
_ToSockaddr_StringHasLength:
; temporarily store a null-terminated copy of the ip string in A0
MOVE.L A0,A2
SUBQ #1,D3 ; DBRA loop runs D3 + 1 times
_ToSockaddr_CopyIPString:
MOVE.B (A1)+,(A2)+
DBRA D3,_ToSockaddr_CopyIPString
MOVE.B #0,(A2) ; end of string
; if the string contains "INADDR_ANY", we use that value instead
MOVE.L A0,A1
@ -546,7 +577,15 @@ _ToSockaddr_ParseIPAddress:
_ToSockaddr_DoneParsing:
MOVEM.L (SP)+,A0-A3/D3
MOVE.L D0,sockaddr_in_sin_addr(A0)
; create struct sockaddr_in
MOVE.B #len_sockaddr_in,(A0)
MOVE.B #AF_INET,sockaddr_in_sin_family(A0)
MOVE.W D2,sockaddr_in_sin_port(A0)
LEA sockaddr_in_sin_addr(A0),A3
MOVE.L D0,(A3)+
CLR.L (A3)+
CLR.L (A3)+
MOVE.L A0,D0
MOVEM.L (SP)+,A0/A3/D3
@ -626,7 +665,6 @@ _SocketCreateInetSocket_Done:
Ret_Int
_SocketConnect_LibraryOpen:
MOVE.L D0,-(SP) ; socket id onto stack
Rbsr L_SocketIPAddressPortToSockaddr
@ -644,6 +682,8 @@ _SocketConnect_SockaddrIn:
MOVE.L D0,A0
MOVE.L (SP)+,D0
CLR.W $100
MOVE.L D0,-(SP)
MOVEM.L A0/A3,-(SP)
Dload A3
@ -1334,7 +1374,7 @@ _SocketSelect_PerformSelect
PreserveStackFunction
EnsureBSDSocketLibrary _SocketInetNtoa_LibraryOpen
RestoreStackInstruction
RestoreStackFunction
Ret_Int
_SocketInetNtoa_LibraryOpen:
@ -1354,10 +1394,25 @@ _SocketInetNtoA_StringSizeLoop:
MOVE.L A0,D3
SUB.L A2,D3 ; D3 = length
SUBQ #1,D3 ; get rid of the null terminator
MOVE.L A0,D4
SUB.L A2,D4 ; D4 = length
SUBQ #1,D4 ; get rid of the null terminator
; add 2 and even out the space
MOVE.L D4,D3
AND.W #$FFFE,D3
ADDQ.W #2,D3
Rjsr L_Demande ; string base address is in A0/A1
MOVE.W D3,(A0)+ ; length of string
SUBQ #1,D3
LEA 2(A0,D3.W),A1
MOVE.L A1,HiChaine(A5)
MOVE.L A0,A1
MOVE.W D4,(A0)+ ; length of string
SUBQ #1,D4
_SocketInetNtoA_StringCopyLoop:
MOVE.B (A2,D3),(A0,D3)
@ -1431,7 +1486,7 @@ _SocketRecvString_NotTooLong:
_SocketRecvString_BufferAllocated:
MOVE.L D0,A0 ; buffer address
MOVE.L D1,D0 ; socket
MOVE.L (SP)+,D1 ; length
MOVE.L (SP)+,D1 ; reserved ram buffer length
MOVEQ #0,D2 ; flags
MOVEM.L A0-A1/D1,-(SP)
@ -1459,39 +1514,38 @@ _SocketRecvString_BufferAllocated:
Ret_String
; TODO received data is wrong somewhere
_SocketRecvString_DataReceived:
; D0 contains receive length
; D0 contains socket receive length
MOVE.L D1,-(SP)
; TODO: handle zero return length
MOVE.L A0,A2 ; A2 contains read buffer
MOVE.L D1,-(SP) ; reserved ram buffer length
; demande/hichaine string setup
MOVEQ #0,D3
MOVE.W D0,D3 ; prep for L_Demande. can we request a zero length string?
MOVE.L A0,A2 ; L_Demande blows away A0 and A1, A2 now contains buffer
MOVE.W D0,D3
AND.W #$FFFE,D3
ADDQ #2,D3
Rjsr L_Demande ; A0/A1 contain string address
MOVE.W D3,(A0)+ ; put in string length
SUBQ #1,D3 ; reduce by one for DBRA
LEA 2(A0,D3.W),A1
MOVE.L A1,HiChaine(A5)
MOVE.L A0,A1
MOVE.W D0,(A1)+ ; put in string length
SUBQ #1,D0 ; reduce by one for DBRA
MOVE.L A2,A3 ; A3 now contains start of buffer
_SocketRecvString_CopyData:
MOVE.B (A2,D3),(A0,D3)
DBRA D3,_SocketRecvString_CopyData
MOVE.B (A2,D0),(A1,D0)
DBRA D0,_SocketRecvString_CopyData
MOVE.L (SP)+,D0 ; reserved ram buffer length
EvenOutStringAddress A0,D2
; add to string manager for garbage collection?
MOVE.L A0,HiChaine(A5)
MOVE.L (SP)+,D0
; free ram
MOVE.L A1,-(SP) ; A1 contains our string addres
;MOVE.L D1,D0
MOVE.L A0,-(SP)
MOVE.L A3,A1
Rjsr L_RamFree
MOVE.L (SP)+,D3 ; string return
MOVE.L (SP)+,A3
RestoreStackFunction
@ -1885,7 +1939,7 @@ _SocketReuseAddr_LibraryOpen:
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; =Dns Get Host Address By Name$(Name String)
; =Dns Get Address By Name$(Name String)
;
; Get the status of a socket
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1900,15 +1954,43 @@ _SocketReuseAddr_LibraryOpen:
Ret_String
_DnsGetHostAddressByName_LibraryOpen:
; string so you need demande, hichaine, and chvide
MOVE.L D3,A0 ; name
ADD.L #2,A0 ; skip length, string is null terminated (?)
MOVEQ #0,D0
MOVE.W (A0)+,D0 ; d0 contains length
MOVE.L D0,D1 ; d1 also has length
MOVE.L D0,D2 ; d2 also has length
Rjsr L_RamFast ; d0 contains address
BNE _DnsGetHostAddressByName_StringRamAllocated
WithDataStorage
LoadBSDSocketBase
CALLLIB gethostbyname
EndDataStorage
MOVE.L ChVide(A5),D3
RestoreStackFunction
Ret_String
_DnsGetHostAddressByName_StringRamAllocated:
MOVE.L D0,A1 ; a1 contains address
SUBQ #1,D1 ; reduce by one for DBRA
_DnsGetHostAddressByName_KeepCopyingAMOSString
MOVE.B (A0)+,(A1)+ ; byte copy
DBRA D1,_DnsGetHostAddressByName_KeepCopyingAMOSString ; keep copying
MOVE.B #0,(A1)+ ; null terminate string
MOVE.L D0,A0 ; first param of gethostbyname
MOVEM.L A0/D2,-(SP)
WithDataStorage
LoadBSDSocketBase
CALLLIB gethostbyname
EndDataStorage
MOVEM.L (SP)+,A0/D2
; free the ram before we go any farther
MOVE.L D0,-(SP)
MOVE.L A0,A1
MOVE.L D2,D0
Rjsr L_RamFree
MOVE.L (SP)+,D0
TST.L D0
BNE _DnsGetHostAddressByName_GetIPAddress
@ -1919,7 +2001,6 @@ _DnsGetHostAddressByName_LibraryOpen:
Ret_String
_DnsGetHostAddressByName_GetIPAddress:
MOVE.L D0,A0
MOVE.L 16(A0),A1 ; **h_addr_list
MOVE.L (A1),A1 ; *h_addr_list
@ -1940,18 +2021,24 @@ _DnsGetHostAddressByName_GetIPAddressLength:
BNE _DnsGetHostAddressByName_GetIPAddressLength
MOVE.L (SP)+,A2
Rjsr L_Demande ; string is in A0/A1
MOVE.W D3,(A0)+
SUBQ #1,D3
MOVE.L D3,D4
AND.W #$FFFE,D3
ADDQ #2,D3
Rjsr L_Demande ; string is in A0/A1
LEA 2(A0,D3.W),A1
MOVE.L A1,HiChaine(A5)
MOVE.L A0,D3
MOVE.W D4,(A0)+
SUBQ #1,D4
_DnsGetHostAddressByName_KeepCopying:
MOVE.B (A2,D3),(A0,D3)
DBRA D3,_DnsGetHostAddressByName_KeepCopying
EvenOutStringAddress A0,D0
MOVE.L A0,HiChaine(A5)
MOVE.L A1,D3
MOVE.B (A2,D4),(A0,D4)
DBRA D4,_DnsGetHostAddressByName_KeepCopying
RestoreStackFunction
@ -2053,6 +2140,46 @@ _SocketCloseSocket_LibraryOpen:
RestoreStackFunction
Ret_Int
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Int=Socket Herrno
;
; Return Herrno value, errors related to DNS resolution
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Lib_Par SocketHerrno
; - - - - - - - - - - - - -
PreserveStackFunction
; set up tag list memory and place for herrno to go
Dlea AcceptScratchArea,A0
MOVE.L A0,A2
Dlea SelectScratchArea,A1
; build the tag list
MOVE.L HerrnoTag,(A0)+
MOVE.L A1,(A0)+
MOVE.L 0,(A0)+
MOVE.L 0,(A0)+
MOVE.L A2,A0
WithDataStorage
LoadBSDSocketBase
CALLLIB SocketBaseTagList
EndDataStorage
TST.L D0
BEQ _SocketHerrno_success
; failed
MOVE.L #-1,D3
RestoreStackFunction
Ret_Int
_SocketHerrno_success:
MOVE.L (A1),D3
RestoreStackFunction
Ret_Int
;
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Even if you do not have error messages, you MUST

40
src/BSDSocket_Labels.s Normal file
View File

@ -0,0 +1,40 @@
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; BSDSocket.s, list of the library functions on the 26-04-2024 08:23:46
;
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
L_Cold: set 0
L_SocketLibraryOpen: set 2
L_SocketLibraryClose: set 3
L_DoSocketSockaddrFree: set 4
L_SocketIPAddressPortToSockaddr:set 5
L_SocketCreateInetSocket:set 6
L_SocketConnect: set 7
L_SocketSendString: set 8
L_SocketSendData: set 9
L_SocketBind: set 10
L_SocketErrno: set 11
L_SocketListen: set 12
L_SocketAccept: set 13
L_SocketSetNonblocking: set 14
L_SocketSetsockoptInt: set 15
L_SocketGetsockoptInt: set 16
L_SocketFdsetZero: set 17
L_SocketFdsetSet: set 18
L_SocketFdsetIsSet: set 19
L_SocketSelect: set 20
L_SocketGetDebugArea: set 21
L_SocketGetHost: set 22
L_SocketGetPort: set 23
L_SocketInetNtoA: set 24
L_SocketRecvString: set 25
L_SocketRecvData: set 26
L_DoSocketLibraryClose: set 27
L_SocketWaitAsyncWriting:set 28
L_SocketWaitAsyncReading:set 29
L_SocketReuseAddr: set 30
L_MicrosecondsToTimeval:set 31
L_SetSockoptInt: set 32
L_DnsGetHostAddressByName:set 33
L_SocketSetTimeout: set 34
L_SocketCloseSocket: set 35
L_SocketHerrno: set 36

5
src/BSDSocket_Size.s Normal file
View File

@ -0,0 +1,5 @@
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; BSDSocket.s, library size on the 26-04-2024 08:23:46
;
; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Lib_Size equ 39

View File

@ -1,10 +1,13 @@
echo "***Assembling AMOSPro_BSDSocket.Lib"
assign AMOSPro_System: MiSTerHD:Development/AMOSPro/AMOS_Pro
Stuff:Development/AMOS-Professional-Official-mas/c/Library_Digest BSDSocket.s
Stuff:Development/AMOS-Professional-Official-mas/c/Genam FROM BSDSocket.s TO AMOSPro_BSDSocket.Lib
assign AMOSPro_System: SYS:Development/AMOS_Pro
assign AMOSPro_Sources: amos-pro-bsdsocket-extension:stuff/AMOS-Professional-Official
AMOSPro_Sources:c/Library_Digest BSDSocket.s
AMOSPro_Sources:c/Genam FROM BSDSocket.s TO AMOSPro_BSDSocket.Lib
;delete >NIL: BSDSocket_Labels.s
;delete >NIL: BSDSocket_Size.s
FAILAT 21
copy AMOSPro_System:APSystem/AMOSPro_BSDSocket.lib AMOSPro_System:APSystem/AMOSPro_BSDSocket.lib.bak
FAILAT 10
copy AMOSPro_BSDSocket.Lib AMOSPro_System:APSystem/
;use an amos file here that includes the plugin to quickly build a test program
;apcmp "aqua_test_plugin.amos" inclib

107
src/bsdsocket_lib.fd Normal file
View File

@ -0,0 +1,107 @@
##base _SocketBase
##public
##bias 30
socket(domain,type,protocol)(d0/d1/d2)
bind(sock,name,namelen)(d0/a0/d1)
listen(sock,backlog)(d0/d1)
accept(sock,addr,addrlen)(d0/a0/a1)
connect(sock,name,namelen)(d0/a0/d1)
sendto(sock,buf,len,flags,to,tolen)(d0/a0/d1/d2/a1/d3)
send(sock,buf,len,flags)(d0/a0/d1/d2)
recvfrom(sock,buf,len,flags,addr,addrlen)(d0/a0/d1/d2/a1/a2)
recv(sock,buf,len,flags)(d0/a0/d1/d2)
shutdown(sock,how)(d0/d1)
setsockopt(sock,level,optname,optval,optlen)(d0/d1/d2/a0/d3)
getsockopt(sock,level,optname,optval,optlen)(d0/d1/d2/a0/a1)
getsockname(sock,name,namelen)(d0/a0/a1)
getpeername(sock,name,namelen)(d0/a0/a1)
IoctlSocket(sock,req,argp)(d0/d1/a0)
CloseSocket(sock)(d0)
WaitSelect(nfds,read_fds,write_fds,except_fds,timeout,signals)(d0/a0/a1/a2/a3/d1)
SetSocketSignals(int_mask,io_mask,urgent_mask)(d0/d1/d2)
getdtablesize()()
ObtainSocket(id,domain,type,protocol)(d0/d1/d2/d3)
ReleaseSocket(sock,id)(d0/d1)
ReleaseCopyOfSocket(sock,id)(d0/d1)
Errno()()
SetErrnoPtr(errno_ptr,size)(a0/d0)
Inet_NtoA(ip)(d0)
inet_addr(cp)(a0)
Inet_LnaOf(in)(d0)
Inet_NetOf(in)(d0)
Inet_MakeAddr(net,host)(d0/d1)
inet_network(cp)(a0)
gethostbyname(name)(a0)
gethostbyaddr(addr,len,type)(a0/d0/d1)
getnetbyname(name)(a0)
getnetbyaddr(net,type)(d0/d1)
getservbyname(name,proto)(a0/a1)
getservbyport(port,proto)(d0/a0)
getprotobyname(name)(a0)
getprotobynumber(proto)(d0)
vsyslog(pri,msg,args)(d0/a0/a1)
Dup2Socket(old_socket,new_socket)(d0/d1)
sendmsg(sock,msg,flags)(d0/a0/d1)
recvmsg(sock,msg,flags)(d0/a0/d1)
gethostname(name,namelen)(a0/d0)
gethostid()()
SocketBaseTagList(tags)(a0)
GetSocketEvents(event_ptr)(a0)
##bias 366
bpf_open(channel)(d0)
bpf_close(channel)(d0)
bpf_read(channel,buffer,len)(d0/a0/d1)
bpf_write(channel,buffer,len)(d0/a0/d1)
bpf_set_notify_mask(channel,signal_mask)(d1/d0)
bpf_set_interrupt_mask(channel,signal_mask)(d0/d1)
bpf_ioctl(channel,command,buffer)(d0/d1/a0)
bpf_data_waiting(channel)(d0)
AddRouteTagList(tags)(a0)
DeleteRouteTagList(tags)(a0)
##bias 432
FreeRouteInfo(buf)(a0)
GetRouteInfo(address_family,flags)(d0/d1)
AddInterfaceTagList(interface_name,device_name,unit,tags)(a0/a1/d0/a2)
ConfigureInterfaceTagList(interface_name,tags)(a0/a1)
ReleaseInterfaceList(list)(a0)
ObtainInterfaceList()()
QueryInterfaceTagList(interface_name,tags)(a0/a1)
CreateAddrAllocMessageA(version,protocol,interface_name,result_ptr,tags)(d0/d1/a0/a1/a2)
DeleteAddrAllocMessage(aam)(a0)
BeginInterfaceConfig(message)(a0)
AbortInterfaceConfig(message)(a0)
AddNetMonitorHookTagList(type,hook,tags)(d0/a0/a1)
RemoveNetMonitorHook(hook)(a0)
GetNetworkStatistics(type,version,destination,size)(d0/d1/a0/d2)
AddDomainNameServer(address)(a0)
RemoveDomainNameServer(address)(a0)
ReleaseDomainNameServerList(list)(a0)
ObtainDomainNameServerList()()
setnetent(stay_open)(d0)
endnetent()()
getnetent()()
setprotoent(stay_open)(d0)
endprotoent()()
getprotoent()()
setservent(stay_open)(d0)
endservent()()
getservent()()
inet_aton(cp,addr)(a0/a1)
inet_ntop(af,src,dst,size)(d0/a0/a1/d1)
inet_pton(af,src,dst)(d0/a0/a1)
In_LocalAddr(address)(d0)
In_CanForward(address)(d0)
mbuf_copym(m,off,len)(a0/d0/d1)
mbuf_copyback(m,off,len,cp)(a0/d0/d1/a1)
mbuf_copydata(m,off,len,cp)(a0/d0/d1/a1)
mbuf_free(m)(a0)
mbuf_freem(m)(a0)
mbuf_get()()
mbuf_gethdr()()
mbuf_prepend(m,len)(a0/d0)
mbuf_cat(m,n)(a0/a1)
mbuf_adj(mp,req_len)(a0/d0)
mbuf_pullup(m,len)(a0/d0)
ProcessIsServer(pr)(a0)
ObtainServerSocket()()
##end

208
src/bsdsocket_lvo.i Normal file
View File

@ -0,0 +1,208 @@
IFND LIBRARIES_BSDSOCKET_LVO_I
LIBRARIES_BSDSOCKET_LVO_I SET 1
XDEF _LVOsocket
XDEF _LVObind
XDEF _LVOlisten
XDEF _LVOaccept
XDEF _LVOconnect
XDEF _LVOsendto
XDEF _LVOsend
XDEF _LVOrecvfrom
XDEF _LVOrecv
XDEF _LVOshutdown
XDEF _LVOsetsockopt
XDEF _LVOgetsockopt
XDEF _LVOgetsockname
XDEF _LVOgetpeername
XDEF _LVOIoctlSocket
XDEF _LVOCloseSocket
XDEF _LVOWaitSelect
XDEF _LVOSetSocketSignals
XDEF _LVOgetdtablesize
XDEF _LVOObtainSocket
XDEF _LVOReleaseSocket
XDEF _LVOReleaseCopyOfSocket
XDEF _LVOErrno
XDEF _LVOSetErrnoPtr
XDEF _LVOInet_NtoA
XDEF _LVOinet_addr
XDEF _LVOInet_LnaOf
XDEF _LVOInet_NetOf
XDEF _LVOInet_MakeAddr
XDEF _LVOinet_network
XDEF _LVOgethostbyname
XDEF _LVOgethostbyaddr
XDEF _LVOgetnetbyname
XDEF _LVOgetnetbyaddr
XDEF _LVOgetservbyname
XDEF _LVOgetservbyport
XDEF _LVOgetprotobyname
XDEF _LVOgetprotobynumber
XDEF _LVOvsyslog
XDEF _LVODup2Socket
XDEF _LVOsendmsg
XDEF _LVOrecvmsg
XDEF _LVOgethostname
XDEF _LVOgethostid
XDEF _LVOSocketBaseTagList
XDEF _LVOGetSocketEvents
XDEF _LVObpf_open
XDEF _LVObpf_close
XDEF _LVObpf_read
XDEF _LVObpf_write
XDEF _LVObpf_set_notify_mask
XDEF _LVObpf_set_interrupt_mask
XDEF _LVObpf_ioctl
XDEF _LVObpf_data_waiting
XDEF _LVOAddRouteTagList
XDEF _LVODeleteRouteTagList
XDEF _LVOFreeRouteInfo
XDEF _LVOGetRouteInfo
XDEF _LVOAddInterfaceTagList
XDEF _LVOConfigureInterfaceTagList
XDEF _LVOReleaseInterfaceList
XDEF _LVOObtainInterfaceList
XDEF _LVOQueryInterfaceTagList
XDEF _LVOCreateAddrAllocMessageA
XDEF _LVODeleteAddrAllocMessage
XDEF _LVOBeginInterfaceConfig
XDEF _LVOAbortInterfaceConfig
XDEF _LVOAddNetMonitorHookTagList
XDEF _LVORemoveNetMonitorHook
XDEF _LVOGetNetworkStatistics
XDEF _LVOAddDomainNameServer
XDEF _LVORemoveDomainNameServer
XDEF _LVOReleaseDomainNameServerList
XDEF _LVOObtainDomainNameServerList
XDEF _LVOsetnetent
XDEF _LVOendnetent
XDEF _LVOgetnetent
XDEF _LVOsetprotoent
XDEF _LVOendprotoent
XDEF _LVOgetprotoent
XDEF _LVOsetservent
XDEF _LVOendservent
XDEF _LVOgetservent
XDEF _LVOinet_aton
XDEF _LVOinet_ntop
XDEF _LVOinet_pton
XDEF _LVOIn_LocalAddr
XDEF _LVOIn_CanForward
XDEF _LVOmbuf_copym
XDEF _LVOmbuf_copyback
XDEF _LVOmbuf_copydata
XDEF _LVOmbuf_free
XDEF _LVOmbuf_freem
XDEF _LVOmbuf_get
XDEF _LVOmbuf_gethdr
XDEF _LVOmbuf_prepend
XDEF _LVOmbuf_cat
XDEF _LVOmbuf_adj
XDEF _LVOmbuf_pullup
XDEF _LVOProcessIsServer
XDEF _LVOObtainServerSocket
_LVOsocket EQU -30
_LVObind EQU -36
_LVOlisten EQU -42
_LVOaccept EQU -48
_LVOconnect EQU -54
_LVOsendto EQU -60
_LVOsend EQU -66
_LVOrecvfrom EQU -72
_LVOrecv EQU -78
_LVOshutdown EQU -84
_LVOsetsockopt EQU -90
_LVOgetsockopt EQU -96
_LVOgetsockname EQU -102
_LVOgetpeername EQU -108
_LVOIoctlSocket EQU -114
_LVOCloseSocket EQU -120
_LVOWaitSelect EQU -126
_LVOSetSocketSignals EQU -132
_LVOgetdtablesize EQU -138
_LVOObtainSocket EQU -144
_LVOReleaseSocket EQU -150
_LVOReleaseCopyOfSocket EQU -156
_LVOErrno EQU -162
_LVOSetErrnoPtr EQU -168
_LVOInet_NtoA EQU -174
_LVOinet_addr EQU -180
_LVOInet_LnaOf EQU -186
_LVOInet_NetOf EQU -192
_LVOInet_MakeAddr EQU -198
_LVOinet_network EQU -204
_LVOgethostbyname EQU -210
_LVOgethostbyaddr EQU -216
_LVOgetnetbyname EQU -222
_LVOgetnetbyaddr EQU -228
_LVOgetservbyname EQU -234
_LVOgetservbyport EQU -240
_LVOgetprotobyname EQU -246
_LVOgetprotobynumber EQU -252
_LVOvsyslog EQU -258
_LVODup2Socket EQU -264
_LVOsendmsg EQU -270
_LVOrecvmsg EQU -276
_LVOgethostname EQU -282
_LVOgethostid EQU -288
_LVOSocketBaseTagList EQU -294
_LVOGetSocketEvents EQU -300
_LVObpf_open EQU -366
_LVObpf_close EQU -372
_LVObpf_read EQU -378
_LVObpf_write EQU -384
_LVObpf_set_notify_mask EQU -390
_LVObpf_set_interrupt_mask EQU -396
_LVObpf_ioctl EQU -402
_LVObpf_data_waiting EQU -408
_LVOAddRouteTagList EQU -414
_LVODeleteRouteTagList EQU -420
_LVOFreeRouteInfo EQU -432
_LVOGetRouteInfo EQU -438
_LVOAddInterfaceTagList EQU -444
_LVOConfigureInterfaceTagList EQU -450
_LVOReleaseInterfaceList EQU -456
_LVOObtainInterfaceList EQU -462
_LVOQueryInterfaceTagList EQU -468
_LVOCreateAddrAllocMessageA EQU -474
_LVODeleteAddrAllocMessage EQU -480
_LVOBeginInterfaceConfig EQU -486
_LVOAbortInterfaceConfig EQU -492
_LVOAddNetMonitorHookTagList EQU -498
_LVORemoveNetMonitorHook EQU -504
_LVOGetNetworkStatistics EQU -510
_LVOAddDomainNameServer EQU -516
_LVORemoveDomainNameServer EQU -522
_LVOReleaseDomainNameServerList EQU -528
_LVOObtainDomainNameServerList EQU -534
_LVOsetnetent EQU -540
_LVOendnetent EQU -546
_LVOgetnetent EQU -552
_LVOsetprotoent EQU -558
_LVOendprotoent EQU -564
_LVOgetprotoent EQU -570
_LVOsetservent EQU -576
_LVOendservent EQU -582
_LVOgetservent EQU -588
_LVOinet_aton EQU -594
_LVOinet_ntop EQU -600
_LVOinet_pton EQU -606
_LVOIn_LocalAddr EQU -612
_LVOIn_CanForward EQU -618
_LVOmbuf_copym EQU -624
_LVOmbuf_copyback EQU -630
_LVOmbuf_copydata EQU -636
_LVOmbuf_free EQU -642
_LVOmbuf_freem EQU -648
_LVOmbuf_get EQU -654
_LVOmbuf_gethdr EQU -660
_LVOmbuf_prepend EQU -666
_LVOmbuf_cat EQU -672
_LVOmbuf_adj EQU -678
_LVOmbuf_pullup EQU -684
_LVOProcessIsServer EQU -690
_LVOObtainServerSocket EQU -696
ENDC

BIN
test/TestSuite.amos Normal file

Binary file not shown.