]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli/nbt: add nbt_name_send_raw()
authorStefan Metzmacher <metze@samba.org>
Thu, 15 Feb 2024 16:47:13 +0000 (17:47 +0100)
committerStefan Metzmacher <metze@samba.org>
Fri, 5 Apr 2024 12:24:41 +0000 (12:24 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15620

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
libcli/nbt/libnbt.h
libcli/nbt/nbtsocket.c

index 204484be73f6f41dfb31d8faff72d6640c52d8d2..6a30c9fedb51a7ee7a08486441e2c02ade4fc7cb 100644 (file)
@@ -331,6 +331,9 @@ 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);
+NTSTATUS nbt_name_send_raw(struct nbt_name_socket *nbtsock,
+                          struct socket_address *dest,
+                          const DATA_BLOB pkt_blob);
 NTSTATUS nbt_name_reply_send(struct nbt_name_socket *nbtsock,
                             struct socket_address *dest,
                             struct nbt_name_packet *request);
index 47e73cf2e8d22d496476605c964fc2caa906c2ba..b2945ad912f9bf41ebd58c731ab19c9c36a4d6f8 100644 (file)
@@ -448,6 +448,50 @@ failed:
        return NULL;
 }
 
+/*
+  send off a nbt name packet
+*/
+_PUBLIC_ NTSTATUS nbt_name_send_raw(struct nbt_name_socket *nbtsock,
+                                   struct socket_address *dest,
+                                   const DATA_BLOB pkt_blob)
+{
+       struct nbt_name_request *req;
+
+       req = talloc_zero(nbtsock, struct nbt_name_request);
+       NT_STATUS_HAVE_NO_MEMORY(req);
+
+       req->nbtsock = nbtsock;
+       req->dest = socket_address_copy(req, dest);
+       if (req->dest == NULL) {
+               goto failed;
+       }
+       req->state = NBT_REQUEST_SEND;
+       /*
+        * We don't expect a response so
+        * just pretent it is a request,
+        * but we really don't care about the
+        * content.
+        */
+       req->is_reply = true;
+
+       req->encoded = data_blob_dup_talloc(req, pkt_blob);
+       if (req->encoded.length != pkt_blob.length) {
+               goto failed;
+       }
+
+       talloc_set_destructor(req, nbt_name_request_destructor);
+
+       DLIST_ADD_END(nbtsock->send_queue, req);
+
+       TEVENT_FD_WRITEABLE(nbtsock->fde);
+
+       return NT_STATUS_OK;
+
+failed:
+       talloc_free(req);
+       return NT_STATUS_NO_MEMORY;
+}
+
 
 /*
   send off a nbt name reply