]> andersk Git - moira.git/commitdiff
fixed bug with IP address uniqueness check
authornocuser <nocuser>
Fri, 28 Oct 1994 13:41:46 +0000 (13:41 +0000)
committernocuser <nocuser>
Fri, 28 Oct 1994 13:41:46 +0000 (13:41 +0000)
server/qsetup.dc

index 39e0f43fd7ae5b8a2cc650838cad54f789cb7313..5171628370d013ad693cf346d2009f76f6670385 100644 (file)
@@ -977,17 +977,35 @@ setup_ahst(q,argv,cl)
     }
     if (value == 0) return(MR_ADDRESS);
     if (value != -1) {
+        /*
+         * an address or unique was specified.
+         */
        id = *(int *)argv[8+row];
        EXEC SQL SELECT saddr, mask, high, low INTO :addr, :mask, :high, :low
          FROM subnet WHERE snet_id = :id;
        if (ingres_errno) return(mr_errcode);
        if (value != -2) {
+            /*
+             * someone specified an IP address for the host record
+             */
            if ((value & mask) != addr) return(MR_ADDRESS);
-           name = argv[9+row];
+            /* 
+             * run the address argument through inet_addr(). This
+             * has the effect that any out of bounds host addrs will
+             * be converted to a valid host addr. We do this now
+             * so that the uniqueness check works. We should also
+             * link in an inet_addr() that returns an error for
+             * this case. 
+             */
+           name = inet_ntoa(inet_addr(argv[9+row]));
            EXEC SQL SELECT count(mach_id) INTO :cnt FROM machine
              WHERE address = :name;
            if (ingres_errno) return(mr_errcode);
            if (cnt > 0) {
+                /*
+                 * make IP address is unique. If this a modify request
+                 * (row == 1), then we expect one record to exist.
+                 */
                if (row == 0 || row == 1 && cnt > 1) return(MR_ADDRESS);
                if (row == 1 && cnt == 1) {
                    EXEC SQL SELECT mach_id INTO :id FROM machine
@@ -996,6 +1014,11 @@ setup_ahst(q,argv,cl)
                }
            }
        } else {
+            /*
+             * a "unique" address was specified. Walk through the
+             * range specified in the network record, return
+             * error if no room left.
+             */
            for (id = low; id <= high; id++) {
                if (((id & 0xff) == 0) ||
                    ((id & 0xff) == 255))
@@ -1012,6 +1035,9 @@ setup_ahst(q,argv,cl)
            else
              value = htonl(value);
        }
+        /*
+         * we have an address in value. Convert it to a string and store it.
+         */
        value = htonl(value);
        strcpy(argv[9+row], inet_ntoa(value));
     } else {
This page took 0.039905 seconds and 5 git commands to generate.