Cosmetical changes in network code, updated TCP timer code.

git-svn-id: svn://kolibrios.org@6011 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr
2015-12-27 15:37:31 +00:00
parent 116d2c8d6a
commit c81c3fbd4f
18 changed files with 1061 additions and 1086 deletions

View File

@@ -20,70 +20,69 @@ $Revision$
; ICMP types & codes
ICMP_ECHOREPLY = 0 ; echo reply message
ICMP_ECHOREPLY = 0 ; echo reply message
ICMP_UNREACH = 3
ICMP_UNREACH_NET = 0 ; bad net
ICMP_UNREACH_HOST = 1 ; bad host
ICMP_UNREACH_PROTOCOL = 2 ; bad protocol
ICMP_UNREACH_PORT = 3 ; bad port
ICMP_UNREACH_NEEDFRAG = 4 ; IP_DF caused drop
ICMP_UNREACH_SRCFAIL = 5 ; src route failed
ICMP_UNREACH_NET_UNKNOWN = 6 ; unknown net
ICMP_UNREACH_HOST_UNKNOWN = 7 ; unknown host
ICMP_UNREACH_ISOLATED = 8 ; src host isolated
ICMP_UNREACH_NET_PROHIB = 9 ; prohibited access
ICMP_UNREACH_HOST_PROHIB = 10 ; ditto
ICMP_UNREACH_TOSNET = 11 ; bad tos for net
ICMP_UNREACH_TOSHOST = 12 ; bad tos for host
ICMP_UNREACH_FILTER_PROHIB = 13 ; admin prohib
ICMP_UNREACH_HOST_PRECEDENCE = 14 ; host prec vio.
ICMP_UNREACH_PRECEDENCE_CUTOFF = 15 ; prec cutoff
ICMP_UNREACH_NET = 0 ; bad net
ICMP_UNREACH_HOST = 1 ; bad host
ICMP_UNREACH_PROTOCOL = 2 ; bad protocol
ICMP_UNREACH_PORT = 3 ; bad port
ICMP_UNREACH_NEEDFRAG = 4 ; IP_DF caused drop
ICMP_UNREACH_SRCFAIL = 5 ; src route failed
ICMP_UNREACH_NET_UNKNOWN = 6 ; unknown net
ICMP_UNREACH_HOST_UNKNOWN = 7 ; unknown host
ICMP_UNREACH_ISOLATED = 8 ; src host isolated
ICMP_UNREACH_NET_PROHIB = 9 ; prohibited access
ICMP_UNREACH_HOST_PROHIB = 10 ; ditto
ICMP_UNREACH_TOSNET = 11 ; bad tos for net
ICMP_UNREACH_TOSHOST = 12 ; bad tos for host
ICMP_UNREACH_FILTER_PROHIB = 13 ; admin prohib
ICMP_UNREACH_HOST_PRECEDENCE = 14 ; host prec vio.
ICMP_UNREACH_PRECEDENCE_CUTOFF = 15 ; prec cutoff
ICMP_SOURCEQUENCH = 4 ; Packet lost, slow down
ICMP_SOURCEQUENCH = 4 ; Packet lost, slow down
ICMP_REDIRECT = 5 ; shorter route, codes:
ICMP_REDIRECT_NET = 0 ; for network
ICMP_REDIRECT_HOST = 1 ; for host
ICMP_REDIRECT_TOSNET = 2 ; for tos and net
ICMP_REDIRECT_TOSHOST = 3 ; for tos and host
ICMP_REDIRECT = 5 ; shorter route, codes:
ICMP_REDIRECT_NET = 0 ; for network
ICMP_REDIRECT_HOST = 1 ; for host
ICMP_REDIRECT_TOSNET = 2 ; for tos and net
ICMP_REDIRECT_TOSHOST = 3 ; for tos and host
ICMP_ALTHOSTADDR = 6 ; alternate host address
ICMP_ECHO = 8 ; echo service
ICMP_ROUTERADVERT = 9 ; router advertisement
ICMP_ROUTERADVERT_NORMAL = 0 ; normal advertisement
ICMP_ROUTERADVERT_NOROUTE_COMMON= 16 ; selective routing
ICMP_ALTHOSTADDR = 6 ; alternate host address
ICMP_ECHO = 8 ; echo service
ICMP_ROUTERADVERT = 9 ; router advertisement
ICMP_ROUTERADVERT_NORMAL = 0 ; normal advertisement
ICMP_ROUTERADVERT_NOROUTE_COMMON= 16 ; selective routing
ICMP_ROUTERSOLICIT = 10 ; router solicitation
ICMP_TIMXCEED = 11 ; time exceeded, code:
ICMP_TIMXCEED_INTRANS = 0 ; ttl==0 in transit
ICMP_TIMXCEED_REASS = 1 ; ttl==0 in reass
ICMP_ROUTERSOLICIT = 10 ; router solicitation
ICMP_TIMXCEED = 11 ; time exceeded, code:
ICMP_TIMXCEED_INTRANS = 0 ; ttl==0 in transit
ICMP_TIMXCEED_REASS = 1 ; ttl==0 in reass
ICMP_PARAMPROB = 12 ; ip header bad
ICMP_PARAMPROB_ERRATPTR = 0 ; error at param ptr
ICMP_PARAMPROB_OPTABSENT = 1 ; req. opt. absent
ICMP_PARAMPROB_LENGTH = 2 ; bad length
ICMP_PARAMPROB = 12 ; ip header bad
ICMP_PARAMPROB_ERRATPTR = 0 ; error at param ptr
ICMP_PARAMPROB_OPTABSENT = 1 ; req. opt. absent
ICMP_PARAMPROB_LENGTH = 2 ; bad length
ICMP_TSTAMP = 13 ; timestamp request
ICMP_TSTAMPREPLY = 14 ; timestamp reply
ICMP_IREQ = 15 ; information request
ICMP_IREQREPLY = 16 ; information reply
ICMP_MASKREQ = 17 ; address mask request
ICMP_MASKREPLY = 18 ; address mask reply
ICMP_TRACEROUTE = 30 ; traceroute
ICMP_DATACONVERR = 31 ; data conversion error
ICMP_MOBILE_REDIRECT = 32 ; mobile host redirect
ICMP_IPV6_WHEREAREYOU = 33 ; IPv6 where-are-you
ICMP_IPV6_IAMHERE = 34 ; IPv6 i-am-here
ICMP_MOBILE_REGREQUEST = 35 ; mobile registration req
ICMP_MOBILE_REGREPLY = 36 ; mobile registreation reply
ICMP_SKIP = 39 ; SKIP
ICMP_PHOTURIS = 40 ; Photuris
ICMP_PHOTURIS_UNKNOWN_INDEX = 1 ; unknown sec index
ICMP_PHOTURIS_AUTH_FAILED = 2 ; auth failed
ICMP_PHOTURIS_DECRYPT_FAILED = 3 ; decrypt failed
ICMP_TSTAMP = 13 ; timestamp request
ICMP_TSTAMPREPLY = 14 ; timestamp reply
ICMP_IREQ = 15 ; information request
ICMP_IREQREPLY = 16 ; information reply
ICMP_MASKREQ = 17 ; address mask request
ICMP_MASKREPLY = 18 ; address mask reply
ICMP_TRACEROUTE = 30 ; traceroute
ICMP_DATACONVERR = 31 ; data conversion error
ICMP_MOBILE_REDIRECT = 32 ; mobile host redirect
ICMP_IPV6_WHEREAREYOU = 33 ; IPv6 where-are-you
ICMP_IPV6_IAMHERE = 34 ; IPv6 i-am-here
ICMP_MOBILE_REGREQUEST = 35 ; mobile registration req
ICMP_MOBILE_REGREPLY = 36 ; mobile registreation reply
ICMP_SKIP = 39 ; SKIP
ICMP_PHOTURIS = 40 ; Photuris
ICMP_PHOTURIS_UNKNOWN_INDEX = 1 ; unknown sec index
ICMP_PHOTURIS_AUTH_FAILED = 2 ; auth failed
ICMP_PHOTURIS_DECRYPT_FAILED = 3 ; decrypt failed
struct ICMP_header
@@ -107,13 +106,13 @@ endg
;-----------------------------------------------------------------
;
; ICMP_init
;
;-----------------------------------------------------------------
;-----------------------------------------------------------------;
; ;
; ICMP_init ;
; ;
;-----------------------------------------------------------------;
macro ICMP_init {
macro icmp_init {
xor eax, eax
mov edi, ICMP_PACKETS_TX
@@ -123,25 +122,23 @@ macro ICMP_init {
}
;-----------------------------------------------------------------
;
; ICMP_input:
;
; This procedure will send reply's to ICMP echo's
; and insert packets into sockets when needed
;
; IN: Pointer to buffer in [esp]
; ebx = pointer to device struct
; ecx = ICMP Packet size
; edx = ptr to IPv4 header
; esi = ptr to ICMP Packet data
; edi = interface number*4
;
; OUT: /
;
;-----------------------------------------------------------------
;-----------------------------------------------------------------;
; ;
; icmp_input: Send a reply's to an ICMP echo or insert packets ;
; into socket. ;
; ;
; IN: [esp] = ptr to buffer ;
; ebx = ptr to device struct ;
; ecx = ICMP Packet size ;
; edx = ptr to IPv4 header ;
; esi = ptr to ICMP Packet data ;
; edi = interface number*4 ;
; ;
; OUT: / ;
; ;
;-----------------------------------------------------------------;
align 4
ICMP_input:
icmp_input:
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input\n"
@@ -204,7 +201,7 @@ ICMP_input:
call mutex_lock
popa
jmp SOCKET_input
jmp socket_input
@@ -274,7 +271,7 @@ ICMP_input:
test eax, eax
jnz @f
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP transmit failed\n"
call NET_ptr_to_num4
call net_ptr_to_num4
inc [ICMP_PACKETS_TX + edi]
@@:
ret
@@ -293,26 +290,26 @@ ICMP_input:
.dump:
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: dumping\n"
call NET_BUFF_free
call net_buff_free
ret
if 0
;-----------------------------------------------------------------
;
; ICMP_output
;
; IN: eax = dest ip
; bh = type
; bl = code
; ecx = data length
; edx = source ip
; esi = data offset
; edi = identifier shl 16 + sequence number
;
;-----------------------------------------------------------------
;-----------------------------------------------------------------;
; ;
; icmp_output ;
; ;
; IN: eax = dest ip ;
; bh = type ;
; bl = code ;
; ecx = data length ;
; edx = source ip ;
; esi = data offset ;
; edi = identifier shl 16 + sequence number ;
; ;
;-----------------------------------------------------------------;
align 4
ICMP_output:
icmp_output:
DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet\n"
@@ -364,17 +361,17 @@ end if
;-----------------------------------------------------------------
;
; ICMP_output_raw
;
; IN: eax = socket ptr
; ecx = data length
; edx = data pointer
;
;-----------------------------------------------------------------
;-----------------------------------------------------------------;
; ;
; icmp_output_raw ;
; ;
; IN: eax = socket ptr ;
; ecx = data length ;
; edx = data pointer ;
; ;
;-----------------------------------------------------------------;
align 4
ICMP_output_raw:
icmp_output_raw:
DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet for socket %x, data ptr=%x\n", eax, edx
@@ -384,7 +381,7 @@ ICMP_output_raw:
mov edi, [eax + IP_SOCKET.RemoteIP]
mov al, [eax + IP_SOCKET.ttl]
mov ah, IP_PROTO_ICMP
call IPv4_output
call ipv4_output
jz .fail
pop esi
@@ -407,7 +404,7 @@ ICMP_output_raw:
call [ebx + NET_DEVICE.transmit]
test eax, eax
jnz @f
call NET_ptr_to_num4
call net_ptr_to_num4
inc [ICMP_PACKETS_TX + edi]
@@:
ret
@@ -422,21 +419,19 @@ ICMP_output_raw:
;-----------------------------------------------------------------
;
; ICMP_API
;
; This function is called by system function 75
;
; IN: subfunction number in bl
; device number in bh
; ecx, edx, .. depends on subfunction
;
; OUT:
;
;-----------------------------------------------------------------
;-----------------------------------------------------------------;
; ;
; icmp_api: Part of system function 76. ;
; ;
; IN: bl = subfunction number ;
; bh = device number ;
; ecx, edx, .. depends on subfunction ;
; ;
; OUT: depends on subfunction ;
; ;
;-----------------------------------------------------------------;
align 4
ICMP_api:
icmp_api:
movzx eax, bh
shl eax, 2