summaryrefslogtreecommitdiff
path: root/source4/nbt_server/wins
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-24 12:18:11 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:29:59 -0500
commitf4b488ec011e0acaef80f88d72308671cff185e2 (patch)
treed9d78d0835a48e8cd32975758e504c891ea54ea0 /source4/nbt_server/wins
parent6b2d6ce60416726cae1bb4b234342fb53281b315 (diff)
downloadsamba-f4b488ec011e0acaef80f88d72308671cff185e2.tar.gz
samba-f4b488ec011e0acaef80f88d72308671cff185e2.tar.bz2
samba-f4b488ec011e0acaef80f88d72308671cff185e2.zip
r8734: fixed the wins server for the new ldb DN restrictions.
This gets it working, but I'm rather worried about the speed. We used to get more than 5000 ops/sec, but now we are down to around 15 ops/sec. I suspect a bug in ldb. (This used to be commit 83727bf72c970effdc5995e2f6e7816a57887b5c)
Diffstat (limited to 'source4/nbt_server/wins')
-rw-r--r--source4/nbt_server/wins/winsdb.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c
index 152338eca6..c46c4c571e 100644
--- a/source4/nbt_server/wins/winsdb.c
+++ b/source4/nbt_server/wins/winsdb.c
@@ -83,6 +83,31 @@ static void winsdb_remove_version(struct wins_server *winssrv, uint64_t version)
}
}
+
+/*
+ return a DN for a nbt_name
+*/
+static char *winsdb_dn(TALLOC_CTX *mem_ctx, struct nbt_name *name)
+{
+ char *ret = talloc_asprintf(mem_ctx, "type=%02x", name->type);
+ if (ret == NULL) {
+ return ret;
+ }
+ if (name->name && *name->name) {
+ ret = talloc_asprintf_append(ret, ",name=%s", name->name);
+ }
+ if (ret == NULL) {
+ return ret;
+ }
+ if (name->scope && *name->scope) {
+ ret = talloc_asprintf_append(ret, ",scope=%s", name->scope);
+ }
+ if (ret == NULL) {
+ return ret;
+ }
+ return ret;
+}
+
/*
load a WINS entry from the database
*/
@@ -97,7 +122,7 @@ struct winsdb_record *winsdb_load(struct wins_server *winssrv,
const char *expr;
int i;
- expr = talloc_asprintf(tmp_ctx, "dn=NAME=%s", nbt_name_string(tmp_ctx, name));
+ expr = talloc_asprintf(tmp_ctx, "dn=%s", winsdb_dn(tmp_ctx, name));
if (expr == NULL) goto failed;
/* find the record in the WINS database */
@@ -159,8 +184,9 @@ static struct ldb_message *winsdb_message(struct wins_server *winssrv,
struct ldb_message *msg = ldb_msg_new(mem_ctx);
if (msg == NULL) goto failed;
- msg->dn = talloc_asprintf(msg, "NAME=%s", nbt_name_string(msg, rec->name));
+ msg->dn = winsdb_dn(msg, rec->name);
if (msg->dn == NULL) goto failed;
+ ret |= ldb_msg_add_fmt(ldb, msg, "objectClass", "wins");
ret |= ldb_msg_add_fmt(ldb, msg, "active", "%u", rec->state);
ret |= ldb_msg_add_fmt(ldb, msg, "nbFlags", "0x%04x", rec->nb_flags);
ret |= ldb_msg_add_string(ldb, msg, "registeredBy", rec->registered_by);
@@ -250,7 +276,7 @@ uint8_t winsdb_delete(struct wins_server *winssrv, struct winsdb_record *rec)
winsdb_remove_version(winssrv, rec->version);
- dn = talloc_asprintf(tmp_ctx, "NAME=%s", nbt_name_string(tmp_ctx, rec->name));
+ dn = winsdb_dn(tmp_ctx, rec->name);
if (dn == NULL) goto failed;
ret = ldb_delete(ldb, dn);