]> andersk Git - moira.git/commitdiff
From jhawk: If we're given an IP address on the command line, do a
authorzacheiss <zacheiss>
Mon, 20 Aug 2001 23:23:52 +0000 (23:23 +0000)
committerzacheiss <zacheiss>
Mon, 20 Aug 2001 23:23:52 +0000 (23:23 +0000)
lookup based on it.

clients/stella/stella.c

index 2c7f3ee3363147f4312afc19d3e8140e36afe183..4142aae7eaf5a5258854278c41bf1908af3f1a2b 100644 (file)
@@ -5,11 +5,17 @@
  *
  * Somewhat based on blanche
  *
- * Copyright (C) 2000 by the Massachusetts Institute of Technology.
+ * Copyright (C) 2000, 2001 by the Massachusetts Institute of Technology.
  * For copying and distribution information, please see the file
  * <mit-copyright.h>.
  */
 
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
 #include <mit-copyright.h>
 #include <moira.h>
 #include <moira_site.h>
@@ -62,6 +68,7 @@ char *hostname, *whoami;
 char *newname, *address, *network, *h_status, *vendor, *model;
 char *os, *location, *contact, *billing_contact, *adm_cmt, *op_cmt;
 
+in_addr_t ipaddress;
 struct owner_type *owner;
 
 void usage(char **argv);
@@ -321,6 +328,22 @@ int main(int argc, char **argv)
   if (status)
     exit(2);
 
+  /* Perform the lookup by IP address if that's what we've been handed */
+  if ((ipaddress=inet_addr(hostname)) != -1) {
+    char *args[5];
+    char *argv[30];
+
+    args[1] = strdup(hostname);
+    args[0] = args[2] = args[3] = "*";
+    status = wrap_mr_query("get_host", 4, args, store_host_info, argv);
+
+    if (status) {
+      com_err(whoami, status, "while looking up IP address.");
+    } else {
+      hostname = argv[0];
+    }
+  }
+
   /* create if needed */
   if (create_flag)
     {
This page took 0.898836 seconds and 5 git commands to generate.