r11025: r10313@SERNOX: metze | 2005-09-19 12:19:27 +0200
authorStefan Metzmacher <metze@samba.org>
Fri, 14 Oct 2005 12:49:36 +0000 (12:49 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:42:16 +0000 (13:42 -0500)
 add wrapper functions for the "address" attribute in the winsdb,
 the goal is to store the expiry time and the wins owner per address,
 which is needed for wins replication

 metze
(This used to be commit 2fd3bbd0449af3702bf473f97474bc1343f7a502)

source4/nbt_server/wins/winsdb.c

index 72531e4c6250dbc959165b45bf27cb49b0812586..2b17104b9dc9a4d305aa5a96923ef728aea41af3 100644 (file)
@@ -119,6 +119,24 @@ static struct ldb_dn *winsdb_dn(TALLOC_CTX *mem_ctx, struct nbt_name *name)
        return dn;
 }
 
+static const char *winsdb_addr_decode(TALLOC_CTX *mem_ctx, struct ldb_val *val)
+{
+       const char *addr;
+       addr = talloc_steal(mem_ctx, val->data);
+       return addr;
+}
+
+static int ldb_msg_add_winsdb_addr(struct ldb_context *ldb, struct ldb_message *msg, 
+                                  const char *attr_name, const char *addr)
+{
+       struct ldb_val val;
+
+       val.data = discard_const_p(uint8_t, addr);
+       val.length = strlen(addr);
+
+       return ldb_msg_add_value(ldb, msg, attr_name, &val);
+}
+
 /*
   load a WINS entry from the database
 */
@@ -159,7 +177,8 @@ struct winsdb_record *winsdb_load(struct wins_server *winssrv,
        if (rec->addresses == NULL) goto failed;
 
        for (i=0;i<el->num_values;i++) {
-               rec->addresses[i] = talloc_steal(rec->addresses, el->values[i].data);
+               rec->addresses[i] = winsdb_addr_decode(rec->addresses, &el->values[i]);
+               if (rec->addresses[i] == NULL) goto failed;
        }
        rec->addresses[i] = NULL;