6 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
8 C-STRUCT: struct-rtentry
10 { "struct-sockaddr" "rt_dst" }
11 { "struct-sockaddr" "rt_gateway" }
12 { "struct-sockaddr" "rt_genmask" }
13 { "ushort" "rt_flags" }
17 { "uchar" "rt_class" }
19 { "short" "rt_metric" }
22 { "ulong" "rt_window" }
23 { "ushort" "rt_irtt" } ;
25 : RTF_UP HEX: 0001 ; ! Route usable.
26 : RTF_GATEWAY HEX: 0002 ; ! Destination is a gateway.
28 : RTF_HOST HEX: 0004 ; ! Host entry (net otherwise).
29 : RTF_REINSTATE HEX: 0008 ; ! Reinstate route after timeout.
30 : RTF_DYNAMIC HEX: 0010 ; ! Created dyn. (by redirect).
31 : RTF_MODIFIED HEX: 0020 ; ! Modified dyn. (by redirect).
32 : RTF_MTU HEX: 0040 ; ! Specific MTU for this route.
33 : RTF_MSS RTF_MTU ; ! Compatibility.
34 : RTF_WINDOW HEX: 0080 ; ! Per route window clamping.
35 : RTF_IRTT HEX: 0100 ; ! Initial round trip time.
36 : RTF_REJECT HEX: 0200 ; ! Reject route.
37 : RTF_STATIC HEX: 0400 ; ! Manually injected route.
38 : RTF_XRESOLVE HEX: 0800 ; ! External resolver.
39 : RTF_NOFORWARD HEX: 1000 ; ! Forwarding inhibited.
40 : RTF_THROW HEX: 2000 ; ! Go to next class.
41 : RTF_NOPMTUDISC HEX: 4000 ; ! Do not send packets with DF.
43 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
45 USING: kernel alien.c-types io.sockets
46 unix unix.linux.sockios ;
48 : route ( dst gateway genmask flags -- )
50 "struct-rtentry" <c-object>
51 r> 0 <inet4> make-sockaddr over set-struct-rtentry-rt_dst
52 r> 0 <inet4> make-sockaddr over set-struct-rtentry-rt_gateway
53 r> 0 <inet4> make-sockaddr over set-struct-rtentry-rt_genmask
54 r> over set-struct-rtentry-rt_flags
55 AF_INET SOCK_DGRAM 0 socket SIOCADDRT rot ioctl drop ;