]> git.ipfire.org Git - thirdparty/strongswan.git/blob - src/charon-tkm/src/ees/esa_event_service.adb
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / charon-tkm / src / ees / esa_event_service.adb
1 --
2 -- Copyright (C) 2012 Reto Buerki
3 -- Copyright (C) 2012 Adrian-Ken Rueegsegger
4 --
5 -- Copyright (C) secunet Security Networks AG
6 --
7 -- This program is free software; you can redistribute it and/or modify it
8 -- under the terms of the GNU General Public License as published by the
9 -- Free Software Foundation; either version 2 of the License, or (at your
10 -- option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 --
12 -- This program is distributed in the hope that it will be useful, but
13 -- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 -- for more details.
16 --
17
18 with Anet.Sockets.Unix;
19 with Anet.Receivers.Stream;
20
21 with Tkmrpc.Dispatchers.Ees;
22 with Tkmrpc.Process_Stream;
23
24 pragma Elaborate_All (Anet.Receivers.Stream);
25 pragma Elaborate_All (Tkmrpc.Process_Stream);
26
27 package body Esa_Event_Service
28 is
29
30 package Unix_TCP_Receiver is new Anet.Receivers.Stream
31 (Socket_Type => Anet.Sockets.Unix.TCP_Socket_Type,
32 Address_Type => Anet.Sockets.Unix.Full_Path_Type,
33 Accept_Connection => Anet.Sockets.Unix.Accept_Connection);
34
35 procedure Dispatch is new Tkmrpc.Process_Stream
36 (Dispatch => Tkmrpc.Dispatchers.Ees.Dispatch,
37 Address_Type => Anet.Sockets.Unix.Full_Path_Type);
38
39 Sock : aliased Anet.Sockets.Unix.TCP_Socket_Type;
40 Receiver : Unix_TCP_Receiver.Receiver_Type (S => Sock'Access);
41
42 -------------------------------------------------------------------------
43
44 procedure Finalize
45 is
46 begin
47 Receiver.Stop;
48 end Finalize;
49
50 -------------------------------------------------------------------------
51
52 procedure Init (Address : Interfaces.C.Strings.chars_ptr)
53 is
54 Path : constant String := Interfaces.C.Strings.Value (Address);
55 begin
56 Sock.Init;
57 Sock.Bind (Path => Anet.Sockets.Unix.Path_Type (Path));
58 Receiver.Listen (Callback => Dispatch'Access);
59 end Init;
60
61 end Esa_Event_Service;