summaryrefslogtreecommitdiffstats
path: root/source4/nbt_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/nbt_server
parent806b3fdbc12b3284ab9872a4ecae3a7ee34ea171 (diff)
downloadsamba-f55ea8bb3dca868e21663cd90eaea7a35cd7886c.tar.gz
samba-f55ea8bb3dca868e21663cd90eaea7a35cd7886c.tar.xz
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')
-rw-r--r--source4/nbt_server/defense.c3
-rw-r--r--source4/nbt_server/dgram/browse.c3
-rw-r--r--source4/nbt_server/dgram/netlogon.c13
-rw-r--r--source4/nbt_server/dgram/ntlogon.c6
-rw-r--r--source4/nbt_server/dgram/request.c39
-rw-r--r--source4/nbt_server/interfaces.c31
-rw-r--r--source4/nbt_server/irpc.c13
-rw-r--r--source4/nbt_server/nodestatus.c5
-rw-r--r--source4/nbt_server/packet.c15
-rw-r--r--source4/nbt_server/query.c3
-rw-r--r--source4/nbt_server/wins/wins_dns_proxy.c14
-rw-r--r--source4/nbt_server/wins/winsserver.c40
12 files changed, 126 insertions, 59 deletions
diff --git a/source4/nbt_server/defense.c b/source4/nbt_server/defense.c
index 7811c254c05..86b3eb968b8 100644
--- a/source4/nbt_server/defense.c
+++ b/source4/nbt_server/defense.c
@@ -25,6 +25,7 @@
#include "system/network.h"
#include "nbt_server/nbt_server.h"
#include "nbt_server/wins/winsserver.h"
+#include "lib/socket/socket.h"
/*
@@ -33,7 +34,7 @@
*/
void nbtd_request_defense(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
- const struct nbt_peer_socket *src)
+ struct socket_address *src)
{
struct nbtd_iface_name *iname;
struct nbt_name *name;
diff --git a/source4/nbt_server/dgram/browse.c b/source4/nbt_server/dgram/browse.c
index 49e43eeb685..2486354052c 100644
--- a/source4/nbt_server/dgram/browse.c
+++ b/source4/nbt_server/dgram/browse.c
@@ -22,13 +22,14 @@
#include "includes.h"
#include "nbt_server/nbt_server.h"
+#include "lib/socket/socket.h"
/*
handle incoming browse mailslot requests
*/
void nbtd_mailslot_browse_handler(struct dgram_mailslot_handler *dgmslot,
struct nbt_dgram_packet *packet,
- const struct nbt_peer_socket *src)
+ struct socket_address *src)
{
DEBUG(2,("Browse request on '%s' from %s:%d\n",
dgmslot->mailslot_name, src->addr, src->port));
diff --git a/source4/nbt_server/dgram/netlogon.c b/source4/nbt_server/dgram/netlogon.c
index 858b2909573..5ba826cc336 100644
--- a/source4/nbt_server/dgram/netlogon.c
+++ b/source4/nbt_server/dgram/netlogon.c
@@ -32,7 +32,7 @@
*/
static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot,
struct nbt_dgram_packet *packet,
- const struct nbt_peer_socket *src,
+ const struct socket_address *src,
struct nbt_netlogon_packet *netlogon)
{
struct nbt_name *name = &packet->data.msg.dest_name;
@@ -90,7 +90,7 @@ static void nbtd_netlogon_getdc(struct dgram_mailslot_handler *dgmslot,
*/
static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot,
struct nbt_dgram_packet *packet,
- const struct nbt_peer_socket *src,
+ const struct socket_address *src,
struct nbt_netlogon_packet *netlogon)
{
struct nbt_name *name = &packet->data.msg.dest_name;
@@ -102,6 +102,11 @@ static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot,
struct ldb_message **ref_res, **dom_res;
int ret;
const char **services = lp_server_services();
+ struct socket_address *my_ip = socket_get_my_addr(dgmslot->dgmsock->sock, packet);
+ if (!my_ip) {
+ DEBUG(0, ("Could not obtain own IP address for datagram socket\n"));
+ return;
+ }
/* only answer getdc requests on the PDC or LOGON names */
if (name->type != NBT_NAME_PDC && name->type != NBT_NAME_LOGON) {
@@ -181,7 +186,7 @@ static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot,
pdc->site_name2 = "Default-First-Site-Name";
pdc->unknown = 0x10; /* what is this? */
pdc->unknown2 = 2; /* and this ... */
- pdc->pdc_ip = socket_get_my_addr(dgmslot->dgmsock->sock, packet);
+ pdc->pdc_ip = my_ip->addr;
pdc->nt_version = 13;
pdc->lmnt_token = 0xFFFF;
pdc->lm20_token = 0xFFFF;
@@ -200,7 +205,7 @@ static void nbtd_netlogon_getdc2(struct dgram_mailslot_handler *dgmslot,
*/
void nbtd_mailslot_netlogon_handler(struct dgram_mailslot_handler *dgmslot,
struct nbt_dgram_packet *packet,
- const struct nbt_peer_socket *src)
+ struct socket_address *src)
{
NTSTATUS status = NT_STATUS_NO_MEMORY;
struct nbtd_interface *iface =
diff --git a/source4/nbt_server/dgram/ntlogon.c b/source4/nbt_server/dgram/ntlogon.c
index 191bac8a54a..dad80fbe7d7 100644
--- a/source4/nbt_server/dgram/ntlogon.c
+++ b/source4/nbt_server/dgram/ntlogon.c
@@ -22,14 +22,14 @@
#include "includes.h"
#include "nbt_server/nbt_server.h"
-
+#include "lib/socket/socket.h"
/*
reply to a SAM LOGON request
*/
static void nbtd_ntlogon_sam_logon(struct dgram_mailslot_handler *dgmslot,
struct nbt_dgram_packet *packet,
- const struct nbt_peer_socket *src,
+ const struct socket_address *src,
struct nbt_ntlogon_packet *ntlogon)
{
struct nbt_name *name = &packet->data.msg.dest_name;
@@ -66,7 +66,7 @@ static void nbtd_ntlogon_sam_logon(struct dgram_mailslot_handler *dgmslot,
*/
void nbtd_mailslot_ntlogon_handler(struct dgram_mailslot_handler *dgmslot,
struct nbt_dgram_packet *packet,
- const struct nbt_peer_socket *src)
+ struct socket_address *src)
{
NTSTATUS status = NT_STATUS_NO_MEMORY;
struct nbtd_interface *iface =
diff --git a/source4/nbt_server/dgram/request.c b/source4/nbt_server/dgram/request.c
index 25b08eb5cf9..7a1f7c42d8d 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
diff --git a/source4/nbt_server/interfaces.c b/source4/nbt_server/interfaces.c
index 41a27fdeb0c..10bdc0bb14e 100644
--- a/source4/nbt_server/interfaces.c
+++ b/source4/nbt_server/interfaces.c
@@ -33,7 +33,7 @@
*/
static void nbtd_request_handler(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
- const struct nbt_peer_socket *src)
+ struct socket_address *src)
{
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
struct nbtd_interface);
@@ -102,6 +102,8 @@ static NTSTATUS nbtd_add_socket(struct nbtd_server *nbtsrv,
{
struct nbtd_interface *iface;
NTSTATUS status;
+ struct socket_address *bcast_address;
+ struct socket_address *unicast_address;
/*
we actually create two sockets. One listens on the broadcast address
@@ -125,30 +127,49 @@ static NTSTATUS nbtd_add_socket(struct nbtd_server *nbtsrv,
/* listen for broadcasts on port 137 */
bcast_nbtsock = nbt_name_socket_init(iface, nbtsrv->task->event_ctx);
- NT_STATUS_HAVE_NO_MEMORY(bcast_nbtsock);
+ if (!bcast_nbtsock) {
+ talloc_free(iface);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ bcast_address = socket_address_from_strings(bcast_nbtsock, bcast_nbtsock->sock->backend_name,
+ bcast, lp_nbt_port());
+ if (!bcast_address) {
+ talloc_free(iface);
+ return NT_STATUS_NO_MEMORY;
+ }
- status = socket_listen(bcast_nbtsock->sock, bcast, lp_nbt_port(), 0, 0);
+ status = socket_listen(bcast_nbtsock->sock, bcast_address, 0, 0);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to bind to %s:%d - %s\n",
bcast, lp_nbt_port(), nt_errstr(status)));
talloc_free(iface);
return status;
}
+ talloc_free(bcast_address);
nbt_set_incoming_handler(bcast_nbtsock, nbtd_request_handler, iface);
}
/* listen for unicasts on port 137 */
iface->nbtsock = nbt_name_socket_init(iface, nbtsrv->task->event_ctx);
- NT_STATUS_HAVE_NO_MEMORY(iface->nbtsock);
+ if (!iface->nbtsock) {
+ talloc_free(iface);
+ return NT_STATUS_NO_MEMORY;
+ }
- status = socket_listen(iface->nbtsock->sock, bind_address, lp_nbt_port(), 0, 0);
+ unicast_address = socket_address_from_strings(iface->nbtsock, iface->nbtsock->sock->backend_name,
+ bind_address, lp_nbt_port());
+
+ status = socket_listen(iface->nbtsock->sock, unicast_address, 0, 0);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("Failed to bind to %s:%d - %s\n",
bind_address, lp_nbt_port(), nt_errstr(status)));
talloc_free(iface);
return status;
}
+ talloc_free(unicast_address);
+
nbt_set_incoming_handler(iface->nbtsock, nbtd_request_handler, iface);
/* also setup the datagram listeners */
diff --git a/source4/nbt_server/irpc.c b/source4/nbt_server/irpc.c
index b3b168a8c0d..8b9c4cfcaac 100644
--- a/source4/nbt_server/irpc.c
+++ b/source4/nbt_server/irpc.c
@@ -25,6 +25,7 @@
#include "smbd/service_task.h"
#include "nbt_server/nbt_server.h"
#include "nbt_server/wins/winsserver.h"
+#include "lib/socket/socket.h"
/*
serve out the nbt statistics
@@ -57,7 +58,7 @@ struct getdc_state {
static void getdc_recv_ntlogon_reply(struct dgram_mailslot_handler *dgmslot,
struct nbt_dgram_packet *packet,
- const struct nbt_peer_socket *src)
+ struct socket_address *src)
{
struct getdc_state *s =
talloc_get_type(dgmslot->private, struct getdc_state);
@@ -120,7 +121,7 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg,
struct nbt_ntlogon_packet p;
struct nbt_ntlogon_sam_logon *r;
struct nbt_name src, dst;
- struct nbt_peer_socket dest;
+ struct socket_address *dest;
struct dgram_mailslot_handler *handler;
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
@@ -152,10 +153,12 @@ static NTSTATUS nbtd_getdcname(struct irpc_message *msg,
make_nbt_name_client(&src, req->in.my_computername);
make_nbt_name(&dst, req->in.domainname, 0x1c);
- dest.addr = req->in.ip_address;
- dest.port = 138;
+ dest = socket_address_from_strings(msg, iface->dgmsock->sock->backend_name,
+ req->in.ip_address, 138);
+ NT_STATUS_HAVE_NO_MEMORY(dest);
+
status = dgram_mailslot_ntlogon_send(iface->dgmsock, DGRAM_DIRECT_GROUP,
- &dst, &dest,
+ &dst, dest,
&src, &p);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("dgram_mailslot_ntlogon_send failed: %s\n",
diff --git a/source4/nbt_server/nodestatus.c b/source4/nbt_server/nodestatus.c
index efd4720790b..140451d74af 100644
--- a/source4/nbt_server/nodestatus.c
+++ b/source4/nbt_server/nodestatus.c
@@ -24,13 +24,14 @@
#include "dlinklist.h"
#include "system/network.h"
#include "nbt_server/nbt_server.h"
+#include "lib/socket/socket.h"
/*
send a name status reply
*/
static void nbtd_node_status_reply(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *request_packet,
- const struct nbt_peer_socket *src,
+ struct socket_address *src,
struct nbt_name *name,
struct nbtd_interface *iface)
{
@@ -99,7 +100,7 @@ failed:
*/
void nbtd_query_status(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
- const struct nbt_peer_socket *src)
+ struct socket_address *src)
{
struct nbt_name *name;
struct nbtd_iface_name *iname;
diff --git a/source4/nbt_server/packet.c b/source4/nbt_server/packet.c
index d7211c8ca4d..8909d7bbc44 100644
--- a/source4/nbt_server/packet.c
+++ b/source4/nbt_server/packet.c
@@ -22,12 +22,13 @@
#include "includes.h"
#include "nbt_server/nbt_server.h"
+#include "lib/socket/socket.h"
/*
we received a badly formed packet - log it
*/
void nbtd_bad_packet(struct nbt_name_packet *packet,
- const struct nbt_peer_socket *src, const char *reason)
+ const struct socket_address *src, const char *reason)
{
DEBUG(2,("nbtd: bad packet '%s' from %s:%d\n", reason, src->addr, src->port));
if (DEBUGLVL(5)) {
@@ -42,7 +43,7 @@ void nbtd_bad_packet(struct nbt_name_packet *packet,
*/
BOOL nbtd_self_packet(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
- const struct nbt_peer_socket *src)
+ const struct socket_address *src)
{
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
struct nbtd_interface);
@@ -82,7 +83,7 @@ BOOL nbtd_self_packet(struct nbt_name_socket *nbtsock,
*/
void nbtd_name_query_reply(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *request_packet,
- const struct nbt_peer_socket *src,
+ struct socket_address *src,
struct nbt_name *name, uint32_t ttl,
uint16_t nb_flags, const char **addresses)
{
@@ -146,7 +147,7 @@ failed:
*/
void nbtd_negative_name_query_reply(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *request_packet,
- const struct nbt_peer_socket *src)
+ struct socket_address *src)
{
struct nbt_name_packet *packet;
struct nbt_name *name = &request_packet->questions[0].name;
@@ -189,7 +190,7 @@ failed:
*/
void nbtd_name_registration_reply(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *request_packet,
- const struct nbt_peer_socket *src,
+ struct socket_address *src,
uint8_t rcode)
{
struct nbt_name_packet *packet;
@@ -237,7 +238,7 @@ failed:
*/
void nbtd_name_release_reply(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *request_packet,
- const struct nbt_peer_socket *src,
+ struct socket_address *src,
uint8_t rcode)
{
struct nbt_name_packet *packet;
@@ -283,7 +284,7 @@ failed:
*/
void nbtd_wack_reply(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *request_packet,
- const struct nbt_peer_socket *src,
+ struct socket_address *src,
uint32_t ttl)
{
struct nbt_name_packet *packet;
diff --git a/source4/nbt_server/query.c b/source4/nbt_server/query.c
index 793e4671d52..078a876c8e7 100644
--- a/source4/nbt_server/query.c
+++ b/source4/nbt_server/query.c
@@ -25,13 +25,14 @@
#include "system/network.h"
#include "nbt_server/nbt_server.h"
#include "nbt_server/wins/winsserver.h"
+#include "lib/socket/socket.h"
/*
answer a name query
*/
void nbtd_request_query(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
- const struct nbt_peer_socket *src)
+ struct socket_address *src)
{
struct nbtd_iface_name *iname;
struct nbt_name *name;
diff --git a/source4/nbt_server/wins/wins_dns_proxy.c b/source4/nbt_server/wins/wins_dns_proxy.c
index 23dfa19cc66..540f4e2c380 100644
--- a/source4/nbt_server/wins/wins_dns_proxy.c
+++ b/source4/nbt_server/wins/wins_dns_proxy.c
@@ -31,7 +31,7 @@
struct wins_dns_proxy_state {
struct nbt_name_socket *nbtsock;
struct nbt_name_packet *packet;
- struct nbt_peer_socket src;
+ struct socket_address *src;
};
static void nbtd_wins_dns_proxy_handler(struct composite_context *creq)
@@ -53,11 +53,11 @@ static void nbtd_wins_dns_proxy_handler(struct composite_context *creq)
talloc_steal(s->packet, addresses);
if (!addresses) goto notfound;
- nbtd_name_query_reply(s->nbtsock, s->packet, &s->src, name,
+ nbtd_name_query_reply(s->nbtsock, s->packet, s->src, name,
0, nb_flags, addresses);
return;
notfound:
- nbtd_negative_name_query_reply(s->nbtsock, s->packet, &s->src);
+ nbtd_negative_name_query_reply(s->nbtsock, s->packet, s->src);
}
/*
@@ -65,7 +65,7 @@ notfound:
*/
void nbtd_wins_dns_proxy_query(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
- const struct nbt_peer_socket *src)
+ struct socket_address *src)
{
struct nbt_name *name = &packet->questions[0].name;
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
@@ -81,8 +81,10 @@ void nbtd_wins_dns_proxy_query(struct nbt_name_socket *nbtsock,
if (!s) goto failed;
s->nbtsock = nbtsock;
s->packet = talloc_steal(s, packet);
- s->src = *src;
- talloc_steal(s, src->addr);
+ s->src = src;
+ if (!talloc_reference(s, src)) {
+ goto failed;
+ }
creq = resolve_name_send(name, iface->nbtsrv->task->event_ctx, methods);
if (!creq) goto failed;
diff --git a/source4/nbt_server/wins/winsserver.c b/source4/nbt_server/wins/winsserver.c
index 98ae6139058..8760ffe922c 100644
--- a/source4/nbt_server/wins/winsserver.c
+++ b/source4/nbt_server/wins/winsserver.c
@@ -28,6 +28,7 @@
#include "system/time.h"
#include "libcli/composite/composite.h"
#include "smbd/service_task.h"
+#include "lib/socket/socket.h"
/*
work out the ttl we will use given a client requested ttl
@@ -59,7 +60,7 @@ static enum wrepl_name_type wrepl_type(uint16_t nb_flags, struct nbt_name *name,
*/
static uint8_t wins_register_new(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
- const struct nbt_peer_socket *src,
+ const struct socket_address *src,
enum wrepl_name_type type)
{
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
@@ -109,7 +110,7 @@ static uint8_t wins_update_ttl(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
struct winsdb_record *rec,
struct winsdb_addr *winsdb_addr,
- const struct nbt_peer_socket *src)
+ const struct socket_address *src)
{
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
struct nbtd_interface);
@@ -143,7 +144,7 @@ static uint8_t wins_sgroup_merge(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
struct winsdb_record *rec,
const char *address,
- const struct nbt_peer_socket *src)
+ const struct socket_address *src)
{
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
struct nbtd_interface);
@@ -170,7 +171,7 @@ struct wack_state {
struct nbt_name_socket *nbtsock;
struct nbt_name_packet *request_packet;
struct winsdb_record *rec;
- struct nbt_peer_socket src;
+ struct socket_address *src;
const char *reg_address;
enum wrepl_name_type new_type;
struct wins_challenge_io io;
@@ -183,9 +184,9 @@ struct wack_state {
static void wins_wack_deny(struct wack_state *s)
{
nbtd_name_registration_reply(s->nbtsock, s->request_packet,
- &s->src, NBT_RCODE_ACT);
+ s->src, NBT_RCODE_ACT);
DEBUG(4,("WINS: denied name registration request for %s from %s:%d\n",
- nbt_name_string(s, s->rec->name), s->src.addr, s->src.port));
+ nbt_name_string(s, s->rec->name), s->src->addr, s->src->port));
talloc_free(s);
}
@@ -217,7 +218,7 @@ static void wins_wack_allow(struct wack_state *s)
uint8_t rcode;
winsdb_delete(s->winssrv->wins_db, rec);
- rcode = wins_register_new(s->nbtsock, s->request_packet, &s->src, s->new_type);
+ rcode = wins_register_new(s->nbtsock, s->request_packet, s->src, s->new_type);
if (rcode != NBT_RCODE_OK) {
DEBUG(1,("WINS: record %s failed to register as new during WACK\n",
nbt_name_string(s, rec->name)));
@@ -228,7 +229,7 @@ static void wins_wack_allow(struct wack_state *s)
}
rec->expire_time = time(NULL) + ttl;
- rec->registered_by = s->src.addr;
+ rec->registered_by = s->src->addr;
/*
* now remove all addresses that're the client doesn't hold anymore
@@ -269,7 +270,7 @@ static void wins_wack_allow(struct wack_state *s)
done:
nbtd_name_registration_reply(s->nbtsock, s->request_packet,
- &s->src, NBT_RCODE_OK);
+ s->src, NBT_RCODE_OK);
failed:
talloc_free(s);
}
@@ -332,7 +333,7 @@ static void wack_wins_challenge_handler(struct composite_context *c_req)
static void wins_register_wack(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
struct winsdb_record *rec,
- const struct nbt_peer_socket *src,
+ struct socket_address *src,
enum wrepl_name_type new_type)
{
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
@@ -352,9 +353,8 @@ static void wins_register_wack(struct nbt_name_socket *nbtsock,
s->rec = talloc_steal(s, rec);
s->reg_address = packet->additional[0].rdata.netbios.addresses[0].ipaddr;
s->new_type = new_type;
- s->src.port = src->port;
- s->src.addr = talloc_strdup(s, src->addr);
- if (s->src.addr == NULL) goto failed;
+ s->src = src;
+ if (talloc_reference(s, src) == NULL) goto failed;
s->io.in.nbtd_server = iface->nbtsrv;
s->io.in.event_ctx = iface->nbtsrv->task->event_ctx;
@@ -390,7 +390,7 @@ failed:
*/
static void nbtd_winsserver_register(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
- const struct nbt_peer_socket *src)
+ struct socket_address *src)
{
NTSTATUS status;
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
@@ -548,7 +548,7 @@ done:
*/
static void nbtd_winsserver_query(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
- const struct nbt_peer_socket *src)
+ struct socket_address *src)
{
NTSTATUS status;
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
@@ -656,7 +656,7 @@ notfound:
*/
static void nbtd_winsserver_release(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
- const struct nbt_peer_socket *src)
+ struct socket_address *src)
{
NTSTATUS status;
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
@@ -699,6 +699,12 @@ static void nbtd_winsserver_release(struct nbt_name_socket *nbtsock,
* silently ignored
*/
if (!winsdb_addr_list_check(rec->addresses, src->addr)) {
+ int i;
+ DEBUG(4,("WINS: silently ignoring attempted name release on %s from %s\n", nbt_name_string(rec, rec->name), src->addr));
+ DEBUGADD(4, ("Registered Addressss: \n"));
+ for (i=0; rec->addresses && rec->addresses[i]; i++) {
+ DEBUGADD(4, ("%s\n", rec->addresses[i]->address));
+ }
goto done;
}
@@ -766,7 +772,7 @@ done:
*/
void nbtd_winsserver_request(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
- const struct nbt_peer_socket *src)
+ struct socket_address *src)
{
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
struct nbtd_interface);