/*
possible states for pending requests
*/
-enum nbt_request_state {NBT_REQUEST_SEND,
- NBT_REQUEST_WAIT,
+enum nbt_request_state {NBT_REQUEST_SEND,
+ NBT_REQUEST_WAIT,
NBT_REQUEST_DONE,
NBT_REQUEST_TIMEOUT,
NBT_REQUEST_ERROR};
/* is it a reply? */
bool is_reply;
-
+
/* the encoded request */
DATA_BLOB encoded;
/* what to do with incoming request packets */
struct {
- void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
+ void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
struct socket_address *);
void *private_data;
} incoming;
/* what to do with unexpected replies */
struct {
- void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
+ void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
struct socket_address *);
void *private_data;
} unexpected;
} out;
};
-struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
+struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
struct event_context *event_ctx,
struct smb_iconv_convenience *iconv_convenience);
struct nbt_name_request *nbt_name_query_send(struct nbt_name_socket *nbtsock,
struct nbt_name_query *io);
-NTSTATUS nbt_name_query_recv(struct nbt_name_request *req,
+NTSTATUS nbt_name_query_recv(struct nbt_name_request *req,
TALLOC_CTX *mem_ctx, struct nbt_name_query *io);
-NTSTATUS nbt_name_query(struct nbt_name_socket *nbtsock,
+NTSTATUS nbt_name_query(struct nbt_name_socket *nbtsock,
TALLOC_CTX *mem_ctx, struct nbt_name_query *io);
struct nbt_name_request *nbt_name_status_send(struct nbt_name_socket *nbtsock,
struct nbt_name_status *io);
-NTSTATUS nbt_name_status_recv(struct nbt_name_request *req,
+NTSTATUS nbt_name_status_recv(struct nbt_name_request *req,
TALLOC_CTX *mem_ctx, struct nbt_name_status *io);
-NTSTATUS nbt_name_status(struct nbt_name_socket *nbtsock,
+NTSTATUS nbt_name_status(struct nbt_name_socket *nbtsock,
TALLOC_CTX *mem_ctx, struct nbt_name_status *io);
NTSTATUS nbt_name_dup(TALLOC_CTX *mem_ctx, struct nbt_name *name, struct nbt_name *newname);
NTSTATUS nbt_name_from_blob(TALLOC_CTX *mem_ctx, const DATA_BLOB *blob, struct nbt_name *name);
void nbt_choose_called_name(TALLOC_CTX *mem_ctx, struct nbt_name *n, const char *name, int type);
char *nbt_name_string(TALLOC_CTX *mem_ctx, const struct nbt_name *name);
-NTSTATUS nbt_name_register(struct nbt_name_socket *nbtsock,
+NTSTATUS nbt_name_register(struct nbt_name_socket *nbtsock,
TALLOC_CTX *mem_ctx, struct nbt_name_register *io);
-NTSTATUS nbt_name_refresh(struct nbt_name_socket *nbtsock,
+NTSTATUS nbt_name_refresh(struct nbt_name_socket *nbtsock,
TALLOC_CTX *mem_ctx, struct nbt_name_refresh *io);
-NTSTATUS nbt_name_release(struct nbt_name_socket *nbtsock,
+NTSTATUS nbt_name_release(struct nbt_name_socket *nbtsock,
TALLOC_CTX *mem_ctx, struct nbt_name_release *io);
NTSTATUS nbt_name_register_wins(struct nbt_name_socket *nbtsock,
TALLOC_CTX *mem_ctx,
NTSTATUS nbt_name_refresh_wins(struct nbt_name_socket *nbtsock,
TALLOC_CTX *mem_ctx,
struct nbt_name_refresh_wins *io);
-NTSTATUS nbt_name_register_recv(struct nbt_name_request *req,
+NTSTATUS nbt_name_register_recv(struct nbt_name_request *req,
TALLOC_CTX *mem_ctx, struct nbt_name_register *io);
struct nbt_name_request *nbt_name_register_send(struct nbt_name_socket *nbtsock,
struct nbt_name_register *io);
-NTSTATUS nbt_name_release_recv(struct nbt_name_request *req,
+NTSTATUS nbt_name_release_recv(struct nbt_name_request *req,
TALLOC_CTX *mem_ctx, struct nbt_name_release *io);
struct nbt_name_request *nbt_name_release_send(struct nbt_name_socket *nbtsock,
struct nbt_name_release *io);
-NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req,
+NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req,
TALLOC_CTX *mem_ctx, struct nbt_name_refresh *io);
NTSTATUS nbt_set_incoming_handler(struct nbt_name_socket *nbtsock,
- void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
+ void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
struct socket_address *),
void *private_data);
-NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
+NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
struct socket_address *dest,
struct nbt_name_packet *request);
-/*
+/*
Unix SMB/CIFS implementation.
make nbt name query requests
Copyright (C) Andrew Tridgell 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
-#include "libcli/nbt/libnbt.h"
-#include "libcli/nbt/nbt_proto.h"
+#include "../libcli/nbt/libnbt.h"
+#include "../libcli/nbt/nbt_proto.h"
#include "lib/socket/socket.h"
#include "param/param.h"
failed:
talloc_free(packet);
- return NULL;
+ return NULL;
}
/**
wait for a name query reply
*/
-_PUBLIC_ NTSTATUS nbt_name_query_recv(struct nbt_name_request *req,
+_PUBLIC_ NTSTATUS nbt_name_query_recv(struct nbt_name_request *req,
TALLOC_CTX *mem_ctx, struct nbt_name_query *io)
{
NTSTATUS status;
talloc_free(req);
return status;
}
-
+
packet = req->replies[0].packet;
io->out.reply_from = talloc_steal(mem_ctx, req->replies[0].dest->addr);
talloc_free(req);
return NT_STATUS_NO_MEMORY;
}
-
+
for (i=0;i<io->out.num_addrs;i++) {
- io->out.reply_addrs[i] = talloc_steal(io->out.reply_addrs,
+ io->out.reply_addrs[i] = talloc_steal(io->out.reply_addrs,
packet->answers[0].rdata.netbios.addresses[i].ipaddr);
}
io->out.reply_addrs[i] = NULL;
talloc_steal(mem_ctx, io->out.name.name);
talloc_steal(mem_ctx, io->out.name.scope);
-
+
talloc_free(req);
return NT_STATUS_OK;
/**
wait for a name query reply
*/
-_PUBLIC_ NTSTATUS nbt_name_query(struct nbt_name_socket *nbtsock,
+_PUBLIC_ NTSTATUS nbt_name_query(struct nbt_name_socket *nbtsock,
TALLOC_CTX *mem_ctx, struct nbt_name_query *io)
{
struct nbt_name_request *req = nbt_name_query_send(nbtsock, io);
failed:
talloc_free(packet);
- return NULL;
+ return NULL;
}
/**
wait for a name status reply
*/
-_PUBLIC_ NTSTATUS nbt_name_status_recv(struct nbt_name_request *req,
+_PUBLIC_ NTSTATUS nbt_name_status_recv(struct nbt_name_request *req,
TALLOC_CTX *mem_ctx, struct nbt_name_status *io)
{
NTSTATUS status;
talloc_free(req);
return status;
}
-
+
packet = req->replies[0].packet;
io->out.reply_from = talloc_steal(mem_ctx, req->replies[0].dest->addr);
talloc_steal(io->out.status.names, io->out.status.names[i].name);
}
-
+
talloc_free(req);
return NT_STATUS_OK;
/**
wait for a name status reply
*/
-_PUBLIC_ NTSTATUS nbt_name_status(struct nbt_name_socket *nbtsock,
+_PUBLIC_ NTSTATUS nbt_name_status(struct nbt_name_socket *nbtsock,
TALLOC_CTX *mem_ctx, struct nbt_name_status *io)
{
struct nbt_name_request *req = nbt_name_status_send(nbtsock, io);
-/*
+/*
Unix SMB/CIFS implementation.
send out a name refresh request
Copyright (C) Andrew Tridgell 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
-#include "libcli/nbt/libnbt.h"
-#include "libcli/nbt/nbt_proto.h"
+#include "../libcli/nbt/libnbt.h"
+#include "../libcli/nbt/nbt_proto.h"
#include "libcli/composite/composite.h"
#include "lib/socket/socket.h"
#include "param/param.h"
struct nbt_rdata_address, 1);
if (packet->additional[0].rdata.netbios.addresses == NULL) goto failed;
packet->additional[0].rdata.netbios.addresses[0].nb_flags = io->in.nb_flags;
- packet->additional[0].rdata.netbios.addresses[0].ipaddr =
+ packet->additional[0].rdata.netbios.addresses[0].ipaddr =
talloc_strdup(packet->additional, io->in.address);
- dest = socket_address_from_strings(nbtsock,
- nbtsock->sock->backend_name,
+ dest = socket_address_from_strings(nbtsock,
+ nbtsock->sock->backend_name,
io->in.dest_addr, io->in.dest_port);
if (dest == NULL) goto failed;
req = nbt_name_request_send(nbtsock, dest, packet,
failed:
talloc_free(packet);
- return NULL;
+ return NULL;
}
/*
wait for a refresh reply
*/
-_PUBLIC_ NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req,
+_PUBLIC_ NTSTATUS nbt_name_refresh_recv(struct nbt_name_request *req,
TALLOC_CTX *mem_ctx, struct nbt_name_refresh *io)
{
NTSTATUS status;
talloc_free(req);
return status;
}
-
+
packet = req->replies[0].packet;
io->out.reply_from = talloc_steal(mem_ctx, req->replies[0].dest->addr);
talloc_free(req);
return NT_STATUS_INVALID_NETWORK_RESPONSE;
}
- io->out.reply_addr = talloc_steal(mem_ctx,
+ io->out.reply_addr = talloc_steal(mem_ctx,
packet->answers[0].rdata.netbios.addresses[0].ipaddr);
talloc_steal(mem_ctx, io->out.name.name);
talloc_steal(mem_ctx, io->out.name.scope);
/*
synchronous name refresh request
*/
-_PUBLIC_ NTSTATUS nbt_name_refresh(struct nbt_name_socket *nbtsock,
+_PUBLIC_ NTSTATUS nbt_name_refresh(struct nbt_name_socket *nbtsock,
TALLOC_CTX *mem_ctx, struct nbt_name_refresh *io)
{
struct nbt_name_request *req = nbt_name_refresh_send(nbtsock, io);
{
struct composite_context *c = talloc_get_type(req->async.private_data,
struct composite_context);
- struct refresh_wins_state *state = talloc_get_type(c->private_data,
+ struct refresh_wins_state *state = talloc_get_type(c->private_data,
struct refresh_wins_state);
NTSTATUS status;
state->wins_port = io->in.wins_port;
state->wins_servers = str_list_copy(state, io->in.wins_servers);
- if (state->wins_servers == NULL ||
+ if (state->wins_servers == NULL ||
state->wins_servers[0] == NULL) goto failed;
state->addresses = str_list_copy(state, io->in.addresses);
- if (state->addresses == NULL ||
+ if (state->addresses == NULL ||
state->addresses[0] == NULL) goto failed;
state->io->in.name = io->in.name;
NTSTATUS status;
status = composite_wait(c);
if (NT_STATUS_IS_OK(status)) {
- struct refresh_wins_state *state =
+ struct refresh_wins_state *state =
talloc_get_type(c->private_data, struct refresh_wins_state);
io->out.wins_server = talloc_steal(mem_ctx, state->wins_servers[0]);
io->out.rcode = state->io->out.rcode;
-/*
+/*
Unix SMB/CIFS implementation.
send out a name registration request
Copyright (C) Andrew Tridgell 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
-#include "libcli/nbt/libnbt.h"
-#include "libcli/nbt/nbt_proto.h"
+#include "../libcli/nbt/libnbt.h"
+#include "../libcli/nbt/nbt_proto.h"
#include "libcli/composite/composite.h"
#include "lib/socket/socket.h"
#include "librpc/gen_ndr/ndr_nbt.h"
struct nbt_rdata_address, 1);
if (packet->additional[0].rdata.netbios.addresses == NULL) goto failed;
packet->additional[0].rdata.netbios.addresses[0].nb_flags = io->in.nb_flags;
- packet->additional[0].rdata.netbios.addresses[0].ipaddr =
+ packet->additional[0].rdata.netbios.addresses[0].ipaddr =
talloc_strdup(packet->additional, io->in.address);
if (packet->additional[0].rdata.netbios.addresses[0].ipaddr == NULL) goto failed;
- dest = socket_address_from_strings(packet, nbtsock->sock->backend_name,
+ dest = socket_address_from_strings(packet, nbtsock->sock->backend_name,
io->in.dest_addr, io->in.dest_port);
if (dest == NULL) goto failed;
req = nbt_name_request_send(nbtsock, dest, packet,
failed:
talloc_free(packet);
- return NULL;
+ return NULL;
}
/*
wait for a registration reply
*/
-_PUBLIC_ NTSTATUS nbt_name_register_recv(struct nbt_name_request *req,
+_PUBLIC_ NTSTATUS nbt_name_register_recv(struct nbt_name_request *req,
TALLOC_CTX *mem_ctx, struct nbt_name_register *io)
{
NTSTATUS status;
talloc_free(req);
return status;
}
-
+
packet = req->replies[0].packet;
io->out.reply_from = talloc_steal(mem_ctx, req->replies[0].dest->addr);
talloc_free(req);
return NT_STATUS_INVALID_NETWORK_RESPONSE;
}
- io->out.reply_addr = talloc_steal(mem_ctx,
+ io->out.reply_addr = talloc_steal(mem_ctx,
packet->answers[0].rdata.netbios.addresses[0].ipaddr);
talloc_steal(mem_ctx, io->out.name.name);
talloc_steal(mem_ctx, io->out.name.scope);
-
+
talloc_free(req);
return NT_STATUS_OK;
/*
synchronous name registration request
*/
-_PUBLIC_ NTSTATUS nbt_name_register(struct nbt_name_socket *nbtsock,
+_PUBLIC_ NTSTATUS nbt_name_register(struct nbt_name_socket *nbtsock,
TALLOC_CTX *mem_ctx, struct nbt_name_register *io)
{
struct nbt_name_request *req = nbt_name_register_send(nbtsock, io);
c->state = COMPOSITE_STATE_ERROR;
c->status = NT_STATUS_CONFLICTING_ADDRESSES;
DEBUG(3,("Name registration conflict from %s for %s with ip %s - rcode %d\n",
- state->io->out.reply_from,
+ state->io->out.reply_from,
nbt_name_string(state, &state->io->out.name),
state->io->out.reply_addr,
state->io->out.rcode));
{
struct composite_context *c = talloc_get_type(req->async.private_data,
struct composite_context);
- struct register_wins_state *state = talloc_get_type(c->private_data,
+ struct register_wins_state *state = talloc_get_type(c->private_data,
struct register_wins_state);
NTSTATUS status;
state->wins_port = io->in.wins_port;
state->wins_servers = str_list_copy(state, io->in.wins_servers);
- if (state->wins_servers == NULL ||
+ if (state->wins_servers == NULL ||
state->wins_servers[0] == NULL) goto failed;
state->addresses = str_list_copy(state, io->in.addresses);
- if (state->addresses == NULL ||
+ if (state->addresses == NULL ||
state->addresses[0] == NULL) goto failed;
state->io->in.name = io->in.name;
NTSTATUS status;
status = composite_wait(c);
if (NT_STATUS_IS_OK(status)) {
- struct register_wins_state *state =
+ struct register_wins_state *state =
talloc_get_type(c->private_data, struct register_wins_state);
io->out.wins_server = talloc_steal(mem_ctx, state->wins_servers[0]);
io->out.rcode = state->io->out.rcode;
-/*
+/*
Unix SMB/CIFS implementation.
send out a name release request
Copyright (C) Andrew Tridgell 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
-#include "libcli/nbt/libnbt.h"
-#include "libcli/nbt/nbt_proto.h"
+#include "../libcli/nbt/libnbt.h"
+#include "../libcli/nbt/nbt_proto.h"
#include "lib/socket/socket.h"
#include "param/param.h"
struct nbt_rdata_address, 1);
if (packet->additional[0].rdata.netbios.addresses == NULL) goto failed;
packet->additional[0].rdata.netbios.addresses[0].nb_flags = io->in.nb_flags;
- packet->additional[0].rdata.netbios.addresses[0].ipaddr =
+ packet->additional[0].rdata.netbios.addresses[0].ipaddr =
talloc_strdup(packet->additional, io->in.address);
- dest = socket_address_from_strings(packet, nbtsock->sock->backend_name,
+ dest = socket_address_from_strings(packet, nbtsock->sock->backend_name,
io->in.dest_addr, io->in.dest_port);
if (dest == NULL) goto failed;
req = nbt_name_request_send(nbtsock, dest, packet,
failed:
talloc_free(packet);
- return NULL;
+ return NULL;
}
/*
wait for a release reply
*/
-_PUBLIC_ NTSTATUS nbt_name_release_recv(struct nbt_name_request *req,
+_PUBLIC_ NTSTATUS nbt_name_release_recv(struct nbt_name_request *req,
TALLOC_CTX *mem_ctx, struct nbt_name_release *io)
{
NTSTATUS status;
talloc_free(req);
return status;
}
-
+
packet = req->replies[0].packet;
io->out.reply_from = talloc_steal(mem_ctx, req->replies[0].dest->addr);
talloc_free(req);
return NT_STATUS_INVALID_NETWORK_RESPONSE;
}
- io->out.reply_addr = talloc_steal(mem_ctx,
+ io->out.reply_addr = talloc_steal(mem_ctx,
packet->answers[0].rdata.netbios.addresses[0].ipaddr);
talloc_steal(mem_ctx, io->out.name.name);
talloc_steal(mem_ctx, io->out.name.scope);
/*
synchronous name release request
*/
-_PUBLIC_ NTSTATUS nbt_name_release(struct nbt_name_socket *nbtsock,
+_PUBLIC_ NTSTATUS nbt_name_release(struct nbt_name_socket *nbtsock,
TALLOC_CTX *mem_ctx, struct nbt_name_release *io)
{
struct nbt_name_request *req = nbt_name_release_send(nbtsock, io);
-/*
+/*
Unix SMB/CIFS implementation.
low level socket handling for nbt requests
Copyright (C) Andrew Tridgell 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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include "lib/events/events.h"
#include "lib/util/dlinklist.h"
-#include "libcli/nbt/libnbt.h"
+#include "../libcli/nbt/libnbt.h"
#include "lib/socket/socket.h"
#include "librpc/gen_ndr/ndr_nbt.h"
#include "param/param.h"
destroy a pending request
*/
static int nbt_name_request_destructor(struct nbt_name_request *req)
-{
+{
if (req->state == NBT_REQUEST_SEND) {
DLIST_REMOVE(req->nbtsock->send_queue, req);
}
if (req->nbtsock->send_queue == NULL) {
EVENT_FD_NOT_WRITEABLE(req->nbtsock->fde);
}
- if (req->nbtsock->num_pending == 0 &&
+ if (req->nbtsock->num_pending == 0 &&
req->nbtsock->incoming.handler == NULL) {
EVENT_FD_NOT_READABLE(req->nbtsock->fde);
}
while ((req = nbtsock->send_queue)) {
size_t len;
-
+
len = req->encoded.length;
- status = socket_sendto(nbtsock->sock, &req->encoded, &len,
+ status = socket_sendto(nbtsock->sock, &req->encoded, &len,
req->dest);
- if (NT_STATUS_IS_ERR(status)) goto failed;
+ if (NT_STATUS_IS_ERR(status)) goto failed;
if (!NT_STATUS_IS_OK(status)) {
talloc_free(tmp_ctx);
static void nbt_name_socket_timeout(struct event_context *ev, struct timed_event *te,
struct timeval t, void *private)
{
- struct nbt_name_request *req = talloc_get_type(private,
+ struct nbt_name_request *req = talloc_get_type(private,
struct nbt_name_request);
if (req->num_retries != 0) {
req->num_retries--;
- req->te = event_add_timed(req->nbtsock->event_ctx, req,
+ req->te = event_add_timed(req->nbtsock->event_ctx, req,
timeval_add(&t, req->timeout, 0),
nbt_name_socket_timeout, req);
if (req->state != NBT_REQUEST_SEND) {
req->state = NBT_REQUEST_SEND;
- DLIST_ADD_END(req->nbtsock->send_queue, req,
+ DLIST_ADD_END(req->nbtsock->send_queue, req,
struct nbt_name_request *);
}
EVENT_FD_WRITEABLE(req->nbtsock->fde);
}
if (DEBUGLVL(10)) {
- DEBUG(10,("Received nbt packet of length %d from %s:%d\n",
+ DEBUG(10,("Received nbt packet of length %d from %s:%d\n",
(int)blob.length, src->addr, src->port));
NDR_PRINT_DEBUG(nbt_name_packet, packet);
}
}
/* find the matching request */
- req = (struct nbt_name_request *)idr_find(nbtsock->idr,
+ req = (struct nbt_name_request *)idr_find(nbtsock->idr,
packet->name_trn_id);
if (req == NULL) {
if (nbtsock->unexpected.handler) {
req->num_retries = 0;
req->received_wack = true;
/* although there can be a timeout in the packet, w2k3 screws it up,
- so better to set it ourselves */
+ so better to set it ourselves */
req->timeout = lp_parm_int(global_loadparm, NULL, "nbt", "wack_timeout", 30);
- req->te = event_add_timed(req->nbtsock->event_ctx, req,
+ req->te = event_add_timed(req->nbtsock->event_ctx, req,
timeval_current_ofs(req->timeout, 0),
nbt_name_socket_timeout, req);
talloc_free(tmp_ctx);
return;
}
-
+
req->replies = talloc_realloc(req, req->replies, struct nbt_name_reply, req->num_replies+1);
if (req->replies == NULL) {
static void nbt_name_socket_handler(struct event_context *ev, struct fd_event *fde,
uint16_t flags, void *private)
{
- struct nbt_name_socket *nbtsock = talloc_get_type(private,
+ struct nbt_name_socket *nbtsock = talloc_get_type(private,
struct nbt_name_socket);
if (flags & EVENT_FD_WRITE) {
nbt_name_socket_send(nbtsock);
- }
+ }
if (flags & EVENT_FD_READ) {
nbt_name_socket_recv(nbtsock);
}
initialise a nbt_name_socket. The event_ctx is optional, if provided
then operations will use that event context
*/
-_PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
+_PUBLIC_ struct nbt_name_socket *nbt_name_socket_init(TALLOC_CTX *mem_ctx,
struct event_context *event_ctx,
struct smb_iconv_convenience *iconv_convenience)
{
nbtsock->unexpected.handler = NULL;
nbtsock->iconv_convenience = iconv_convenience;
- nbtsock->fde = event_add_fd(nbtsock->event_ctx, nbtsock,
+ nbtsock->fde = event_add_fd(nbtsock->event_ctx, nbtsock,
socket_get_fd(nbtsock->sock), 0,
nbt_name_socket_handler, nbtsock);
-
+
return nbtsock;
failed:
/*
send off a nbt name request
*/
-struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
+struct nbt_name_request *nbt_name_request_send(struct nbt_name_socket *nbtsock,
struct socket_address *dest,
struct nbt_name_packet *request,
int timeout, int retries,
id = idr_get_new_random(req->nbtsock->idr, req, UINT16_MAX);
} else {
if (idr_find(req->nbtsock->idr, request->name_trn_id)) goto failed;
- id = idr_get_new_above(req->nbtsock->idr, req, request->name_trn_id,
+ id = idr_get_new_above(req->nbtsock->idr, req, request->name_trn_id,
UINT16_MAX);
}
if (id == -1) goto failed;
request->name_trn_id = id;
req->name_trn_id = id;
- req->te = event_add_timed(nbtsock->event_ctx, req,
+ req->te = event_add_timed(nbtsock->event_ctx, req,
timeval_current_ofs(req->timeout, 0),
nbt_name_socket_timeout, req);
-
- talloc_set_destructor(req, nbt_name_request_destructor);
- ndr_err = ndr_push_struct_blob(&req->encoded, req,
+ talloc_set_destructor(req, nbt_name_request_destructor);
+
+ ndr_err = ndr_push_struct_blob(&req->encoded, req,
req->nbtsock->iconv_convenience,
request,
(ndr_push_flags_fn_t)ndr_push_nbt_name_packet);
DLIST_ADD_END(nbtsock->send_queue, req, struct nbt_name_request *);
if (DEBUGLVL(10)) {
- DEBUG(10,("Queueing nbt packet to %s:%d\n",
+ DEBUG(10,("Queueing nbt packet to %s:%d\n",
req->dest->addr, req->dest->port));
NDR_PRINT_DEBUG(nbt_name_packet, request);
}
/*
send off a nbt name reply
*/
-_PUBLIC_ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
+_PUBLIC_ NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
struct socket_address *dest,
struct nbt_name_packet *request)
{
req->state = NBT_REQUEST_SEND;
req->is_reply = true;
- talloc_set_destructor(req, nbt_name_request_destructor);
+ talloc_set_destructor(req, nbt_name_request_destructor);
if (DEBUGLVL(10)) {
- NDR_PRINT_DEBUG(nbt_name_packet, request);
+ NDR_PRINT_DEBUG(nbt_name_packet, request);
}
- ndr_err = ndr_push_struct_blob(&req->encoded, req,
+ ndr_err = ndr_push_struct_blob(&req->encoded, req,
req->nbtsock->iconv_convenience,
request,
(ndr_push_flags_fn_t)ndr_push_nbt_name_packet);
setup a handler for incoming requests
*/
_PUBLIC_ NTSTATUS nbt_set_incoming_handler(struct nbt_name_socket *nbtsock,
- void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
+ void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
struct socket_address *),
void *private)
{
-/*
+/*
Unix SMB/CIFS implementation.
Samba utility functions
Copyright © Jelmer Vernooij <jelmer@samba.org> 2008
-
+
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 3 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, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
#include <Python.h>
#include "libcli/util/pyerrors.h"
-#include "libcli/nbt/libnbt.h"
+#include "../libcli/nbt/libnbt.h"
#include "lib/events/events.h"
#include "param/param.h"
return NULL;
ev = s4_event_context_init(ret->mem_ctx);
- ret->socket = nbt_name_socket_init(ret->mem_ctx, ev, lp_iconv_convenience(global_loadparm));
+ ret->socket = nbt_name_socket_init(ret->mem_ctx, ev, lp_iconv_convenience(global_loadparm));
return (PyObject *)ret;
}
*dest_addr = PyString_AsString(obj);
*dest_port = NBT_NAME_SERVICE_PORT;
return true;
- }
+ }
if (PyTuple_Check(obj)) {
if (PyTuple_Size(obj) < 1) {
PyErr_SetString(PyExc_TypeError, "Destination tuple size invalid");
return false;
}
-
+
if (!PyString_Check(PyTuple_GetItem(obj, 0))) {
PyErr_SetString(PyExc_TypeError, "Destination tuple first element not string");
return false;
return false;
}
-static PyObject *PyObject_FromNBTName(struct nbt_name_socket *socket, struct smb_iconv_convenience *ic,
+static PyObject *PyObject_FromNBTName(struct nbt_name_socket *socket, struct smb_iconv_convenience *ic,
struct nbt_name *name)
{
if (name->scope) {
io.in.timeout = 0;
io.in.retries = 3;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|bbii:query_name",
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|bbii:query_name",
discard_const_p(char *, kwnames),
- &py_name, &py_dest,
- &io.in.broadcast, &io.in.wins_lookup,
+ &py_name, &py_dest,
+ &io.in.broadcast, &io.in.wins_lookup,
&io.in.timeout, &io.in.retries)) {
return NULL;
}
Py_DECREF(ret);
return NULL;
}
-
+
for (i = 0; i < io.out.num_addrs; i++) {
PyList_SetItem(reply_addrs, i, PyString_FromString(io.out.reply_addrs[i]));
}
io.in.timeout = 0;
io.in.retries = 0;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|ii:name_status",
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|ii:name_status",
discard_const_p(char *, kwnames),
- &py_name, &py_dest,
+ &py_name, &py_dest,
&io.in.timeout, &io.in.retries)) {
return NULL;
}
py_names = PyList_New(io.out.status.num_names);
for (i = 0; i < io.out.status.num_names; i++) {
- PyList_SetItem(py_names, i, Py_BuildValue("(sii)",
+ PyList_SetItem(py_names, i, Py_BuildValue("(sii)",
io.out.status.names[i].name,
- io.out.status.names[i].nb_flags,
+ io.out.status.names[i].nb_flags,
io.out.status.names[i].type));
}
struct nbt_name_register io;
NTSTATUS status;
- const char *kwnames[] = { "name", "address", "dest", "register_demand", "broadcast",
+ const char *kwnames[] = { "name", "address", "dest", "register_demand", "broadcast",
"multi_homed", "ttl", "timeout", "retries", NULL };
io.in.broadcast = true;
io.in.timeout = 0;
io.in.retries = 0;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OsO|bbbiii:query_name",
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OsO|bbbiii:query_name",
discard_const_p(char *, kwnames),
- &py_name, &io.in.address, &py_dest,
- &io.in.register_demand,
- &io.in.broadcast, &io.in.multi_homed,
+ &py_name, &io.in.address, &py_dest,
+ &io.in.register_demand,
+ &io.in.broadcast, &io.in.multi_homed,
&io.in.ttl, &io.in.timeout, &io.in.retries)) {
return NULL;
}
struct nbt_name_refresh io;
NTSTATUS status;
- const char *kwnames[] = { "name", "address", "dest", "nb_flags", "broadcast",
+ const char *kwnames[] = { "name", "address", "dest", "nb_flags", "broadcast",
"ttl", "timeout", "retries", NULL };
io.in.broadcast = true;
io.in.timeout = 0;
io.in.retries = 0;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OsO|ibiii:query_name",
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OsO|ibiii:query_name",
discard_const_p(char *, kwnames),
- &py_name, &io.in.address, &py_dest,
- &io.in.nb_flags,
- &io.in.broadcast,
+ &py_name, &io.in.address, &py_dest,
+ &io.in.nb_flags,
+ &io.in.broadcast,
&io.in.ttl, &io.in.timeout, &io.in.retries)) {
return NULL;
}
}
static PyMethodDef py_nbt_methods[] = {
- { "query_name", (PyCFunction)py_nbt_name_query, METH_VARARGS|METH_KEYWORDS,
+ { "query_name", (PyCFunction)py_nbt_name_query, METH_VARARGS|METH_KEYWORDS,
"S.query_name(name, dest, broadcast=True, wins=False, timeout=0, retries=3) -> (reply_from, name, reply_addr)\n"
"Query for a NetBIOS name" },
{ "register_name", (PyCFunction)py_nbt_name_register, METH_VARARGS|METH_KEYWORDS,