Use null-terminated IP address for socket addr lookup
This commit is contained in:
parent
fbc9dae690
commit
1645cf9ad4
|
@ -366,14 +366,18 @@ _ToSockaddr_PortOK:
|
||||||
MOVE.L sockaddr_ram-MB(A3),A0
|
MOVE.L sockaddr_ram-MB(A3),A0
|
||||||
ADD.L D3,A0 ; A0 contains our offset in ram
|
ADD.L D3,A0 ; A0 contains our offset in ram
|
||||||
|
|
||||||
MOVE.B #len_sockaddr_in,sockaddr_in_sin_len(A0)
|
MOVEM.L A1-A3/D3,-(SP)
|
||||||
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
|
; temporarily store a null-terminated copy of the ip string in A0
|
||||||
ADDQ #2,A0 ; string data starts 2 bytes in
|
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
|
; if the string contains "INADDR_ANY", we use that value instead
|
||||||
MOVE.L A0,A1
|
MOVE.L A0,A1
|
||||||
|
@ -397,8 +401,15 @@ _ToSockaddr_ParseIPAddress:
|
||||||
CALLLIB inet_addr
|
CALLLIB inet_addr
|
||||||
|
|
||||||
_ToSockaddr_DoneParsing:
|
_ToSockaddr_DoneParsing:
|
||||||
MOVEM.L (SP)+,A0-A3/D3
|
MOVEM.L (SP)+,A1-A3/D3
|
||||||
MOVE.L D0,sockaddr_in_sin_addr(A0)
|
|
||||||
|
; create struct sockaddr_in
|
||||||
|
MOVE.W #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
|
MOVE.L A0,D0
|
||||||
MOVEM.L (SP)+,A0/A3/D3
|
MOVEM.L (SP)+,A0/A3/D3
|
||||||
|
|
|
@ -16,8 +16,7 @@ SO_REUSEADDR EQU $4
|
||||||
MAX_SOCKETS EQU 64
|
MAX_SOCKETS EQU 64
|
||||||
|
|
||||||
len_sockaddr_in EQU 16
|
len_sockaddr_in EQU 16
|
||||||
sockaddr_in_sin_len EQU 0
|
sockaddr_in_sin_family EQU 0
|
||||||
sockaddr_in_sin_family EQU 1
|
|
||||||
sockaddr_in_sin_port EQU 2
|
sockaddr_in_sin_port EQU 2
|
||||||
sockaddr_in_sin_addr EQU 4
|
sockaddr_in_sin_addr EQU 4
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue