Commit 3471c7dd authored by ROOL's avatar ROOL 🤖
Browse files

Fix to socklib error return handling

Detail:
  copyerror - the highest error is now ENEEDAUTH (81) but socklib was clamping everything above EREMOTE (71).
  mkveneers/InetSWIs - use centrally held Hdr for OS SWI definitions.
  socklib.h/LibraryDoc - remove internal function _makecall() which is no longer used.
Admin:
  Submission for TCP/IP bounty.

Version 5.65. Tagged as 'TCPIPLibs-5_65'
parent d8f28141
Acorn TCP/IP libraries version 5.64
Acorn TCP/IP libraries version 5.65
-----------------------------------
These libraries are an update to the libraries described in chapter 123 of the PRM
......@@ -764,16 +764,17 @@ int _copyerror(_kernel_oserror *e);
Description
-----------
_Copyerror is used by Socklib for all Socket_... SWI calls it makes. If a SWI
returns an error, then _copyerror is called. Copyerror takes the following
This function is used by Socklib for all Socket_... SWI calls it makes. If a
SWI returns an error, then _copyerror is called which takes the following
actions:
_Copyerror copies the supplied error block into the global error structure
_inet_error. It then sets errno from the SWI's returned error number, converting
standard Internet errors (ie those returned by the SWI in the range &20E00 -
&20E7F) to the values used in C by subtracting &20E00. If - after that - the value
of errno is still greater than EREMOTE, makecall then sets errno to ESRCH.
Finally, _copyerror returns a value of -1.
* copies the supplied error block into the global error structure _inet_error.
* sets errno from the SWI's returned error number, converting standard
Internet errors (ie those returned by the SWI in the range &20E00 -
&20E7F) to the values used in C by subtracting &20E00. If - after that - the
value of errno is still greater than ENEEDAUTH, then errno is changed to
ESRCH.
* finally the function returns a value of -1.
Exported by
-----------
......@@ -1414,12 +1415,6 @@ LISTEN
The backlog is no longer limited to 5 in Internet 5.
_MAKECALL
=========
Makecall is no longer used by Socklib, but is still exported for backwards
compatibility. See _COPYERROR.
NAMISIPADR
==========
New prototype: struct hostent *namisipadr(const char *name);
......
/* (5.64)
/* (5.65)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 5.64
#define Module_MajorVersion_CMHG 5.65
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 28 Apr 2018
#define Module_Date_CMHG 19 May 2018
#define Module_MajorVersion "5.64"
#define Module_Version 564
#define Module_MajorVersion "5.65"
#define Module_Version 565
#define Module_MinorVersion ""
#define Module_Date "28 Apr 2018"
#define Module_Date "19 May 2018"
#define Module_ApplicationDate "28-Apr-18"
#define Module_ApplicationDate "19-May-18"
#define Module_ComponentName "TCPIPLibs"
#define Module_ComponentPath "mixed/RiscOS/Sources/Lib/TCPIPLibs"
#define Module_FullVersion "5.64"
#define Module_HelpVersion "5.64 (28 Apr 2018)"
#define Module_LibraryVersionInfo "5:64"
#define Module_FullVersion "5.65"
#define Module_HelpVersion "5.65 (19 May 2018)"
#define Module_LibraryVersionInfo "5:65"
......@@ -30,7 +30,7 @@ ASFLAGS= -depend !Depend ${THROWBACK}
ASFLAGSZM= -depend !Depend ${THROWBACK} -predefine "module SETL {TRUE}"
OFILES4= accept.o bind.o connect.o copyerror.o getpeernam.o \
getsocknam.o getsockopt.o getstabsiz.o listen.o makecall.o \
getsocknam.o getsockopt.o getstabsiz.o listen.o \
recv.o recvfrom.o recvmsg.o select.o send.o sendmsg.o \
sendto.o setsockopt.o shutdown.o sockclose.o socket.o \
socketstat.o sockioctl.o sockread.o sockreadv.o sockwrite.o \
......@@ -39,7 +39,7 @@ OFILES4= accept.o bind.o connect.o copyerror.o getpeernam.o \
sockver.o _inet_err.o
ZFILES4= z.accept z.bind z.connect z.copyerror z.getpeernam \
z.getsocknam z.getsockopt z.getstabsiz z.listen z.makecall \
z.getsocknam z.getsockopt z.getstabsiz z.listen \
z.recv z.recvfrom z.recvmsg z.select z.send z.sendmsg \
z.sendto z.setsockopt z.shutdown z.sockclose z.socket \
z.socketstat z.sockioctl z.sockread z.sockreadv z.sockwrite \
......@@ -48,7 +48,7 @@ ZFILES4= z.accept z.bind z.connect z.copyerror z.getpeernam \
z.sockver z._inet_err
OFILES5= accept5.o bind.o connect.o copyerror.o getpeerna5.o \
getsockna5.o getsockopt.o getstabsiz.o listen.o makecall.o \
getsockna5.o getsockopt.o getstabsiz.o listen.o \
recv5.o recvfrom5.o recvmsg5.o select.o send5.o sendmsg5.o \
sendto.o setsockopt.o shutdown.o sockclose.o socket.o \
socketstat.o sockioctl.o sockread.o sockreadv.o sockwrite.o \
......@@ -57,7 +57,7 @@ OFILES5= accept5.o bind.o connect.o copyerror.o getpeerna5.o \
orecvfrom.o kvm_nlist.o sockver.o _inet_err.o
ZFILES5= z.accept5 z.bind z.connect z.copyerror z.getpeerna5 \
z.getsockna5 z.getsockopt z.getstabsiz z.listen z.makecall \
z.getsockna5 z.getsockopt z.getstabsiz z.listen \
z.recv5 z.recvfrom5 z.recvmsg5 z.select z.send5 z.sendmsg5 \
z.sendto z.setsockopt z.shutdown z.sockclose z.socket \
z.socketstat z.sockioctl z.sockread z.sockreadv z.sockwrite \
......
......@@ -125,6 +125,5 @@ extern int sendtosm(int s, const void *buf, size_t len,
*/
extern int _copyerror(_kernel_oserror *e);
extern char *_inet_err(void);
extern int _makecall(int swinum, _kernel_swi_regs *in, _kernel_swi_regs *out);
/* EOF socklib.h */
......@@ -12,7 +12,6 @@
; See the License for the specific language governing permissions and
; limitations under the License.
;
OS_EnterOS * &16
XSocket_Creat * &61200
XSocket_Bind * &61201
XSocket_Listen * &61202
......
......@@ -70,6 +70,9 @@ sub build_asm {
printf(OUT ";\n\n");
# Get the definitions for OS_EnterOS and the other SWIs
printf(OUT "\tGET\tHdr:ListOpts\n");
printf(OUT "\tGET\tHdr:Macros\n");
printf(OUT "\tGET\tHdr:System\n");
printf(OUT "\tGET\thdr.InetSWIs\n\n");
printf(OUT "\tAREA\tSockLib,CODE,READONLY\n\n");
......
......@@ -17,8 +17,8 @@
GBLL module
]
ESRCH * 3
EREMOTE * 71
ESRCH * 3
ENEEDAUTH * 81
AREA SockLib,CODE,READONLY
ROUT
......@@ -38,8 +38,8 @@ _copyerror
CMPS a3,#&280
BGE %F1
AND a2,a2,#&FF
; If UNIX-style error is > EREMOTE, change it to ESRCH
CMPS a2,#EREMOTE
; If UNIX-style error is > ENEEDAUTH, change it to ESRCH
CMPS a2,#ENEEDAUTH
MOVGT a2,#ESRCH
; Update errno
......
; Copyright 1997 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; -*-As-*-
;
; $Header$
; $Source$
;
; Copyright (c) 1995 Acorn Computers Ltd., Cambridge, UK
;
; makecall.s - based upon code generated by Norcroft RISC OS ARM C
; vsn 5.06 (Acorn Computers Ltd) [Jun 26 1995]
;
; :RCS Log discontinued:
;
; Revision 1.2 96/03/19 10:21:34 kbracey
; Merged the two variants into a single source file
; Nasty -zM relocation bug fixed.
;
; Revision 1.1 95/08/17 18:41:56 kwelton
; Initial revision
;
GET Hdr:ListOpts
GET Hdr:Macros
GET Hdr:System
GET Hdr:Machine.<Machine>
GET Hdr:APCS.<APCS>
ESRCH * 3
EREMOTE * 71
; If "module" is not predefined on the command line, declare it
; here (it defaults to {FALSE})
[ :LNOT::DEF:module
GBLL module
]
AREA |As$$code|, CODE, READONLY
[ :LNOT:module
IMPORT __rt_stkovf_split_small
]
IMPORT _kernel_swi
;
; **********************************************************************
;
; makecall - call the Internet module, and deal with the return value
;
; int _makecall(int swinum, _kernel_swi_regs *in, _kernel_swi_regs *out)
;
[ :LNOT:module
;
; this is "_makecall", for the benefit of stack backtracing
;
= "_makecall", 0, 0, 0 ; Be careful when changing length!
DCD &ff00000c
]
EXPORT _makecall
_makecall
[ module
MOV ip, sp
STMDB sp!, {v1-v3, fp, ip, lr, pc}
SUB fp, ip, #4
|
MOV ip, sp
STMDB sp!, {a1-a4}
STMDB sp!, {v1-v3, fp, ip, lr, pc}
SUB fp, ip, #20
;
; stack limit checking
;
CMPS sp, sl
BLLT __rt_stkovf_split_small
;
; by making the call to the Internet module
; from SVC mode, we can make sure that no callbacks go off between
; detecting an error and copying the error block into _inet_error.
;
SWI OS_EnterOS
]
;
; make the SWI call, result into v3, setting Z flag in the process
;
MOV v1, a3
BL _kernel_swi
MOVS v3, a1
LDR lr, adrerrno
[ module
LDR ip, [sl, #-536]
ADD lr, ip, lr
]
MOVEQ a1, #0
STREQ a1, [lr]
BEQ OKreturn
;
; SWI call failed - fill in errno, and copy error block into _inet_error
; first step is to read the error number, and decide whether it is a
; properly formatted inet error (inet errorblock should start at 0x20e00,
; but it currently starts at 0 because of all the applications out there
; that expect this to be the case).
;
LDR a1, [v3, #0]
BIC a2, a1, #&ff
SUB a4, a2, #&20c00
TEQ a4, #&200
BNE noerrblock
;
; using inet error block: offsets 0-7f should be converted to an errno
; style number, other errors should be left alone.
;
AND a2, a1, #&ff
CMP a2, #&80
ANDLT a1, a1, #&7f
noerrblock
CMPS a1, #EREMOTE
MOVGT a1, #ESRCH
STR a1, [lr] ; place error number into errno
;
; copy error block into _inet_error which is 256 bytes long
;
LDR v2, adr_inet_error
[ module
ADD v2, ip, v2
]
MOV ip, #16 ; 16*(4*4)=256
0 LDMIA v3!, {a2-a4,v1}
STMIA v2!, {a2-a4,v1}
SUBS ip, ip, #1
BNE %B0
[ :LNOT:module
;
; back to user mode before returning error to caller
;
[ {CONFIG}=26
TEQP pc, #0
|
MRS a1, CPSR
BIC a1, a1, #15
MSR CPSR_c, a1
]
]
MVN a1, #0 ; non-banked register: OK
[ {CONFIG}=26
LDMDB fp, {v1-v3, fp, sp, pc}^ ; return -1
|
LDMDB fp, {v1-v3, fp, sp, pc} ; return -1
]
;
; back to user mode before returning to caller
;
OKreturn
[ :LNOT:module
[ {CONFIG}=26
TEQP pc, #0
|
MRS a1, CPSR
BIC a1, a1, #15
MSR CPSR_c, a1
]
]
LDR a1, [v1, #0] ; non-banked registers: OK
[ {CONFIG}=26
LDMDB fp, {v1-v3, fp, sp, pc}^ ; return R0 from SWI
|
LDMDB fp, {v1-v3, fp, sp, pc} ; return R0 from SWI
]
adrerrno
IMPORT errno
DCD errno
adr_inet_error
IMPORT _inet_error
DCD _inet_error
END
; EOF makecall.s
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment