1 ! Copyright (C) 2010 John Benediktsson
2 ! See https://factorcode.org/license.txt for BSD license
4 USING: accessors arrays combinators io.sockets
5 io.sockets.private kernel sequences system
11 { [ os windows? ] [ "windows.winsock" ] }
12 { [ os unix? ] [ "unix.ffi" ] }
17 MEMO: IPPROTO_ICMP4 ( -- protocol )
18 "icmp" getprotobyname proto>> ;
20 MEMO: IPPROTO_ICMP6 ( -- protocol )
21 "ipv6-icmp" getprotobyname proto>> ;
23 GENERIC: with-icmp ( addrspec -- addrspec )
32 M: ipv4 with-icmp host>> <icmp4> ;
34 M: icmp4 protocol drop IPPROTO_ICMP4 ;
36 M: icmp4 port>> drop 0 ;
38 M: icmp4 parse-sockaddr call-next-method with-icmp ;
40 M: icmp4 resolve-host 1array ;
45 : <icmp6> ( host -- icmp6 ) 0 icmp6 boa ;
47 M: ipv6 with-icmp host>> <icmp6> ;
49 M: icmp6 protocol drop IPPROTO_ICMP6 ;
51 M: icmp6 port>> drop 0 ;
53 M: icmp6 parse-sockaddr call-next-method with-icmp ;
55 M: icmp6 resolve-host 1array ;
58 TUPLE: icmp < hostname ;
62 M: icmp resolve-host call-next-method [ with-icmp ] map ;