]> gitweb.factorcode.org Git - factor.git/blob - extra/unix/linux/if/if.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / extra / unix / linux / if / if.factor
1
2 USING: alien.syntax ;
3
4 IN: unix.linux.if
5
6 : IFNAMSIZ    16 ;
7 : IF_NAMESIZE 16 ;
8 : IFHWADDRLEN 6 ;
9
10 ! Standard interface flags (netdevice->flags)
11
12 : IFF_UP          HEX: 1 ;              ! interface is up
13 : IFF_BROADCAST   HEX: 2 ;              ! broadcast address valid
14 : IFF_DEBUG       HEX: 4 ;              ! turn on debugging
15 : IFF_LOOPBACK    HEX: 8 ;              ! is a loopback net
16 : IFF_POINTOPOINT HEX: 10 ;             ! interface is has p-p link
17 : IFF_NOTRAILERS  HEX: 20 ;             ! avoid use of trailers
18 : IFF_RUNNING     HEX: 40 ;             ! interface running and carrier ok
19 : IFF_NOARP       HEX: 80 ;             ! no ARP protocol
20 : IFF_PROMISC     HEX: 100 ;            ! receive all packets
21 : IFF_ALLMULTI    HEX: 200 ;            ! receive all multicast packets
22
23 : IFF_MASTER      HEX: 400 ;            ! master of a load balancer
24 : IFF_SLAVE       HEX: 800 ;            ! slave of a load balancer
25
26 : IFF_MULTICAST   HEX: 1000 ;           ! Supports multicast
27
28 ! #define IFF_VOLATILE
29 ! (IFF_LOOPBACK|IFF_POINTOPOINT|IFF_BROADCAST|IFF_MASTER|IFF_SLAVE|IFF_RUNNING)
30
31 : IFF_PORTSEL     HEX: 2000 ;           ! can set media type
32 : IFF_AUTOMEDIA   HEX: 4000 ;           ! auto media select active
33 : IFF_DYNAMIC     HEX: 8000 ;           ! dialup device with changing addresses
34
35 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
36
37 C-STRUCT: struct-ifmap
38   { "ulong" "mem-start" }
39   { "ulong" "mem-end" }
40   { "ushort" "base-addr" }
41   { "uchar" "irq" }
42   { "uchar" "dma" }
43   { "uchar" "port" } ;
44
45 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
46
47 ! Hmm... the generic sockaddr type isn't defined anywhere.
48 ! Put it here for now.
49
50 TYPEDEF: ushort sa_family_t
51
52 C-STRUCT: struct-sockaddr
53   { "sa_family_t" "sa_family" }
54   { { "char" 14 } "sa_data" } ;
55
56 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
57
58 ! C-UNION: union-ifr-ifrn { "char" IFNAMSIZ } ;
59
60 C-UNION: union-ifr-ifrn { "char" 16 } ;
61
62 C-UNION: union-ifr-ifru
63  "struct-sockaddr"
64 !   "sockaddr"
65   "short"
66   "int"
67   "struct-ifmap"
68 !   { "char" IFNAMSIZ }
69   { "char" 16 }
70   "caddr_t" ;
71
72 C-STRUCT: struct-ifreq
73   { "union-ifr-ifrn" "ifr-ifrn" }
74   { "union-ifr-ifru" "ifr-ifru" } ;
75
76 : ifr-name      ( struct-ifreq -- value ) struct-ifreq-ifr-ifrn ;
77
78 : ifr-hwaddr    ( struct-ifreq -- value ) struct-ifreq-ifr-ifru ;
79 : ifr-addr      ( struct-ifreq -- value ) struct-ifreq-ifr-ifru ;
80 : ifr-dstaddr   ( struct-ifreq -- value ) struct-ifreq-ifr-ifru ;
81 : ifr-broadaddr ( struct-ifreq -- value ) struct-ifreq-ifr-ifru ;
82 : ifr-netmask   ( struct-ifreq -- value ) struct-ifreq-ifr-ifru ;
83 : ifr-flags     ( struct-ifreq -- value ) struct-ifreq-ifr-ifru ;
84
85 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
86
87 C-UNION: union-ifc-ifcu "caddr_t" "struct-ifreq*" ;
88
89 C-STRUCT: struct-ifconf
90   { "int" "ifc-len" }
91   { "union-ifc-ifcu" "ifc-ifcu" } ;
92
93 : ifc-len ( struct-ifconf -- value ) struct-ifconf-ifc-len ;
94
95 : ifc-buf ( struct-ifconf -- value ) struct-ifconf-ifc-ifcu ;
96 : ifc-req ( struct-ifconf -- value ) struct-ifconf-ifc-ifcu ;
97
98 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!