Module: unix-sockets Synopsis: Baseline Unix 98 address resolution structs, types, and constants functions as defined in Linux Copyright: Original Code is Copyright (c) 1995-2004 Functional Objects, Inc. All rights reserved. License: Functional Objects Library Public License Version 1.0 Dual-license: GNU Lesser General Public License Warranty: Distributed WITHOUT WARRANTY OF ANY KIND // Source: http://www.opengroup.org/onlinepubs/007908799/xnsix.html define constant = ; define constant = ; define constant = ; define constant = ; // TODO: Abide by the letter of the law? /* define C-struct slot s-addr-value :: ; pointer-type-name: ; end C-struct; */ define constant = ; define constant = ; define method s-addr-value (addr :: ) => (addr-val :: ) pointer-value(addr) end method; define method s-addr-value-setter (addr-val :: , addr :: ) => (addr-val :: ) error("The type struct in_addr has been mapped to Dylan as an immutable " "machine word value and its field cannot be set."); end method; define C-pointer-type => ; define C-struct slot sin-family-value :: ; slot sin-port-value :: ; slot sin-addr-value :: ; // NOTE: A filler required on linux to make all address structs the same // size as struct sockaddr. array slot sin-data :: , length: 8; pointer-type-name: ; end C-struct; ignore(sin-data, sin-data-setter); // link layer socket structure define C-struct slot sll-family :: ; slot sll-protocol :: ; slot sll-ifindex :: ; slot sll-hatype :: ; slot sll-pkttype :: ; slot sll-halen :: ; array slot sll-addr :: , length: 8; pointer-type-name: ; end C-struct; // IP_PROTO* define constant $INADDR-ANY = as(, 0); define constant $INADDR-BROADCAST = as(, #xffffffff); define constant $INADDR-NONE = as(, #xffffffff); define constant = ; define constant = ; define inline-only C-function ntohl parameter netlong :: ; result val :: ; c-name: "ntohl"; end C-function; define inline-only C-function ntohs parameter netshort :: ; result val :: ; c-name: "ntohs"; end C-function; define inline-only C-function htonl parameter hostlong :: ; result val :: ; c-name: "htonl"; end C-function; define inline-only C-function htons parameter hostshort :: ; result val :: ; c-name: "htons"; end C-function; /// From netdb.h define C-pointer-type => ; define C-struct slot h-name-value :: ; slot h-aliases-value :: ; slot h-addrtype-value :: ; slot h-length-value :: ; slot h-addr-list-value :: ; pointer-type-name: ; end C-struct; define C-struct slot n-name-value :: ; slot n-aliases-value :: ; slot n-addrtype-value :: ; slot n-net-value :: ; pointer-type-name: ; end C-struct; define C-struct slot p-name-value :: ; slot p-aliases-value :: ; slot p-proto-value :: ; pointer-type-name: ; end C-struct; define C-struct slot s-name-value :: ; slot s-aliases-value :: ; slot s-port-value :: ; slot s-proto-value :: ; pointer-type-name: ; end C-struct; /// From unistd.h define C-function gethostname parameter name :: ; parameter namelen :: ; result val :: ; c-name: "gethostname"; end C-function; /// from net/if.h define constant $IFF-UP = #x1; define constant $IFF-BROADCAST = #x2; define constant $IFF-DEBUG = #x4; define constant $IFF-LOOPBACK = #x8; define constant $IFF-POINTOPOINT = #x10; define constant $IFF-NOTRAILERS = #x20; define constant $IFF-RUNNING = #x40; define constant $IFF-NOARP = #x80; define constant $IFF-PROMISC = #x100; define constant $IFF-ALLMULTI = #x200; define constant $IFF-MASTER = #x400; define constant $IFF-SLAVE = #x800; define constant $IFF-MULTICAST = #x1000; define constant $IFF-PORTSEL = #x2000; define constant $IFF-AUTOMEDIA = #x4000; define C-union slot ifru-flags :: ; slot ifru-ivalue :: ; end C-union; define constant $IF-NAMESIZE = 16; define C-struct array slot %ifr-name :: , length: $IF-NAMESIZE; slot ifr-ifru :: ; pointer-type-name: ; end C-struct; define method ifr-name (ifreq :: ) => (name :: ); error("not implemented"); end method ifr-name; define method ifr-name-setter (name :: , ifreq :: ) => () for(c in name, i from 0 below $IF-NAMESIZE - 1) %ifr-name(ifreq, i) := as(, c); finally %ifr-name(ifreq, i) := 0; end for; end method ifr-name-setter; define method ifr-ifindex (ifreq :: ) => (interface-index :: ) ifreq.ifr-ifru.ifru-ivalue end method ifr-ifindex; define method ifr-ifindex-setter (value :: , ifreq :: ) => (interface-index :: ) ifreq.ifr-ifru.ifru-ivalue := value end method ifr-ifindex-setter; define method ifr-flags (ifreq :: ) => (interface-index :: ) ifreq.ifr-ifru.ifru-flags end method ifr-flags; define method ifr-flags-setter (value :: , ifreq :: ) => (interface-index :: ) ifreq.ifr-ifru.ifru-flags := value end method ifr-flags-setter; define constant $SIOCGIFINDEX = #x8933; define constant $SIOCGIFFLAGS = #x8913; define constant $SIOCSIFFLAGS = #x8914; // eof