libsmb/namecache.c

ソースコードを見る。

関数

BOOL namecache_enable (void)
 Initialise namecache system.
BOOL namecache_shutdown (void)
 Shutdown namecache.
static char * namecache_key (const char *name, int name_type)
 Generates a key for netbios name lookups on basis of netbios name and type.
BOOL namecache_store (const char *name, int name_type, int num_names, struct ip_service *ip_list)
 Store a name(s) in the name cache
BOOL namecache_fetch (const char *name, int name_type, struct ip_service **ip_list, int *num_names)
 Look up a name in the cache.
BOOL namecache_delete (const char *name, int name_type)
 Remove a namecache entry.
static void flush_netbios_name (const char *key, const char *value, time_t timeout, void *dptr)
 Delete single namecache entry.
void namecache_flush (void)
 Flush all names from the name cache.
static char * namecache_status_record_key (const char *name, int name_type1, int name_type2, struct in_addr keyip)
BOOL namecache_status_store (const char *keyname, int keyname_type, int name_type, struct in_addr keyip, const char *srvname)
BOOL namecache_status_fetch (const char *keyname, int keyname_type, int name_type, struct in_addr keyip, char *srvname_out)


関数

BOOL namecache_enable ( void   ) 

Initialise namecache system.

Function calls gencache initialisation function to perform necessary actions

戻り値:
true upon successful initialisation of the cache or false on failure

namecache.c37 行で定義されています。

参照先 gencache_init().

参照元 main().

00038 {
00039         /*
00040          * Check if name caching disabled by setting the name cache
00041          * timeout to zero.
00042          */ 
00043 
00044         if (lp_name_cache_timeout() == 0) {
00045                 DEBUG(5, ("namecache_enable: disabling netbios name cache\n"));
00046                 return False;
00047         }
00048 
00049         /* Init namecache by calling gencache initialisation */
00050 
00051         if (!gencache_init()) {
00052                 DEBUG(2, ("namecache_enable: Couldn't initialise namecache on top of gencache.\n"));
00053                 return False;
00054         }
00055 
00056         /* I leave it for now, though I don't think we really need this (mimir, 27.09.2002) */
00057         DEBUG(5, ("namecache_enable: enabling netbios namecache, timeout %d "
00058                   "seconds\n", lp_name_cache_timeout()));
00059 
00060         return True;
00061 }

BOOL namecache_shutdown ( void   ) 

Shutdown namecache.

Routine calls gencache close function to safely close gencache file.

戻り値:
true upon successful shutdown of the cache or false on failure

namecache.c72 行で定義されています。

参照先 gencache_shutdown().

参照元 main()send_fs_socket().

00073 {
00074         if (!gencache_shutdown()) {
00075                 DEBUG(2, ("namecache_shutdown: Couldn't close namecache on top of gencache.\n"));
00076                 return False;
00077         }
00078         
00079         DEBUG(5, ("namecache_shutdown: netbios namecache closed successfully.\n"));
00080         return True;
00081 }

static char* namecache_key ( const char *  name,
int  name_type 
) [static]

Generates a key for netbios name lookups on basis of netbios name and type.

The caller must free returned key string when finished.

引数:
name netbios name string (case insensitive)
name_type netbios type of the name being looked up
戻り値:
string consisted of uppercased name and appended type number

namecache.c96 行で定義されています。

参照先 asprintf()strupper_static().

参照元 namecache_delete()namecache_fetch()namecache_store().

00097 {
00098         char *keystr;
00099         asprintf(&keystr, NBTKEY_FMT, strupper_static(name), name_type);
00100 
00101         return keystr;
00102 }

BOOL namecache_store ( const char *  name,
int  name_type,
int  num_names,
struct ip_service ip_list 
)

Store a name(s) in the name cache

引数:
name netbios names array
name_type integer netbios name type
num_names number of names being stored
ip_list array of in_addr structures containing ip addresses being stored

namecache.c115 行で定義されています。

参照先 DEBUGLEVELgencache_init()gencache_set()ipstr_list_make()namecache_key()port.

参照元 dcip_to_name()internal_resolve_name().

00117 {
00118         time_t expiry;
00119         char *key, *value_string;
00120         int i;
00121         BOOL ret;
00122 
00123         /*
00124          * we use gecache call to avoid annoying debug messages about
00125          * initialised namecache again and again...
00126          */
00127         if (!gencache_init()) return False;
00128 
00129         if (name_type > 255) {
00130                 return False; /* Don't store non-real name types. */
00131         }
00132 
00133         if ( DEBUGLEVEL >= 5 ) {
00134                 DEBUG(5, ("namecache_store: storing %d address%s for %s#%02x: ",
00135                         num_names, num_names == 1 ? "": "es", name, name_type));
00136 
00137                 for (i = 0; i < num_names; i++) 
00138                         DEBUGADD(5, ("%s:%d%s", inet_ntoa(ip_list[i].ip), 
00139                                 ip_list[i].port, (i == (num_names - 1) ? "" : ",")));
00140                         
00141                 DEBUGADD(5, ("\n"));
00142         }
00143         
00144         key = namecache_key(name, name_type);
00145         if (!key) {
00146                 return False;
00147         }
00148 
00149         expiry = time(NULL) + lp_name_cache_timeout();
00150 
00151         /*
00152          * Generate string representation of ip addresses list
00153          * First, store the number of ip addresses and then
00154          * place each single ip
00155          */
00156         if (!ipstr_list_make(&value_string, ip_list, num_names)) {
00157                 SAFE_FREE(key);
00158                 SAFE_FREE(value_string);
00159                 return False;
00160         }
00161         
00162         /* set the entry */
00163         ret = gencache_set(key, value_string, expiry);
00164         SAFE_FREE(key);
00165         SAFE_FREE(value_string);
00166         return ret;
00167 }

BOOL namecache_fetch ( const char *  name,
int  name_type,
struct ip_service **  ip_list,
int *  num_names 
)

Look up a name in the cache.

引数:
name netbios name to look up for
name_type netbios name type of
name 
ip_list mallocated list of IP addresses if found in the cache, NULL otherwise
num_names number of entries found
戻り値:
true upon successful fetch or false if name isn't found in the cache or has expired

namecache.c183 行で定義されています。

参照先 gencache_get()gencache_init()ipstr_list_parse()namecache_key()timeout.

参照元 internal_resolve_name().

00185 {
00186         char *key, *value;
00187         time_t timeout;
00188 
00189         /* exit now if null pointers were passed as they're required further */
00190         if (!ip_list || !num_names) return False;
00191 
00192         if (!gencache_init())
00193                 return False;
00194 
00195         if (name_type > 255) {
00196                 return False; /* Don't fetch non-real name types. */
00197         }
00198 
00199         *num_names = 0;
00200 
00201         /* 
00202          * Use gencache interface - lookup the key
00203          */
00204         key = namecache_key(name, name_type);
00205         if (!key) {
00206                 return False;
00207         }
00208 
00209         if (!gencache_get(key, &value, &timeout)) {
00210                 DEBUG(5, ("no entry for %s#%02X found.\n", name, name_type));
00211                 SAFE_FREE(key);
00212                 return False;
00213         } else {
00214                 DEBUG(5, ("name %s#%02X found.\n", name, name_type));
00215         }
00216         
00217         /*
00218          * Split up the stored value into the list of IP adresses
00219          */
00220         *num_names = ipstr_list_parse(value, ip_list);
00221         
00222         SAFE_FREE(key);
00223         SAFE_FREE(value);
00224                          
00225         return *num_names > 0;          /* true only if some ip has been fetched */
00226 }

BOOL namecache_delete ( const char *  name,
int  name_type 
)

Remove a namecache entry.

Needed for site support.

namecache.c233 行で定義されています。

参照先 gencache_del()gencache_init()namecache_key().

参照元 ads_dc_name()ads_find_dc()ads_startup_int().

00234 {
00235         BOOL ret;
00236         char *key;
00237 
00238         if (!gencache_init())
00239                 return False;
00240 
00241         if (name_type > 255) {
00242                 return False; /* Don't fetch non-real name types. */
00243         }
00244 
00245         key = namecache_key(name, name_type);
00246         if (!key) {
00247                 return False;
00248         }
00249         ret = gencache_del(key);
00250         SAFE_FREE(key);
00251         return ret;
00252 }

static void flush_netbios_name ( const char *  key,
const char *  value,
time_t  timeout,
void *  dptr 
) [static]

Delete single namecache entry.

Look at the gencache_iterate definition.

namecache.c260 行で定義されています。

参照先 gencache_del().

参照元 namecache_flush().

00261 {
00262         gencache_del(key);
00263         DEBUG(5, ("Deleting entry %s\n", key));
00264 }

void namecache_flush ( void   ) 

Flush all names from the name cache.

It's done by gencache_iterate()

戻り値:
True upon successful deletion or False in case of an error

namecache.c275 行で定義されています。

参照先 flush_netbios_name()gencache_init()gencache_iterate().

00276 {
00277         if (!gencache_init())
00278                 return;
00279 
00280         /* 
00281          * iterate through each NBT cache's entry and flush it
00282          * by flush_netbios_name function
00283          */
00284         gencache_iterate(flush_netbios_name, NULL, "NBT/*");
00285         DEBUG(5, ("Namecache flushed\n"));
00286 }

static char* namecache_status_record_key ( const char *  name,
int  name_type1,
int  name_type2,
struct in_addr  keyip 
) [static]

namecache.c290 行で定義されています。

参照先 asprintf()strupper_static().

参照元 namecache_status_fetch()namecache_status_store().

00292 {
00293         char *keystr;
00294 
00295         asprintf(&keystr, "NBT/%s#%02X.%02X.%s",
00296                         strupper_static(name), name_type1, name_type2, inet_ntoa(keyip));
00297         return keystr;
00298 }

BOOL namecache_status_store ( const char *  keyname,
int  keyname_type,
int  name_type,
struct in_addr  keyip,
const char *  srvname 
)

namecache.c302 行で定義されています。

参照先 gencache_init()gencache_set()namecache_status_record_key().

参照元 name_status_find().

00305 {
00306         char *key;
00307         time_t expiry;
00308         BOOL ret;
00309 
00310         if (!gencache_init())
00311                 return False;
00312 
00313         key = namecache_status_record_key(keyname, keyname_type, name_type, keyip);
00314         if (!key)
00315                 return False;
00316 
00317         expiry = time(NULL) + lp_name_cache_timeout();
00318         ret = gencache_set(key, srvname, expiry);
00319 
00320         if (ret)
00321                 DEBUG(5, ("namecache_status_store: entry %s -> %s\n", key, srvname ));
00322         else
00323                 DEBUG(5, ("namecache_status_store: entry %s store failed.\n", key ));
00324 
00325         SAFE_FREE(key);
00326         return ret;
00327 }

BOOL namecache_status_fetch ( const char *  keyname,
int  keyname_type,
int  name_type,
struct in_addr  keyip,
char *  srvname_out 
)

namecache.c331 行で定義されています。

参照先 gencache_get()gencache_init()namecache_status_record_key()strlcpy()timeout.

参照元 name_status_find().

00333 {
00334         char *key = NULL;
00335         char *value = NULL;
00336         time_t timeout;
00337 
00338         if (!gencache_init())
00339                 return False;
00340 
00341         key = namecache_status_record_key(keyname, keyname_type, name_type, keyip);
00342         if (!key)
00343                 return False;
00344 
00345         if (!gencache_get(key, &value, &timeout)) {
00346                 DEBUG(5, ("namecache_status_fetch: no entry for %s found.\n", key));
00347                 SAFE_FREE(key);
00348                 return False;
00349         } else {
00350                 DEBUG(5, ("namecache_status_fetch: key %s -> %s\n", key, value ));
00351         }
00352 
00353         strlcpy(srvname_out, value, 16);
00354         SAFE_FREE(key);
00355         SAFE_FREE(value);
00356         return True;
00357 }


Sambaに対してSat Aug 29 21:23:49 2009に生成されました。  doxygen 1.4.7