-- --
-- S p e c --
-- --
--- Copyright (C) 2008, AdaCore --
+-- Copyright (C) 2008-2009, 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- --
Failure : constant C.int := -1;
type time_t is
- range -2 ** (8 * Constants.SIZEOF_tv_sec - 1)
- .. 2 ** (8 * Constants.SIZEOF_tv_sec - 1) - 1;
- for time_t'Size use 8 * Constants.SIZEOF_tv_sec;
+ range -2 ** (8 * SOSC.SIZEOF_tv_sec - 1)
+ .. 2 ** (8 * SOSC.SIZEOF_tv_sec - 1) - 1;
+ for time_t'Size use 8 * SOSC.SIZEOF_tv_sec;
pragma Convention (C, time_t);
type suseconds_t is
- range -2 ** (8 * Constants.SIZEOF_tv_usec - 1)
- .. 2 ** (8 * Constants.SIZEOF_tv_usec - 1) - 1;
- for suseconds_t'Size use 8 * Constants.SIZEOF_tv_usec;
+ range -2 ** (8 * SOSC.SIZEOF_tv_usec - 1)
+ .. 2 ** (8 * SOSC.SIZEOF_tv_usec - 1) - 1;
+ for suseconds_t'Size use 8 * SOSC.SIZEOF_tv_usec;
pragma Convention (C, suseconds_t);
type Timeval is record
-------------------------------------------
Families : constant array (Family_Type) of C.int :=
- (Family_Inet => Constants.AF_INET,
- Family_Inet6 => Constants.AF_INET6);
+ (Family_Inet => SOSC.AF_INET,
+ Family_Inet6 => SOSC.AF_INET6);
Lengths : constant array (Family_Type) of C.unsigned_char :=
- (Family_Inet => Constants.SIZEOF_sockaddr_in,
- Family_Inet6 => Constants.SIZEOF_sockaddr_in6);
+ (Family_Inet => SOSC.SIZEOF_sockaddr_in,
+ Family_Inet6 => SOSC.SIZEOF_sockaddr_in6);
----------------------------
-- Generic socket address --
-- and protocol specific address types) start with the same 2-byte header,
-- which is either a length and a family (one byte each) or just a two-byte
-- family. The following unchecked union describes the two possible layouts
- -- and is meant to be constrained with Constants.Have_Sockaddr_Len.
+ -- and is meant to be constrained with SOSC.Have_Sockaddr_Len.
type Sockaddr_Length_And_Family
(Has_Sockaddr_Len : Boolean := False)
Sa_Family : Sockaddr_Length_And_Family;
-- Address family (and address length on some platforms)
- Sa_Data : C.char_array (1 .. 14) := (others => C.nul);
+ Sa_Data : C.char_array (1 .. 14) := (others => C.nul);
-- Family-specific data
-- Note that some platforms require that all unused (reserved) bytes
-- in addresses be initialized to 0 (e.g. VxWorks).
Sin_Family : Sockaddr_Length_And_Family;
-- Address family (and address length on some platforms)
- Sin_Port : C.unsigned_short;
+ Sin_Port : C.unsigned_short;
-- Port in network byte order
- Sin_Addr : In_Addr;
+ Sin_Addr : In_Addr;
-- IPv4 address
- Sin_Zero : C.char_array (1 .. 8) := (others => C.nul);
+ Sin_Zero : C.char_array (1 .. 8) := (others => C.nul);
-- Padding
+ --
-- Note that some platforms require that all unused (reserved) bytes
-- in addresses be initialized to 0 (e.g. VxWorks).
end record;
C.Strings.Null_Ptr);
-- Arrays of C (char *)
- type Servent is record
- S_Name : C.Strings.chars_ptr;
- S_Aliases : Chars_Ptr_Pointers.Pointer;
- S_Port : C.int;
- S_Proto : C.Strings.chars_ptr;
- end record;
- pragma Convention (C, Servent);
- -- Service entry
+ type Servent is new
+ System.Storage_Elements.Storage_Array (1 .. SOSC.SIZEOF_struct_servent);
+ for Servent'Alignment use 8;
+ -- Service entry. This is an opaque type used only via the following
+ -- accessor functions, because 'struct servent' has different layouts on
+ -- different platforms.
type Servent_Access is access all Servent;
pragma Convention (C, Servent_Access);
-- Access to service entry
+ function Servent_S_Name
+ (E : Servent_Access) return C.Strings.chars_ptr;
+
+ function Servent_S_Aliases
+ (E : Servent_Access) return Chars_Ptr_Pointers.Pointer;
+
+ function Servent_S_Port
+ (E : Servent_Access) return C.int;
+
+ function Servent_S_Proto
+ (E : Servent_Access) return C.Strings.chars_ptr;
+
+ procedure Servent_Set_S_Name
+ (E : Servent_Access;
+ S_Name : C.Strings.chars_ptr);
+
+ procedure Servent_Set_S_Aliases
+ (E : Servent_Access;
+ S_Aliases : Chars_Ptr_Pointers.Pointer);
+
+ procedure Servent_Set_S_Port
+ (E : Servent_Access;
+ S_Port : C.int);
+
+ procedure Servent_Set_S_Proto
+ (E : Servent_Access;
+ S_Proto : C.Strings.chars_ptr);
+
------------------
-- Host entries --
------------------
type Hostent is record
H_Name : C.Strings.chars_ptr;
H_Aliases : Chars_Ptr_Pointers.Pointer;
- H_Addrtype : Constants.H_Addrtype_T;
- H_Length : Constants.H_Length_T;
+ H_Addrtype : SOSC.H_Addrtype_T;
+ H_Length : SOSC.H_Length_T;
H_Addr_List : In_Addr_Access_Pointers.Pointer;
end record;
pragma Convention (C, Hostent);
pragma Convention (C, Hostent_Access);
-- Access to host entry
+ ------------------------------------
+ -- Scatter/gather vector handling --
+ ------------------------------------
+
+ type Msghdr is record
+ Msg_Name : System.Address;
+ Msg_Namelen : C.unsigned;
+ Msg_Iov : System.Address;
+ Msg_Iovlen : SOSC.Msg_Iovlen_T;
+ Msg_Control : System.Address;
+ Msg_Controllen : C.size_t;
+ Msg_Flags : C.int;
+ end record;
+ pragma Convention (C, Msghdr);
+
----------------------------
-- Socket sets management --
----------------------------
- type Int_Access is access all C.int;
- pragma Convention (C, Int_Access);
- -- Access to C integers
-
- procedure Free_Socket_Set (Set : Fd_Set_Access);
- -- Free system-dependent socket set
-
procedure Get_Socket_From_Set
- (Set : Fd_Set_Access;
- Socket : Int_Access;
- Last : Int_Access);
+ (Set : access Fd_Set;
+ Last : access C.int;
+ Socket : access C.int);
-- Get last socket in Socket and remove it from the socket set. The
-- parameter Last is a maximum value of the largest socket. This hint is
-- used to avoid scanning very large socket sets. After a call to
-- socket set.
procedure Insert_Socket_In_Set
- (Set : Fd_Set_Access;
+ (Set : access Fd_Set;
Socket : C.int);
-- Insert socket in the socket set
function Is_Socket_In_Set
- (Set : Fd_Set_Access;
+ (Set : access constant Fd_Set;
Socket : C.int) return C.int;
-- Check whether Socket is in the socket set, return a non-zero
-- value if it is, zero if it is not.
procedure Last_Socket_In_Set
- (Set : Fd_Set_Access;
- Last : Int_Access);
+ (Set : access Fd_Set;
+ Last : access C.int);
-- Find the largest socket in the socket set. This is needed for select().
-- When Last_Socket_In_Set is called, parameter Last is a maximum value of
-- the largest socket. This hint is used to avoid scanning very large
-- socket sets. After the call, Last is set back to the real largest socket
-- in the socket set.
- function New_Socket_Set
- (Set : Fd_Set_Access) return Fd_Set_Access;
- -- Allocate a new socket set which is a system-dependent structure and
- -- initialize by copying Set if it is non-null, by making it empty
- -- otherwise.
-
- procedure Remove_Socket_From_Set
- (Set : Fd_Set_Access;
- Socket : C.int);
+ procedure Remove_Socket_From_Set (Set : access Fd_Set; Socket : C.int);
-- Remove socket from the socket set
+ procedure Reset_Socket_Set (Set : access Fd_Set);
+ -- Make Set empty
+
------------------------------------------
-- Pairs of signalling file descriptors --
------------------------------------------
-- Indices into an Fd_Pair value providing access to each of the connected
-- file descriptors.
-private
+ function Inet_Pton
+ (Af : C.int;
+ Cp : C.Strings.chars_ptr;
+ Inp : System.Address) return C.int;
- pragma Import (C, Free_Socket_Set, "__gnat_free_socket_set");
+ function C_Ioctl
+ (Fd : C.int;
+ Req : C.int;
+ Arg : access C.int) return C.int;
+
+private
pragma Import (C, Get_Socket_From_Set, "__gnat_get_socket_from_set");
pragma Import (C, Is_Socket_In_Set, "__gnat_is_socket_in_set");
pragma Import (C, Last_Socket_In_Set, "__gnat_last_socket_in_set");
- pragma Import (C, New_Socket_Set, "__gnat_new_socket_set");
pragma Import (C, Insert_Socket_In_Set, "__gnat_insert_socket_in_set");
pragma Import (C, Remove_Socket_From_Set, "__gnat_remove_socket_from_set");
+ pragma Import (C, Reset_Socket_Set, "__gnat_reset_socket_set");
+ pragma Import (C, C_Ioctl, "__gnat_socket_ioctl");
+ pragma Import (C, Inet_Pton, SOSC.Inet_Pton_Linkname);
+
+ pragma Import (C, Servent_S_Name, "__gnat_servent_s_name");
+ pragma Import (C, Servent_S_Aliases, "__gnat_servent_s_aliases");
+ pragma Import (C, Servent_S_Port, "__gnat_servent_s_port");
+ pragma Import (C, Servent_S_Proto, "__gnat_servent_s_proto");
+ pragma Import (C, Servent_Set_S_Name, "__gnat_servent_set_s_name");
+ pragma Import (C, Servent_Set_S_Aliases, "__gnat_servent_set_s_aliases");
+ pragma Import (C, Servent_Set_S_Port, "__gnat_servent_set_s_port");
+ pragma Import (C, Servent_Set_S_Proto, "__gnat_servent_set_s_proto");
end GNAT.Sockets.Thin_Common;