summaryrefslogtreecommitdiff
path: root/source4/nbt_server/wins/winsdb.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/nbt_server/wins/winsdb.c')
-rw-r--r--source4/nbt_server/wins/winsdb.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c
index 0b7d16b532..551bc85727 100644
--- a/source4/nbt_server/wins/winsdb.c
+++ b/source4/nbt_server/wins/winsdb.c
@@ -93,6 +93,46 @@ static struct ldb_dn *winsdb_dn(TALLOC_CTX *mem_ctx, struct nbt_name *name)
return dn;
}
+struct nbt_name *winsdb_nbt_name(TALLOC_CTX *mem_ctx, struct ldb_dn *dn)
+{
+ struct nbt_name *name;
+ uint32_t cur = 0;
+
+ name = talloc(mem_ctx, struct nbt_name);
+ if (!name) goto failed;
+
+ if (dn->comp_num > 3) {
+ goto failed;
+ }
+
+ if (dn->comp_num > cur && strcasecmp("scope", dn->components[cur].name) == 0) {
+ name->scope = talloc_steal(name, dn->components[cur].value.data);
+ cur++;
+ } else {
+ name->scope = NULL;
+ }
+
+ if (dn->comp_num > cur && strcasecmp("name", dn->components[cur].name) == 0) {
+ name->name = talloc_steal(name, dn->components[cur].value.data);
+ cur++;
+ } else {
+ name->name = talloc_strdup(name, "");
+ if (!name->name) goto failed;
+ }
+
+ if (dn->comp_num > cur && strcasecmp("type", dn->components[cur].name) == 0) {
+ name->type = strtoul((char *)dn->components[cur].value.data, NULL, 16);
+ cur++;
+ } else {
+ goto failed;
+ }
+
+ return name;
+failed:
+ talloc_free(name);
+ return NULL;
+}
+
/*
decode the winsdb_addr("address") attribute:
"172.31.1.1" or