Mercurial > hg > CbC > CbC_gcc
diff gcc/ada/libgnat/g-socket.ads @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
line wrap: on
line diff
--- a/gcc/ada/libgnat/g-socket.ads Fri Oct 27 22:46:09 2017 +0900 +++ b/gcc/ada/libgnat/g-socket.ads Thu Oct 25 07:37:49 2018 +0900 @@ -6,7 +6,7 @@ -- -- -- S p e c -- -- -- --- Copyright (C) 2001-2017, AdaCore -- +-- Copyright (C) 2001-2018, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -489,7 +489,32 @@ No_Port : constant Port_Type; -- Uninitialized port number - type Inet_Addr_Type (Family : Family_Type := Family_Inet) is private; + type Inet_Addr_Comp_Type is mod 2 ** 8; + -- Octet for Internet address + + Inet_Addr_Bytes_Length : constant array (Family_Type) of Positive := + (Family_Inet => 4, Family_Inet6 => 16); + + type Inet_Addr_Bytes is array (Natural range <>) of Inet_Addr_Comp_Type; + + subtype Inet_Addr_V4_Type is + Inet_Addr_Bytes (1 .. Inet_Addr_Bytes_Length (Family_Inet)); + subtype Inet_Addr_V6_Type is + Inet_Addr_Bytes (1 .. Inet_Addr_Bytes_Length (Family_Inet6)); + + subtype Inet_Addr_VN_Type is Inet_Addr_Bytes; + -- For backwards compatibility + + type Inet_Addr_Type (Family : Family_Type := Family_Inet) is record + case Family is + when Family_Inet => + Sin_V4 : Inet_Addr_V4_Type := (others => 0); + + when Family_Inet6 => + Sin_V6 : Inet_Addr_V6_Type := (others => 0); + end case; + end record; + -- An Internet address depends on an address family (IPv4 contains 4 octets -- and IPv6 contains 16 octets). Any_Inet_Addr is a special value treated -- like a wildcard enabling all addresses. No_Inet_Addr provides a special @@ -506,6 +531,23 @@ All_Hosts_Group_Inet_Addr : constant Inet_Addr_Type; All_Routers_Group_Inet_Addr : constant Inet_Addr_Type; + -- Functions to handle masks and prefixes + + function Mask + (Family : Family_Type; + Length : Natural; + Host : Boolean := False) return Inet_Addr_Type; + -- Return an address mask of the given family with the given prefix length. + -- If Host is False, this is a network mask (i.e. network bits are 1, + -- and host bits are 0); if Host is True, this is a host mask (i.e. + -- network bits are 0, and host bits are 1). + + function "and" (Addr, Mask : Inet_Addr_Type) return Inet_Addr_Type; + function "or" (Net, Host : Inet_Addr_Type) return Inet_Addr_Type; + function "not" (Mask : Inet_Addr_Type) return Inet_Addr_Type; + -- Bit-wise operations on inet addresses (both operands must have the + -- same address family). + type Sock_Addr_Type (Family : Family_Type := Family_Inet) is record Addr : Inet_Addr_Type (Family); Port : Port_Type; @@ -1213,24 +1255,6 @@ -- undefined if Last = No_Socket. end record; - subtype Inet_Addr_Comp_Type is Natural range 0 .. 255; - -- Octet for Internet address - - type Inet_Addr_VN_Type is array (Natural range <>) of Inet_Addr_Comp_Type; - - subtype Inet_Addr_V4_Type is Inet_Addr_VN_Type (1 .. 4); - subtype Inet_Addr_V6_Type is Inet_Addr_VN_Type (1 .. 16); - - type Inet_Addr_Type (Family : Family_Type := Family_Inet) is record - case Family is - when Family_Inet => - Sin_V4 : Inet_Addr_V4_Type := (others => 0); - - when Family_Inet6 => - Sin_V6 : Inet_Addr_V6_Type := (others => 0); - end case; - end record; - Any_Port : constant Port_Type := 0; No_Port : constant Port_Type := 0;