summaryrefslogtreecommitdiff
path: root/src/irmd/main.c
diff options
context:
space:
mode:
authorSander Vrijders <sander.vrijders@intec.ugent.be>2016-02-23 17:04:49 +0100
committerSander Vrijders <sander.vrijders@intec.ugent.be>2016-02-23 17:04:49 +0100
commita3eb060b8d4419c1af85d3acf081f45cdc27708d (patch)
treed24203b64c5d229be028b6e04ab1a2958624bf0d /src/irmd/main.c
parentd773fdaad545c122ff81acb57080c8baf46f3735 (diff)
downloadouroboros-a3eb060b8d4419c1af85d3acf081f45cdc27708d.tar.gz
ouroboros-a3eb060b8d4419c1af85d3acf081f45cdc27708d.zip
lib: Initial messages for the IRM
This provides the initial messages to be passed between the irmd and libouroboros-irm.
Diffstat (limited to 'src/irmd/main.c')
-rw-r--r--src/irmd/main.c57
1 files changed, 55 insertions, 2 deletions
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 8ab071e0..b4e43534 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -1,10 +1,63 @@
-#define OUROBOROS_PREFIX "irm"
+/*
+ * Ouroboros - Copyright (C) 2016
+ *
+ * The IPC Resource Manager
+ *
+ * Sander Vrijders <sander.vrijders@intec.ugent.be>
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#define OUROBOROS_PREFIX "irmd"
#include <ouroboros/logs.h>
+#include <ouroboros/common.h>
+#include <ouroboros/sockets.h>
+#include <ouroboros/irm.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+
+#define BUF_SIZE 256
int main()
{
- LOG_DBG("Test of the IRM");
+ int sockfd;
+
+ sockfd = server_socket_open(IRM_SOCK_PATH);
+ if (sockfd < 0)
+ return -1;
+
+ while (true) {
+ int cli_sockfd;
+ struct irm_msg_sock msg;
+ ssize_t count;
+ char buf[BUF_SIZE];
+
+ cli_sockfd = accept(sockfd, 0, 0);
+ if (cli_sockfd < 0) {
+ LOG_ERR("Cannot accept new connection");
+ }
+
+ count = read(cli_sockfd, buf, BUF_SIZE);
+ if (count) {
+ msg = (struct struct irm_msg_sock) buf;
+ LOG_INFO("Got message code %d", buf.code);
+ }
+
+ close(cli_sockfd);
+ }
return 0;
}