Ejemplo n.º 1
0
static struct node_status *lookup_byaddr_backend(char *addr, int *count)
{
	int fd;
	struct in_addr  ip;
	struct nmb_name nname;
	struct node_status *status;

	fd = wins_lookup_open_socket_in();
	if (fd == -1)
		return NULL;

	make_nmb_name(&nname, "*", 0);
	ip = *interpret_addr2(addr);
	status = node_status_query(fd,&nname,ip, count, NULL);

	close(fd);
	return status;
}
Ejemplo n.º 2
0
static struct in_addr *lookup_byname_backend(const char *name, int *count)
{
	int fd;
	struct ip_service *ret = NULL;
	struct in_addr *return_ip;
	int j, i, flags = 0;

	*count = 0;

	/* always try with wins first */
	if (resolve_wins(name,0x20,&ret,count)) {
		if ( count == 0 )
			return NULL;
		if ( (return_ip = (struct in_addr *)malloc((*count)*sizeof(struct in_addr))) == NULL ) {
			free( ret );
			return NULL;
		}

		/* copy the IP addresses */
		for ( i=0; i<(*count); i++ ) 
			return_ip[i] = ret[i].ip;
		
		free( ret );
		return return_ip;
	}

	fd = wins_lookup_open_socket_in();
	if (fd == -1) {
		return NULL;
	}

	/* uggh, we have to broadcast to each interface in turn */
	for (j=iface_count() - 1;
	     j >= 0;
	     j--) {
		struct in_addr *bcast = iface_n_bcast(j);
		return_ip = name_query(fd,name,0x20,True,True,*bcast,count, &flags, NULL);
		if (return_ip) break;
	}

	close(fd);
	return return_ip;
}
Ejemplo n.º 3
0
static struct in_addr *lookup_byname_backend(const char *name, int *count)
{
	int fd;
	struct in_addr *ret = NULL;
	struct in_addr  p;
	int j, flags;

	*count = 0;

	fd = wins_lookup_open_socket_in();
	if (fd == -1)
		return NULL;

	p = wins_srv_ip();
	if( !is_zero_ip(p) ) {
		ret = name_query(fd,name,0x20,False,True, p, count, &flags);
		goto out;
	}

	if (lp_wins_support()) {
		/* we are our own WINS server */
		ret = name_query(fd,name,0x20,False,True, *interpret_addr2("127.0.0.1"), count, &flags);
		goto out;
	}

	/* uggh, we have to broadcast to each interface in turn */
	for (j=iface_count() - 1;
	     j >= 0;
	     j--) {
		struct in_addr *bcast = iface_n_bcast(j);
		ret = name_query(fd,name,0x20,True,True,*bcast,count, &flags);
		if (ret) break;
	}

 out:

	close(fd);
	return ret;
}