Changeset 740 for vendor/current/source3/utils/nmblookup.c
- Timestamp:
- Nov 14, 2012, 12:59:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source3/utils/nmblookup.c
r414 r740 21 21 22 22 #include "includes.h" 23 24 extern bool AllowDebugChange; 23 #include "popt_common.h" 24 #include "libsmb/nmblib.h" 25 25 26 26 static bool give_flags = false; … … 108 108 ****************************************************************************/ 109 109 110 static void do_node_status(int fd, 111 const char *name, 110 static void do_node_status(const char *name, 112 111 int type, 113 112 struct sockaddr_storage *pss) … … 115 114 struct nmb_name nname; 116 115 int count, i, j; 117 NODE_STATUS_STRUCT *status;116 struct node_status *addrs; 118 117 struct node_status_extra extra; 119 118 fstring cleanname; 120 119 char addr[INET6_ADDRSTRLEN]; 120 NTSTATUS status; 121 121 122 122 print_sockaddr(addr, sizeof(addr), pss); 123 123 d_printf("Looking up status of %s\n",addr); 124 124 make_nmb_name(&nname, name, type); 125 status = node_status_query(fd, &nname, pss, &count, &extra); 126 if (status) { 125 status = node_status_query(talloc_tos(), &nname, pss, 126 &addrs, &count, &extra); 127 if (NT_STATUS_IS_OK(status)) { 127 128 for (i=0;i<count;i++) { 128 pull_ascii_fstring(cleanname, status[i].name);129 pull_ascii_fstring(cleanname, addrs[i].name); 129 130 for (j=0;cleanname[j];j++) { 130 131 if (!isprint((int)cleanname[j])) { … … 133 134 } 134 135 d_printf("\t%-15s <%02x> - %s\n", 135 cleanname, status[i].type,136 node_status_flags( status[i].flags));136 cleanname,addrs[i].type, 137 node_status_flags(addrs[i].flags)); 137 138 } 138 139 d_printf("\n\tMAC Address = %02X-%02X-%02X-%02X-%02X-%02X\n", … … 141 142 extra.mac_addr[4], extra.mac_addr[5]); 142 143 d_printf("\n"); 143 SAFE_FREE(status);144 TALLOC_FREE(addrs); 144 145 } else { 145 146 d_printf("No reply from %s\n\n",addr); … … 154 155 static bool query_one(const char *lookup, unsigned int lookup_type) 155 156 { 156 int j, count, flags = 0; 157 int j, count; 158 uint8_t flags; 157 159 struct sockaddr_storage *ip_list=NULL; 160 NTSTATUS status = NT_STATUS_NOT_FOUND; 158 161 159 162 if (got_bcast) { … … 161 164 print_sockaddr(addr, sizeof(addr), &bcast_addr); 162 165 d_printf("querying %s on %s\n", lookup, addr); 163 ip_list = name_query(ServerFD,lookup,lookup_type,use_bcast, 164 use_bcast?true:recursion_desired, 165 &bcast_addr, &count, &flags, NULL); 166 status = name_query(lookup,lookup_type,use_bcast, 167 use_bcast?true:recursion_desired, 168 &bcast_addr, talloc_tos(), 169 &ip_list, &count, &flags); 166 170 } else { 167 171 const struct in_addr *bcast; … … 180 184 d_printf("querying %s on %s\n", 181 185 lookup, addr); 182 ip_list = name_query(ServerFD,lookup,lookup_type, 183 use_bcast, 184 use_bcast?True:recursion_desired, 185 &bcast_ss,&count, &flags, NULL); 186 } 187 } 188 189 if (!ip_list) { 186 status = name_query(lookup,lookup_type, 187 use_bcast, 188 use_bcast?True:recursion_desired, 189 &bcast_ss, talloc_tos(), 190 &ip_list, &count, &flags); 191 } 192 } 193 194 if (!NT_STATUS_IS_OK(status)) { 190 195 return false; 191 196 } … … 215 220 */ 216 221 if (find_status) { 217 do_node_status(ServerFD, lookup, 218 lookup_type, &ip_list[j]); 219 } 220 } 221 222 free(ip_list); 223 224 return (ip_list != NULL); 222 do_node_status(lookup, lookup_type, &ip_list[j]); 223 } 224 } 225 226 TALLOC_FREE(ip_list); 227 228 return NT_STATUS_IS_OK(status); 225 229 } 226 230 … … 259 263 load_case_tables(); 260 264 261 setup_logging(argv[0], True);265 setup_logging(argv[0], DEBUG_STDOUT); 262 266 263 267 pc = poptGetContext("nmblookup", argc, (const char **)argv, … … 336 340 in_addr_to_sockaddr_storage(&ss, ip); 337 341 fstrcpy(lookup,"*"); 338 do_node_status( ServerFD,lookup, lookup_type, &ss);342 do_node_status(lookup, lookup_type, &ss); 339 343 continue; 340 344 }
Note:
See TracChangeset
for help on using the changeset viewer.