& "-Werror";
end Compiler;
+ package Binder is
+ for Default_Switches ("ada") use Build_Common.Ada_Binder_Switches;
+ end Binder;
+
end Build_Charon;
"-fstack-check",
"-gnato",
"-g");
+
+ Ada_Binder_Switches := ("-E");
+
end Build_Common;
project Build_Tests is
for Languages use ("Ada", "C");
- for Source_Dirs use ("src/tkm", "src/ees", "tests");
+ for Source_Dirs use ("src/ees", "src/ehandler", "src/tkm", "tests");
for Main use ("test_runner");
for Object_Dir use Build_Common.Obj_Dir;
--- /dev/null
+/*
+ * Copyright (C) 2012 Reto Buerki
+ * Copyright (C) 2012 Adrian-Ken Rueegsegger
+ * Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include <sys/types.h>
+#include <signal.h>
+#include <utils/debug.h>
+
+#include "eh_callbacks.h"
+
+void charon_terminate(char *msg)
+{
+ DBG1(DBG_DMN, "critical TKM error, terminating!");
+ DBG1(DBG_DMN, msg);
+ kill(0, SIGTERM);
+}
--- /dev/null
+/*
+ * Copyright (C) 2012 Reto Buerki
+ * Copyright (C) 2012 Adrian-Ken Rueegsegger
+ * Hochschule fuer Technik Rapperswil
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#ifndef EH_CALLBACKS_H_
+#define EH_CALLBACKS_H_
+
+/**
+ * Log given message and terminate charon.
+ */
+void charon_terminate(char *msg);
+
+#endif /** EH_CALLBACKS_H_ */
--- /dev/null
+--
+-- Copyright (C) 2012 Reto Buerki
+-- Copyright (C) 2012 Adrian-Ken Rueegsegger
+-- Hochschule fuer Technik Rapperswil
+--
+-- This program is free software; you can redistribute it and/or modify it
+-- under the terms of the GNU General Public License as published by the
+-- Free Software Foundation; either version 2 of the License, or (at your
+-- option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+--
+-- This program is distributed in the hope that it will be useful, but
+-- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+-- for more details.
+--
+
+with Ada.Exceptions;
+
+with GNAT.Exception_Actions;
+
+with Interfaces.C.Strings;
+
+package body Exception_Handler
+is
+
+ procedure Charon_Terminate (Message : Interfaces.C.Strings.chars_ptr);
+ pragma Import (C, Charon_Terminate, "charon_terminate");
+
+ procedure Bailout (Ex : Ada.Exceptions.Exception_Occurrence);
+ -- Signal critical condition to charon daemon.
+
+ -------------------------------------------------------------------------
+
+ procedure Bailout (Ex : Ada.Exceptions.Exception_Occurrence)
+ is
+ begin
+ if Ada.Exceptions.Exception_Name (Ex) = "_ABORT_SIGNAL" then
+
+ -- Ignore runtime-internal abort signal exception.
+
+ return;
+ end if;
+
+ Charon_Terminate (Message => Interfaces.C.Strings.New_String
+ (Ada.Exceptions.Exception_Information (Ex)));
+ end Bailout;
+
+ -------------------------------------------------------------------------
+
+ procedure Init
+ is
+ begin
+ GNAT.Exception_Actions.Register_Global_Action
+ (Action => Bailout'Access);
+ end Init;
+
+end Exception_Handler;
--- /dev/null
+--
+-- Copyright (C) 2012 Reto Buerki
+-- Copyright (C) 2012 Adrian-Ken Rueegsegger
+-- Hochschule fuer Technik Rapperswil
+--
+-- This program is free software; you can redistribute it and/or modify it
+-- under the terms of the GNU General Public License as published by the
+-- Free Software Foundation; either version 2 of the License, or (at your
+-- option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
+--
+-- This program is distributed in the hope that it will be useful, but
+-- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+-- for more details.
+--
+
+package Exception_Handler
+is
+
+ procedure Init;
+ pragma Export (C, Init, "ehandler_init");
+ -- Register last-chance exception handler.
+
+end Exception_Handler;
extern result_type ees_server_init(const char * const address);
extern void ees_server_finalize(void);
+extern void ehandler_init(void);
/*
* Private additions to tkm_t.
/* initialize TKM client library */
tkmlib_init();
+
+ ehandler_init();
+
if (ike_init(IKE_SOCKET) != TKM_OK)
{
tkmlib_final();