summaryrefslogtreecommitdiff
path: root/source4/dsdb/schema/schema_prefixmap.c
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamen.mazdrashki@postpath.com>2009-10-24 00:48:14 +0300
committerStefan Metzmacher <metze@samba.org>2009-11-06 14:05:37 +0100
commitf4475368f07f2de07f3f9d7c68de027dfb8e7284 (patch)
tree1bf81f2d5e12da0391d7f7ffcec991f9257d34d0 /source4/dsdb/schema/schema_prefixmap.c
parent39ab7b8ebdefd13fb586d65da76173c0a3fa5fa5 (diff)
downloadsamba-f4475368f07f2de07f3f9d7c68de027dfb8e7284.tar.gz
samba-f4475368f07f2de07f3f9d7c68de027dfb8e7284.tar.bz2
samba-f4475368f07f2de07f3f9d7c68de027dfb8e7284.zip
s4/drs: Move making of partial-binary-oid to a separate function
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'source4/dsdb/schema/schema_prefixmap.c')
-rw-r--r--source4/dsdb/schema/schema_prefixmap.c65
1 files changed, 45 insertions, 20 deletions
diff --git a/source4/dsdb/schema/schema_prefixmap.c b/source4/dsdb/schema/schema_prefixmap.c
index 08e51559d6..6943ee0217 100644
--- a/source4/dsdb/schema/schema_prefixmap.c
+++ b/source4/dsdb/schema/schema_prefixmap.c
@@ -131,41 +131,66 @@ static WERROR _dsdb_schema_pfm_add_entry(struct dsdb_schema_prefixmap *pfm, DATA
/**
- * Make ATTID for given OID
+ * Make partial binary OID for supplied OID.
* Reference: [MS-DRSR] section 5.12.2
*/
-WERROR dsdb_schema_pfm_make_attid(struct dsdb_schema_prefixmap *pfm, const char *oid, uint32_t *attid)
+static WERROR _dsdb_pfm_make_binary_oid(const char *full_oid, TALLOC_CTX *mem_ctx,
+ DATA_BLOB *_bin_oid, uint32_t *_last_subid)
{
- uint32_t i;
- uint32_t lo_word, hi_word;
- DATA_BLOB bin_oid;
- const char *last_subid;
- uint32_t last_value;
- struct dsdb_schema_prefixmap_oid *pfm_entry;
-
- if (!pfm) return WERR_INVALID_PARAMETER;
- if (!oid) return WERR_INVALID_PARAMETER;
+ uint32_t last_subid;
+ const char *oid_subid;
/* make last sub-identifier value */
- last_subid = strrchr(oid, '.');
- if (!last_subid) {
+ oid_subid = strrchr(full_oid, '.');
+ if (!oid_subid) {
return WERR_INVALID_PARAMETER;
}
- last_subid++;
- last_value = strtoul(last_subid, NULL, 10);
+ oid_subid++;
+ last_subid = strtoul(oid_subid, NULL, 10);
/* encode oid in BER format */
- if (!ber_write_OID_String(pfm, &bin_oid, oid)) {
+ if (!ber_write_OID_String(mem_ctx, _bin_oid, full_oid)) {
return WERR_INTERNAL_ERROR;
}
/* get the prefix of the OID */
- if (last_value < 128) {
- bin_oid.length -= 1;
+ if (last_subid < 128) {
+ _bin_oid->length -= 1;
} else {
- bin_oid.length -= 2;
+ _bin_oid->length -= 2;
}
+ /* return last_value if requested */
+ if (_last_subid) {
+ *_last_subid = last_subid;
+ }
+
+ return WERR_OK;
+}
+
+/**
+ * Make ATTID for given OID
+ * Reference: [MS-DRSR] section 5.12.2
+ */
+WERROR dsdb_schema_pfm_make_attid(struct dsdb_schema_prefixmap *pfm, const char *oid, uint32_t *attid)
+{
+ WERROR werr;
+ uint32_t i;
+ uint32_t lo_word, hi_word;
+ uint32_t last_value;
+ DATA_BLOB bin_oid;
+ struct dsdb_schema_prefixmap_oid *pfm_entry;
+
+ if (!pfm) {
+ return WERR_INVALID_PARAMETER;
+ }
+ if (!oid) {
+ return WERR_INVALID_PARAMETER;
+ }
+
+ werr = _dsdb_pfm_make_binary_oid(oid, pfm, &bin_oid, &last_value);
+ W_ERROR_NOT_OK_RETURN(werr);
+
/* search the prefix in the prefix table, if none found, add
* one entry for new prefix.
*/
@@ -182,7 +207,7 @@ WERROR dsdb_schema_pfm_make_attid(struct dsdb_schema_prefixmap *pfm, const char
/* add entry in no entry exists */
if (!pfm_entry) {
uint32_t idx;
- WERROR werr = _dsdb_schema_pfm_add_entry(pfm, bin_oid, &idx);
+ werr = _dsdb_schema_pfm_add_entry(pfm, bin_oid, &idx);
W_ERROR_NOT_OK_RETURN(werr);
pfm_entry = &pfm->prefixes[idx];