handle a request timeout
*/
static void nbt_name_socket_timeout(struct tevent_context *ev, struct tevent_timer *te,
- struct timeval t, void *private)
+ struct timeval t, void *private_data)
{
- struct nbt_name_request *req = talloc_get_type(private,
+ struct nbt_name_request *req = talloc_get_type(private_data,
struct nbt_name_request);
if (req->num_retries != 0) {
return;
}
+ talloc_steal(req, packet);
+ talloc_steal(req, src);
+ talloc_free(tmp_ctx);
+ nbt_name_socket_handle_response_packet(req, packet, src);
+}
+
+void nbt_name_socket_handle_response_packet(struct nbt_name_request *req,
+ struct nbt_name_packet *packet,
+ struct socket_address *src)
+{
/* if this is a WACK response, this we need to go back to waiting,
but perhaps increase the timeout */
if ((packet->operation & NBT_OPCODE) == NBT_OPCODE_WACK) {
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;
}
/* if we don't want multiple replies then we are done */
if (req->allow_multiple_replies &&
req->num_replies < NBT_MAX_REPLIES) {
- talloc_free(tmp_ctx);
return;
}
req->status = NT_STATUS_OK;
done:
- talloc_free(tmp_ctx);
if (req->async.fn) {
req->async.fn(req);
}
handle fd events on a nbt_name_socket
*/
static void nbt_name_socket_handler(struct tevent_context *ev, struct tevent_fd *fde,
- uint16_t flags, void *private)
+ uint16_t flags, void *private_data)
{
- struct nbt_name_socket *nbtsock = talloc_get_type(private,
+ struct nbt_name_socket *nbtsock = talloc_get_type(private_data,
struct nbt_name_socket);
if (flags & EVENT_FD_WRITE) {
nbt_name_socket_send(nbtsock);
_PUBLIC_ NTSTATUS nbt_set_incoming_handler(struct nbt_name_socket *nbtsock,
void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
struct socket_address *),
- void *private)
+ void *private_data)
{
nbtsock->incoming.handler = handler;
- nbtsock->incoming.private_data = private;
+ nbtsock->incoming.private_data = private_data;
EVENT_FD_READABLE(nbtsock->fde);
return NT_STATUS_OK;
}
+/*
+ setup a handler for unexpected requests
+*/
+NTSTATUS nbt_set_unexpected_handler(struct nbt_name_socket *nbtsock,
+ void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
+ struct socket_address *),
+ void *private_data)
+{
+ nbtsock->unexpected.handler = handler;
+ nbtsock->unexpected.private_data = private_data;
+ EVENT_FD_READABLE(nbtsock->fde);
+ return NT_STATUS_OK;
+}
/*
turn a NBT rcode into a NTSTATUS