summaryrefslogtreecommitdiff
path: root/source4/nbt_server
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2005-12-30 20:08:52 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:49:05 -0500
commit0391b1cb3a1527aed5beefbdda67a6ce5062bbab (patch)
treeff995fa2d5056d0b7c44fa09965fd10eb7e1839c /source4/nbt_server
parenteef64ba0344f2a6ff95bbe09a213f9bc8751b020 (diff)
downloadsamba-0391b1cb3a1527aed5beefbdda67a6ce5062bbab.tar.gz
samba-0391b1cb3a1527aed5beefbdda67a6ce5062bbab.tar.bz2
samba-0391b1cb3a1527aed5beefbdda67a6ce5062bbab.zip
r12617: create a winsdb_handle and pass that arround,
so we later can hang the local owner address, on this handle too metze (This used to be commit 49ba4cc11144671cafcbe2967954bfd786ea6e76)
Diffstat (limited to 'source4/nbt_server')
-rw-r--r--source4/nbt_server/config.mk1
-rw-r--r--source4/nbt_server/wins/winsdb.c36
-rw-r--r--source4/nbt_server/wins/winsdb.h9
3 files changed, 35 insertions, 11 deletions
diff --git a/source4/nbt_server/config.mk b/source4/nbt_server/config.mk
index a8aab7b2ad..60c338d0fc 100644
--- a/source4/nbt_server/config.mk
+++ b/source4/nbt_server/config.mk
@@ -5,6 +5,7 @@
[SUBSYSTEM::WINSDB]
OBJ_FILES = \
wins/winsdb.o
+PRIVATE_PROTO_HEADER = wins/winsdb_proto.h
REQUIRED_SUBSYSTEMS = \
LIBLDB
# End SUBSYSTEM WINSDB
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c
index 5fcad32903..42a6f19d84 100644
--- a/source4/nbt_server/wins/winsdb.c
+++ b/source4/nbt_server/wins/winsdb.c
@@ -32,13 +32,14 @@
/*
return the new maxVersion and save it
*/
-static uint64_t winsdb_allocate_version(struct ldb_context *wins_db)
+static uint64_t winsdb_allocate_version(struct winsdb_handle *h)
{
int trans;
int ret;
struct ldb_dn *dn;
struct ldb_result *res = NULL;
struct ldb_message *msg = NULL;
+ struct ldb_context *wins_db = h->ldb;
TALLOC_CTX *tmp_ctx = talloc_new(wins_db);
uint64_t maxVersion = 0;
@@ -366,7 +367,7 @@ const char **winsdb_addr_string_list(TALLOC_CTX *mem_ctx, struct winsdb_addr **a
/*
load a WINS entry from the database
*/
-NTSTATUS winsdb_lookup(struct ldb_context *wins_db,
+NTSTATUS winsdb_lookup(struct winsdb_handle *h,
struct nbt_name *name,
TALLOC_CTX *mem_ctx,
struct winsdb_record **_rec)
@@ -375,6 +376,7 @@ NTSTATUS winsdb_lookup(struct ldb_context *wins_db,
struct ldb_result *res = NULL;
int ret;
struct winsdb_record *rec;
+ struct ldb_context *wins_db = h->ldb;
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
/* find the record in the WINS database */
@@ -578,9 +580,10 @@ failed:
/*
save a WINS record into the database
*/
-uint8_t winsdb_add(struct ldb_context *wins_db, struct winsdb_record *rec, uint32_t flags)
+uint8_t winsdb_add(struct winsdb_handle *h, struct winsdb_record *rec, uint32_t flags)
{
struct ldb_message *msg;
+ struct ldb_context *wins_db = h->ldb;
TALLOC_CTX *tmp_ctx = talloc_new(wins_db);
int trans = -1;
int ret = 0;
@@ -589,7 +592,7 @@ uint8_t winsdb_add(struct ldb_context *wins_db, struct winsdb_record *rec, uint3
if (trans != LDB_SUCCESS) goto failed;
if (flags & WINSDB_FLAG_ALLOC_VERSION) {
- rec->version = winsdb_allocate_version(wins_db);
+ rec->version = winsdb_allocate_version(h);
if (rec->version == 0) goto failed;
}
if (flags & WINSDB_FLAG_TAKE_OWNERSHIP) {
@@ -617,9 +620,10 @@ failed:
/*
modify a WINS record in the database
*/
-uint8_t winsdb_modify(struct ldb_context *wins_db, struct winsdb_record *rec, uint32_t flags)
+uint8_t winsdb_modify(struct winsdb_handle *h, struct winsdb_record *rec, uint32_t flags)
{
struct ldb_message *msg;
+ struct ldb_context *wins_db = h->ldb;
TALLOC_CTX *tmp_ctx = talloc_new(wins_db);
int trans;
int ret;
@@ -629,7 +633,7 @@ uint8_t winsdb_modify(struct ldb_context *wins_db, struct winsdb_record *rec, ui
if (trans != LDB_SUCCESS) goto failed;
if (flags & WINSDB_FLAG_ALLOC_VERSION) {
- rec->version = winsdb_allocate_version(wins_db);
+ rec->version = winsdb_allocate_version(h);
if (rec->version == 0) goto failed;
}
if (flags & WINSDB_FLAG_TAKE_OWNERSHIP) {
@@ -662,8 +666,9 @@ failed:
/*
delete a WINS record from the database
*/
-uint8_t winsdb_delete(struct ldb_context *wins_db, struct winsdb_record *rec)
+uint8_t winsdb_delete(struct winsdb_handle *h, struct winsdb_record *rec)
{
+ struct ldb_context *wins_db = h->ldb;
TALLOC_CTX *tmp_ctx = talloc_new(wins_db);
const struct ldb_dn *dn;
int trans;
@@ -690,8 +695,19 @@ failed:
return NBT_RCODE_SVR;
}
-struct ldb_context *winsdb_connect(TALLOC_CTX *mem_ctx)
+struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx)
{
- return ldb_wrap_connect(mem_ctx, lock_path(mem_ctx, lp_wins_url()),
- system_session(mem_ctx), NULL, 0, NULL);
+ struct winsdb_handle *h = NULL;
+
+ h = talloc(mem_ctx, struct winsdb_handle);
+ if (!h) return NULL;
+
+ h->ldb = ldb_wrap_connect(h, lock_path(h, lp_wins_url()),
+ system_session(h), NULL, 0, NULL);
+ if (!h->ldb) goto failed;
+
+ return h;
+failed:
+ talloc_free(h);
+ return NULL;
}
diff --git a/source4/nbt_server/wins/winsdb.h b/source4/nbt_server/wins/winsdb.h
index 2cf3b56c74..f890a10148 100644
--- a/source4/nbt_server/wins/winsdb.h
+++ b/source4/nbt_server/wins/winsdb.h
@@ -50,9 +50,14 @@ struct winsdb_record {
const char *registered_by;
};
+struct winsdb_handle {
+ /* wins server database handle */
+ struct ldb_context *ldb;
+};
+
struct wins_server {
/* wins server database handle */
- struct ldb_context *wins_db;
+ struct winsdb_handle *wins_db;
/* some configuration */
struct {
@@ -70,3 +75,5 @@ struct wins_server {
uint32_t tombstone_interval;
} config;
};
+
+#include "nbt_server/wins/winsdb_proto.h"