1 ! Copyright (C) 2010 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
4 USING: accessors arrays combinators generic kernel io.sockets
5 io.sockets.private memoize sequences system vocabs.parser ;
10 { [ os windows? ] [ "windows.winsock" ] }
11 { [ os unix? ] [ "unix.ffi" ] }
16 MEMO: IPPROTO_ICMP4 ( -- protocol )
17 "icmp" getprotobyname proto>> ;
19 MEMO: IPPROTO_ICMP6 ( -- protocol )
20 "ipv6-icmp" getprotobyname proto>> ;
22 GENERIC: with-icmp ( addrspec -- addrspec )
31 M: ipv4 with-icmp host>> <icmp4> ;
33 M: icmp4 protocol drop IPPROTO_ICMP4 ;
35 M: icmp4 port>> drop 0 ;
37 M: icmp4 parse-sockaddr call-next-method with-icmp ;
39 M: icmp4 resolve-host 1array ;
44 : <icmp6> ( host -- icmp6 ) 0 icmp6 boa ;
46 M: ipv6 with-icmp host>> <icmp6> ;
48 M: icmp6 protocol drop IPPROTO_ICMP6 ;
50 M: icmp6 port>> drop 0 ;
52 M: icmp6 parse-sockaddr call-next-method with-icmp ;
54 M: icmp6 resolve-host 1array ;
57 TUPLE: icmp < hostname ;
61 M: icmp resolve-host call-next-method [ with-icmp ] map ;