2003-11-29 00:19:19 +00:00
|
|
|
/* Copyright (c) 2003 Juan Lang
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 12:49:52 +00:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-11-29 00:19:19 +00:00
|
|
|
*/
|
|
|
|
#ifndef __WINE_NBNAMECACHE_H
|
|
|
|
#define __WINE_NBNAMECACHE_H
|
|
|
|
|
2004-02-10 20:09:43 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
2003-11-29 00:19:19 +00:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "nb30.h"
|
|
|
|
|
|
|
|
struct NBNameCache;
|
|
|
|
|
|
|
|
/* Represents an entry in the name cache. If the NetBIOS name is known, it's
|
|
|
|
* in nbname. Otherwise, nbname begins with '*'. numAddresses defines the
|
|
|
|
* number of addresses in addresses.
|
|
|
|
* Notice that it allows multiple addresses per name, but doesn't explicitly
|
|
|
|
* allow group names. That's because all names so far are unique; if a use for
|
|
|
|
* group names comes up, adding a flag here is simple enough.
|
|
|
|
* Also, only the first NCBNAMSZ - 1 bytes are considered significant. This is
|
|
|
|
* because a name may have been resolved using DNS, and the suffix byte is
|
|
|
|
* always truncated for DNS lookups.
|
|
|
|
*/
|
|
|
|
typedef struct _NBNameCacheEntry
|
|
|
|
{
|
|
|
|
UCHAR name[NCBNAMSZ];
|
|
|
|
UCHAR nbname[NCBNAMSZ];
|
|
|
|
DWORD numAddresses;
|
|
|
|
DWORD addresses[1];
|
|
|
|
} NBNameCacheEntry;
|
|
|
|
|
|
|
|
/* Functions that create, manipulate, and destroy a name cache. Thread-safe,
|
|
|
|
* with the exception of NBNameCacheDestroy--ensure that no other threads are
|
2008-04-08 21:22:43 +00:00
|
|
|
* manipulating the cache before destroying it.
|
2003-11-29 00:19:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Allocates a new name cache from heap, and sets the expire time on new
|
|
|
|
* entries to entryExpireTimeMS after a cache entry is added.
|
|
|
|
*/
|
2011-05-13 15:39:17 +00:00
|
|
|
struct NBNameCache *NBNameCacheCreate(HANDLE heap, DWORD entryExpireTimeMS) DECLSPEC_HIDDEN;
|
2003-11-29 00:19:19 +00:00
|
|
|
|
|
|
|
/* Adds an entry to the cache. The entry is assumed to have been allocated
|
|
|
|
* from the same heap as the name cache; the name cache will own the entry
|
|
|
|
* from now on. The entry's expire time is initialized at this time to
|
|
|
|
* entryExpireTimeMS + the current time in MS. If an existing entry with the
|
|
|
|
* same name was in the cache, the entry is replaced. Returns TRUE on success
|
|
|
|
* or FALSE on failure.
|
|
|
|
*/
|
2011-05-13 15:39:17 +00:00
|
|
|
BOOL NBNameCacheAddEntry(struct NBNameCache *cache, NBNameCacheEntry *entry) DECLSPEC_HIDDEN;
|
2003-11-29 00:19:19 +00:00
|
|
|
|
|
|
|
/* Finds the entry with name name in the cache and returns a pointer to it, or
|
|
|
|
* NULL if it isn't found.
|
|
|
|
*/
|
|
|
|
const NBNameCacheEntry *NBNameCacheFindEntry(struct NBNameCache *cache,
|
2011-05-13 15:39:17 +00:00
|
|
|
const UCHAR name[NCBNAMSZ]) DECLSPEC_HIDDEN;
|
2003-11-29 00:19:19 +00:00
|
|
|
|
2011-05-13 15:39:17 +00:00
|
|
|
void NBNameCacheDestroy(struct NBNameCache *cache) DECLSPEC_HIDDEN;
|
2003-11-29 00:19:19 +00:00
|
|
|
|
|
|
|
#endif /* ndef __WINE_NBNAMECACHE_H */
|