}
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 = (char *) 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
}
}
} 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))
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 {