svn commit: samba r11034 - in branches/SAMBA_4_0: . source/include
source/nbt_server/wins
metze at samba.org
metze at samba.org
Fri Oct 14 12:53:52 GMT 2005
Author: metze
Date: 2005-10-14 12:53:50 +0000 (Fri, 14 Oct 2005)
New Revision: 11034
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=11034
Log:
r10344 at SERNOX: metze | 2005-09-20 11:35:54 +0200
create winsdb_record() and winsdb_message() as public functions
so that they can be used in the wrepl_server/
metze
Modified:
branches/SAMBA_4_0/
branches/SAMBA_4_0/source/include/structs.h
branches/SAMBA_4_0/source/nbt_server/wins/winsdb.c
Changeset:
Property changes on: branches/SAMBA_4_0
___________________________________________________________________
Name: svk:merge
- 0c0555d6-39d7-0310-84fc-f1cc0bd64818:/branches/tmp/samba4-winsrepl:10343
3a72dc49-98ff-0310-ab52-9b7ed7945d91:/local/samba4:9495
a953eb74-4aff-0310-a63c-855d20285ebb:/local/samba4:11632
d349723c-e9fc-0310-b8a8-fdedf1c27407:/local/SAMBA_4_0:5616
d349723c-e9fc-0310-b8a8-fdedf1c27407:/local/samba-SAMBA_4_0:5609
+ 0c0555d6-39d7-0310-84fc-f1cc0bd64818:/branches/tmp/samba4-winsrepl:10344
3a72dc49-98ff-0310-ab52-9b7ed7945d91:/local/samba4:9495
a953eb74-4aff-0310-a63c-855d20285ebb:/local/samba4:11632
d349723c-e9fc-0310-b8a8-fdedf1c27407:/local/SAMBA_4_0:5616
d349723c-e9fc-0310-b8a8-fdedf1c27407:/local/samba-SAMBA_4_0:5609
Modified: branches/SAMBA_4_0/source/include/structs.h
===================================================================
--- branches/SAMBA_4_0/source/include/structs.h 2005-10-14 12:52:51 UTC (rev 11033)
+++ branches/SAMBA_4_0/source/include/structs.h 2005-10-14 12:53:50 UTC (rev 11034)
@@ -276,6 +276,8 @@
struct wreplsrv_in_connection;
struct wreplsrv_in_call;
+struct winsdb_record;
+
struct wrepl_packet;
struct wrepl_associate;
struct wrepl_associate_stop;
Modified: branches/SAMBA_4_0/source/nbt_server/wins/winsdb.c
===================================================================
--- branches/SAMBA_4_0/source/nbt_server/wins/winsdb.c 2005-10-14 12:52:51 UTC (rev 11033)
+++ branches/SAMBA_4_0/source/nbt_server/wins/winsdb.c 2005-10-14 12:53:50 UTC (rev 11034)
@@ -401,9 +401,7 @@
struct ldb_message **res = NULL;
int ret;
struct winsdb_record *rec;
- struct ldb_message_element *el;
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
- int i;
/* find the record in the WINS database */
ret = ldb_search(winssrv->wins_db, winsdb_dn(tmp_ctx, name), LDB_SCOPE_BASE,
@@ -413,9 +411,36 @@
}
if (ret != 1) goto failed;
- rec = talloc(tmp_ctx, struct winsdb_record);
+ rec = winsdb_record(res[0], tmp_ctx);
if (rec == NULL) goto failed;
+ rec->name = name;
+ /* see if it has already expired */
+ if (rec->state == WINS_REC_ACTIVE &&
+ rec->expire_time <= time(NULL)) {
+ DEBUG(5,("WINS: expiring name %s (expired at %s)\n",
+ nbt_name_string(tmp_ctx, rec->name), timestring(tmp_ctx, rec->expire_time)));
+ rec->state = WINS_REC_RELEASED;
+ }
+
+ talloc_steal(mem_ctx, rec);
+ talloc_free(tmp_ctx);
+ return rec;
+
+failed:
+ talloc_free(tmp_ctx);
+ return NULL;
+}
+
+struct winsdb_record *winsdb_record(struct ldb_message *msg, TALLOC_CTX *mem_ctx)
+{
+ struct winsdb_record *rec;
+ struct ldb_message_element *el;
+ uint32_t i;
+
+ rec = talloc(mem_ctx, struct winsdb_record);
+ if (rec == NULL) goto failed;
+
/* parse it into a more convenient winsdb_record structure */
rec->name = name;
rec->state = ldb_msg_find_int(res[0], "active", WINS_REC_RELEASED);
@@ -428,7 +453,7 @@
if (!rec->wins_owner) rec->wins_owner = WINSDB_OWNER_LOCAL;
- el = ldb_msg_find_element(res[0], "address");
+ el = ldb_msg_find_element(msg, "address");
if (el == NULL) goto failed;
rec->addresses = talloc_array(rec, struct winsdb_addr *, el->num_values+1);
@@ -440,29 +465,17 @@
}
rec->addresses[i] = NULL;
- /* see if it has already expired */
- if (rec->state == WINS_REC_ACTIVE &&
- rec->expire_time <= time(NULL)) {
- DEBUG(5,("WINS: expiring name %s (expired at %s)\n",
- nbt_name_string(tmp_ctx, rec->name), timestring(tmp_ctx, rec->expire_time)));
- rec->state = WINS_REC_RELEASED;
- }
-
- talloc_steal(mem_ctx, rec);
- talloc_free(tmp_ctx);
return rec;
-
failed:
- talloc_free(tmp_ctx);
+ talloc_free(rec);
return NULL;
}
-
/*
form a ldb_message from a winsdb_record
*/
-static struct ldb_message *winsdb_message(struct wins_server *winssrv,
- struct winsdb_record *rec, TALLOC_CTX *mem_ctx)
+struct ldb_message *winsdb_message(struct ldb_context *ldb,
+ struct winsdb_record *rec, TALLOC_CTX *mem_ctx)
{
int i, ret=0;
struct ldb_message *msg = ldb_msg_new(mem_ctx);
@@ -506,7 +519,7 @@
rec->version = winsdb_allocate_version(winssrv);
if (rec->version == 0) goto failed;
- msg = winsdb_message(winssrv, rec, tmp_ctx);
+ msg = winsdb_message(winssrv->wins_db, rec, tmp_ctx);
if (msg == NULL) goto failed;
ret = ldb_add(ldb, msg);
if (ret != 0) goto failed;
@@ -543,7 +556,7 @@
if (rec->version == 0) goto failed;
rec->wins_owner = WINSDB_OWNER_LOCAL;
- msg = winsdb_message(winssrv, rec, tmp_ctx);
+ msg = winsdb_message(winssrv->wins_db, rec, tmp_ctx);
if (msg == NULL) goto failed;
for (i=0;i<msg->num_elements;i++) {
More information about the samba-cvs
mailing list