diff --git a/src/server/Makefile.am b/src/server/Makefile.am
--- a/src/server/Makefile.am
+++ b/src/server/Makefile.am
@@ -1,7 +1,7 @@
COMMON_SOURCES = slavefuncs.c slavefuncs.h distrenjob.c distrenjob.h
bin_PROGRAMS = distrend distrenslave
-distrend_SOURCES = distrend.c ${COMMON_SOURCES} user_mgr.c user_mgr.h
+distrend_SOURCES = distrend.c distrend.h ${COMMON_SOURCES} user_mgr.c user_mgr.h listen.h listen.c
distrend_LDADD = @DISTLIBS_LIBS@ @top_builddir@/src/common/libdistrencommon.la @LIST_LIBS@
distrend_CFLAGS = @DISTLIBS_CFLAGS@ -I@top_srcdir@/src/common
diff --git a/src/server/distrend.c b/src/server/distrend.c
--- a/src/server/distrend.c
+++ b/src/server/distrend.c
@@ -28,6 +28,7 @@
#include "execio.h"
#include "options.h"
#include "distrenjob.h"
+#include "listen.h"
#include "protocol.h"
#include "slavefuncs.h"
#include "asprintf.h"
@@ -50,15 +51,6 @@
/* ******************* Structs ************************ */
-// Gets config info from confs
-struct distrend_config
-{
- cfg_t *mycfg;
- struct options_common *options;
- struct distrend_listen **listens; /*< Null terminated array of structs */
- char *datadir;
-};
-
struct general_info {
short int jobs_in_queue; //
unsigned short int free_clients;
@@ -124,27 +116,6 @@ void distrend_action_free()
{
}
-/**
- Start listening
-*/
-void distrend_listen()
-{
-
-}
-/**
- Stop listening
-*/
-void distrend_unlisten()
-{
-
-}
-/**
- This is probably just a placeholder for remotio
-*/
-void remotio_send_to_client()
-{
- // I am futile!
-}
/** Fill variables after crash / shutdown from XML dumps */
int start_data(struct distrenjob *head, char *datadir)
@@ -1072,7 +1043,7 @@ int main(int argc, char *argv[])
struct distrenjob head;
int cont;
- struct distrend_listenset *listenset;
+ struct distrend_clientset *clients;
struct distrend_config *config;
enum clientstatus
@@ -1217,7 +1188,7 @@ int main(int argc, char *argv[])
}
}
- distrend_listen(&listenset, config);
+ distrend_listen(config, &clients);
/* This is called the "main loop" */
while(cont)
{
@@ -1255,7 +1226,7 @@ int main(int argc, char *argv[])
distrend_action_free(action);
}
- distrend_unlisten(listenset);
+ distrend_unlisten(config->listens, clients);
distrend_config_free(config);
xmlcleanup();
diff --git a/src/server/distrend.h b/src/server/distrend.h
new file mode 100644
--- /dev/null
+++ b/src/server/distrend.h
@@ -0,0 +1,39 @@
+/*
+ Copyright 2009 Nathan Phillip Brink
+
+ This file is a part of DistRen.
+
+ DistRen is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ DistRen 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with DistRen. If not, see .
+
+*/
+
+struct distrend_config;
+
+#ifndef _DISTREN_DISTREN_H_
+#define _DISTREN_DISTREN_H_
+
+#include
+
+#include "listen.h"
+
+struct distrend_config
+{
+ cfg_t *mycfg;
+ struct options_common *options;
+ struct distrend_listen *listens; /*< Null terminated array of structs */
+ char *datadir;
+};
+
+
+#endif
diff --git a/src/server/listen.c b/src/server/listen.c
new file mode 100644
--- /dev/null
+++ b/src/server/listen.c
@@ -0,0 +1,89 @@
+/*
+ Copyright 2009 Nathan Phillip Brink
+
+ This file is a part of DistRen.
+
+ DistRen is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ DistRen 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with DistRen. If not, see .
+*/
+
+#include "listen.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+/* local */
+
+struct distrend_client
+{
+ int sock;
+ int state;
+};
+
+struct distrend_clientset
+{
+ LIST *clients;
+};
+
+
+int distrend_listen(struct distrend_config *config, struct distrend_clientset **clients)
+{
+ int tmp;
+
+ struct sockaddr_in6 sockaddr =
+ {
+ .sin6_family = AF_INET6,
+ .sin6_port = 0,
+ .sin6_flowinfo = 0,
+ .sin6_addr = IN6ADDR_ANY_INIT,
+ .sin6_scope_id = 0
+ };
+
+ *clients = malloc(sizeof(struct distrend_clientset));
+
+ (*clients)->clients = list_init();
+
+ sockaddr.sin6_port = htonl(4050);
+
+ config->listens->sock = socket(AF_INET6, SOCK_STREAM, 0);
+ tmp = bind(config->listens->sock, (struct sockaddr *)&sockaddr, sizeof(sockaddr));
+ if(tmp == -1)
+ {
+ perror("bind");
+ free(*clients);
+
+ return 1;
+ }
+
+ tmp = listen(config->listens->sock, 1);
+
+ return 0;
+}
+
+int distrend_unlisten(struct distrend_listen *listens, struct distrend_clientset *clients)
+{
+ fprintf(stderr, "%s:%d: I am a stub that needn't be implemented 'til later\n", __FILE__, __LINE__);
+
+ return 1;
+}
+/**
+ This is probably just NOT a placeholder for remotio
+*/
+void remotio_send_to_client()
+{
+ fprintf(stderr, "%s:%d: I am futile! And I'm happy because of it :-D\n", __FILE__, __LINE__);
+}
diff --git a/src/server/listen.h b/src/server/listen.h
new file mode 100644
--- /dev/null
+++ b/src/server/listen.h
@@ -0,0 +1,52 @@
+/*
+ Copyright 2009 Nathan Phillip Brink
+
+ This file is a part of DistRen.
+
+ DistRen is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ DistRen 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with DistRen. If not, see .
+*/
+
+struct distrend_clientset;
+struct distrend_listen;
+
+#ifndef _DISTREN_LISTEN_H
+#define _DISTREN_LISTEN_H
+
+#include "distrend.h"
+
+struct distrend_listen
+{
+ int port;
+ int sock;
+};
+
+
+/**
+ initializes the listens and clientset
+ @param config the configuration from distrend
+ @param clients a pointer to a struct distrend_clientset pointer which will be set to memory allocated for the clientset
+ */
+int distrend_listen(struct distrend_config *config, struct distrend_clientset **clients);
+
+/**
+ cleans listening socket. Unnecessary for a working server, currently a stub.
+ */
+int distrend_unlisten(struct distrend_listen *listens, struct distrend_clientset *clients);
+
+/**
+ This is probably just NOT a placeholder for remotio
+*/
+void remotio_send_to_client();
+
+#endif