Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1299653
| From | Thomas Schoebel-Theuer <tst@schoebel-theuer.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFC 25/31] mars: add new module light_net |
| Date | 2015-12-31 12:50 +0100 |
| Message-ID | <qLJTY-3U9-37@gated-at.bofh.it> (permalink) |
| References | <qLJKi-3PB-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Signed-off-by: Thomas Schoebel-Theuer <tst@schoebel-theuer.de>
---
drivers/staging/mars/mars_light/light_net.c | 109 ++++++++++++++++++++++++++++
1 file changed, 109 insertions(+)
create mode 100644 drivers/staging/mars/mars_light/light_net.c
diff --git a/drivers/staging/mars/mars_light/light_net.c b/drivers/staging/mars/mars_light/light_net.c
new file mode 100644
index 0000000..9890edd
--- /dev/null
+++ b/drivers/staging/mars/mars_light/light_net.c
@@ -0,0 +1,109 @@
+/*
+ * MARS Long Distance Replication Software
+ *
+ * Copyright (C) 2010-2014 Thomas Schoebel-Theuer
+ * Copyright (C) 2011-2014 1&1 Internet AG
+ *
+ * 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.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/string.h>
+
+#include <linux/mars_light/light_strategy.h>
+#include <linux/xio/xio_net.h>
+
+static
+char *_xio_translate_hostname(const char *name)
+{
+ char *res = brick_strdup(name);
+ char *test;
+ char *tmp;
+
+ for (tmp = res; *tmp; tmp++) {
+ if (*tmp == ':') {
+ *tmp = '\0';
+ break;
+ }
+ }
+
+ tmp = path_make("/mars/ips/ip-%s", res);
+ if (unlikely(!tmp))
+ goto done;
+
+ test = mars_readlink(tmp);
+ if (test && test[0]) {
+ XIO_DBG("'%s' => '%s'\n", tmp, test);
+ brick_string_free(res);
+ res = test;
+ } else {
+ brick_string_free(test);
+ XIO_WRN("no hostname translation for '%s'\n", tmp);
+ }
+ brick_string_free(tmp);
+
+done:
+ return res;
+}
+
+int xio_send_dent_list(struct xio_socket *sock, struct list_head *anchor)
+{
+ struct list_head *tmp;
+ struct mars_dent *dent;
+ int status = 0;
+
+ for (tmp = anchor->next; tmp != anchor; tmp = tmp->next) {
+ dent = container_of(tmp, struct mars_dent, dent_link);
+ status = xio_send_struct(sock, dent, mars_dent_meta);
+ if (status < 0)
+ break;
+ }
+ if (status >= 0) { /* send EOR */
+ status = xio_send_struct(sock, NULL, mars_dent_meta);
+ }
+ return status;
+}
+
+int xio_recv_dent_list(struct xio_socket *sock, struct list_head *anchor)
+{
+ int status;
+
+ for (;;) {
+ struct mars_dent *dent = brick_zmem_alloc(sizeof(struct mars_dent));
+
+ INIT_LIST_HEAD(&dent->dent_link);
+ INIT_LIST_HEAD(&dent->brick_list);
+
+ status = xio_recv_struct(sock, dent, mars_dent_meta);
+ if (status <= 0) {
+ xio_free_dent(dent);
+ goto done;
+ }
+ list_add_tail(&dent->dent_link, anchor);
+ }
+done:
+ return status;
+}
+
+/***************** module init stuff ************************/
+
+int __init init_sy_net(void)
+{
+ XIO_INF("init_sy_net()\n");
+ xio_translate_hostname = _xio_translate_hostname;
+ return 0;
+}
+
+void exit_sy_net(void)
+{
+ XIO_INF("exit_sy_net()\n");
+}
--
2.6.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC 00/31] Current state of MARS Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:40 +0100 [RFC 07/31] mars: add new module lib_pairing_heap Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:40 +0100 [RFC 31/31] mars: activate build Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:40 +0100 [RFC 04/31] mars: add new module brick_checking Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100 [RFC 29/31] mars: add new module Makefile Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100 [RFC 17/31] mars: add new module xio_bio Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100 [RFC 15/31] mars: add new module lib_mapfree Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100 [RFC 27/31] mars: add new module mars_proc Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100 [RFC 21/31] mars: add new module xio_copy Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100 [RFC 20/31] mars: add new module xio_if Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100 [RFC 13/31] mars: add new module xio Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100 [RFC 25/31] mars: add new module light_net Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100 [RFC 23/31] mars: add new module xio_server Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100 [RFC 01/31] mars: add new module lamport Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100 [RFC 19/31] mars: add new module xio_client Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100 [RFC 11/31] mars: add new module lib_timing Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100 [RFC 08/31] mars: add new module lib_queue Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100 [RFC 18/31] mars: add new module xio_sio Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100 [RFC 16/31] mars: add new module lib_log Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100 [RFC 26/31] mars: add new module light_server_strategy Thomas Schoebel-Theuer <tst@schoebel-theuer.de> - 2015-12-31 12:50 +0100
csiph-web