summaryrefslogtreecommitdiff
path: root/source4/nbt_server/wins
diff options
context:
space:
mode:
Diffstat (limited to 'source4/nbt_server/wins')
-rw-r--r--source4/nbt_server/wins/winsserver.c44
-rw-r--r--source4/nbt_server/wins/winswack.c25
2 files changed, 34 insertions, 35 deletions
diff --git a/source4/nbt_server/wins/winsserver.c b/source4/nbt_server/wins/winsserver.c
index 5470a38c97..c9758b3162 100644
--- a/source4/nbt_server/wins/winsserver.c
+++ b/source4/nbt_server/wins/winsserver.c
@@ -41,7 +41,7 @@ uint32_t wins_server_ttl(struct wins_server *winssrv, uint32_t ttl)
*/
static uint8_t wins_register_new(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
- const char *src_address, int src_port)
+ const struct nbt_peer_socket *src)
{
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
struct nbtd_interface);
@@ -56,7 +56,7 @@ static uint8_t wins_register_new(struct nbt_name_socket *nbtsock,
rec.nb_flags = nb_flags;
rec.state = WINS_REC_ACTIVE;
rec.expire_time = time(NULL) + ttl;
- rec.registered_by = src_address;
+ rec.registered_by = src->addr;
if (IS_GROUP_NAME(name, nb_flags)) {
rec.addresses = str_list_make(packet, "255.255.255.255", NULL);
} else {
@@ -77,7 +77,7 @@ static uint8_t wins_register_new(struct nbt_name_socket *nbtsock,
static uint8_t wins_update_ttl(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
struct winsdb_record *rec,
- const char *src_address, int src_port)
+ const struct nbt_peer_socket *src)
{
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
struct nbtd_interface);
@@ -89,7 +89,7 @@ static uint8_t wins_update_ttl(struct nbt_name_socket *nbtsock,
if (now + ttl > rec->expire_time) {
rec->expire_time = now + ttl;
}
- rec->registered_by = src_address;
+ rec->registered_by = src->addr;
DEBUG(5,("WINS: refreshed registration of %s at %s\n",
nbt_name_string(packet, rec->name), address));
@@ -102,7 +102,7 @@ static uint8_t wins_update_ttl(struct nbt_name_socket *nbtsock,
*/
static void nbtd_winsserver_register(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
- const char *src_address, int src_port)
+ const struct nbt_peer_socket *src)
{
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
struct nbtd_interface);
@@ -121,11 +121,11 @@ static void nbtd_winsserver_register(struct nbt_name_socket *nbtsock,
rec = winsdb_load(winssrv, name, packet);
if (rec == NULL) {
- rcode = wins_register_new(nbtsock, packet, src_address, src_port);
+ rcode = wins_register_new(nbtsock, packet, src);
goto done;
} else if (rec->state != WINS_REC_ACTIVE) {
winsdb_delete(winssrv, rec);
- rcode = wins_register_new(nbtsock, packet, src_address, src_port);
+ rcode = wins_register_new(nbtsock, packet, src);
goto done;
}
@@ -140,31 +140,31 @@ static void nbtd_winsserver_register(struct nbt_name_socket *nbtsock,
/* if its an active unique name, and the registration is for a group, then
see if the unique name owner still wants the name */
if (!(rec->nb_flags & NBT_NM_GROUP) && (nb_flags & NBT_NM_GROUP)) {
- wins_register_wack(nbtsock, packet, rec, src_address, src_port);
+ wins_register_wack(nbtsock, packet, rec, src);
return;
}
/* if the registration is for a group, then just update the expiry time
and we are done */
if (IS_GROUP_NAME(name, nb_flags)) {
- wins_update_ttl(nbtsock, packet, rec, src_address, src_port);
+ 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 (str_list_check(rec->addresses, address)) {
- wins_update_ttl(nbtsock, packet, rec, src_address, src_port);
+ wins_update_ttl(nbtsock, packet, rec, src);
goto done;
}
/* we have to do a WACK to see if the current owner is willing
to give up its claim */
- wins_register_wack(nbtsock, packet, rec, src_address, src_port);
+ wins_register_wack(nbtsock, packet, rec, src);
return;
done:
- nbtd_name_registration_reply(nbtsock, packet, src_address, src_port, rcode);
+ nbtd_name_registration_reply(nbtsock, packet, src, rcode);
}
@@ -174,7 +174,7 @@ done:
*/
static void nbtd_winsserver_query(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
- const char *src_address, int src_port)
+ const struct nbt_peer_socket *src)
{
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
struct nbtd_interface);
@@ -184,11 +184,11 @@ static void nbtd_winsserver_query(struct nbt_name_socket *nbtsock,
rec = winsdb_load(winssrv, name, packet);
if (rec == NULL || rec->state != WINS_REC_ACTIVE) {
- nbtd_negative_name_query_reply(nbtsock, packet, src_address, src_port);
+ nbtd_negative_name_query_reply(nbtsock, packet, src);
return;
}
- nbtd_name_query_reply(nbtsock, packet, src_address, src_port, name,
+ nbtd_name_query_reply(nbtsock, packet, src, name,
0, rec->nb_flags, rec->addresses);
}
@@ -197,7 +197,7 @@ static void nbtd_winsserver_query(struct nbt_name_socket *nbtsock,
*/
static void nbtd_winsserver_release(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
- const char *src_address, int src_port)
+ const struct nbt_peer_socket *src)
{
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
struct nbtd_interface);
@@ -214,7 +214,7 @@ static void nbtd_winsserver_release(struct nbt_name_socket *nbtsock,
/* we only allow releases from an owner - other releases are
silently ignored */
- if (str_list_check(rec->addresses, src_address)) {
+ if (str_list_check(rec->addresses, src->addr)) {
const char *address = packet->additional[0].rdata.netbios.addresses[0].ipaddr;
DEBUG(4,("WINS: released name %s at %s\n", nbt_name_string(rec, rec->name), address));
@@ -227,7 +227,7 @@ static void nbtd_winsserver_release(struct nbt_name_socket *nbtsock,
done:
/* we match w2k3 by always giving a positive reply to name releases. */
- nbtd_name_release_reply(nbtsock, packet, src_address, src_port, NBT_RCODE_OK);
+ nbtd_name_release_reply(nbtsock, packet, src, NBT_RCODE_OK);
}
@@ -236,7 +236,7 @@ done:
*/
void nbtd_winsserver_request(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
- const char *src_address, int src_port)
+ const struct nbt_peer_socket *src)
{
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
struct nbtd_interface);
@@ -247,18 +247,18 @@ void nbtd_winsserver_request(struct nbt_name_socket *nbtsock,
switch (packet->operation & NBT_OPCODE) {
case NBT_OPCODE_QUERY:
- nbtd_winsserver_query(nbtsock, packet, src_address, src_port);
+ nbtd_winsserver_query(nbtsock, packet, src);
break;
case NBT_OPCODE_REGISTER:
case NBT_OPCODE_REFRESH:
case NBT_OPCODE_REFRESH2:
case NBT_OPCODE_MULTI_HOME_REG:
- nbtd_winsserver_register(nbtsock, packet, src_address, src_port);
+ nbtd_winsserver_register(nbtsock, packet, src);
break;
case NBT_OPCODE_RELEASE:
- nbtd_winsserver_release(nbtsock, packet, src_address, src_port);
+ nbtd_winsserver_release(nbtsock, packet, src);
break;
}
diff --git a/source4/nbt_server/wins/winswack.c b/source4/nbt_server/wins/winswack.c
index 8c7841d095..c9f102fdc8 100644
--- a/source4/nbt_server/wins/winswack.c
+++ b/source4/nbt_server/wins/winswack.c
@@ -30,8 +30,7 @@ struct wack_state {
struct nbt_name_socket *nbtsock;
struct nbt_name_packet *request_packet;
struct winsdb_record *rec;
- const char *src_address;
- int src_port;
+ struct nbt_peer_socket src;
const char **owner_addresses;
const char *reg_address;
struct nbt_name_query query;
@@ -44,9 +43,9 @@ struct wack_state {
static void wins_wack_deny(struct wack_state *state)
{
nbtd_name_registration_reply(state->nbtsock, state->request_packet,
- state->src_address, state->src_port, NBT_RCODE_ACT);
- DEBUG(4,("WINS: denied name registration request for %s from %s\n",
- nbt_name_string(state, state->rec->name), state->src_address));
+ &state->src, NBT_RCODE_ACT);
+ DEBUG(4,("WINS: denied name registration request for %s from %s:%d\n",
+ nbt_name_string(state, state->rec->name), state->src.addr, state->src.port));
talloc_free(state);
}
@@ -68,7 +67,7 @@ static void wins_wack_allow(struct wack_state *state)
}
nbtd_name_registration_reply(state->nbtsock, state->request_packet,
- state->src_address, state->src_port, NBT_RCODE_OK);
+ &state->src, NBT_RCODE_OK);
rec->addresses = str_list_add(rec->addresses, state->reg_address);
if (rec->addresses == NULL) goto failed;
@@ -77,7 +76,7 @@ static void wins_wack_allow(struct wack_state *state)
if (now + ttl > rec->expire_time) {
rec->expire_time = now + ttl;
}
- rec->registered_by = state->src_address;
+ rec->registered_by = state->src.addr;
winsdb_modify(state->winssrv, rec);
@@ -158,7 +157,7 @@ failed:
void wins_register_wack(struct nbt_name_socket *nbtsock,
struct nbt_name_packet *packet,
struct winsdb_record *rec,
- const char *src_address, int src_port)
+ const struct nbt_peer_socket *src)
{
struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private,
struct nbtd_interface);
@@ -175,11 +174,11 @@ void wins_register_wack(struct nbt_name_socket *nbtsock,
state->nbtsock = nbtsock;
state->request_packet = talloc_steal(state, packet);
state->rec = talloc_steal(state, rec);
- state->src_port = src_port;
state->owner_addresses = rec->addresses;
state->reg_address = packet->additional[0].rdata.netbios.addresses[0].ipaddr;
- state->src_address = talloc_strdup(state, src_address);
- if (state->src_address == NULL) goto failed;
+ state->src.port = src->port;
+ state->src.addr = talloc_strdup(state, src->addr);
+ if (state->src.addr == NULL) goto failed;
/* setup a name query to the first address */
state->query.in.name = *rec->name;
@@ -198,7 +197,7 @@ void wins_register_wack(struct nbt_name_socket *nbtsock,
/* send a WACK to the client, specifying the maximum time it could
take to check with the owner, plus some slack */
ttl = 5 + 4 * str_list_length(rec->addresses);
- nbtd_wack_reply(nbtsock, packet, src_address, src_port, ttl);
+ nbtd_wack_reply(nbtsock, packet, src, ttl);
req = nbt_name_query_send(nbtsock, &state->query);
if (req == NULL) goto failed;
@@ -209,5 +208,5 @@ void wins_register_wack(struct nbt_name_socket *nbtsock,
failed:
talloc_free(state);
- nbtd_name_registration_reply(nbtsock, packet, src_address, src_port, NBT_RCODE_SVR);
+ nbtd_name_registration_reply(nbtsock, packet, src, NBT_RCODE_SVR);
}