summaryrefslogtreecommitdiff
path: root/source4/cldap_server
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2006-01-09 22:12:53 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:49:57 -0500
commitf55ea8bb3dca868e21663cd90eaea7a35cd7886c (patch)
tree80aab2a3f10310e1946821603752cd407e435214 /source4/cldap_server
parent806b3fdbc12b3284ab9872a4ecae3a7ee34ea171 (diff)
downloadsamba-f55ea8bb3dca868e21663cd90eaea7a35cd7886c.tar.gz
samba-f55ea8bb3dca868e21663cd90eaea7a35cd7886c.tar.bz2
samba-f55ea8bb3dca868e21663cd90eaea7a35cd7886c.zip
r12804: This patch reworks the Samba4 sockets layer to use a socket_address
structure that is more generic than just 'IP/port'. It now passes make test, and has been reviewed and updated by metze. (Thankyou *very* much). This passes 'make test' as well as kerberos use (not currently in the testsuite). The original purpose of this patch was to have Samba able to pass a socket address stucture from the BSD layer into the kerberos routines and back again. It also removes nbt_peer_addr, which was being used for a similar purpose. It is a large change, but worthwhile I feel. Andrew Bartlett (This used to be commit 88198c4881d8620a37086f80e4da5a5b71c5bbb2)
Diffstat (limited to 'source4/cldap_server')
-rw-r--r--source4/cldap_server/cldap_server.c20
-rw-r--r--source4/cldap_server/netlogon.c8
2 files changed, 19 insertions, 9 deletions
diff --git a/source4/cldap_server/cldap_server.c b/source4/cldap_server/cldap_server.c
index e112d7a33b..7270e01a4d 100644
--- a/source4/cldap_server/cldap_server.c
+++ b/source4/cldap_server/cldap_server.c
@@ -32,12 +32,12 @@
*/
static void cldapd_request_handler(struct cldap_socket *cldap,
struct ldap_message *ldap_msg,
- const char *src_address, int src_port)
+ struct socket_address *src)
{
struct ldap_SearchRequest *search;
if (ldap_msg->type != LDAP_TAG_SearchRequest) {
DEBUG(0,("Invalid CLDAP request type %d from %s:%d\n",
- ldap_msg->type, src_address, src_port));
+ ldap_msg->type, src->addr, src->port));
return;
}
@@ -46,12 +46,12 @@ static void cldapd_request_handler(struct cldap_socket *cldap,
if (search->num_attributes == 1 &&
strcasecmp(search->attributes[0], "netlogon") == 0) {
cldapd_netlogon_request(cldap, ldap_msg->messageid,
- search->tree, src_address, src_port);
+ search->tree, src);
} else {
DEBUG(0,("Unknown CLDAP search for '%s'\n",
ldb_filter_from_tree(ldap_msg,
ldap_msg->r.SearchRequest.tree)));
- cldap_empty_reply(cldap, ldap_msg->messageid, src_address, src_port);
+ cldap_empty_reply(cldap, ldap_msg->messageid, src);
}
}
@@ -62,13 +62,21 @@ static void cldapd_request_handler(struct cldap_socket *cldap,
static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, const char *address)
{
struct cldap_socket *cldapsock;
+ struct socket_address *socket_address;
NTSTATUS status;
/* listen for unicasts on the CLDAP port (389) */
cldapsock = cldap_socket_init(cldapd, cldapd->task->event_ctx);
NT_STATUS_HAVE_NO_MEMORY(cldapsock);
- status = socket_listen(cldapsock->sock, address, lp_cldap_port(), 0, 0);
+ socket_address = socket_address_from_strings(cldapsock, cldapsock->sock->backend_name,
+ address, lp_cldap_port());
+ if (!socket_address) {
+ talloc_free(cldapsock);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ status = socket_listen(cldapsock->sock, socket_address, 0, 0);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to bind to %s:%d - %s\n",
address, lp_cldap_port(), nt_errstr(status)));
@@ -76,6 +84,8 @@ static NTSTATUS cldapd_add_socket(struct cldapd_server *cldapd, const char *addr
return status;
}
+ talloc_free(socket_address);
+
cldap_set_incoming_handler(cldapsock, cldapd_request_handler, cldapd);
return NT_STATUS_OK;
diff --git a/source4/cldap_server/netlogon.c b/source4/cldap_server/netlogon.c
index e58907d69f..476b9dfed5 100644
--- a/source4/cldap_server/netlogon.c
+++ b/source4/cldap_server/netlogon.c
@@ -193,7 +193,7 @@ static NTSTATUS cldapd_netlogon_fill(struct cldapd_server *cldapd,
void cldapd_netlogon_request(struct cldap_socket *cldap,
uint32_t message_id,
struct ldb_parse_tree *tree,
- const char *src_address, int src_port)
+ struct socket_address *src)
{
struct cldapd_server *cldapd = talloc_get_type(cldap->incoming.private, struct cldapd_server);
int i;
@@ -266,13 +266,13 @@ void cldapd_netlogon_request(struct cldap_socket *cldap,
domain, host, user, version, domain_guid));
status = cldapd_netlogon_fill(cldapd, tmp_ctx, domain, domain_guid,
- user, src_address,
+ user, src->addr,
version, &netlogon);
if (!NT_STATUS_IS_OK(status)) {
goto failed;
}
- status = cldap_netlogon_reply(cldap, message_id, src_address, src_port, version,
+ status = cldap_netlogon_reply(cldap, message_id, src, version,
&netlogon);
if (!NT_STATUS_IS_OK(status)) {
goto failed;
@@ -285,5 +285,5 @@ failed:
DEBUG(2,("cldap netlogon query failed domain=%s host=%s version=%d - %s\n",
domain, host, version, nt_errstr(status)));
talloc_free(tmp_ctx);
- cldap_empty_reply(cldap, message_id, src_address, src_port);
+ cldap_empty_reply(cldap, message_id, src);
}