r11007: r10109@SERNOX: metze | 2005-09-09 12:29:12 +0200
authorStefan Metzmacher <metze@samba.org>
Fri, 14 Oct 2005 12:38:07 +0000 (12:38 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:41:25 +0000 (13:41 -0500)
 - move structs to a seperate header file
 - move the code for the wreplsrv_in_call handling to a seperate file

 metze
(This used to be commit c9a8544446312d96ecadcf370af76d9dc5b2531a)

source4/include/structs.h
source4/wrepl_server/config.mk
source4/wrepl_server/wrepl_in_call.c [new file with mode: 0644]
source4/wrepl_server/wrepl_server.c
source4/wrepl_server/wrepl_server.h [new file with mode: 0644]

index bd0ebc5a27e4fc49f763c713de8a26d619045009..86cd3e1de8315e58292d680ef746c03645d6d695 100644 (file)
@@ -272,6 +272,9 @@ struct mutex_ops;
 
 struct ads_struct;
 
+struct wreplsrv_in_connection;
+struct wreplsrv_in_call;
+
 struct wrepl_packet;
 struct wrepl_associate;
 struct wrepl_associate_stop;
index d5c194d2aa18e8ac9c5cefdd8daf7148f14b3fa8..b7275c8a6556b806609dfbc5c45039aa73753e08 100644 (file)
@@ -4,7 +4,8 @@
 # Start SUBSYSTEM WREPL_SRV
 [SUBSYSTEM::WREPL_SRV]
 INIT_OBJ_FILES = \
-               wrepl_server/wrepl_server.o
+               wrepl_server/wrepl_server.o \
+               wrepl_server/wrepl_in_call.o
 REQUIRED_SUBSYSTEMS = \
                LIBCLI_WREPL WINSDB
 # End SUBSYSTEM WREPL_SRV
diff --git a/source4/wrepl_server/wrepl_in_call.c b/source4/wrepl_server/wrepl_in_call.c
new file mode 100644 (file)
index 0000000..444fda5
--- /dev/null
@@ -0,0 +1,109 @@
+/* 
+   Unix SMB/CIFS implementation.
+   
+   WINS Replication server
+   
+   Copyright (C) Stefan Metzmacher     2005
+   
+   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.
+*/
+
+#include "includes.h"
+#include "dlinklist.h"
+#include "lib/events/events.h"
+#include "lib/socket/socket.h"
+#include "smbd/service_task.h"
+#include "smbd/service_stream.h"
+#include "lib/messaging/irpc.h"
+#include "librpc/gen_ndr/ndr_winsrepl.h"
+#include "wrepl_server/wrepl_server.h"
+
+static NTSTATUS wreplsrv_in_start_association(struct wreplsrv_in_call *call)
+{
+       struct wrepl_stop *stop;
+
+       call->rep_packet.opcode         = WREPL_OPCODE_BITS;
+       call->rep_packet.assoc_ctx      = 0;
+       call->rep_packet.mess_type      = WREPL_STOP_ASSOCIATION;
+       stop                            = &call->rep_packet.message.stop;
+       stop->reason                    = 4;
+
+       return NT_STATUS_OK;
+}
+
+static NTSTATUS wreplsrv_in_replication(struct wreplsrv_in_call *call)
+{
+       struct wrepl_replication *repl_in = &call->req_packet.message.replication;
+       struct wrepl_stop *stop_out;
+
+       switch (repl_in->command) {
+               case WREPL_REPL_TABLE_QUERY:
+                       break;
+               case WREPL_REPL_TABLE_REPLY:
+                       break;
+               case WREPL_REPL_SEND_REQUEST:
+                       break;
+               case WREPL_REPL_SEND_REPLY:
+                       break;
+               case WREPL_REPL_UPDATE:
+                       break;
+               case WREPL_REPL_5:
+                       break;
+               case WREPL_REPL_INFORM:
+                       break;
+               case WREPL_REPL_9:
+                       break;
+       }
+
+       call->rep_packet.opcode         = WREPL_OPCODE_BITS;
+       call->rep_packet.assoc_ctx      = 0;
+       call->rep_packet.mess_type      = WREPL_STOP_ASSOCIATION;
+       stop_out                        = &call->rep_packet.message.stop;
+       stop_out->reason                = 4;
+
+       return NT_STATUS_OK;
+}
+
+NTSTATUS wreplsrv_in_call(struct wreplsrv_in_call *call)
+{
+       struct wrepl_stop *stop_out;
+
+       /* TODO: check opcode and assoc_ctx */
+
+       switch (call->req_packet.mess_type) {
+               case WREPL_START_ASSOCIATION:
+                       return wreplsrv_in_start_association(call);
+
+               case WREPL_START_ASSOCIATION_REPLY:
+                       /* this is not valid here */
+                       break;
+               case WREPL_STOP_ASSOCIATION:
+                       /* this is not valid here */
+                       break;
+
+               case WREPL_REPLICATION:
+                       return wreplsrv_in_replication(call);
+       }
+
+       call->rep_packet.opcode         = WREPL_OPCODE_BITS;
+       call->rep_packet.assoc_ctx      = 0;
+       call->rep_packet.mess_type      = WREPL_STOP_ASSOCIATION;
+       call->rep_packet.padding        = data_blob(NULL, 0);
+       stop_out                        = &call->rep_packet.message.stop;
+       stop_out->reason                = 4;
+
+       return NT_STATUS_OK;
+}
+
index 10dc8245073c9338c6d7e341abe09d36e6d09ebe..50be38e8d64586ab4e9c330579f4dfb83f290efa 100644 (file)
 #include "smbd/service_stream.h"
 #include "lib/messaging/irpc.h"
 #include "librpc/gen_ndr/ndr_winsrepl.h"
+#include "wrepl_server/wrepl_server.h"
 
-struct wreplsrv_service;
-struct wreplsrv_in_connection;
-struct wreplsrv_out_connection;
-struct wreplsrv_partner;
-struct wreplsrv_pull_partner_item;
-struct wreplsrv_push_partner_item;
-
-/*
-  state of an incoming wrepl call
-*/
-struct wreplsrv_in_call {
-       struct wreplsrv_in_connection *wreplconn;
-       struct wrepl_packet req_packet;
-       struct wrepl_packet rep_packet;
-};
-
-/*
-  state of an incoming wrepl connection
-*/
-struct wreplsrv_in_connection {
-       struct wreplsrv_in_connection *prev,*next;
-       struct stream_connection *conn;
-
-       /* our global service context */
-       struct wreplsrv_service *service;
-
-       /*
-        * the partner that connects us,
-        * can be NULL, when we got a connection
-        * from an unknown address
-        */
-       struct wreplsrv_partner *partner;
-
-       /*
-        * we need to take care of our own ip address,
-        * as this is the WINS-Owner ID the peer expect
-        * from us.
-        */
-       const char *our_ip;
-
-       /* the partial input on the connection */
-       DATA_BLOB partial;
-       size_t partial_read;
-
-       /*
-        * are we currently processing a request?
-        * this prevents loops, with half async code
-        */
-       BOOL processing;
-
-       /* the list of outgoing DATA_BLOB's that needs to be send */
-       struct data_blob_list_item *send_queue;
-};
-
-/*
-  state of an outcoming wrepl connection
-*/
-struct wreplsrv_out_connection {
-       struct wreplsrv_partner *partner;
-};
-
-/*
-  state of the whole wrepl service
-*/
-struct wreplsrv_service {
-       /* the whole wrepl service is in one task */
-       struct task_server *task;
-
-       /* all incoming connections */
-       struct wreplsrv_in_connection *in_connections;
-
-       /* all partners (pull and push) */
-       struct wreplsrv_partner *partners;
-
-       /* all pull partners */
-       struct wreplsrv_pull_partner *pull_partners;
-
-       /* all push partners */
-       struct wreplsrv_push_partner *push_partners;
-};
-
-static void wreplsrv_terminate_connection(struct wreplsrv_in_connection *wreplconn, const char *reason)
+void wreplsrv_terminate_connection(struct wreplsrv_in_connection *wreplconn, const char *reason)
 {
        stream_terminate_connection(wreplconn->conn, reason);
 }
 
-static NTSTATUS wreplsrv_in_start_association(struct wreplsrv_in_call *call)
-{
-       struct wrepl_stop *stop;
-
-       call->rep_packet.opcode         = WREPL_OPCODE_BITS;
-       call->rep_packet.assoc_ctx      = 0;
-       call->rep_packet.mess_type      = WREPL_STOP_ASSOCIATION;
-       stop                            = &call->rep_packet.message.stop;
-       stop->reason                    = 4;
-
-       return NT_STATUS_OK;
-}
-
-static NTSTATUS wreplsrv_in_replication(struct wreplsrv_in_call *call)
-{
-       struct wrepl_replication *repl_in = &call->req_packet.message.replication;
-       struct wrepl_stop *stop_out;
-
-       switch (repl_in->command) {
-               case WREPL_REPL_TABLE_QUERY:
-                       break;
-               case WREPL_REPL_TABLE_REPLY:
-                       break;
-               case WREPL_REPL_SEND_REQUEST:
-                       break;
-               case WREPL_REPL_SEND_REPLY:
-                       break;
-               case WREPL_REPL_UPDATE:
-                       break;
-               case WREPL_REPL_INFORM:
-                       break;
-       }
-
-       call->rep_packet.opcode         = WREPL_OPCODE_BITS;
-       call->rep_packet.assoc_ctx      = 0;
-       call->rep_packet.mess_type      = WREPL_STOP_ASSOCIATION;
-       stop_out                        = &call->rep_packet.message.stop;
-       stop_out->reason                = 4;
-
-       return NT_STATUS_OK;
-}
-
-static NTSTATUS wreplsrv_in_call(struct wreplsrv_in_call *call)
-{
-       struct wrepl_stop *stop_out;
-
-       /* TODO: check opcode and assoc_ctx */
-
-       switch (call->req_packet.mess_type) {
-               case WREPL_START_ASSOCIATION:
-                       return wreplsrv_in_start_association(call);
-
-               case WREPL_START_ASSOCIATION_REPLY:
-                       /* this is not valid here */
-                       break;
-               case WREPL_STOP_ASSOCIATION:
-                       /* this is not valid here */
-                       break;
-
-               case WREPL_REPLICATION:
-                       return wreplsrv_in_replication(call);
-       }
-
-       call->rep_packet.opcode         = WREPL_OPCODE_BITS;
-       call->rep_packet.assoc_ctx      = 0;
-       call->rep_packet.mess_type      = WREPL_STOP_ASSOCIATION;
-       call->rep_packet.padding        = data_blob(NULL, 0);
-       stop_out                        = &call->rep_packet.message.stop;
-       stop_out->reason                = 4;
-
-       return NT_STATUS_OK;
-}
-
 /*
   called when we get a new connection
 */
diff --git a/source4/wrepl_server/wrepl_server.h b/source4/wrepl_server/wrepl_server.h
new file mode 100644 (file)
index 0000000..f8bd59d
--- /dev/null
@@ -0,0 +1,102 @@
+/* 
+   Unix SMB/CIFS implementation.
+   
+   WINS Replication server
+   
+   Copyright (C) Stefan Metzmacher     2005
+   
+   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.
+*/
+
+struct wreplsrv_service;
+struct wreplsrv_in_connection;
+struct wreplsrv_out_connection;
+struct wreplsrv_partner;
+struct wreplsrv_pull_partner_item;
+struct wreplsrv_push_partner_item;
+
+/*
+  state of an incoming wrepl call
+*/
+struct wreplsrv_in_call {
+       struct wreplsrv_in_connection *wreplconn;
+       struct wrepl_packet req_packet;
+       struct wrepl_packet rep_packet;
+};
+
+/*
+  state of an incoming wrepl connection
+*/
+struct wreplsrv_in_connection {
+       struct wreplsrv_in_connection *prev,*next;
+       struct stream_connection *conn;
+
+       /* our global service context */
+       struct wreplsrv_service *service;
+
+       /*
+        * the partner that connects us,
+        * can be NULL, when we got a connection
+        * from an unknown address
+        */
+       struct wreplsrv_partner *partner;
+
+       /*
+        * we need to take care of our own ip address,
+        * as this is the WINS-Owner ID the peer expect
+        * from us.
+        */
+       const char *our_ip;
+
+       /* the partial input on the connection */
+       DATA_BLOB partial;
+       size_t partial_read;
+
+       /*
+        * are we currently processing a request?
+        * this prevents loops, with half async code
+        */
+       BOOL processing;
+
+       /* the list of outgoing DATA_BLOB's that needs to be send */
+       struct data_blob_list_item *send_queue;
+};
+
+/*
+  state of an outcoming wrepl connection
+*/
+struct wreplsrv_out_connection {
+       struct wreplsrv_partner *partner;
+};
+
+/*
+  state of the whole wrepl service
+*/
+struct wreplsrv_service {
+       /* the whole wrepl service is in one task */
+       struct task_server *task;
+
+       /* all incoming connections */
+       struct wreplsrv_in_connection *in_connections;
+
+       /* all partners (pull and push) */
+       struct wreplsrv_partner *partners;
+
+       /* all pull partners */
+       struct wreplsrv_pull_partner *pull_partners;
+
+       /* all push partners */
+       struct wreplsrv_push_partner *push_partners;
+};