diff options
author | Andrew Bartlett <abartlet@samba.org> | 2006-01-09 22:12:53 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:49:57 -0500 |
commit | f55ea8bb3dca868e21663cd90eaea7a35cd7886c (patch) | |
tree | 80aab2a3f10310e1946821603752cd407e435214 /source4/nbt_server/dgram/request.c | |
parent | 806b3fdbc12b3284ab9872a4ecae3a7ee34ea171 (diff) | |
download | samba-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/nbt_server/dgram/request.c')
-rw-r--r-- | source4/nbt_server/dgram/request.c | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/source4/nbt_server/dgram/request.c b/source4/nbt_server/dgram/request.c index 25b08eb5cf..7a1f7c42d8 100644 --- a/source4/nbt_server/dgram/request.c +++ b/source4/nbt_server/dgram/request.c @@ -44,7 +44,7 @@ static const struct { */ void dgram_request_handler(struct nbt_dgram_socket *dgmsock, struct nbt_dgram_packet *packet, - const struct nbt_peer_socket *src) + struct socket_address *src) { DEBUG(0,("General datagram request from %s:%d\n", src->addr, src->port)); NDR_PRINT_DEBUG(nbt_dgram_packet, packet); @@ -58,37 +58,62 @@ NTSTATUS nbtd_dgram_setup(struct nbtd_interface *iface, const char *bind_address { struct nbt_dgram_socket *bcast_dgmsock; struct nbtd_server *nbtsrv = iface->nbtsrv; + struct socket_address *bcast_addr, *bind_addr; NTSTATUS status; + TALLOC_CTX *tmp_ctx = talloc_new(iface); /* the list of mailslots that we are interested in */ int i; + if (!tmp_ctx) { + return NT_STATUS_NO_MEMORY; + } + /* listen for broadcasts on port 138 */ bcast_dgmsock = nbt_dgram_socket_init(iface, nbtsrv->task->event_ctx); - NT_STATUS_HAVE_NO_MEMORY(bcast_dgmsock); + if (!bcast_dgmsock) { + talloc_free(tmp_ctx); + return NT_STATUS_NO_MEMORY; + } - status = socket_listen(bcast_dgmsock->sock, iface->bcast_address, - lp_dgram_port(), 0, 0); + bcast_addr = socket_address_from_strings(tmp_ctx, bcast_dgmsock->sock->backend_name, + iface->bcast_address, + lp_dgram_port()); + + status = socket_listen(bcast_dgmsock->sock, bcast_addr, 0, 0); if (!NT_STATUS_IS_OK(status)) { + talloc_free(tmp_ctx); DEBUG(0,("Failed to bind to %s:%d - %s\n", iface->bcast_address, lp_dgram_port(), nt_errstr(status))); return status; } + talloc_free(bcast_addr); dgram_set_incoming_handler(bcast_dgmsock, dgram_request_handler, iface); + bind_addr = socket_address_from_strings(tmp_ctx, bcast_dgmsock->sock->backend_name, + bind_address, + lp_dgram_port()); + /* listen for unicasts on port 138 */ iface->dgmsock = nbt_dgram_socket_init(iface, nbtsrv->task->event_ctx); - NT_STATUS_HAVE_NO_MEMORY(iface->dgmsock); + if (!iface->dgmsock) { + talloc_free(tmp_ctx); + return NT_STATUS_NO_MEMORY; + } - status = socket_listen(iface->dgmsock->sock, bind_address, - lp_dgram_port(), 0, 0); + status = socket_listen(iface->dgmsock->sock, bind_addr, 0, 0); if (!NT_STATUS_IS_OK(status)) { + talloc_free(tmp_ctx); DEBUG(0,("Failed to bind to %s:%d - %s\n", bind_address, lp_dgram_port(), nt_errstr(status))); return status; } + talloc_free(bind_addr); + dgram_set_incoming_handler(iface->dgmsock, dgram_request_handler, iface); + talloc_free(tmp_ctx); + for (i=0;i<ARRAY_SIZE(mailslot_handlers);i++) { /* note that we don't need to keep the pointer |