summaryrefslogtreecommitdiff
path: root/source4/ldap_server
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-01-14 01:32:56 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:08:49 -0500
commit9327ec51d11855ec0ceac3ce1f4e0a75c8b57081 (patch)
tree7f4427b4246b91b050c16e8dc5d1f0433eb7cc2d /source4/ldap_server
parentcfc10f2a83b7c6190742498f1027256215cd0b31 (diff)
downloadsamba-9327ec51d11855ec0ceac3ce1f4e0a75c8b57081.tar.gz
samba-9327ec51d11855ec0ceac3ce1f4e0a75c8b57081.tar.bz2
samba-9327ec51d11855ec0ceac3ce1f4e0a75c8b57081.zip
r4728: split up server_services into:
- stream_socket services the smb, ldap and rpc service which sets up a srtam socket end then waits for connections and - task services which this you can create a seperate task that do something (this is also going through the process_model subsystem so with -M standard a new process for this created with -M thread a new thread ... I'll add datagram services later when we whave support for datagram sockets in lib/socket/ see the next commit as an example for service_task's metze (This used to be commit d5fa02746c6569b09b6e05785642da2fad3ba3e0)
Diffstat (limited to 'source4/ldap_server')
-rw-r--r--source4/ldap_server/ldap_server.c68
1 files changed, 27 insertions, 41 deletions
diff --git a/source4/ldap_server/ldap_server.c b/source4/ldap_server/ldap_server.c
index bc851713b5..52a519721f 100644
--- a/source4/ldap_server/ldap_server.c
+++ b/source4/ldap_server/ldap_server.c
@@ -34,21 +34,22 @@ static void ldapsrv_terminate_connection(struct ldapsrv_connection *ldap_conn, c
server_terminate_connection(ldap_conn->connection, reason);
}
+static const struct server_stream_ops *ldapsrv_get_stream_ops(void);
+
/*
add a socket address to the list of events, one event per port
*/
-static void add_socket(struct server_service *service,
- const struct model_ops *model_ops,
+static void add_socket(struct server_service *service,
struct ipv4_addr *ifip)
{
- struct server_socket *srv_sock;
+ struct server_stream_socket *stream_socket;
uint16_t port = 389;
char *ip_str = talloc_strdup(service, sys_inet_ntoa(*ifip));
- srv_sock = service_setup_socket(service, model_ops, "ipv4", ip_str, &port);
+ stream_socket = service_setup_stream_socket(service, ldapsrv_get_stream_ops(), "ipv4", ip_str, &port);
port = 3268;
- srv_sock = service_setup_socket(service, model_ops, "ipv4", ip_str, &port);
+ stream_socket = service_setup_stream_socket(service, ldapsrv_get_stream_ops(), "ipv4", ip_str, &port);
talloc_free(ip_str);
}
@@ -56,8 +57,7 @@ static void add_socket(struct server_service *service,
/****************************************************************************
Open the socket communication.
****************************************************************************/
-static void ldapsrv_init(struct server_service *service,
- const struct model_ops *model_ops)
+static void ldapsrv_init(struct server_service *service)
{
struct ldapsrv_service *ldap_service;
struct ldapsrv_partition *part;
@@ -97,7 +97,7 @@ static void ldapsrv_init(struct server_service *service,
ldap_service->default_partition = part;
DLIST_ADD_END(ldap_service->partitions, part, struct ldapsrv_partition *);
- service->private_data = ldap_service;
+ service->service.private_data = ldap_service;
if (lp_interfaces() && lp_bind_interfaces_only()) {
int num_interfaces = iface_count();
@@ -116,14 +116,14 @@ static void ldapsrv_init(struct server_service *service,
continue;
}
- add_socket(service, model_ops, ifip);
+ add_socket(service, ifip);
}
} else {
struct ipv4_addr ifip;
/* Just bind to lp_socket_address() (usually 0.0.0.0) */
ifip = interpret_addr2(lp_socket_address());
- add_socket(service, model_ops, &ifip);
+ add_socket(service, &ifip);
}
}
@@ -423,7 +423,7 @@ NTSTATUS ldapsrv_flush_responses(struct ldapsrv_connection *conn)
static void ldapsrv_recv(struct server_connection *conn, struct timeval t,
uint16_t flags)
{
- struct ldapsrv_connection *ldap_conn = conn->private_data;
+ struct ldapsrv_connection *ldap_conn = conn->connection.private_data;
uint8_t *buf;
size_t buf_length, msg_length;
DATA_BLOB blob;
@@ -519,7 +519,7 @@ static void ldapsrv_recv(struct server_connection *conn, struct timeval t,
static void ldapsrv_send(struct server_connection *conn, struct timeval t,
uint16_t flags)
{
- struct ldapsrv_connection *ldap_conn = conn->private_data;
+ struct ldapsrv_connection *ldap_conn = conn->connection.private_data;
DEBUG(10,("ldapsrv_send\n"));
@@ -536,20 +536,6 @@ static void ldapsrv_send(struct server_connection *conn, struct timeval t,
}
/*
- called when connection is idle
-*/
-static void ldapsrv_idle(struct server_connection *conn, struct timeval t)
-{
- DEBUG(10,("ldapsrv_idle: not implemented!\n"));
- return;
-}
-
-static void ldapsrv_close(struct server_connection *conn, const char *reason)
-{
- return;
-}
-
-/*
initialise a server_context from a open socket and register a event handler
for reading from that socket
*/
@@ -566,31 +552,31 @@ static void ldapsrv_accept(struct server_connection *conn)
ZERO_STRUCTP(ldap_conn);
ldap_conn->connection = conn;
- ldap_conn->service = talloc_reference(ldap_conn, conn->service->private_data);
+ ldap_conn->service = talloc_reference(ldap_conn, conn->stream_socket->service);
- conn->private_data = ldap_conn;
+ conn->connection.private_data = ldap_conn;
return;
}
-/*
- called on a fatal error that should cause this server to terminate
-*/
-static void ldapsrv_exit(struct server_service *service, const char *reason)
+static const struct server_stream_ops ldap_stream_ops = {
+ .name = "ldap",
+ .socket_init = NULL,
+ .accept_connection = ldapsrv_accept,
+ .recv_handler = ldapsrv_recv,
+ .send_handler = ldapsrv_send,
+ .idle_handler = NULL,
+ .close_connection = NULL
+};
+
+static const struct server_stream_ops *ldapsrv_get_stream_ops(void)
{
- DEBUG(10,("ldapsrv_exit\n"));
- return;
+ return &ldap_stream_ops;
}
static const struct server_service_ops ldap_server_ops = {
.name = "ldap",
- .service_init = ldapsrv_init,
- .accept_connection = ldapsrv_accept,
- .recv_handler = ldapsrv_recv,
- .send_handler = ldapsrv_send,
- .idle_handler = ldapsrv_idle,
- .close_connection = ldapsrv_close,
- .service_exit = ldapsrv_exit,
+ .service_init = ldapsrv_init
};
const struct server_service_ops *ldapsrv_get_ops(void)