From fccbbf354634b31c9c3cb2bca15843f13e3b77f9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 14 Oct 2005 12:22:15 +0000 Subject: r10997: r11980@SERNOX (orig r10037): metze | 2005-09-05 14:21:40 +0200 add struct nbt_peer_socket and use it instead of passing const char *addr, uint16 port everyhwere (tridge: can you review this please, (make test works) metze (This used to be commit a599d7a4ae881c94be2c2d908a398838549942bb) --- source4/nbt_server/defense.c | 23 +++++++++---------- source4/nbt_server/interfaces.c | 14 ++++++------ source4/nbt_server/nodestatus.c | 18 +++++++-------- source4/nbt_server/packet.c | 40 ++++++++++++++++---------------- source4/nbt_server/query.c | 19 ++++++++-------- source4/nbt_server/wins/winsserver.c | 44 ++++++++++++++++++------------------ source4/nbt_server/wins/winswack.c | 25 ++++++++++---------- 7 files changed, 90 insertions(+), 93 deletions(-) (limited to 'source4/nbt_server') diff --git a/source4/nbt_server/defense.c b/source4/nbt_server/defense.c index 8d71b31c65..f8c73c6a3a 100644 --- a/source4/nbt_server/defense.c +++ b/source4/nbt_server/defense.c @@ -32,24 +32,24 @@ */ void nbtd_request_defense(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_iface_name *iname; struct nbt_name *name; struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, struct nbtd_interface); - NBTD_ASSERT_PACKET(packet, src_address, packet->qdcount == 1); - NBTD_ASSERT_PACKET(packet, src_address, packet->arcount == 1); - NBTD_ASSERT_PACKET(packet, src_address, + NBTD_ASSERT_PACKET(packet, src->addr, packet->qdcount == 1); + NBTD_ASSERT_PACKET(packet, src->addr, packet->arcount == 1); + NBTD_ASSERT_PACKET(packet, src->addr, packet->questions[0].question_type == NBT_QTYPE_NETBIOS); - NBTD_ASSERT_PACKET(packet, src_address, + NBTD_ASSERT_PACKET(packet, src->addr, packet->questions[0].question_class == NBT_QCLASS_IP); - NBTD_ASSERT_PACKET(packet, src_address, + NBTD_ASSERT_PACKET(packet, src->addr, packet->additional[0].rr_type == NBT_QTYPE_NETBIOS); - NBTD_ASSERT_PACKET(packet, src_address, + NBTD_ASSERT_PACKET(packet, src->addr, packet->additional[0].rr_class == NBT_QCLASS_IP); - NBTD_ASSERT_PACKET(packet, src_address, + NBTD_ASSERT_PACKET(packet, src->addr, packet->additional[0].rdata.netbios.length == 6); /* see if we have the requested name on this interface */ @@ -60,10 +60,9 @@ void nbtd_request_defense(struct nbt_name_socket *nbtsock, !IS_GROUP_NAME(name, iname->nb_flags)) { DEBUG(2,("Defending name %s on %s against %s\n", nbt_name_string(packet, name), - iface->bcast_address, src_address)); - nbtd_name_registration_reply(nbtsock, packet, - src_address, src_port, NBT_RCODE_ACT); + iface->bcast_address, src->addr)); + nbtd_name_registration_reply(nbtsock, packet, src, NBT_RCODE_ACT); } else { - nbtd_winsserver_request(nbtsock, packet, src_address, src_port); + nbtd_winsserver_request(nbtsock, packet, src); } } diff --git a/source4/nbt_server/interfaces.c b/source4/nbt_server/interfaces.c index aa22e5d4ad..23276123d5 100644 --- a/source4/nbt_server/interfaces.c +++ b/source4/nbt_server/interfaces.c @@ -32,7 +32,7 @@ */ static void nbtd_request_handler(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); @@ -41,32 +41,32 @@ static void nbtd_request_handler(struct nbt_name_socket *nbtsock, nbtsrv->stats.total_received++; /* see if its from one of our own interfaces - if so, then ignore it */ - if (nbtd_self_packet(nbtsock, packet, src_address, src_port)) { - DEBUG(10,("Ignoring self packet from %s:%d\n", src_address, src_port)); + if (nbtd_self_packet(nbtsock, packet, src)) { + DEBUG(10,("Ignoring self packet from %s:%d\n", src->addr, src->port)); return; } switch (packet->operation & NBT_OPCODE) { case NBT_OPCODE_QUERY: nbtsrv->stats.query_count++; - nbtd_request_query(nbtsock, packet, src_address, src_port); + nbtd_request_query(nbtsock, packet, src); break; case NBT_OPCODE_REGISTER: case NBT_OPCODE_REFRESH: case NBT_OPCODE_REFRESH2: nbtsrv->stats.register_count++; - nbtd_request_defense(nbtsock, packet, src_address, src_port); + nbtd_request_defense(nbtsock, packet, src); break; case NBT_OPCODE_RELEASE: case NBT_OPCODE_MULTI_HOME_REG: nbtsrv->stats.release_count++; - nbtd_winsserver_request(nbtsock, packet, src_address, src_port); + nbtd_winsserver_request(nbtsock, packet, src); break; default: - nbtd_bad_packet(packet, src_address, "Unexpected opcode"); + nbtd_bad_packet(packet, src, "Unexpected opcode"); break; } } diff --git a/source4/nbt_server/nodestatus.c b/source4/nbt_server/nodestatus.c index daae7b8a78..ccbdc2b933 100644 --- a/source4/nbt_server/nodestatus.c +++ b/source4/nbt_server/nodestatus.c @@ -30,7 +30,7 @@ */ static void nbtd_node_status_reply(struct nbt_name_socket *nbtsock, struct nbt_name_packet *request_packet, - const char *src_address, int src_port, + const struct nbt_peer_socket *src, struct nbt_name *name, struct nbtd_interface *iface) { @@ -84,10 +84,10 @@ static void nbtd_node_status_reply(struct nbt_name_socket *nbtsock, ZERO_STRUCT(packet->answers[0].rdata.status.statistics); DEBUG(7,("Sending node status reply for %s to %s:%d\n", - nbt_name_string(packet, name), src_address, src_port)); + nbt_name_string(packet, name), src->addr, src->port)); nbtsrv->stats.total_sent++; - nbt_name_reply_send(nbtsock, src_address, src_port, packet); + nbt_name_reply_send(nbtsock, src, packet); failed: talloc_free(packet); @@ -99,16 +99,16 @@ failed: */ void nbtd_query_status(struct nbt_name_socket *nbtsock, struct nbt_name_packet *packet, - const char *src_address, int src_port) + const struct nbt_peer_socket *src) { struct nbt_name *name; struct nbtd_iface_name *iname; struct nbtd_interface *iface = talloc_get_type(nbtsock->incoming.private, struct nbtd_interface); - NBTD_ASSERT_PACKET(packet, src_address, packet->qdcount == 1); - NBTD_ASSERT_PACKET(packet, src_address, packet->questions[0].question_type == NBT_QTYPE_STATUS); - NBTD_ASSERT_PACKET(packet, src_address, packet->questions[0].question_class == NBT_QCLASS_IP); + NBTD_ASSERT_PACKET(packet, src->addr, packet->qdcount == 1); + NBTD_ASSERT_PACKET(packet, src->addr, packet->questions[0].question_type == NBT_QTYPE_STATUS); + NBTD_ASSERT_PACKET(packet, src->addr, packet->questions[0].question_class == NBT_QCLASS_IP); /* see if we have the requested name on this interface */ name = &packet->questions[0].name; @@ -116,10 +116,10 @@ void nbtd_query_status(struct nbt_name_socket *nbtsock, iname = nbtd_find_iname(iface, name, NBT_NM_ACTIVE); if (iname == NULL) { DEBUG(7,("Node status query for %s from %s - not found on %s\n", - nbt_name_string(packet, name), src_address, iface->ip_address)); + nbt_name_string(packet, name), src->addr, iface->ip_address)); return; } - nbtd_node_status_reply(nbtsock, packet, src_address, src_port, + nbtd_node_status_reply(nbtsock, packet, src, &iname->name, iface); } diff --git a/source4/nbt_server/packet.c b/source4/nbt_server/packet.c index c1e0c4411b..9c9983b63c 100644 --- a/source4/nbt_server/packet.c +++ b/source4/nbt_server/packet.c @@ -28,9 +28,9 @@ we received a badly formed packet - log it */ void nbtd_bad_packet(struct nbt_name_packet *packet, - const char *src_address, const char *reason) + const struct nbt_peer_socket *src, const char *reason) { - DEBUG(2,("nbtd: bad packet '%s' from %s\n", reason, src_address)); + DEBUG(2,("nbtd: bad packet '%s' from %s:%d\n", reason, src->addr, src->port)); if (DEBUGLVL(5)) { NDR_PRINT_DEBUG(nbt_name_packet, packet); } @@ -43,7 +43,7 @@ void nbtd_bad_packet(struct nbt_name_packet *packet, */ BOOL nbtd_self_packet(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); @@ -55,7 +55,7 @@ BOOL nbtd_self_packet(struct nbt_name_socket *nbtsock, } /* if its not from the nbt port, then it wasn't a broadcast from us */ - if (src_port != lp_nbt_port()) { + if (src->port != lp_nbt_port()) { return False; } @@ -69,7 +69,7 @@ BOOL nbtd_self_packet(struct nbt_name_socket *nbtsock, /* we have to loop over our interface list, seeing if its from one of our own interfaces */ for (iface=nbtsrv->interfaces;iface;iface=iface->next) { - if (strcmp(src_address, iface->ip_address) == 0) { + if (strcmp(src->addr, iface->ip_address) == 0) { return True; } } @@ -83,7 +83,7 @@ BOOL nbtd_self_packet(struct nbt_name_socket *nbtsock, */ void nbtd_name_query_reply(struct nbt_name_socket *nbtsock, struct nbt_name_packet *request_packet, - const char *src_address, int src_port, + const struct nbt_peer_socket *src, struct nbt_name *name, uint32_t ttl, uint16_t nb_flags, const char **addresses) { @@ -132,10 +132,10 @@ void nbtd_name_query_reply(struct nbt_name_socket *nbtsock, } DEBUG(7,("Sending name query reply for %s at %s to %s:%d\n", - nbt_name_string(packet, name), addresses[0], src_address, src_port)); + nbt_name_string(packet, name), addresses[0], src->addr, src->port)); nbtsrv->stats.total_sent++; - nbt_name_reply_send(nbtsock, src_address, src_port, packet); + nbt_name_reply_send(nbtsock, src, packet); failed: talloc_free(packet); @@ -147,7 +147,7 @@ failed: */ void nbtd_negative_name_query_reply(struct nbt_name_socket *nbtsock, struct nbt_name_packet *request_packet, - const char *src_address, int src_port) + const struct nbt_peer_socket *src) { struct nbt_name_packet *packet; struct nbt_name *name = &request_packet->questions[0].name; @@ -176,10 +176,10 @@ void nbtd_negative_name_query_reply(struct nbt_name_socket *nbtsock, ZERO_STRUCT(packet->answers[0].rdata); DEBUG(7,("Sending negative name query reply for %s to %s:%d\n", - nbt_name_string(packet, name), src_address, src_port)); + nbt_name_string(packet, name), src->addr, src->port)); nbtsrv->stats.total_sent++; - nbt_name_reply_send(nbtsock, src_address, src_port, packet); + nbt_name_reply_send(nbtsock, src, packet); failed: talloc_free(packet); @@ -190,7 +190,7 @@ failed: */ void nbtd_name_registration_reply(struct nbt_name_socket *nbtsock, struct nbt_name_packet *request_packet, - const char *src_address, int src_port, + const struct nbt_peer_socket *src, uint8_t rcode) { struct nbt_name_packet *packet; @@ -223,10 +223,10 @@ void nbtd_name_registration_reply(struct nbt_name_socket *nbtsock, DEBUG(7,("Sending %s name registration reply for %s to %s:%d\n", rcode==0?"positive":"negative", - nbt_name_string(packet, name), src_address, src_port)); + nbt_name_string(packet, name), src->addr, src->port)); nbtsrv->stats.total_sent++; - nbt_name_reply_send(nbtsock, src_address, src_port, packet); + nbt_name_reply_send(nbtsock, src, packet); failed: talloc_free(packet); @@ -238,7 +238,7 @@ failed: */ void nbtd_name_release_reply(struct nbt_name_socket *nbtsock, struct nbt_name_packet *request_packet, - const char *src_address, int src_port, + const struct nbt_peer_socket *src, uint8_t rcode) { struct nbt_name_packet *packet; @@ -269,10 +269,10 @@ void nbtd_name_release_reply(struct nbt_name_socket *nbtsock, DEBUG(7,("Sending %s name release reply for %s to %s:%d\n", rcode==0?"positive":"negative", - nbt_name_string(packet, name), src_address, src_port)); + nbt_name_string(packet, name), src->addr, src->port)); nbtsrv->stats.total_sent++; - nbt_name_reply_send(nbtsock, src_address, src_port, packet); + nbt_name_reply_send(nbtsock, src, packet); failed: talloc_free(packet); @@ -284,7 +284,7 @@ failed: */ void nbtd_wack_reply(struct nbt_name_socket *nbtsock, struct nbt_name_packet *request_packet, - const char *src_address, int src_port, + const struct nbt_peer_socket *src, uint32_t ttl) { struct nbt_name_packet *packet; @@ -316,10 +316,10 @@ void nbtd_wack_reply(struct nbt_name_socket *nbtsock, RSSVAL(packet->answers[0].rdata.data.data, 0, request_packet->operation); DEBUG(7,("Sending WACK reply for %s to %s:%d\n", - nbt_name_string(packet, name), src_address, src_port)); + nbt_name_string(packet, name), src->addr, src->port)); nbtsrv->stats.total_sent++; - nbt_name_reply_send(nbtsock, src_address, src_port, packet); + nbt_name_reply_send(nbtsock, src, packet); failed: talloc_free(packet); diff --git a/source4/nbt_server/query.c b/source4/nbt_server/query.c index c51a146adf..c64ac5986a 100644 --- a/source4/nbt_server/query.c +++ b/source4/nbt_server/query.c @@ -31,7 +31,7 @@ */ void nbtd_request_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_iface_name *iname; struct nbt_name *name; @@ -41,14 +41,14 @@ void nbtd_request_query(struct nbt_name_socket *nbtsock, /* see if its a node status query */ if (packet->qdcount == 1 && packet->questions[0].question_type == NBT_QTYPE_STATUS) { - nbtd_query_status(nbtsock, packet, src_address, src_port); + nbtd_query_status(nbtsock, packet, src); return; } - NBTD_ASSERT_PACKET(packet, src_address, packet->qdcount == 1); - NBTD_ASSERT_PACKET(packet, src_address, + NBTD_ASSERT_PACKET(packet, src->addr, packet->qdcount == 1); + NBTD_ASSERT_PACKET(packet, src->addr, packet->questions[0].question_type == NBT_QTYPE_NETBIOS); - NBTD_ASSERT_PACKET(packet, src_address, + NBTD_ASSERT_PACKET(packet, src->addr, packet->questions[0].question_class == NBT_QCLASS_IP); /* see if we have the requested name on this interface */ @@ -65,13 +65,12 @@ void nbtd_request_query(struct nbt_name_socket *nbtsock, /* if the name does not exist, then redirect to WINS server if recursion has been asked for */ if (packet->operation & NBT_FLAG_RECURSION_DESIRED) { - nbtd_winsserver_request(nbtsock, packet, src_address, src_port); + nbtd_winsserver_request(nbtsock, packet, src); return; } /* otherwise send a negative reply */ - nbtd_negative_name_query_reply(nbtsock, packet, - src_address, src_port); + nbtd_negative_name_query_reply(nbtsock, packet, src); return; } @@ -80,11 +79,11 @@ void nbtd_request_query(struct nbt_name_socket *nbtsock, if (!(iname->nb_flags & NBT_NM_ACTIVE) && (packet->operation & NBT_FLAG_BROADCAST)) { DEBUG(7,("Query for %s from %s - name not active yet on %s\n", - nbt_name_string(packet, name), src_address, iface->ip_address)); + nbt_name_string(packet, name), src->addr, iface->ip_address)); return; } - nbtd_name_query_reply(nbtsock, packet, src_address, src_port, + nbtd_name_query_reply(nbtsock, packet, src, &iname->name, iname->ttl, iname->nb_flags, nbtd_address_list(iface, packet)); } 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); } -- cgit