diff options
Diffstat (limited to 'source4/nbt_server/wins')
-rw-r--r-- | source4/nbt_server/wins/winsdb.c | 31 | ||||
-rw-r--r-- | source4/nbt_server/wins/winsdb.h | 21 | ||||
-rw-r--r-- | source4/nbt_server/wins/winsserver.c | 31 |
3 files changed, 61 insertions, 22 deletions
diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c index 49ffb13797..50baa50898 100644 --- a/source4/nbt_server/wins/winsdb.c +++ b/source4/nbt_server/wins/winsdb.c @@ -44,10 +44,8 @@ static uint64_t winsdb_allocate_version(struct wins_server *winssrv) dn = ldb_dn_explode(tmp_ctx, "CN=VERSION"); if (!dn) goto failed; - ret |= ldb_msg_add_string(msg, "objectClass", "winsEntry"); - ret |= ldb_msg_add_fmt(msg, "minVersion", "%llu", winssrv->min_version); - ret |= ldb_msg_add_fmt(msg, "maxVersion", "%llu", winssrv->max_version); - if (ret != 0) goto failed; + dn = ldb_dn_explode(tmp_ctx, "CN=VERSION"); + if (!dn) goto failed; if (ret == 1) { maxVersion = ldb_msg_find_uint64(res[0], "maxVersion", 0); @@ -71,6 +69,9 @@ static uint64_t winsdb_allocate_version(struct wins_server *winssrv) talloc_free(tmp_ctx); return maxVersion; + talloc_free(tmp_ctx); + return maxVersion; + failed: talloc_free(tmp_ctx); return 0; @@ -742,16 +743,19 @@ struct ldb_message *winsdb_message(struct ldb_context *ldb, msg->dn = winsdb_dn(msg, rec->name); if (msg->dn == NULL) goto failed; - ret |= ldb_msg_add_fmt(msg, "objectClass", "wins"); - ret |= ldb_msg_add_fmt(msg, "active", "%u", rec->state); - ret |= ldb_msg_add_fmt(msg, "nbFlags", "0x%04x", rec->nb_flags); - ret |= ldb_msg_add_string(msg, "registeredBy", rec->registered_by); - ret |= ldb_msg_add_string(msg, "expires", + ret |= ldb_msg_add_fmt(msg, "objectClass", "winsRecord"); + ret |= ldb_msg_add_fmt(msg, "recordType", "%u", rec->type); + ret |= ldb_msg_add_fmt(msg, "recordState", "%u", rec->state); + ret |= ldb_msg_add_fmt(msg, "nodeType", "%u", rec->node); + ret |= ldb_msg_add_fmt(msg, "isStatic", "%u", rec->is_static); + ret |= ldb_msg_add_string(msg, "expireTime", ldb_timestring(msg, rec->expire_time)); - ret |= ldb_msg_add_fmt(msg, "version", "%llu", rec->version); + ret |= ldb_msg_add_fmt(msg, "versionID", "%llu", rec->version); + ret |= ldb_msg_add_string(msg, "winsOwner", rec->wins_owner); for (i=0;rec->addresses[i];i++) { - ret |= ldb_msg_add_string(msg, "address", rec->addresses[i]); + ret |= ldb_msg_add_winsdb_addr(msg, "address", rec->addresses[i]); } + ret |= ldb_msg_add_string(msg, "registeredBy", rec->registered_by); if (ret != 0) goto failed; return msg; @@ -771,12 +775,12 @@ uint8_t winsdb_add(struct wins_server *winssrv, struct winsdb_record *rec) int trans = -1; int ret = 0; - trans = ldb_transaction_start(ldb); if (trans != LDB_SUCCESS) goto failed; rec->version = winsdb_allocate_version(winssrv); if (rec->version == 0) goto failed; + rec->wins_owner = WINSDB_OWNER_LOCAL; msg = winsdb_message(winssrv->wins_db, rec, tmp_ctx); if (msg == NULL) goto failed; @@ -849,9 +853,6 @@ uint8_t winsdb_delete(struct wins_server *winssrv, struct winsdb_record *rec) int trans; int ret; - if(!winsdb_remove_version(winssrv, rec->version)) - goto failed; - dn = winsdb_dn(tmp_ctx, rec->name); if (dn == NULL) goto failed; diff --git a/source4/nbt_server/wins/winsdb.h b/source4/nbt_server/wins/winsdb.h index c775159a18..2ac1884063 100644 --- a/source4/nbt_server/wins/winsdb.h +++ b/source4/nbt_server/wins/winsdb.h @@ -20,9 +20,13 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -enum wins_record_state { - WINS_REC_RELEASED =0, - WINS_REC_ACTIVE =1 +#define WINSDB_OWNER_LOCAL "0.0.0.0" +#define WINSDB_GROUP_ADDRESS "255.255.255.255" + +struct winsdb_addr { + const char *address; + const char *wins_owner; + time_t expire_time; }; #define WINSDB_OWNER_LOCAL "0.0.0.0" @@ -39,10 +43,17 @@ struct winsdb_addr { */ struct winsdb_record { struct nbt_name *name; - uint16_t nb_flags; - enum wins_record_state state; + enum wrepl_name_type type; + enum wrepl_name_state state; + enum wrepl_name_node node; + BOOL is_static; const char *wins_owner; time_t expire_time; + uint64_t version; + const char *wins_owner; + struct winsdb_addr **addresses; + + /* only needed for debugging problems */ const char *registered_by; struct winsdb_addr **addresses; uint64_t version; diff --git a/source4/nbt_server/wins/winsserver.c b/source4/nbt_server/wins/winsserver.c index 8a5fabae4e..0f6717f4a9 100644 --- a/source4/nbt_server/wins/winsserver.c +++ b/source4/nbt_server/wins/winsserver.c @@ -36,6 +36,21 @@ uint32_t wins_server_ttl(struct wins_server *winssrv, uint32_t ttl) return ttl; } +static enum wrepl_name_type wrepl_type(uint16_t nb_flags, struct nbt_name *name, BOOL mhomed) +{ + /* this copes with the nasty hack that is the type 0x1c name */ + if (name->type != NBT_NAME_LOGON) { + return WREPL_TYPE_SGROUP; + } + if (nb_flags & NBT_NM_GROUP) { + return WREPL_TYPE_GROUP; + } + if (mhomed) { + return WREPL_TYPE_MHOMED; + } + return WREPL_TYPE_UNIQUE; +} + /* register a new name with WINS */ @@ -51,6 +66,9 @@ static uint8_t wins_register_new(struct nbt_name_socket *nbtsock, uint16_t nb_flags = packet->additional[0].rdata.netbios.addresses[0].nb_flags; const char *address = packet->additional[0].rdata.netbios.addresses[0].ipaddr; struct winsdb_record rec; + enum wrepl_name_type type; + enum wrepl_name_node node; + BOOL mhomed = ((packet->operation & NBT_OPCODE) == NBT_OPCODE_MULTI_HOME_REG); rec.name = name; rec.nb_flags = nb_flags; @@ -137,7 +155,7 @@ static void nbtd_winsserver_register(struct nbt_name_socket *nbtsock, } /* its an active name - first see if the registration is of the right type */ - if ((rec->nb_flags & NBT_NM_GROUP) && !(nb_flags & NBT_NM_GROUP)) { + if ((rec->type == WREPL_TYPE_GROUP) && !(nb_flags & NBT_NM_GROUP)) { DEBUG(2,("WINS: Attempt to register unique name %s when group name is active\n", nbt_name_string(packet, name))); rcode = NBT_RCODE_ACT; @@ -158,6 +176,15 @@ static void nbtd_winsserver_register(struct nbt_name_socket *nbtsock, goto done; } + /* + * TODO: this complete functions needs a lot of work, + * to handle special group and multiomed registrations + */ + if (name->type == NBT_NAME_LOGON) { + wins_update_ttl(nbtsock, packet, rec, src); + goto done; + } + /* if the registration is for an address that is currently active, then just update the expiry time */ if (winsdb_addr_list_check(rec->addresses, address)) { @@ -246,7 +273,7 @@ static void nbtd_winsserver_release(struct nbt_name_socket *nbtsock, DEBUG(4,("WINS: released name %s at %s\n", nbt_name_string(rec, rec->name), address)); winsdb_addr_list_remove(rec->addresses, address); if (rec->addresses[0] == NULL) { - rec->state = WINS_REC_RELEASED; + rec->state = WREPL_STATE_RELEASED; } winsdb_modify(winssrv, rec); } |