Difference between revisions of "OSWORD &C0"
(Added Resolver details.) |
m (typo.) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:OSWORD]] | [[Category:OSWORD]] | ||
− | OSWORD &C0 (192) - IP Networking and DNS Resolver | + | ==OSWORD &C0 (192) - IP Networking and DNS Resolver== |
==Specification== | ==Specification== | ||
− | + | On entry: | |
− | + | XY?0 = send block length | |
− | + | XY?1 = receive block length | |
− | + | XY?2 = command, 0-63=Socket, 64-127=Resolver, 128-253=Reserved, 254=Eureka | |
− | + | XY?3 = 0, returns 0 or error value | |
− | + | XY!4 = socket | |
− | + | XY!8 =>data | |
− | + | XY!12 = data length | |
− | + | XY!16 = flags | |
− | + | XY!20 =>IP address | |
− | + | XY!24 = IP address length, if zero, X%!20 = IPv4 address | |
− | + | ||
− | + | On exit: | |
− | + | XY?2 = 0 if call supported, unchanged if call unsupported or no handler present | |
− | + | XY?3 = 0 or returned error | |
− | + | XY!4 onwards: any returned data | |
− | + | Memory pointed to by XY!8 on entry may be modified | |
===Socket Commands=== | ===Socket Commands=== | ||
Line 48: | Line 48: | ||
&16 Socket_Readv X%!4=sock, X%!8=iov, X%!12=iovcnt | &16 Socket_Readv X%!4=sock, X%!8=iov, X%!12=iovcnt | ||
&17 Socket_Writev X%!4=sock, X%!8=iov, X%!12=iovcnt | &17 Socket_Writev X%!4=sock, X%!8=iov, X%!12=iovcnt | ||
+ | |||
+ | ===Return values=== | ||
+ | OSWORD &C0 returns: | ||
+ | |||
+ | #define socket_EBADF 0x9u /*Bad descriptor*/ | ||
+ | #define socket_EAGAIN 0xBu /*No more ports*/ | ||
+ | #define socket_EFAULT 0xEu /*Bad address*/ | ||
+ | #define socket_EINVAL 0x16u /*Invalid argument*/ | ||
+ | #define socket_EWOULDBLOCK 0x23u /*Operation would block*/ | ||
+ | #define socket_EINPROGRESS 0x24u /*Operation now in progress*/ | ||
+ | #define socket_EALREADY 0x25u /*Operation already in progress*/ | ||
+ | #define socket_ENOTSOCK 0x26u /*Socket operation on non-socket*/ | ||
+ | #define socket_EDESTADDRREQ 0x27u /*Destination address required*/ | ||
+ | #define socket_EMSGSIZE 0x28u /*Message too long*/ | ||
+ | #define socket_EPROTOTYPE 0x29u /*Protocol wrong type for socket*/ | ||
+ | #define socket_ENOPROTOOPT 0x2Au /*Protocol not available*/ | ||
+ | #define socket_EPROTONOSUPPORT 0x2Bu /*Protocol not supported*/ | ||
+ | #define socket_ESOCKTNOSUPPORT 0x2Cu /*Socket type not supported*/ | ||
+ | #define socket_EOPNOTSUPP 0x2Du /*Operation not supported on socket*/ | ||
+ | #define socket_EPFNOSUPPORT 0x2Eu /*Protocol family not supported*/ | ||
+ | #define socket_EAFNOSUPPORT 0x2Fu /*Address family not supported by protocol family*/ | ||
+ | #define socket_EADDRINUSE 0x30u /*Address already in use*/ | ||
+ | #define socket_EADDRNOTAVAIL 0x31u /*Can't assign requested address*/ | ||
+ | #define socket_ENETDOWN 0x32u /*Network is down*/ | ||
+ | #define socket_ENETUNREACH 0x33u /*Network is unreachable*/ | ||
+ | #define socket_ENETRESET 0x34u /*Network dropped connection on reset*/ | ||
+ | #define socket_ECONNABORTED 0x35u /*Software caused connection abort*/ | ||
+ | #define socket_ECONNRESET 0x36u /*Connection reset by peer*/ | ||
+ | #define socket_ENOBUFS 0x37u /*No buffer space available*/ | ||
+ | #define socket_EISCONN 0x38u /*Socket is already connected*/ | ||
+ | #define socket_ENOTCONN 0x39u /*Socket is not connected*/ | ||
+ | #define socket_ESHUTDOWN 0x3Au /*Can't send after socket shutdown*/ | ||
+ | #define socket_ETOOMANYREFS 0x3Bu /*Too many references: can't splice*/ | ||
+ | #define socket_ETIMEDOUT 0x3Cu /*Connection timed out*/ | ||
+ | #define socket_ECONNREFUSED 0x3Du /*Connection refused*/ | ||
+ | #define socket_EHOSTDOWN 0x40u /*Host is down*/ | ||
+ | #define socket_EHOSTUNREACH 0x41u /*No route to host*/ | ||
+ | |||
+ | <!-- | ||
+ | &D0 No network address | ||
+ | &88 Out of range | ||
+ | &92 Aborted | ||
+ | &BF Can't extend | ||
+ | &13 String too long ***BAD ERR*** | ||
+ | &FE Bad command | ||
+ | &D6 Not found | ||
+ | &CB Bad option | ||
+ | &DE Channel | ||
+ | &FC Bad address | ||
+ | &C6 Media full | ||
+ | &11 Escape | ||
+ | &A4 Host not known | ||
+ | &A5 No reply | ||
+ | &CC Bad name | ||
+ | &93 No! | ||
+ | &CD Bad drive | ||
+ | &C1 Read only | ||
+ | &B9 Bad password | ||
+ | &BC User not known | ||
+ | &C8 Media changed | ||
+ | &AE Not logged on | ||
+ | &BD Access violation | ||
+ | &C0 Too many open | ||
+ | &A1 Server error | ||
+ | &CE Bad dir | ||
+ | &C4 Exists | ||
+ | &96 Can't delete CSD | ||
+ | &C3 Locked | ||
+ | &C2 Open | ||
+ | &B4 Dir not empty | ||
+ | &A8 Is a dir | ||
+ | &B7 Outside file | ||
+ | &CF Bad attribute | ||
+ | &A6 Resolver busy | ||
+ | &1E Bad call ***BAD ERR*** | ||
+ | &AF Capabilities don't match | ||
+ | --> | ||
===Coding=== | ===Coding=== | ||
Line 68: | Line 145: | ||
==Specification== | ==Specification== | ||
− | + | On entry: | |
− | + | XY?0 = send block length | |
− | + | XY?1 = receive block length | |
− | + | XY?2 = command, 0-63=Socket, 64-127=Resolver, 128-255=Reserved | |
− | + | XY?3 = 0, returns 0 or error value | |
− | + | XY!4 => host name | |
− | + | ||
− | + | On exit: | |
− | + | XY?2 = 0 if call supported, unchanged if call unsupported or no handler present | |
− | + | XY?3 = 0 or returned error | |
− | + | XY!4 onwards: any returned data | |
===Resolver Commands=== | ===Resolver Commands=== | ||
Line 94: | Line 171: | ||
REM > BLib.DNS | REM > BLib.DNS | ||
+ | DEFFNDNS_GetHost(A$):A%=65 | ||
DEFFNDNS_GetHostByName(A$):A%=64 | DEFFNDNS_GetHostByName(A$):A%=64 | ||
− | |||
!X%=&1808:X%?2=A%:X%!4=name%:$name%=A$:A%=192:CALL&FFF1:=X%+4 AND X%?3=0 | !X%=&1808:X%?2=A%:X%!4=name%:$name%=A$:A%=192:CALL&FFF1:=X%+4 AND X%?3=0 | ||
Line 106: | Line 183: | ||
* http://mdfs.net/Docs/Comp/BBC/Network | * http://mdfs.net/Docs/Comp/BBC/Network | ||
* http://mdfs.net/Archive/BBCMicro/2009/08/03/014013.htm | * http://mdfs.net/Archive/BBCMicro/2009/08/03/014013.htm | ||
+ | |||
+ | |||
+ | ==OSWORD &C0 (192) - Eureka memory control== | ||
+ | |||
+ | ==Specification== | ||
+ | On entry: | ||
+ | XY?0 = &0C - send block length | ||
+ | XY?1 = &0D - receive block length | ||
+ | XY?2 = &FE - Eureka command | ||
+ | XY?3 = &FF - Eureka command | ||
+ | XY?4 = &0B - command block length | ||
+ | XY?5 = command : 1 = Read from 64K RAM | ||
+ | : 2 = Write to 64K RAM | ||
+ | : 3 = Copy within 64K RAM | ||
+ | XY+6..7 = Source start address | ||
+ | XY+8..9 = Source end address | ||
+ | XY+10..11 = Destination address | ||
+ | |||
[[User:Jgharston|Jgharston]] 01:36, 19 December 2010 (UTC) | [[User:Jgharston|Jgharston]] 01:36, 19 December 2010 (UTC) |
Latest revision as of 05:49, 12 April 2020
Contents
OSWORD &C0 (192) - IP Networking and DNS Resolver
Specification
On entry: XY?0 = send block length XY?1 = receive block length XY?2 = command, 0-63=Socket, 64-127=Resolver, 128-253=Reserved, 254=Eureka XY?3 = 0, returns 0 or error value XY!4 = socket XY!8 =>data XY!12 = data length XY!16 = flags XY!20 =>IP address XY!24 = IP address length, if zero, X%!20 = IPv4 address On exit: XY?2 = 0 if call supported, unchanged if call unsupported or no handler present XY?3 = 0 or returned error XY!4 onwards: any returned data Memory pointed to by XY!8 on entry may be modified
Socket Commands
Commands passed in XY?2 are those in the RISC OS Socket_ SWIs, that is:
&00 Socket_Creat X%!4=domain, X%!8=type, X%!12=protocol &01 Socket_Bind X%!4=sock, X%!8=name, X%!12=namelen &02 Socket_Listen X%!4=sock, X%!8=backlog &03 Socket_Accept X%!4=sock, X%!8=addr, X%!12=len &04 Socket_Connect X%!4=sock, X%!8=name, X%!12=namelen &05 Socket_Recv X%!4=sock, X%!8=buf, X%!12=len, X%!16=flags &06 Socket_Recvfrom X%!4=sock, X%!8=buf, X%!12=len, X%!16=flags, X%!16=from, X%!20=fromlen &07 Socket_Recvmsg X%!4=sock, X%!8=msg, X%!12=flags &08 Socket_Send X%!4=sock, X%!8=msg, X%!12=len, X%!16=flags &09 Socket_Sendto X%!4=sock, X%!8=msg, X%!12=len, X%!16=flags, X%!16=to, X%!20=tolen &0A Socket_Sendmsg X%!4=sock, X%!8=msg, X%!12=flags &0B Socket_Shutdown X%!4=sock, X%!8=how &0C Socket_Setsockopt X%!4=sock, X%!8=level, X%!12=optname, X%!16=optval, X%!16=optlen &0D Socket_Getsockopt X%!4=sock, X%!8=level, X%!12=optname, X%!16=optval, X%!16=optlen &0E Socket_Getpeername X%!4=sock, X%!8=name, X%!12=namelen &0F Socket_Getsockname X%!4=sock, X%!8=name, X%!12=namelen &10 Socket_Close X%!4=sock &11 Socket_Select X%!4=nfds, X%!8=readfds, X%!12=writefds, X%!16=exceptfds, X%!16=timeout &12 Socket_Ioctl X%!4=sock, X%!8=request, X%!12=argp &13 Socket_Read X%!4=sock, X%!8=buf, X%!12=num &14 Socket_Write X%!4=sock, X%!8=buf, X%!12=num &15 Socket_Stat X%!4=sock, X%!8=buf &16 Socket_Readv X%!4=sock, X%!8=iov, X%!12=iovcnt &17 Socket_Writev X%!4=sock, X%!8=iov, X%!12=iovcnt
Return values
OSWORD &C0 returns:
- define socket_EBADF 0x9u /*Bad descriptor*/
- define socket_EAGAIN 0xBu /*No more ports*/
- define socket_EFAULT 0xEu /*Bad address*/
- define socket_EINVAL 0x16u /*Invalid argument*/
- define socket_EWOULDBLOCK 0x23u /*Operation would block*/
- define socket_EINPROGRESS 0x24u /*Operation now in progress*/
- define socket_EALREADY 0x25u /*Operation already in progress*/
- define socket_ENOTSOCK 0x26u /*Socket operation on non-socket*/
- define socket_EDESTADDRREQ 0x27u /*Destination address required*/
- define socket_EMSGSIZE 0x28u /*Message too long*/
- define socket_EPROTOTYPE 0x29u /*Protocol wrong type for socket*/
- define socket_ENOPROTOOPT 0x2Au /*Protocol not available*/
- define socket_EPROTONOSUPPORT 0x2Bu /*Protocol not supported*/
- define socket_ESOCKTNOSUPPORT 0x2Cu /*Socket type not supported*/
- define socket_EOPNOTSUPP 0x2Du /*Operation not supported on socket*/
- define socket_EPFNOSUPPORT 0x2Eu /*Protocol family not supported*/
- define socket_EAFNOSUPPORT 0x2Fu /*Address family not supported by protocol family*/
- define socket_EADDRINUSE 0x30u /*Address already in use*/
- define socket_EADDRNOTAVAIL 0x31u /*Can't assign requested address*/
- define socket_ENETDOWN 0x32u /*Network is down*/
- define socket_ENETUNREACH 0x33u /*Network is unreachable*/
- define socket_ENETRESET 0x34u /*Network dropped connection on reset*/
- define socket_ECONNABORTED 0x35u /*Software caused connection abort*/
- define socket_ECONNRESET 0x36u /*Connection reset by peer*/
- define socket_ENOBUFS 0x37u /*No buffer space available*/
- define socket_EISCONN 0x38u /*Socket is already connected*/
- define socket_ENOTCONN 0x39u /*Socket is not connected*/
- define socket_ESHUTDOWN 0x3Au /*Can't send after socket shutdown*/
- define socket_ETOOMANYREFS 0x3Bu /*Too many references: can't splice*/
- define socket_ETIMEDOUT 0x3Cu /*Connection timed out*/
- define socket_ECONNREFUSED 0x3Du /*Connection refused*/
- define socket_EHOSTDOWN 0x40u /*Host is down*/
- define socket_EHOSTUNREACH 0x41u /*No route to host*/
Coding
The following is a BASIC Sockets library:
REM > BLib.Socket DEFFNSocket_Open( X%!4, X%!8, X%!12):A%=0 DEFFNSocket_Bind( X%!4, X%!8, X%!12):A%=1 DEFFNSocket_Listen( X%!4, X%!8) :A%=2 DEFFNSocket_Accept( X%!4, X%!8, X%!12):A%=3 DEFFNSocket_Connect(X%!4, X%!8, X%!12):A%=4 DEFFNSocket_Read( X%!4, X%!8, X%!12):A%=5 DEFFNSocket_Write( X%!4, X%!8, X%!12):A%=8 DEFFNSocket_Close( X%!4) :A%=16 !X%=&814:X%?2=A%:A%=192:CALL &FFF1:IFX%?3:=-X%?3 ELSE =X%!4
The calls return a negative number if the call fails, or a positive number (or zero) if the call succeeds, being the returned socket number or byte count, etc.
Specification
On entry: XY?0 = send block length XY?1 = receive block length XY?2 = command, 0-63=Socket, 64-127=Resolver, 128-255=Reserved XY?3 = 0, returns 0 or error value XY!4 => host name On exit: XY?2 = 0 if call supported, unchanged if call unsupported or no handler present XY?3 = 0 or returned error XY!4 onwards: any returned data
Resolver Commands
Commands passed in XY?2 are those in the RISC OS Resolver_ SWIs plus &40, that is:
&40 Resolver_GetHostByName On entry: X%!4=>name, On exit: X%!4=>name, X%!8=>aliases, X%!12=>type, X%!16=length, X%!20=>IP addresses &41 Resolver_GetHost On entry: X%!4=>name, On exit: X%!4=>name, X%!8=>aliases, X%!12=>type, X%!16=length, X%!20=>IP addresses
Coding
The following is a BASIC Resolver library:
REM > BLib.DNS DEFFNDNS_GetHost(A$):A%=65 DEFFNDNS_GetHostByName(A$):A%=64 !X%=&1808:X%?2=A%:X%!4=name%:$name%=A$:A%=192:CALL&FFF1:=X%+4 AND X%?3=0
The calls return zero if the call fails, or the address of an inet address structure.
See Also
- http://mdfs.net/Docs/Comp/BBC/Network/Sockets
- http://mdfs.net/Docs/Comp/BBC/Oswords
- http://mdfs.net/Docs/Comp/BBC/Network
- http://mdfs.net/Archive/BBCMicro/2009/08/03/014013.htm
OSWORD &C0 (192) - Eureka memory control
Specification
On entry: XY?0 = &0C - send block length XY?1 = &0D - receive block length XY?2 = &FE - Eureka command XY?3 = &FF - Eureka command XY?4 = &0B - command block length XY?5 = command : 1 = Read from 64K RAM : 2 = Write to 64K RAM : 3 = Copy within 64K RAM XY+6..7 = Source start address XY+8..9 = Source end address XY+10..11 = Destination address
Jgharston 01:36, 19 December 2010 (UTC)