From 986cee886612ce06db688a758590ed55637183f7 Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Sat, 14 Jul 2012 07:48:41 +0000 Subject: [PATCH] Renamed icmp.asm to ping.asm and added parameter support git-svn-id: svn://kolibrios.org@2872 a494cfbc-eb01-0410-851d-a64ba20cac60 --- data/new-stack/Makefile | 2 +- .../branches/net/applications/icmp/icmp.inc | 77 +++++++++++ .../applications/icmp/{icmp.asm => ping.asm} | 124 ++++-------------- kernel/branches/net/sys.conf | 6 - 4 files changed, 107 insertions(+), 102 deletions(-) create mode 100644 kernel/branches/net/applications/icmp/icmp.inc rename kernel/branches/net/applications/icmp/{icmp.asm => ping.asm} (50%) diff --git a/data/new-stack/Makefile b/data/new-stack/Makefile index 87ad1d14e4..ce5a64d9dc 100644 --- a/data/new-stack/Makefile +++ b/data/new-stack/Makefile @@ -127,7 +127,7 @@ FASM_PROGRAMS:=\ media/midamp:MEDIA/MIDAMP:$(PROGS)/media/midamp/trunk/midamp.asm \ media/startmus:MEDIA/STARTMUS:$(PROGS)/media/startmus/trunk/STARTMUS.ASM \ network/arpcfg:NETWORK/ARPCFG:$(NETPROGS)/arpcfg/arpcfg.asm \ - network/icmp:NETWORK/ICMP:$(NETPROGS)/icmp/icmp.asm \ + network/ping:NETWORK/PING:$(NETPROGS)/icmp/ping.asm \ network/netcfg:NETWORK/NETCFG:$(NETPROGS)/netcfg/netcfg.asm \ network/netstat:NETWORK/NETSTAT:$(NETPROGS)/netstat/netstat.asm \ network/nslookup:NETWORK/NSLOOKUP:$(NETPROGS)/nslookup/nslookup.asm \ diff --git a/kernel/branches/net/applications/icmp/icmp.inc b/kernel/branches/net/applications/icmp/icmp.inc new file mode 100644 index 0000000000..bcafff37e9 --- /dev/null +++ b/kernel/branches/net/applications/icmp/icmp.inc @@ -0,0 +1,77 @@ +; ICMP types & codes + +ICMP_ECHOREPLY equ 0 ; echo reply message + +ICMP_UNREACH equ 3 +ICMP_UNREACH_NET equ 0 ; bad net +ICMP_UNREACH_HOST equ 1 ; bad host +ICMP_UNREACH_PROTOCOL equ 2 ; bad protocol +ICMP_UNREACH_PORT equ 3 ; bad port +ICMP_UNREACH_NEEDFRAG equ 4 ; IP_DF caused drop +ICMP_UNREACH_SRCFAIL equ 5 ; src route failed +ICMP_UNREACH_NET_UNKNOWN equ 6 ; unknown net +ICMP_UNREACH_HOST_UNKNOWN equ 7 ; unknown host +ICMP_UNREACH_ISOLATED equ 8 ; src host isolated +ICMP_UNREACH_NET_PROHIB equ 9 ; prohibited access +ICMP_UNREACH_HOST_PROHIB equ 10 ; ditto +ICMP_UNREACH_TOSNET equ 11 ; bad tos for net +ICMP_UNREACH_TOSHOST equ 12 ; bad tos for host +ICMP_UNREACH_FILTER_PROHIB equ 13 ; admin prohib +ICMP_UNREACH_HOST_PRECEDENCE equ 14 ; host prec vio. +ICMP_UNREACH_PRECEDENCE_CUTOFF equ 15 ; prec cutoff + +ICMP_SOURCEQUENCH equ 4 ; Packet lost, slow down + +ICMP_REDIRECT equ 5 ; shorter route, codes: +ICMP_REDIRECT_NET equ 0 ; for network +ICMP_REDIRECT_HOST equ 1 ; for host +ICMP_REDIRECT_TOSNET equ 2 ; for tos and net +ICMP_REDIRECT_TOSHOST equ 3 ; for tos and host + +ICMP_ALTHOSTADDR equ 6 ; alternate host address +ICMP_ECHO equ 8 ; echo service +ICMP_ROUTERADVERT equ 9 ; router advertisement +ICMP_ROUTERADVERT_NORMAL equ 0 ; normal advertisement +ICMP_ROUTERADVERT_NOROUTE_COMMON equ 16 ; selective routing + +ICMP_ROUTERSOLICIT equ 10 ; router solicitation +ICMP_TIMXCEED equ 11 ; time exceeded, code: +ICMP_TIMXCEED_INTRANS equ 0 ; ttl==0 in transit +ICMP_TIMXCEED_REASS equ 1 ; ttl==0 in reass + +ICMP_PARAMPROB equ 12 ; ip header bad +ICMP_PARAMPROB_ERRATPTR equ 0 ; error at param ptr +ICMP_PARAMPROB_OPTABSENT equ 1 ; req. opt. absent +ICMP_PARAMPROB_LENGTH equ 2 ; bad length + +ICMP_TSTAMP equ 13 ; timestamp request +ICMP_TSTAMPREPLY equ 14 ; timestamp reply +ICMP_IREQ equ 15 ; information request +ICMP_IREQREPLY equ 16 ; information reply +ICMP_MASKREQ equ 17 ; address mask request +ICMP_MASKREPLY equ 18 ; address mask reply +ICMP_TRACEROUTE equ 30 ; traceroute +ICMP_DATACONVERR equ 31 ; data conversion error +ICMP_MOBILE_REDIRECT equ 32 ; mobile host redirect +ICMP_IPV6_WHEREAREYOU equ 33 ; IPv6 where-are-you +ICMP_IPV6_IAMHERE equ 34 ; IPv6 i-am-here +ICMP_MOBILE_REGREQUEST equ 35 ; mobile registration req +ICMP_MOBILE_REGREPLY equ 36 ; mobile registreation reply +ICMP_SKIP equ 39 ; SKIP + +ICMP_PHOTURIS equ 40 ; Photuris +ICMP_PHOTURIS_UNKNOWN_INDEX equ 1 ; unknown sec index +ICMP_PHOTURIS_AUTH_FAILED equ 2 ; auth failed +ICMP_PHOTURIS_DECRYPT_FAILED equ 3 ; decrypt failed + + + +virtual at 0 + ICMP_Packet: + .Type db ? + .Code db ? + .Checksum dw ? + .Identifier dw ? + .SequenceNumber dw ? + .Data: +end virtual \ No newline at end of file diff --git a/kernel/branches/net/applications/icmp/icmp.asm b/kernel/branches/net/applications/icmp/ping.asm similarity index 50% rename from kernel/branches/net/applications/icmp/icmp.asm rename to kernel/branches/net/applications/icmp/ping.asm index 00ce68b952..e5e26e5f16 100644 --- a/kernel/branches/net/applications/icmp/icmp.asm +++ b/kernel/branches/net/applications/icmp/ping.asm @@ -1,16 +1,30 @@ +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; ;; +;; Copyright (C) KolibriOS team 2010-2012. All rights reserved. ;; +;; Distributed under terms of the GNU General Public License ;; +;; ;; +;; ping.asm - ICMP echo client for KolibriOS ;; +;; ;; +;; Written by hidnplayr@kolibrios.org ;; +;; ;; +;; GNU GENERAL PUBLIC LICENSE ;; +;; Version 2, June 1991 ;; +;; ;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + format binary as "" use32 org 0x0 -; standard header + db 'MENUET01' ; signature dd 1 ; header version dd start ; entry point dd I_END ; initialized size dd mem ; required memory dd mem ; stack pointer - dd 0 ; parameters + dd s ; parameters dd 0 ; path @@ -20,91 +34,11 @@ include '../macros.inc' purge mov,add,sub include '../proc32.inc' include '../dll.inc' - include '../network.inc' +include 'icmp.inc' -; ICMP types & codes - -ICMP_ECHOREPLY equ 0 ; echo reply message - -ICMP_UNREACH equ 3 -ICMP_UNREACH_NET equ 0 ; bad net -ICMP_UNREACH_HOST equ 1 ; bad host -ICMP_UNREACH_PROTOCOL equ 2 ; bad protocol -ICMP_UNREACH_PORT equ 3 ; bad port -ICMP_UNREACH_NEEDFRAG equ 4 ; IP_DF caused drop -ICMP_UNREACH_SRCFAIL equ 5 ; src route failed -ICMP_UNREACH_NET_UNKNOWN equ 6 ; unknown net -ICMP_UNREACH_HOST_UNKNOWN equ 7 ; unknown host -ICMP_UNREACH_ISOLATED equ 8 ; src host isolated -ICMP_UNREACH_NET_PROHIB equ 9 ; prohibited access -ICMP_UNREACH_HOST_PROHIB equ 10 ; ditto -ICMP_UNREACH_TOSNET equ 11 ; bad tos for net -ICMP_UNREACH_TOSHOST equ 12 ; bad tos for host -ICMP_UNREACH_FILTER_PROHIB equ 13 ; admin prohib -ICMP_UNREACH_HOST_PRECEDENCE equ 14 ; host prec vio. -ICMP_UNREACH_PRECEDENCE_CUTOFF equ 15 ; prec cutoff - -ICMP_SOURCEQUENCH equ 4 ; Packet lost, slow down - -ICMP_REDIRECT equ 5 ; shorter route, codes: -ICMP_REDIRECT_NET equ 0 ; for network -ICMP_REDIRECT_HOST equ 1 ; for host -ICMP_REDIRECT_TOSNET equ 2 ; for tos and net -ICMP_REDIRECT_TOSHOST equ 3 ; for tos and host - -ICMP_ALTHOSTADDR equ 6 ; alternate host address -ICMP_ECHO equ 8 ; echo service -ICMP_ROUTERADVERT equ 9 ; router advertisement -ICMP_ROUTERADVERT_NORMAL equ 0 ; normal advertisement -ICMP_ROUTERADVERT_NOROUTE_COMMON equ 16 ; selective routing - -ICMP_ROUTERSOLICIT equ 10 ; router solicitation -ICMP_TIMXCEED equ 11 ; time exceeded, code: -ICMP_TIMXCEED_INTRANS equ 0 ; ttl==0 in transit -ICMP_TIMXCEED_REASS equ 1 ; ttl==0 in reass - -ICMP_PARAMPROB equ 12 ; ip header bad -ICMP_PARAMPROB_ERRATPTR equ 0 ; error at param ptr -ICMP_PARAMPROB_OPTABSENT equ 1 ; req. opt. absent -ICMP_PARAMPROB_LENGTH equ 2 ; bad length - -ICMP_TSTAMP equ 13 ; timestamp request -ICMP_TSTAMPREPLY equ 14 ; timestamp reply -ICMP_IREQ equ 15 ; information request -ICMP_IREQREPLY equ 16 ; information reply -ICMP_MASKREQ equ 17 ; address mask request -ICMP_MASKREPLY equ 18 ; address mask reply -ICMP_TRACEROUTE equ 30 ; traceroute -ICMP_DATACONVERR equ 31 ; data conversion error -ICMP_MOBILE_REDIRECT equ 32 ; mobile host redirect -ICMP_IPV6_WHEREAREYOU equ 33 ; IPv6 where-are-you -ICMP_IPV6_IAMHERE equ 34 ; IPv6 i-am-here -ICMP_MOBILE_REGREQUEST equ 35 ; mobile registration req -ICMP_MOBILE_REGREPLY equ 36 ; mobile registreation reply -ICMP_SKIP equ 39 ; SKIP - -ICMP_PHOTURIS equ 40 ; Photuris -ICMP_PHOTURIS_UNKNOWN_INDEX equ 1 ; unknown sec index -ICMP_PHOTURIS_AUTH_FAILED equ 2 ; auth failed -ICMP_PHOTURIS_DECRYPT_FAILED equ 3 ; decrypt failed - - - -virtual at 0 - ICMP_Packet: - .Type db ? - .Code db ? - .Checksum dw ? - .Identifier dw ? - .SequenceNumber dw ? - .Data: -end virtual - - -; entry point start: ; load libraries stdcall dll.Load, @IMPORT @@ -120,8 +54,8 @@ start: push 80 call [con_init] ; main loop - push str1 - call [con_write_asciiz] + cmp byte[s], 0 + jne resolve main: ; write prompt push str2 @@ -144,12 +78,14 @@ main: jnz @b mov byte [esi-2], al pop esi + +resolve: ; resolve name push esp ; reserve stack place push esp ; fourth parameter push 0 ; third parameter push 0 ; second parameter - push esi ; first parameter + push s ; first parameter call [getaddrinfo] pop esi ; test for error @@ -258,17 +194,16 @@ fail2: ; data -title db 'ICMP - test application',0 -str1 db 'ICMP test application v0.1',10,' for KolibriOS # 1540 or later. ',10,10,0 +title db 'ICMP - echo client',0 str2 db '> ',0 -str3 db 'Ping to: ',0 +str3 db 'Ping to ',0 str4 db 10,0 -str5 db 'Name resolution failed.',10,10,0 -str6 db 'Could not open socket',10,10,0 +str5 db 'Name resolution failed.',10,0 +str6 db 'Could not open socket',10,0 str7 db ' time= %u0ms',10,0 str8 db ' timeout!',10,0 str9 db ' miscompare at offset %u',10,0 -str10 db 10,10,'Press any key to exit',0 +str10 db 10,'Press any key to exit',0 sockaddr1: dw AF_INET4 @@ -316,7 +251,6 @@ I_END: buffer_ptr rb BUFFERSIZE -s rb 256 -align 4 -rb 4096 ; stack +s rb 1024 + rb 4096 ; stack mem: diff --git a/kernel/branches/net/sys.conf b/kernel/branches/net/sys.conf index 64a0dc295d..302c927ce2 100644 --- a/kernel/branches/net/sys.conf +++ b/kernel/branches/net/sys.conf @@ -2,12 +2,6 @@ /rd/1=/sys /rd/1/dll=/sys/lib -[net] -active=1 -addr=192.168.1.2 -mask=255.255.255.0 -gate=192.168.1.1 - [gui] mouse_speed=1 mouse_delay=0x00A