00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "includes.h"
00027
00028
00029
00030
00031
00032 void load_lmhosts_file(char *fname)
00033 {
00034 pstring name;
00035 int name_type;
00036 struct in_addr ipaddr;
00037 XFILE *fp = startlmhosts( fname );
00038
00039 if (!fp) {
00040 DEBUG(2,("load_lmhosts_file: Can't open lmhosts file %s. Error was %s\n",
00041 fname, strerror(errno)));
00042 return;
00043 }
00044
00045 while (getlmhostsent(fp, name, &name_type, &ipaddr) ) {
00046 struct subnet_record *subrec = NULL;
00047 enum name_source source = LMHOSTS_NAME;
00048
00049
00050
00051 for (subrec = FIRST_SUBNET; subrec ; subrec = NEXT_SUBNET_EXCLUDING_UNICAST(subrec)) {
00052 if(same_net(ipaddr, subrec->bcast_ip, subrec->mask_ip))
00053 break;
00054 }
00055
00056
00057 if(subrec == NULL)
00058 subrec = remote_broadcast_subnet;
00059
00060 if(name_type == -1) {
00061
00062 (void)add_name_to_subnet(subrec,name,0x00,(uint16)NB_ACTIVE,PERMANENT_TTL,source,1,&ipaddr);
00063 (void)add_name_to_subnet(subrec,name,0x20,(uint16)NB_ACTIVE,PERMANENT_TTL,source,1,&ipaddr);
00064 } else {
00065
00066 (void)add_name_to_subnet(subrec,name,name_type,(uint16)NB_ACTIVE,PERMANENT_TTL,source,1,&ipaddr);
00067 }
00068 }
00069
00070 endlmhosts(fp);
00071 }
00072
00073
00074
00075
00076
00077
00078
00079 BOOL find_name_in_lmhosts(struct nmb_name *nmbname, struct name_record **namerecp)
00080 {
00081 struct name_record *namerec;
00082
00083 *namerecp = NULL;
00084
00085 if((namerec = find_name_on_subnet(remote_broadcast_subnet, nmbname, FIND_ANY_NAME))==NULL)
00086 return False;
00087
00088 if(!NAME_IS_ACTIVE(namerec) || (namerec->data.source != LMHOSTS_NAME))
00089 return False;
00090
00091 *namerecp = namerec;
00092 return True;
00093 }