libndr: add dom_sid0 type that can later be used for CLDAP and MAILSLOT ntlogon packets
authorStefan Metzmacher <metze@samba.org>
Thu, 17 Apr 2008 13:01:45 +0000 (15:01 +0200)
committerStefan Metzmacher <metze@samba.org>
Thu, 17 Apr 2008 14:28:40 +0000 (16:28 +0200)
metze

source/librpc/idl/security.idl
source/librpc/ndr/libndr.h
source/librpc/ndr/ndr_sec_helper.c

index 753fad85cf96ee009877fcab00ddcc71d2f38aa9..314846c53f29b2ca00a9c8d1f082396ae5f883a1 100644 (file)
@@ -22,6 +22,9 @@ cpp_quote("#define dom_sid2 dom_sid")
 /* same struct as dom_sid but inside a 28 bytes fixed buffer in NDR */
 cpp_quote("#define dom_sid28 dom_sid")
 
+/* same struct as dom_sid but in a variable byte buffer, which is maybe empty in NDR */
+cpp_quote("#define dom_sid0 dom_sid")
+
 [
        pointer_default(unique)
 ]
index 2439c386db81fe1e3fd3796abd42c9f7afe9e39c..b719be2bab68c064347585c2e6ddcd05050bc1b7 100644 (file)
@@ -336,6 +336,10 @@ enum ndr_err_code ndr_push_dom_sid28(struct ndr_push *ndr, int ndr_flags, const
 enum ndr_err_code ndr_pull_dom_sid28(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *sid);
 void ndr_print_dom_sid28(struct ndr_print *ndr, const char *name, const struct dom_sid *sid);
 size_t ndr_size_dom_sid28(const struct dom_sid *sid, int flags);
+enum ndr_err_code ndr_push_dom_sid0(struct ndr_push *ndr, int ndr_flags, const struct dom_sid *sid);
+enum ndr_err_code ndr_pull_dom_sid0(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *sid);
+void ndr_print_dom_sid0(struct ndr_print *ndr, const char *name, const struct dom_sid *sid);
+size_t ndr_size_dom_sid0(const struct dom_sid *sid, int flags);
 void ndr_print_ipv4_addr(struct ndr_print *ndr, const char *name, const struct in_addr *_ip);
 void ndr_print_GUID(struct ndr_print *ndr, const char *name, const struct GUID *guid);
 enum ndr_err_code ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, struct smb_iconv_convenience *iconv_convenience, const void *p, ndr_push_flags_fn_t fn);
index 5a0178bd25bbee897b5b8731060b0821ce5b2b6e..1256d7dd2d26769948ceaaef7ceeada42fbb351c 100644 (file)
@@ -48,6 +48,11 @@ size_t ndr_size_dom_sid28(const struct dom_sid *sid, int flags)
        return 8 + 4*sid->num_auths;
 }
 
+size_t ndr_size_dom_sid0(const struct dom_sid *sid, int flags)
+{
+       return ndr_size_dom_sid28(sid, flags);
+}
+
 /*
   return the wire size of a security_ace
 */
@@ -128,6 +133,11 @@ void ndr_print_dom_sid28(struct ndr_print *ndr, const char *name, const struct d
        ndr_print_dom_sid(ndr, name, sid);
 }
 
+void ndr_print_dom_sid0(struct ndr_print *ndr, const char *name, const struct dom_sid *sid)
+{
+       ndr_print_dom_sid(ndr, name, sid);
+}
+
 
 /*
   parse a dom_sid2 - this is a dom_sid but with an extra copy of the num_auths field
@@ -225,3 +235,44 @@ enum ndr_err_code ndr_push_dom_sid28(struct ndr_push *ndr, int ndr_flags, const
        return NDR_ERR_SUCCESS;
 }
 
+/*
+  parse a dom_sid0 - this is a dom_sid in a variable byte buffer, which is maybe empty
+*/
+enum ndr_err_code ndr_pull_dom_sid0(struct ndr_pull *ndr, int ndr_flags, struct dom_sid *sid)
+{
+       if (!(ndr_flags & NDR_SCALARS)) {
+               return NDR_ERR_SUCCESS;
+       }
+
+       if (ndr->data_size == ndr->offset) {
+               ZERO_STRUCTP(sid);
+               return NDR_ERR_SUCCESS;
+       }
+
+       return ndr_pull_dom_sid(ndr, ndr_flags, sid);
+}
+
+/*
+  push a dom_sid0 - this is a dom_sid in a variable byte buffer, which is maybe empty
+*/
+enum ndr_err_code ndr_push_dom_sid0(struct ndr_push *ndr, int ndr_flags, const struct dom_sid *sid)
+{
+       struct dom_sid zero_sid;
+
+       if (!(ndr_flags & NDR_SCALARS)) {
+               return NDR_ERR_SUCCESS;
+       }
+
+       if (!sid) {
+               return NDR_ERR_SUCCESS;
+       }
+
+       ZERO_STRUCT(zero_sid);
+
+       if (memcmp(&zero_sid, sid, sizeof(zero_sid)) == 0) {
+               return NDR_ERR_SUCCESS;
+       }
+
+       return ndr_push_dom_sid(ndr, ndr_flags, sid);
+}
+