+/* setup_asnt - verify that the data entered for the subnet is sane.
+ * In particular, make sure that the "low" and "high" addresses are
+ * correctly ordered, i.e., high > low.
+ */
+
+int setup_asnt(struct query *q, char *argv[], client *cl)
+{
+ int high, low, row, status;
+ char *account_number;
+
+ /* Check for asnt or usnt. */
+ if (q->type == APPEND)
+ row = 0;
+ else
+ row = 1;
+
+ low = atoi(argv[row + 7]);
+ high = atoi(argv[row + 8]);
+ status = atoi(argv[row + 2]);
+ account_number = argv[row + 4];
+
+ /* Don't allow Private subnets to be created without a valid billing
+ * number.
+ */
+ if (status == SNET_STATUS_PRIVATE_10MBPS ||
+ status == SNET_STATUS_PRIVATE_100MBPS ||
+ status == SNET_STATUS_PRIVATE_1000MBPS)
+ {
+ EXEC SQL SELECT account_number FROM accountnumbers
+ WHERE account_number = :account_number;
+ if (sqlca.sqlcode == SQL_NO_MATCH)
+ return MR_ACCOUNT_NUMBER;
+ }
+
+ /* Special case 0.0.0.0 and 255.255.255.255 */
+ if (!(low == 0 || low == -1 || high == 0 || high == -1))
+ if (low > high)
+ return MR_ADDRESS;
+
+ /* If this is update_subnet, we're done. */
+ if (row == 1)
+ return MR_SUCCESS;
+
+ /* For an add_subnet query, allocate and fill in a new snet_id */
+ if ((mr_errcode = prefetch_value(q, argv, cl)) != MR_SUCCESS)
+ return mr_errcode;
+
+ return MR_SUCCESS;
+}