]> gitweb.factorcode.org Git - factor.git/commitdiff
Use SOCK_RAW for ICMP sockets on windows
authorDoug Coleman <doug.coleman@gmail.com>
Wed, 22 Sep 2010 01:03:48 +0000 (20:03 -0500)
committerDoug Coleman <doug.coleman@gmail.com>
Wed, 22 Sep 2010 01:03:48 +0000 (20:03 -0500)
basis/io/sockets/windows/windows.factor

index 3114b3aa8337e3a61baaa3a992e826b99dc58af8..473ad4b1770fb31c5fb122f90878b48e053879ed 100755 (executable)
@@ -1,9 +1,10 @@
 ! Copyright (C) 2007, 2009 Slava Pestov, Doug Coleman.\r
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: accessors alien alien.c-types alien.data classes.struct\r
-combinators destructors io.backend io.ports io.files.windows\r
-io.sockets io.sockets.private kernel libc math sequences system\r
-windows.handles windows.kernel32 windows.types windows.winsock ;\r
+combinators destructors io.backend io.files.windows io.ports\r
+io.sockets io.sockets.icmp io.sockets.private kernel libc math\r
+sequences system windows.handles windows.kernel32 windows.types\r
+windows.winsock ;\r
 FROM: namespaces => get ;\r
 IN: io.sockets.windows\r
 \r
@@ -79,8 +80,18 @@ M: object (server) ( addrspec -- handle )
         dup handle>> listen-backlog listen winsock-return-check\r
     ] with-destructors ;\r
 \r
+GENERIC: windows-socket-type ( obj -- n )\r
+\r
+M: inet4 windows-socket-type drop SOCK_DGRAM ;\r
+\r
+M: inet6 windows-socket-type drop SOCK_DGRAM ;\r
+\r
+M: icmp4 windows-socket-type drop SOCK_RAW ;\r
+\r
+M: icmp6 windows-socket-type drop SOCK_RAW ;\r
+    \r
 M: windows (datagram) ( addrspec -- handle )\r
-    [ SOCK_DGRAM server-socket ] with-destructors ;\r
+    [ dup windows-socket-type server-socket ] with-destructors ;\r
 \r
 \r
 : malloc-int ( n -- alien )\r