summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-06-07 22:09:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:17:48 -0500
commit7c9d76d30c0f89f926744941ba3e0e6dbb24975c (patch)
treef904199fd09b036ece965345c1231961556bce48
parentc6a3ee8baba002d7568d17fb0bc73908eb4da2e7 (diff)
downloadsamba-7c9d76d30c0f89f926744941ba3e0e6dbb24975c.tar.gz
samba-7c9d76d30c0f89f926744941ba3e0e6dbb24975c.tar.bz2
samba-7c9d76d30c0f89f926744941ba3e0e6dbb24975c.zip
r7377: Integrate browse service stuff more nicely
Add notes on mailslots Add TODO list for pidl, including some plans on switching over to using [string] attributes for pidl. (This used to be commit fca195ce072bacb0543625aec7f4bce814e278eb)
-rw-r--r--source4/build/pidl/TODO27
-rw-r--r--source4/libcli/config.mk3
-rw-r--r--source4/libcli/dgram/browse.c98
-rw-r--r--source4/libcli/dgram/mailslot.c16
-rw-r--r--source4/librpc/idl/browse.idl111
-rw-r--r--source4/librpc/idl/nbt.idl102
6 files changed, 243 insertions, 114 deletions
diff --git a/source4/build/pidl/TODO b/source4/build/pidl/TODO
new file mode 100644
index 0000000000..2f45c2d11a
--- /dev/null
+++ b/source4/build/pidl/TODO
@@ -0,0 +1,27 @@
+- Fix string support.
+ This would make strings a special kind of arrays flagged by the
+ [string] attribute. Pidl itself would support a couple of extra
+ attributes for it's own use while being compatible with other IDL
+ compilers.
+ Proposed extensions for pidl:
+ [convert(t)] attribute for forcing conversions from CH_UCS2, etc to UTF8
+ [noterm] attribute
+ [nullterm] attribute
+
+The various flags for strings would change as follows:
+
+LIBNDR_FLAG_STR_ASCII -> [convert(CH_ASCII)]
+LIBNDR_FLAG_STR_LEN4 -> optionally [length_is()]
+LIBNDR_FLAG_STR_SIZE4 -> [size_is()] or if needed [conformant]
+LIBNDR_FLAG_STR_NOTERM -> [noterm]
+LIBNDR_FLAG_STR_NULLTERM -> [nullterm]
+LIBNDR_FLAG_STR_SIZE2 -> uint16 length; [string] char data[length]
+LIBNDR_FLAG_STR_BYTESIZE -> ???
+LIBNDR_FLAG_STR_FIXLEN32 -> [32]
+LIBNDR_FLAG_STR_CONFORMANT -> no longer needed
+LIBNDR_FLAG_STR_CHARLEN -> ???
+LIBNDR_FLAG_STR_UTF8 -> Nothing (but UCS2 has [convert(CH_UCS2)]
+LIBNDR_FLAG_STR_FIXLEN15 -> [15]
+
+- True multiple dimension array / strings in arrays support (closely related to
+ things specified above)
diff --git a/source4/libcli/config.mk b/source4/libcli/config.mk
index 82796f4246..11e54498cf 100644
--- a/source4/libcli/config.mk
+++ b/source4/libcli/config.mk
@@ -43,7 +43,8 @@ ADD_OBJ_FILES = \
libcli/dgram/dgramsocket.o \
libcli/dgram/mailslot.o \
libcli/dgram/netlogon.o \
- libcli/dgram/ntlogon.o
+ libcli/dgram/ntlogon.o \
+ libcli/dgram/browse.o
NOPROTO=YES
REQUIRED_SUBSYSTEMS = LIBCLI_NBT
diff --git a/source4/libcli/dgram/browse.c b/source4/libcli/dgram/browse.c
new file mode 100644
index 0000000000..d7707b7ec8
--- /dev/null
+++ b/source4/libcli/dgram/browse.c
@@ -0,0 +1,98 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ handling for browsing dgram requests
+
+ Copyright (C) Jelmer Vernooij 2005
+ Heavily based on ntlogon.c
+
+ 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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "lib/events/events.h"
+#include "libcli/nbt/libnbt.h"
+#include "libcli/dgram/libdgram.h"
+#include "lib/socket/socket.h"
+#include "librpc/gen_ndr/ndr_nbt.h"
+
+NTSTATUS dgram_mailslot_browse_send(struct nbt_dgram_socket *dgmsock,
+ struct nbt_name *dest_name, const char *dest_address, int dest_port,
+ struct nbt_name *src_name, struct nbt_browse_packet *request)
+{
+ NTSTATUS status;
+ DATA_BLOB blob;
+ TALLOC_CTX *tmp_ctx = talloc_new(dgmsock);
+
+ status = ndr_push_struct_blob(&blob, tmp_ctx, request,
+ (ndr_push_flags_fn_t)ndr_push_nbt_browse_packet);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(tmp_ctx);
+ return status;
+ }
+
+ status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE,
+ NBT_MAILSLOT_BROWSE,
+ dest_name, dest_address, dest_port,
+ src_name, &blob);
+ talloc_free(tmp_ctx);
+ return status;
+}
+
+NTSTATUS dgram_mailslot_browse_reply(struct nbt_dgram_socket *dgmsock,
+ struct nbt_dgram_packet *request, const char *mailslot_name,
+ struct nbt_browse_packet *reply)
+{
+ NTSTATUS status;
+ DATA_BLOB blob;
+ TALLOC_CTX *tmp_ctx = talloc_new(dgmsock);
+ struct nbt_name myname;
+
+ status = ndr_push_struct_blob(&blob, tmp_ctx, reply,
+ (ndr_push_flags_fn_t)ndr_push_nbt_browse_packet);
+ if (!NT_STATUS_IS_OK(status)) {
+ talloc_free(tmp_ctx);
+ return status;
+ }
+
+ make_nbt_name_client(&myname, lp_netbios_name());
+
+ status = dgram_mailslot_send(dgmsock, DGRAM_DIRECT_UNIQUE,
+ mailslot_name,
+ &request->data.msg.source_name,
+ request->source, request->src_port,
+ &myname, &blob);
+ talloc_free(tmp_ctx);
+ return status;
+}
+
+NTSTATUS dgram_mailslot_browse_parse(struct dgram_mailslot_handler *dgmslot,
+ TALLOC_CTX *mem_ctx, struct nbt_dgram_packet *dgram,
+ struct nbt_browse_packet *pkt)
+{
+ DATA_BLOB data = dgram_mailslot_data(dgram);
+ NTSTATUS status;
+
+ status = ndr_pull_struct_blob(&data, mem_ctx, pkt,
+ (ndr_pull_flags_fn_t)ndr_pull_nbt_browse_packet);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("Failed to parse browse packet of length %d\n",
+ data.length));
+ if (DEBUGLVL(10)) {
+ file_save("browse.dat", data.data, data.length);
+ }
+ }
+ return status;
+}
diff --git a/source4/libcli/dgram/mailslot.c b/source4/libcli/dgram/mailslot.c
index 9f02210646..14e7e49fc1 100644
--- a/source4/libcli/dgram/mailslot.c
+++ b/source4/libcli/dgram/mailslot.c
@@ -1,8 +1,8 @@
/*
Unix SMB/CIFS implementation.
- packet handling for mailslot requests
-
+ packet handling for mailslot requests.
+
Copyright (C) Andrew Tridgell 2005
This program is free software; you can redistribute it and/or modify
@@ -20,6 +20,18 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+/*
+ This implements "Class 2 mailslots", i.e. the communication mechanism
+ used for all mailslot packets smaller then 425 bytes.
+
+ "Class 1 mailslots" (which use SMB) are used for messages larger
+ then 426 bytes and are supported on some systems. These are not implemented
+ in Samba4 yet, as there don't appear to be any core services that use
+ them.
+
+ 425 and 426-byte sized messages are not supported at all.
+*/
+
#include "includes.h"
#include "lib/events/events.h"
#include "dlinklist.h"
diff --git a/source4/librpc/idl/browse.idl b/source4/librpc/idl/browse.idl
deleted file mode 100644
index b957e0dc62..0000000000
--- a/source4/librpc/idl/browse.idl
+++ /dev/null
@@ -1,111 +0,0 @@
-#include "idl_types.h"
-
-/*
- IDL structures for Browse service over mailslot operations
-*/
-
-[ uuid("1-2-3-4"),
- depends(security)
-] interface browse
-{
- const string browse_mailslot = "\\MAILSLOT\\BROWSE";
-
- typedef enum {
- HostAnnouncement = 1,
- AnnouncementRequest = 2,
- Election = 8,
- GetBackupListReq = 9,
- GetBackupListResp = 10,
- BecomeBackup = 11,
- DomainAnnouncment = 12,
- MasterAnnouncement = 13,
- ResetBrowserState = 14,
- LocalMasterAnnouncement = 15
- } brow_opcodes;
-
- typedef bitmap {
- SV_TYPE_WORKSTATION = 0x00000001,
- SV_TYPE_SERVER = 0x00000002,
- SV_TYPE_SQLSERVER = 0x00000004,
- SV_TYPE_DOMAIN_CTRL = 0x00000008,
- SV_TYPE_DOMAIN_BAKCTRL = 0x00000010,
- SV_TYPE_TIME_SOURCE = 0x00000020,
- SV_TYPE_AFP = 0x00000040,
- SV_TYPE_NOVELL = 0x00000080,
- SV_TYPE_DOMAIN_MEMBER = 0x00000100,
- SV_TYPE_PRINTQ_SERVER = 0x00000200,
- SV_TYPE_DIALIN_SERVER = 0x00000400,
- SV_TYPE_XENIX_SERVER = 0x00000800,
- SV_TYPE_NT = 0x00001000,
- SV_TYPE_POTENTIAL_BROWSER = 0x00010000,
- SV_TYPE_BACKUP_BROWSER = 0x00020000,
- SV_TYPE_MASTER_BROWSER = 0x00040000,
- SV_TYPE_DOMAIN_MASTER = 0x00080000,
- SV_TYPE_LOCAL_LIST_ONLY = 0x40000000,
- SV_TYPE_DOMAIN_ENUM = 0x80000000
- } brow_server_type;
-
- typedef struct {
- uint8 update_count;
- uint32 ttl;
- char name[16];
- uint8 os_major;
- uint8 os_minor;
- uint32 server_type;
- astring comment;
- } host_announcement;
-
- typedef struct {
- uint8 unknown;
- astring ResponseComputerName;
- } request_announcement;
-
- typedef struct {
- uint8 count;
- uint32 token;
- } backup_list_request;
-
- typedef struct {
- uint8 count;
- uint32 token;
- astring BackupServerList[count];
- } backup_list_response;
-
- typedef struct {
- astring BrowserToPromote;
- } become_backup;
-
- typedef struct {
- uint8 version;
- uint32 criteria;
- uint32 time_up; /* In milliseconds */
- uint32 reserved; /* Must be zero */
- astring ServerName;
- } election_request;
-
- typedef struct {
- uint8 options;
- } reset_state;
-
- typedef struct {
- astring MasterBrowserServerName;
- } master_announcement;
-
- typedef [nodiscriminant] union {
- [case(HostAnnouncement)] host_announcement host_annoucement;
- [case(AnnouncementRequest)] request_announcement announcement_request;
- [case(Election)] election_request election_request;
- [case(GetBackupListReq)] backup_list_request backup_list_request;
- [case(GetBackupListResp)] backup_list_response backup_list_response;
- [case(BecomeBackup)] become_backup become_backup;
- [case(DomainAnnouncement)] master_announcement domain_announcement;
- [case(MasterAnnouncement)] master_announcement master_announcement;
- [case(ResetBrowserState)] reset_state reset_browser_state;
- [case(LocalMasterAnnouncement)] master_announcement local_master_announcement;
- } browse_payload;
-
- typedef [public] struct {
- browse_opcode opcode;
- browse_payload payload;
- } browse_packet;
-}
diff --git a/source4/librpc/idl/nbt.idl b/source4/librpc/idl/nbt.idl
index 95e4abd974..b9061778bf 100644
--- a/source4/librpc/idl/nbt.idl
+++ b/source4/librpc/idl/nbt.idl
@@ -572,4 +572,106 @@
nbt_ntlogon_command command;
[switch_is(command)] nbt_ntlogon_request req;
} nbt_ntlogon_packet;
+
+ /*******************************************/
+ /* \MAILSLOT\BROWSE mailslot requests */
+
+ typedef enum {
+ HostAnnouncement = 1,
+ AnnouncementRequest = 2,
+ Election = 8,
+ GetBackupListReq = 9,
+ GetBackupListResp = 10,
+ BecomeBackup = 11,
+ DomainAnnouncement = 12,
+ MasterAnnouncement = 13,
+ ResetBrowserState = 14,
+ LocalMasterAnnouncement = 15
+ } nbt_browse_opcode;
+
+ typedef bitmap {
+ SV_TYPE_WORKSTATION = 0x00000001,
+ SV_TYPE_SERVER = 0x00000002,
+ SV_TYPE_SQLSERVER = 0x00000004,
+ SV_TYPE_DOMAIN_CTRL = 0x00000008,
+ SV_TYPE_DOMAIN_BAKCTRL = 0x00000010,
+ SV_TYPE_TIME_SOURCE = 0x00000020,
+ SV_TYPE_AFP = 0x00000040,
+ SV_TYPE_NOVELL = 0x00000080,
+ SV_TYPE_DOMAIN_MEMBER = 0x00000100,
+ SV_TYPE_PRINTQ_SERVER = 0x00000200,
+ SV_TYPE_DIALIN_SERVER = 0x00000400,
+ SV_TYPE_XENIX_SERVER = 0x00000800,
+ SV_TYPE_NT = 0x00001000,
+ SV_TYPE_POTENTIAL_BROWSER = 0x00010000,
+ SV_TYPE_BACKUP_BROWSER = 0x00020000,
+ SV_TYPE_MASTER_BROWSER = 0x00040000,
+ SV_TYPE_DOMAIN_MASTER = 0x00080000,
+ SV_TYPE_LOCAL_LIST_ONLY = 0x40000000,
+ SV_TYPE_DOMAIN_ENUM = 0x80000000
+ } nbt_browse_server_type;
+
+ typedef struct {
+ uint8 update_count;
+ uint32 ttl;
+ uint8 name[16];
+ uint8 os_major;
+ uint8 os_minor;
+ uint32 server_type;
+ astring comment;
+ } nbt_browse_host_announcement;
+
+ typedef struct {
+ uint8 unknown;
+ astring ResponseComputerName;
+ } nbt_browse_request_announcement;
+
+ typedef struct {
+ uint8 count;
+ uint32 token;
+ } nbt_browse_backup_list_request;
+
+ typedef struct {
+ uint8 count;
+ uint32 token;
+ nbt_name BackupServerList[count];
+ } nbt_browse_backup_list_response;
+
+ typedef struct {
+ astring BrowserToPromote;
+ } nbt_browse_become_backup;
+
+ typedef struct {
+ uint8 version;
+ uint32 criteria;
+ uint32 time_up; /* In milliseconds */
+ uint32 reserved; /* Must be zero */
+ astring ServerName;
+ } nbt_browse_election_request;
+
+ typedef struct {
+ uint8 options;
+ } nbt_browse_reset_state;
+
+ typedef struct {
+ astring MasterBrowserServerName;
+ } nbt_browse_master_announcement;
+
+ typedef [nodiscriminant] union {
+ [case(HostAnnouncement)] nbt_browse_host_announcement host_annoucement;
+ [case(AnnouncementRequest)] nbt_browse_request_announcement announcement_request;
+ [case(Election)] nbt_browse_election_request election_request;
+ [case(GetBackupListReq)] nbt_browse_backup_list_request backup_list_request;
+ [case(GetBackupListResp)] nbt_browse_backup_list_response backup_list_response;
+ [case(BecomeBackup)] nbt_browse_become_backup become_backup;
+ [case(DomainAnnouncement)] nbt_browse_master_announcement domain_announcement;
+ [case(MasterAnnouncement)] nbt_browse_master_announcement master_announcement;
+ [case(ResetBrowserState)] nbt_browse_reset_state reset_browser_state;
+ [case(LocalMasterAnnouncement)] nbt_browse_master_announcement local_master_announcement;
+ } nbt_browse_payload;
+
+ typedef [public,flag(NDR_NOALIGN)] struct {
+ nbt_browse_opcode opcode;
+ nbt_browse_payload payload;
+ } nbt_browse_packet;
}