1--
2--  Copyright (C) 2014 Reto Buerki <reet@codelabs.ch>
3--  Copyright (C) 2014 Adrian-Ken Rueegsegger <ken@codelabs.ch>
4--
5--  This program is free software; you can redistribute it and/or modify it
6--  under the terms of the GNU General Public License as published by the
7--  Free Software Foundation; either version 2 of the License, or (at your
8--  option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
9--
10--  This program is distributed in the hope that it will be useful, but
11--  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12--  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13--  for more details.
14--
15--  As a special exception, if other files instantiate generics from this
16--  unit,  or  you  link  this  unit  with  other  files  to  produce  an
17--  executable   this  unit  does  not  by  itself  cause  the  resulting
18--  executable to  be  covered by the  GNU General  Public License.  This
19--  exception does  not  however  invalidate  any  other reasons why  the
20--  executable file might be covered by the GNU Public License.
21--
22
23with Anet.Byte_Swapping;
24with Anet.Socket_Families;
25
26package body Anet.Sockets.Thin.Inet is
27
28   -------------------------------------------------------------------------
29
30   function Create_Inet4
31     (Address : IPv4_Addr_Type;
32      Port    : Port_Type)
33      return Thin.Inet.Sockaddr_In_Type
34   is
35   begin
36      return (Family     => Socket_Families.Family_Inet,
37              Sin_Family => Constants.Sys.AF_INET,
38              Sin_Port   => Interfaces.C.unsigned_short
39                (Byte_Swapping.Host_To_Network (Input => Port)),
40              Sin_Addr   => Address,
41              Sin_Zero   => <>);
42   end Create_Inet4;
43
44   -------------------------------------------------------------------------
45
46   function Create_Inet6
47     (Address : IPv6_Addr_Type;
48      Port    : Port_Type)
49      return Thin.Inet.Sockaddr_In_Type
50   is
51   begin
52      return (Family     => Socket_Families.Family_Inet6,
53              Sin_Family => Constants.Sys.AF_INET6,
54              Sin_Port   => Interfaces.C.unsigned_short
55                (Byte_Swapping.Host_To_Network (Input => Port)),
56              Sin6_Addr  => Address,
57              others     => 0);
58   end Create_Inet6;
59
60end Anet.Sockets.Thin.Inet;
61