lib/wins_srv.c

ソースコードを見る。

データ構造

struct  tagged_ip

関数

static char * wins_srv_keystr (struct in_addr wins_ip, struct in_addr src_ip)
BOOL wins_srv_is_dead (struct in_addr wins_ip, struct in_addr src_ip)
void wins_srv_alive (struct in_addr wins_ip, struct in_addr src_ip)
void wins_srv_died (struct in_addr wins_ip, struct in_addr src_ip)
unsigned wins_srv_count (void)
static void parse_ip (struct tagged_ip *ip, const char *str)
char ** wins_srv_tags (void)
void wins_srv_tags_free (char **list)
in_addr wins_srv_ip_tag (const char *tag, struct in_addr src_ip)
unsigned wins_srv_count_tag (const char *tag)

変数

in_addr loopback_ip


関数

static char* wins_srv_keystr ( struct in_addr  wins_ip,
struct in_addr  src_ip 
) [static]

wins_srv.c73 行で定義されています。

参照先 asprintf().

参照元 wins_srv_alive()wins_srv_died()wins_srv_is_dead().

00074 {
00075         char *keystr = NULL, *wins_ip_addr = NULL, *src_ip_addr = NULL;
00076 
00077         wins_ip_addr = SMB_STRDUP(inet_ntoa(wins_ip));
00078         src_ip_addr = SMB_STRDUP(inet_ntoa(src_ip));
00079 
00080         if ( !wins_ip_addr || !src_ip_addr ) {
00081                 DEBUG(0,("wins_srv_keystr: malloc error\n"));
00082                 goto done;
00083         }
00084 
00085         if (asprintf(&keystr, WINS_SRV_FMT, wins_ip_addr, src_ip_addr) == -1) {
00086                 DEBUG(0, (": ns_srv_keystr: malloc error for key string\n"));
00087         }
00088 
00089 done:
00090         SAFE_FREE(wins_ip_addr);
00091         SAFE_FREE(src_ip_addr);
00092 
00093         return keystr;
00094 }

BOOL wins_srv_is_dead ( struct in_addr  wins_ip,
struct in_addr  src_ip 
)

wins_srv.c100 行で定義されています。

参照先 gencache_get()resultwins_srv_keystr().

参照元 resolve_wins()wins_registration_timeout()wins_srv_died()wins_srv_ip_tag().

00101 {
00102         char *keystr = wins_srv_keystr(wins_ip, src_ip);
00103         BOOL result;
00104 
00105         /* If the key exists then the WINS server has been marked as dead */
00106 
00107         result = gencache_get(keystr, NULL, NULL);
00108         SAFE_FREE(keystr);
00109 
00110         DEBUG(4, ("wins_srv_is_dead: %s is %s\n", inet_ntoa(wins_ip),
00111                   result ? "dead" : "alive"));
00112 
00113         return result;
00114 }

void wins_srv_alive ( struct in_addr  wins_ip,
struct in_addr  src_ip 
)

wins_srv.c120 行で定義されています。

参照先 gencache_del()wins_srv_keystr().

参照元 register_name_response().

00121 {
00122         char *keystr = wins_srv_keystr(wins_ip, src_ip);
00123 
00124         gencache_del(keystr);
00125         SAFE_FREE(keystr);
00126 
00127         DEBUG(4, ("wins_srv_alive: marking wins server %s alive\n", 
00128                   inet_ntoa(wins_ip)));
00129 }

void wins_srv_died ( struct in_addr  wins_ip,
struct in_addr  src_ip 
)

wins_srv.c134 行で定義されています。

参照先 gencache_set()is_zero_ip()wins_srv_is_dead()wins_srv_keystr().

参照元 release_name_timeout_response()resolve_wins()wins_registration_timeout().

00135 {
00136         char *keystr;
00137 
00138         if (is_zero_ip(wins_ip) || wins_srv_is_dead(wins_ip, src_ip))
00139                 return;
00140 
00141         keystr = wins_srv_keystr(wins_ip, src_ip);
00142 
00143         gencache_set(keystr, "DOWN", time(NULL) + DEATH_TIME);
00144 
00145         SAFE_FREE(keystr);
00146 
00147         DEBUG(4,("Marking wins server %s dead for %u seconds from source %s\n",
00148                  inet_ntoa(wins_ip), DEATH_TIME, inet_ntoa(src_ip)));
00149 }

unsigned wins_srv_count ( void   ) 

wins_srv.c154 行で定義されています。

参照先 list().

参照元 refresh_my_names()resolve_wins()set_samba_nb_type()we_are_a_wins_client().

00155 {
00156         const char **list;
00157         int count = 0;
00158 
00159         if (lp_wins_support()) {
00160                 /* simple - just talk to ourselves */
00161                 return 1;
00162         }
00163 
00164         list = lp_wins_server_list();
00165         for (count=0; list && list[count]; count++)
00166                 /* nop */ ;
00167 
00168         return count;
00169 }

static void parse_ip ( struct tagged_ip ip,
const char *  str 
) [static]

wins_srv.c184 行で定義されています。

参照先 interpret_addr2()tagged_ip::iptagged_ip::tag.

参照元 wins_srv_count_tag()wins_srv_ip_tag()wins_srv_tags().

00185 {
00186         char *s = strchr(str, ':');
00187         if (!s) {
00188                 fstrcpy(ip->tag, "*");
00189                 ip->ip = *interpret_addr2(str);
00190                 return;
00191         } 
00192 
00193         ip->ip = *interpret_addr2(s+1);
00194         fstrcpy(ip->tag, str);
00195         s = strchr(ip->tag, ':');
00196         if (s) *s = 0;
00197 }

char** wins_srv_tags ( void   ) 

wins_srv.c208 行で定義されています。

参照先 list()parse_ip().

参照元 multihomed_register_name()queue_query_name()resolve_wins()wins_refresh_name()wins_release_name().

00209 {
00210         char **ret = NULL;
00211         int count=0, i, j;
00212         const char **list;
00213 
00214         if (lp_wins_support()) {
00215                 /* give the caller something to chew on. This makes
00216                    the rest of the logic simpler (ie. less special cases) */
00217                 ret = SMB_MALLOC_ARRAY(char *, 2);
00218                 if (!ret) return NULL;
00219                 ret[0] = SMB_STRDUP("*");
00220                 ret[1] = NULL;
00221                 return ret;
00222         }
00223 
00224         list = lp_wins_server_list();
00225         if (!list)
00226                 return NULL;
00227 
00228         /* yes, this is O(n^2) but n is very small */
00229         for (i=0;list[i];i++) {
00230                 struct tagged_ip t_ip;
00231                 
00232                 parse_ip(&t_ip, list[i]);
00233 
00234                 /* see if we already have it */
00235                 for (j=0;j<count;j++) {
00236                         if (strcmp(ret[j], t_ip.tag) == 0) {
00237                                 break;
00238                         }
00239                 }
00240 
00241                 if (j != count) {
00242                         /* we already have it. Move along */
00243                         continue;
00244                 }
00245 
00246                 /* add it to the list */
00247                 ret = SMB_REALLOC_ARRAY(ret, char *, count+2);
00248                 if (!ret) {
00249                         return NULL;
00250                 }
00251                 ret[count] = SMB_STRDUP(t_ip.tag);
00252                 if (!ret[count]) break;
00253                 count++;
00254         }
00255 
00256         if (count) {
00257                 /* make sure we null terminate */
00258                 ret[count] = NULL;
00259         }
00260 
00261         return ret;
00262 }

void wins_srv_tags_free ( char **  list  ) 

wins_srv.c265 行で定義されています。

参照元 multihomed_register_name()queue_query_name()resolve_wins()wins_refresh_name().

00266 {
00267         int i;
00268         if (!list) return;
00269         for (i=0; list[i]; i++) {
00270                 free(list[i]);
00271         }
00272         free(list);
00273 }

struct in_addr wins_srv_ip_tag ( const char *  tag,
struct in_addr  src_ip 
)

wins_srv.c280 行で定義されています。

参照先 tagged_ip::iplist()loopback_ipparse_ip()tagged_ip::tagwins_srv_is_dead()zero_ip().

参照元 multihomed_register_one()queue_query_name()queue_wins_refresh()resolve_wins()wins_registration_timeout()wins_release_name().

00281 {
00282         const char **list;
00283         int i;
00284         struct tagged_ip t_ip;
00285 
00286         /* if we are a wins server then we always just talk to ourselves */
00287         if (lp_wins_support()) {
00288                 return loopback_ip;
00289         }
00290 
00291         list = lp_wins_server_list();
00292         if (!list || !list[0]) {
00293                 struct in_addr ip;
00294                 zero_ip(&ip);
00295                 return ip;
00296         }
00297 
00298         /* find the first live one for this tag */
00299         for (i=0; list[i]; i++) {
00300                 parse_ip(&t_ip, list[i]);
00301                 if (strcmp(tag, t_ip.tag) != 0) {
00302                         /* not for the right tag. Move along */
00303                         continue;
00304                 }
00305                 if (!wins_srv_is_dead(t_ip.ip, src_ip)) {
00306                         fstring src_name;
00307                         fstrcpy(src_name, inet_ntoa(src_ip));
00308                         DEBUG(6,("Current wins server for tag '%s' with source %s is %s\n", 
00309                                  tag, 
00310                                  src_name,
00311                                  inet_ntoa(t_ip.ip)));
00312                         return t_ip.ip;
00313                 }
00314         }
00315         
00316         /* they're all dead - try the first one until they revive */
00317         for (i=0; list[i]; i++) {
00318                 parse_ip(&t_ip, list[i]);
00319                 if (strcmp(tag, t_ip.tag) != 0) {
00320                         continue;
00321                 }
00322                 return t_ip.ip;
00323         }
00324 
00325         /* this can't happen?? */
00326         zero_ip(&t_ip.ip);
00327         return t_ip.ip;
00328 }

unsigned wins_srv_count_tag ( const char *  tag  ) 

wins_srv.c335 行で定義されています。

参照先 list()parse_ip().

参照元 resolve_wins().

00336 {
00337         const char **list;
00338         int i, count=0;
00339 
00340         /* if we are a wins server then we always just talk to ourselves */
00341         if (lp_wins_support()) {
00342                 return 1;
00343         }
00344 
00345         list = lp_wins_server_list();
00346         if (!list || !list[0]) {
00347                 return 0;
00348         }
00349 
00350         /* find the first live one for this tag */
00351         for (i=0; list[i]; i++) {
00352                 struct tagged_ip t_ip;
00353                 parse_ip(&t_ip, list[i]);
00354                 if (strcmp(tag, t_ip.tag) == 0) {
00355                         count++;
00356                 }
00357         }
00358 
00359         return count;
00360 }


変数

struct in_addr loopback_ip

interface.c27 行で定義されています。


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