This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
unstring name;
struct packet_struct *original_packet;
struct subnet_record *orig_broadcast_subnet;
- struct name_record *namerec;
+ struct name_record *namerec = NULL;
uint16 nb_flags;
int num_ips;
int i;
memcpy( (char *)&original_packet, &userdata->data[sizeof(struct subnet_record *)],
sizeof(struct packet_struct *) );
- nb_flags = get_nb_flags( rrec->rdata );
+ if (rrec) {
+ nb_flags = get_nb_flags( rrec->rdata );
+ num_ips = rrec->rdlength / 6;
+ } else {
+ nb_flags = 0;
+ num_ips = 0;
+ }
- num_ips = rrec->rdlength / 6;
if(num_ips == 0) {
DEBUG(0,("wins_proxy_name_query_request_success: Invalid number of IP records (0) \
returned for name %s.\n", nmb_namestr(nmbname) ));
return;
}
- for(i = 0; i < num_ips; i++)
+ for(i = 0; i < num_ips; i++) {
putip( (char *)&iplist[i], (char *)&rrec->rdata[ (i*6) + 2]);
+ }
}
/* Add the queried name to the original subnet as a WINS_PROXY_NAME. */
- if(rrec == PERMANENT_TTL)
+ if(rrec->ttl == PERMANENT_TTL) {
ttl = lp_max_ttl();
+ }
pull_ascii_nstring(name, sizeof(name), nmbname->name);
- namerec = add_name_to_subnet( orig_broadcast_subnet, name,
+ add_name_to_subnet( orig_broadcast_subnet, name,
nmbname->name_type, nb_flags, ttl,
WINS_PROXY_NAME, num_ips, iplist );
- if(iplist != &ip)
+ if(iplist != &ip) {
SAFE_FREE(iplist);
+ }
+
+ namerec = find_name_on_subnet(orig_broadcast_subnet, nmbname, FIND_ANY_NAME);
+ if (!namerec) {
+ DEBUG(0,("wins_proxy_name_query_request_success: failed to add "
+ "name %s to subnet %s !\n",
+ name,
+ orig_broadcast_subnet->subnet_name ));
+ return;
+ }
/*
* Check that none of the IP addresses we are returning is on the
if(namerec && original_packet->packet.nmb.header.nm_flags.bcast) {
for( i = 0; i < namerec->data.num_ips; i++) {
- if( same_net( namerec->data.ip[i], orig_broadcast_subnet->myip,
+ if( same_net_v4( namerec->data.ip[i], orig_broadcast_subnet->myip,
orig_broadcast_subnet->mask_ip ) ) {
DEBUG( 5, ( "wins_proxy_name_query_request_success: name %s is a WINS \
proxy name and is also on the same subnet (%s) as the requestor. \