/* lookup a hostname giving an IP */ static int net_lookup_host(struct net_context *c, int argc, const char **argv) { struct sockaddr_storage ss; int name_type = 0x20; char addr[INET6_ADDRSTRLEN]; const char *name = argv[0]; char *p; if (argc == 0) return net_lookup_usage(c, argc, argv); p = strchr_m(name,'#'); if (p) { *p = '\0'; sscanf(++p,"%x",&name_type); } if (!resolve_name(name, &ss, name_type, false)) { /* we deliberately use DEBUG() here to send it to stderr so scripts aren't mucked up */ DEBUG(0,("Didn't find %s#%02x\n", name, name_type)); return -1; } print_sockaddr(addr, sizeof(addr), &ss); d_printf("%s\n", addr); return 0; }
/* lookup a hostname giving an IP */ static int net_lookup_host(int argc, const char **argv) { struct in_addr ip; int name_type = 0x20; const char *name = argv[0]; char *p; if (argc == 0) return net_lookup_usage(argc, argv); p = strchr_m(name,'#'); if (p) { *p = '\0'; sscanf(++p,"%x",&name_type); } if (!resolve_name(name, &ip, name_type)) { /* we deliberately use DEBUG() here to send it to stderr so scripts aren't mucked up */ DEBUG(0,("Didn't find %s#%02x\n", name, name_type)); return -1; } d_printf("%s\n", inet_ntoa(ip)); return 0; }
/* lookup hosts or IP addresses using internal samba lookup fns */ int net_lookup(struct net_context *c, int argc, const char **argv) { int i; struct functable table[] = { {"HOST", net_lookup_host}, {"LDAP", net_lookup_ldap}, {"DC", net_lookup_dc}, {"PDC", net_lookup_pdc}, {"MASTER", net_lookup_master}, {"KDC", net_lookup_kdc}, {"NAME", net_lookup_name}, {"SID", net_lookup_sid}, {"DSGETDCNAME", net_lookup_dsgetdcname}, {NULL, NULL} }; if (argc < 1) { d_printf(_("\nUsage: \n")); return net_lookup_usage(c, argc, argv); } for (i=0; table[i].funcname; i++) { if (strcasecmp_m(argv[0], table[i].funcname) == 0) return table[i].fn(c, argc-1, argv+1); } /* Default to lookup a hostname so 'net lookup foo#1b' can be used instead of 'net lookup host foo#1b'. The host syntax is a bit confusing as non #00 names can't really be considered hosts as such. */ return net_lookup_host(c, argc, argv); }
/* lookup hosts or IP addresses using internal samba lookup fns */ int net_lookup(int argc, const char **argv) { int i; struct functable table[] = { {"HOST", net_lookup_host}, {"LDAP", net_lookup_ldap}, {"DC", net_lookup_dc}, {"MASTER", net_lookup_master}, {"KDC", net_lookup_kdc}, {NULL, NULL} }; if (argc < 1) { d_printf("\nUsage: \n"); return net_lookup_usage(argc, argv); } for (i=0; table[i].funcname; i++) { if (StrCaseCmp(argv[0], table[i].funcname) == 0) return table[i].fn(argc-1, argv+1); } /* Default to lookup a hostname so 'net lookup foo#1b' can be used instead of 'net lookup host foo#1b'. The host syntax is a bit confusing as non #00 names can't really be considered hosts as such. */ return net_lookup_host(argc, argv); }