nbnamecache.h 2.91 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* 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
15
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16 17 18 19
 */
#ifndef __WINE_NBNAMECACHE_H
#define __WINE_NBNAMECACHE_H

20 21 22
#include <stdarg.h>

#include "windef.h"
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
#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
Austin English's avatar
Austin English committed
48
 * manipulating the cache before destroying it.
49 50 51 52 53
 */

/* Allocates a new name cache from heap, and sets the expire time on new
 * entries to entryExpireTimeMS after a cache entry is added.
 */
54
struct NBNameCache *NBNameCacheCreate(HANDLE heap, DWORD entryExpireTimeMS) DECLSPEC_HIDDEN;
55 56 57 58 59 60 61 62

/* 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.
 */
63
BOOL NBNameCacheAddEntry(struct NBNameCache *cache, NBNameCacheEntry *entry) DECLSPEC_HIDDEN;
64 65 66 67 68

/* 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,
69
 const UCHAR name[NCBNAMSZ]) DECLSPEC_HIDDEN;
70

71
void NBNameCacheDestroy(struct NBNameCache *cache) DECLSPEC_HIDDEN;
72 73

#endif /* ndef __WINE_NBNAMECACHE_H */