/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <synch.h>
#include <stdio.h>
#include <syslog.h>
#include <stdlib.h>
#include <netdb.h>
#include <smbsrv/libsmbns.h>
#include <smbns_netbios.h>
#include <smbns_hash.h>
unsigned char *scope);
int
smb_netbios_cache_init(void)
{
(void) rw_wrlock(&nb_cache_lock);
if (smb_netbios_cache == NULL) {
if (smb_netbios_cache == NULL) {
(void) rw_unlock(&nb_cache_lock);
return (-1);
}
}
(void) rw_unlock(&nb_cache_lock);
return (0);
}
void
smb_netbios_cache_fini(void)
{
(void) rw_wrlock(&nb_cache_lock);
(void) rw_unlock(&nb_cache_lock);
}
void
smb_netbios_cache_clean(void)
{
(void) rw_wrlock(&nb_cache_lock);
(void) ht_clean_table(smb_netbios_cache);
(void) rw_unlock(&nb_cache_lock);
}
int
{
(void) rw_rdlock(&nb_cache_lock);
(void) rw_unlock(&nb_cache_lock);
return (-1);
}
(void) rw_unlock(&nb_cache_lock);
}
int
{
(void) rw_rdlock(&nb_cache_lock);
(void) rw_unlock(&nb_cache_lock);
return (-1);
}
(void) rw_unlock(&nb_cache_lock);
}
/*
* smb_netbios_cache_lookup
*
* Searches the name cache for the given entry, if found
* the entry will be locked before returning to caller
* so caller MUST unlock the entry after it's done with it.
*/
struct name_entry *
{
/* Return our address */
!= 0)
return (NULL);
}
(void) rw_rdlock(&nb_cache_lock);
if (item) {
}
}
(void) rw_unlock(&nb_cache_lock);
return (entry);
}
void
{
if (name)
}
/*
* smb_netbios_cache_lookup_addr
*
* lookup the given 'name' in the cache and then checks
* if the address also matches with the found entry.
* 'name' is supposed to contain only one address.
*
* The found entry will be locked before returning to caller
* so caller MUST unlock the entry after it's done with it.
*/
struct name_entry *
{
(void) rw_rdlock(&nb_cache_lock);
do {
/* note that entry lock isn't released here */
(void) rw_unlock(&nb_cache_lock);
return (entry);
}
}
(void) rw_unlock(&nb_cache_lock);
return (0);
}
int
{
int rc;
/* No point in adding a name with IP address 255.255.255.255 */
return (0);
(void) rw_wrlock(&nb_cache_lock);
/* Name already exists */
entry->attributes |=
(void) rw_unlock(&nb_cache_lock);
return (0);
}
/* Was not primary: looks for others */
(void) rw_unlock(&nb_cache_lock);
return (0);
}
}
rc = 0;
} else {
rc = -1;
}
(void) rw_unlock(&nb_cache_lock);
return (rc);
}
(void) rw_unlock(&nb_cache_lock);
return (-1);
}
(void) rw_unlock(&nb_cache_lock);
return (-1);
}
(void) rw_unlock(&nb_cache_lock);
return (0);
}
void
{
(void) rw_wrlock(&nb_cache_lock);
}
(void) rw_unlock(&nb_cache_lock);
}
/*
* smb_netbios_cache_insert_list
*
* Insert a name with multiple addresses
*/
int
{
do {
&entry);
(void) smb_netbios_cache_insert(&entry);
return (0);
}
void
struct name_entry *name)
{
do {
} else {
do {
return;
}
}
}
/*
* smb_netbios_cache_status
*
* Scan the name cache and gather status for
* Node Status response for names in the given scope
*/
unsigned char *
{
unsigned char *numnames;
unsigned char *scan;
unsigned char *scan_end;
*numnames = 0;
(void) rw_rdlock(&nb_cache_lock);
do {
if (item == 0)
break;
continue;
/* no room for adding next entry */
break;
scan += NETBIOS_NAME_SZ;
(*numnames)++;
}
(void) rw_unlock(&nb_cache_lock);
return (scan);
}
void
{
(void) rw_rdlock(&nb_cache_lock);
do {
if (item == 0)
break;
continue;
do {
if (addr->refresh_ttl)
else
}
(void) rw_unlock(&nb_cache_lock);
}
/*
* Returns TRUE when given name is added to the refresh queue
* FALSE if not.
*/
static boolean_t
{
if (refent) {
}
/* next name */
return (B_TRUE);
}
} else {
if (refent) {
}
/* next name */
return (B_TRUE);
}
return (B_FALSE);
}
/*
* smb_netbios_cache_refresh
*
* Scans the name cache and add all local unique names
* and non-local names the passed refresh queue. Non-
* local names will also be marked as deleted.
*
* NOTE that the caller MUST protect the queue using
* its mutex
*/
void
{
(void) rw_rdlock(&nb_cache_lock);
do { /* name loop */
if (item == 0)
break;
continue;
do { /* address loop */
item))
break;
}
}
(void) rw_unlock(&nb_cache_lock);
}
/*
* smb_netbios_cache_delete_locals
*
* Scans the name cache and add all local names to
* the passed delete queue.
*
* NOTE that the caller MUST protect the queue using
* its mutex
*/
void
{
(void) rw_wrlock(&nb_cache_lock);
do {
if (item == 0)
break;
continue;
if (delent) {
}
}
(void) rw_unlock(&nb_cache_lock);
}
void
{
if (entry == 0)
return;
}
}
/*
* smb_netbios_cache_count
*
* Returns the number of names in the cache
*/
int
{
int cnt;
(void) rw_rdlock(&nb_cache_lock);
(void) rw_unlock(&nb_cache_lock);
return (cnt);
}
void
{
(void) rw_rdlock(&nb_cache_lock);
if (ht_get_total_items(smb_netbios_cache) != 0) {
"Name", "Type", "Address", "TTL");
"-------------------------------",
"------------------------------");
}
while (item) {
}
}
(void) rw_unlock(&nb_cache_lock);
}
void
{
char *type;
int count = 0;
do {
if (count == 0)
else
++count;
}
void
{
do {
}
/*
* smb_netbios_name_dup
*
* Duplicate the given name entry. If 'alladdr' is 0 only
* copy the primary address otherwise duplicate all the
* addresses. NOTE that the duplicate structure is not
* like a regular cache entry i.e. it's a contiguous block
* of memory and each addr structure doesn't have it's own
* allocated memory. So, the returned structure can be freed
* by one free call.
*/
struct name_entry *
{
int addr_cnt = 0;
int size = 0;
if (alladdr) {
addr_cnt++;
}
}
size = sizeof (struct name_entry) +
(addr_cnt * sizeof (addr_entry_t));
if (dup == 0)
return (0);
if (alladdr == 0)
return (dup);
/* LINTED - E_BAD_PTR_CAST_ALIGN */
sizeof (struct name_entry));
dup_addr++;
}
return (dup);
}
static void
{
char *p;
*p = '\0';
}
}
static void
{
}
}
/*ARGSUSED*/
static int
{
int res;
if (res == 0) {
/* Names are the same, compare scopes */
}
return (res);
}
static void
{
}