module Platform; end
module Platform::Socket
  @@@
  constants do |cg|
    cg.include "sys/types.h"
    cg.include "sys/socket.h"
    cg.include "netinet/in.h"
    cg.include "netinet/icmp6.h"
    cg.include "netdb.h"

    %w[
      SO_DEBUG
      SO_ACCEPTCONN
      SO_REUSEADDR
      SO_KEEPALIVE
      SO_DONTROUTE
      SO_BROADCAST
      SO_USELOOPBACK
      SO_LINGER
      SO_OOBINLINE
      SO_REUSEPORT
      SO_TIMESTAMP
      SO_ACCEPTFILTER
      SO_DONTTRUNC
      SO_WANTMORE
      SO_WANTOOBFLAG
      SO_SNDBUF
      SO_RCVBUF
      SO_SNDLOWAT
      SO_RCVLOWAT
      SO_SNDTIMEO
      SO_RCVTIMEO
      SO_ERROR
      SO_TYPE
      SO_NREAD
      SO_NKE
      SO_NOSIGPIPE
      SO_NOADDRERR
      SO_NWRITE
      SO_REUSESHAREUID
      SO_LABEL
      SO_PEERLABEL
      SO_ATTACH_FILTER
      SO_BINDTODEVICE
      SO_DETACH_FILTER
      SO_NO_CHECK
      SO_PASSCRED
      SO_PEERCRED
      SO_PEERNAME
      SO_PRIORITY
      SO_SECURITY_AUTHENTICATION
      SO_SECURITY_ENCRYPTION_NETWORK
      SO_SECURITY_ENCRYPTION_TRANSPORT
    ].each {|c| cg.const(c, "%#x", "(unsigned int)") { |v| v.hex} }
    %w[
      SOCK_STREAM
      SOCK_DGRAM
      SOCK_RAW
      SOCK_RDM
      SOCK_SEQPACKET
      SOCK_MAXADDRLEN
    ].each {|c| cg.const c }
    %w[
      AF_UNSPEC
      AF_LOCAL
      AF_UNIX
      AF_INET
      AF_IMPLINK
      AF_PUP
      AF_CHAOS
      AF_NS
      AF_ISO
      AF_OSI
      AF_ECMA
      AF_DATAKIT
      AF_CCITT
      AF_SNA
      AF_DECnet
      AF_DLI
      AF_LAT
      AF_HYLINK
      AF_APPLETALK
      AF_ROUTE
      AF_LINK
      pseudo_AF_XTP
      AF_COIP
      AF_CNT
      pseudo_AF_RTIP
      AF_IPX
      AF_SIP
      pseudo_AF_PIP
      AF_NDRV
      AF_ISDN
      AF_E164
      pseudo_AF_KEY
      AF_INET6
      AF_NATM
      AF_SYSTEM
      AF_NETBIOS
      AF_PPP
      AF_ATM
      pseudo_AF_HDRCMPLT
      AF_NETGRAPH
      AF_AX25
      AF_MAX
    ].each {|c| cg.const c }
    %w[
      PF_UNSPEC
      PF_LOCAL
      PF_UNIX
      PF_INET
      PF_IMPLINK
      PF_PUP
      PF_CHAOS
      PF_NS
      PF_ISO
      PF_OSI
      PF_ECMA
      PF_DATAKIT
      PF_CCITT
      PF_SNA
      PF_DECnet
      PF_DLI
      PF_LAT
      PF_HYLINK
      PF_APPLETALK
      PF_ROUTE
      PF_LINK
      PF_XTP
      PF_COIP
      PF_CNT
      PF_SIP
      PF_IPX
      PF_RTIP
      PF_PIP
      PF_NDRV
      PF_ISDN
      PF_KEY
      PF_INET6
      PF_NATM
      PF_SYSTEM
      PF_NETBIOS
      PF_PPP
      PF_ATM
      PF_NETGRAPH
      PF_MAX
    ].each {|c| cg.const c}
    %w[
        NI_MAXHOST
        NI_MAXSERV
        NI_NOFQDN
        NI_NUMERICHOST
        NI_NAMEREQD
        NI_NUMERICSERV
        NI_DGRAM
        NI_WITHSCOPEID
        NI_QTYPE_NOOP
        NI_QTYPE_SUPTYPES
        NI_QTYPE_FQDN
        NI_QTYPE_DNSNAME
        NI_QTYPE_NODEADDR
        NI_QTYPE_IPV4ADDR
        NI_SUPTYPE_FLAG_COMPRESS
        NI_FQDN_FLAG_VALIDTTL
        NI_SUPTYPE_FLAG_COMPRESS
        NI_FQDN_FLAG_VALIDTTL
        NI_NODEADDR_FLAG_LINKLOCAL
        NI_NODEADDR_FLAG_SITELOCAL
        NI_NODEADDR_FLAG_GLOBAL
        NI_NODEADDR_FLAG_ALL
        NI_NODEADDR_FLAG_TRUNCATE
        NI_NODEADDR_FLAG_ANYCAST
        NI_NODEADDR_FLAG_LINKLOCAL
        NI_NODEADDR_FLAG_SITELOCAL
        NI_NODEADDR_FLAG_GLOBAL
        NI_NODEADDR_FLAG_ALL
        NI_NODEADDR_FLAG_TRUNCATE
        NI_NODEADDR_FLAG_ANYCAST
        NI_NODEADDR_FLAG_TRUNCATE
        NI_NODEADDR_FLAG_ALL
        NI_NODEADDR_FLAG_COMPAT
        NI_NODEADDR_FLAG_LINKLOCAL
        NI_NODEADDR_FLAG_SITELOCAL
        NI_NODEADDR_FLAG_GLOBAL
        NI_NODEADDR_FLAG_ANYCAST
        NI_NODEADDR_FLAG_TRUNCATE
        NI_NODEADDR_FLAG_ALL
        NI_NODEADDR_FLAG_COMPAT
        NI_NODEADDR_FLAG_LINKLOCAL
        NI_NODEADDR_FLAG_SITELOCAL
        NI_NODEADDR_FLAG_GLOBAL
        NI_NODEADDR_FLAG_ANYCAST
    ].each {|c| cg.const c}
  end
  @@@
end
    
