From: zacheiss Date: Mon, 20 Aug 2001 08:17:34 +0000 (+0000) Subject: Initial implementation of IP address billing support: X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/commitdiff_plain/2d05b47b7111345125253ba054a45b541958565a Initial implementation of IP address billing support: - bump versions of ahst/uhst/ghst/ghbh/asnt/usnt/gsnt to deal with new columns. - Add correct offsets so access_host(), setup_ahst() and followup_ghst() deal with all versions of the queries. - access_host(): Non query owner cannot create a host without a valid account number. - Add setup_asnt() function, used by both asnt and usnt; don't allow creation of subnets whose "high" address is lower than the "low" address. --- diff --git a/server/mr_server.h b/server/mr_server.h index 33921e71..1fb83e92 100644 --- a/server/mr_server.h +++ b/server/mr_server.h @@ -49,7 +49,7 @@ extern char krb_realm[REALM_SZ]; /* max length of query argument allowed */ #define ARGLEN 257 /* Used to setup static argv, maximum argc */ -#define QMAXARGS 22 +#define QMAXARGS 25 /* statistics on number of queries by version number */ extern int newqueries; @@ -229,6 +229,7 @@ int setup_dfil(struct query *q, char *argv[], client *cl); int setup_aftg(struct query *q, char *argv[], client *cl); int setup_dnfp(struct query *q, char *argv[], client *cl); int setup_dqot(struct query *q, char *argv[], client *cl); +int setup_asnt(struct query *q, char *argv[], client *cl); int setup_dsnt(struct query *q, char *argv[], client *cl); int setup_ahst(struct query *q, char *argv[], client *cl); int setup_ahal(struct query *q, char *argv[], client *cl); diff --git a/server/qaccess.pc b/server/qaccess.pc index 2f6a4934..a811beb2 100644 --- a/server/qaccess.pc +++ b/server/qaccess.pc @@ -412,16 +412,19 @@ int access_filesys(struct query *q, char *argv[], client *cl) int access_host(struct query *q, char *argv[], client *cl) { EXEC SQL BEGIN DECLARE SECTION; - int mid, sid, id; + int mid, sid, id, subnet_status; char mtype[MACHINE_OWNER_TYPE_SIZE], stype[SUBNET_OWNER_TYPE_SIZE]; + char *account_number; EXEC SQL END DECLARE SECTION; int status, idx; if (q->version < 6) idx = 0; - else + else if (q->version >= 6 && q->version < 8) idx = 1; - + else + idx = 2; + if (q->type == RETRIEVE) { if (strcmp(argv[0], "*") || strcmp(argv[1], "*") || @@ -442,11 +445,23 @@ int access_host(struct query *q, char *argv[], client *cl) return MR_BAD_CHAR; id = *(int *)argv[8 + idx]; - EXEC SQL SELECT s.owner_type, s.owner_id - INTO :stype, :sid FROM subnet s + EXEC SQL SELECT s.owner_type, s.owner_id, s.status + INTO :stype, :sid, :subnet_status FROM subnet s WHERE s.snet_id = :id; mid = 0; + if (q->version >= 8) + { + if (subnet_status == 1) /* status 1 == Billable */ + { + account_number = argv[7]; + EXEC SQL SELECT account_number FROM accountnumbers + WHERE account_number = :account_number; + if (sqlca.sqlcode == SQL_NO_MATCH) + return MR_ACCOUNT_NUMBER; + } + } + if (find_member(stype, sid, cl)) return MR_SUCCESS; else diff --git a/server/qfollow.pc b/server/qfollow.pc index 09a9d1af..bcd7d46d 100644 --- a/server/qfollow.pc +++ b/server/qfollow.pc @@ -552,8 +552,10 @@ int followup_ghst(struct query *q, struct save_queue *sq, struct validate *v, if (q->version < 6) idx = 0; - else + else if (q->version >= 6 && q->version < 8) idx = 1; + else + idx = 2; while (sq_get_data(sq, &argv)) { diff --git a/server/qsetup.pc b/server/qsetup.pc index ab50d669..3c683c99 100644 --- a/server/qsetup.pc +++ b/server/qsetup.pc @@ -229,6 +229,37 @@ int setup_dmac(struct query *q, char *argv[], client *cl) return MR_SUCCESS; } +/* 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; + + /* Check for asnt or usnt. */ + if (q->type == APPEND) + row = 0; + else + row = 1; + + low = atoi(argv[row + 5]); + high = atoi(argv[row + 6]); + + 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; +} /* setup_dsnt - verify that the subnet is no longer being referenced * and may safely be deleted. @@ -900,8 +931,10 @@ int setup_ahst(struct query *q, char **argv, client *cl) if (q->version < 6) idx = 0; - else + else if (q->version >= 6 && q->version < 8) idx = 1; + else + idx = 2; /* Sanity check name, vendor, model, and os. */ if ((row == 0 || strcasecmp(argv[1], oldname)) && diff --git a/server/queries2.c b/server/queries2.c index 31644d21..155bde95 100644 --- a/server/queries2.c +++ b/server/queries2.c @@ -787,7 +787,7 @@ static char *ghbh2_fields[] = { "inuse", "modtime", "modby", "modwith", }; -static char *ghst_fields[] = { +static char *ghst6_fields[] = { "name", "address", "location", "network", "name", "vendor", "model", "os", "location", "contact", "billing_contact", "use", "status", "status_change", "network", "address", "ace_type", @@ -795,7 +795,7 @@ static char *ghst_fields[] = { "inuse", "modtime", "modby", "modwith", }; -static char *ghbh_fields[] = { +static char *ghbh6_fields[] = { "hwaddr", "name", "vendor", "model", "os", "location", "contact", "billing_contact", "use", "status", "status_change", "network", "address", "ace_type", @@ -803,6 +803,22 @@ static char *ghbh_fields[] = { "inuse", "modtime", "modby", "modwith", }; +static char *ghst_fields[] = { + "name", "address", "location", "network", + "name", "vendor", "model", "os", "location", "contact", "billing_contact", + "account_number", "use", "status", "status_change", "network", "address", + "ace_type", "ace_name", "admin_comment", "ops_comment", "created", "creator", + "inuse", "modtime", "modby", "modwith", +}; + +static char *ghbh_fields[] = { + "hwaddr", + "name", "vendor", "model", "os", "location", "contact", "billing_contact", + "account_number", "use", "status", "status_change", "network", "address", + "ace_type", "ace_name", "admin_comment", "ops_comment", "created", "creator", + "inuse", "modtime", "modby", "modwith", +}; + static struct validate ghst_validate = { 0, 0, @@ -854,13 +870,13 @@ static struct validate ahst2_validate = { set_uppercase_modtime, }; -static char *ahst_fields[] = { +static char *ahst6_fields[] = { "name", "vendor", "model", "os", "location", "contact", "billing_contact", "use", "status", "subnet", "address", "ace_type", "ace_name", "admin_comment", "ops_comment", }; -static struct valobj ahst_valobj[] = { +static struct valobj ahst6_valobj[] = { {V_CHAR, 0, MACHINE_TABLE, "name"}, {V_CHAR, 1, MACHINE_TABLE, "vendor"}, {V_CHAR, 2, MACHINE_TABLE, "model"}, @@ -877,9 +893,45 @@ static struct valobj ahst_valobj[] = { {V_ID, 14, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH}, }; +static struct validate ahst6_validate = { + ahst6_valobj, + 14, + "name", + "name = UPPER('%s')", + 1, + "mach_id", + access_host, + setup_ahst, + set_uppercase_modtime, +}; + +static char *ahst_fields[] = { + "name", "vendor", "model", "os", "location", "contact", "billing_contact", + "account_number", "use", "status", "subnet", "address", "ace_type", + "ace_name", "admin_comment", "ops_comment", +}; + +static struct valobj ahst_valobj[] = { + {V_CHAR, 0, MACHINE_TABLE, "name"}, + {V_CHAR, 1, MACHINE_TABLE, "vendor"}, + {V_CHAR, 2, MACHINE_TABLE, "model"}, + {V_CHAR, 3, MACHINE_TABLE, "os"}, + {V_CHAR, 4, MACHINE_TABLE, "location"}, + {V_CHAR, 5, MACHINE_TABLE, "contact"}, + {V_CHAR, 6, MACHINE_TABLE, "billing_contact"}, + {V_CHAR, 7, MACHINE_TABLE, "account_number"}, + {V_NUM, 8}, + {V_NUM, 9}, + {V_ID, 10, SUBNET_TABLE, "name", "snet_id", MR_SUBNET}, + {V_TYPE, 12, 0, "ace_type", 0, MR_ACE}, + {V_TYPEDATA, 13, 0, 0, 0, MR_ACE}, + {V_ID, 14, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH}, + {V_ID, 15, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH}, +}; + static struct validate ahst_validate = { ahst_valobj, - 14, + 15, "name", "name = UPPER('%s')", 1, @@ -926,14 +978,14 @@ static struct validate uhst2_validate = { set_modtime_by_id, }; -static char *uhst_fields[] = { +static char *uhst6_fields[] = { "name", "newname", "vendor", "model", "os", "location", "contact", "billing_contact", "use", "status", "subnet", "address", "ace_type", "ace_name", "admin_comment", "ops_comment", }; -static struct valobj uhst_valobj[] = { +static struct valobj uhst6_valobj[] = { {V_CHAR, 0, MACHINE_TABLE, "name"}, {V_ID, 0, MACHINE_TABLE, "name", "mach_id", MR_MACHINE}, {V_RENAME, 1, MACHINE_TABLE, "name", "mach_id", MR_NOT_UNIQUE}, @@ -952,9 +1004,48 @@ static struct valobj uhst_valobj[] = { {V_ID, 15, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH}, }; +static struct validate uhst6_validate = { + uhst6_valobj, + 16, + 0, + 0, + 0, + "mach_id", + access_host, + setup_ahst, + set_modtime_by_id, +}; + +static char *uhst_fields[] = { + "name", + "newname", "vendor", "model", "os", "location", "contact", "billing_contact", + "account_number", "use", "status", "subnet", "address", "ace_type", + "ace_name", "admin_comment", "ops_comment", +}; + +static struct valobj uhst_valobj[] = { + {V_CHAR, 0, MACHINE_TABLE, "name"}, + {V_ID, 0, MACHINE_TABLE, "name", "mach_id", MR_MACHINE}, + {V_RENAME, 1, MACHINE_TABLE, "name", "mach_id", MR_NOT_UNIQUE}, + {V_CHAR, 2, MACHINE_TABLE, "vendor"}, + {V_CHAR, 3, MACHINE_TABLE, "model"}, + {V_CHAR, 4, MACHINE_TABLE, "os"}, + {V_CHAR, 5, MACHINE_TABLE, "location"}, + {V_CHAR, 6, MACHINE_TABLE, "contact"}, + {V_CHAR, 7, MACHINE_TABLE, "billing_contact"}, + {V_CHAR, 8, MACHINE_TABLE, "account_number"}, + {V_NUM, 9}, + {V_NUM, 10}, + {V_ID, 11, SUBNET_TABLE, "name", "snet_id", MR_SUBNET}, + {V_TYPE, 13, 0, "ace_type", 0, MR_ACE}, + {V_TYPEDATA, 14, 0, 0, 0, MR_ACE}, + {V_ID, 15, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH}, + {V_ID, 16, STRINGS_TABLE, "string", "string_id", MR_NO_MATCH}, +}; + static struct validate uhst_validate = { uhst_valobj, - 16, + 17, 0, 0, 0, @@ -1052,12 +1143,18 @@ static struct validate dhal_validate = { 0, }; -static char *gsnt_fields[] = { +static char *gsnt2_fields[] = { "name", "name", "description", "address", "mask", "low", "high", "prefix", "ace_type", "ace_name", "modtime", "modby", "modwith" }; +static char *gsnt_fields[] = { + "name", + "name", "description", "status", "address", "mask", "low", "high", "prefix", + "ace_type", "ace_name", "modtime", "modby", "modwith" +}; + static struct validate gsnt_validate = { 0, 0, @@ -1070,12 +1167,12 @@ static struct validate gsnt_validate = { followup_gsnt, }; -static char *asnt_fields[] = { +static char *asnt2_fields[] = { "name", "description", "address", "mask", "low", "high", "prefix", "ace_type", "ace_name", }; -static struct valobj asnt_valobj[] = { +static struct valobj asnt2_valobj[] = { {V_CHAR, 0, SUBNET_TABLE, "name"}, {V_LEN, 1, SUBNET_TABLE, "description"}, {V_NUM, 2}, @@ -1087,9 +1184,9 @@ static struct valobj asnt_valobj[] = { {V_TYPEDATA, 8, 0, 0, 0, MR_ACE}, }; -static struct validate asnt_validate = +static struct validate asnt2_validate = { - asnt_valobj, + asnt2_valobj, 9, "name", "name = UPPER('%s')", @@ -1100,13 +1197,44 @@ static struct validate asnt_validate = set_uppercase_modtime, }; -static char *usnt_fields[] = { +static char *asnt_fields[] = { + "name", "description", "status", "address", "mask", "low", "high", "prefix", + "ace_type", "ace_name", +}; + +static struct valobj asnt_valobj[] = { + {V_CHAR, 0, SUBNET_TABLE, "name"}, + {V_LEN, 1, SUBNET_TABLE, "description"}, + {V_NUM, 2}, + {V_NUM, 3}, + {V_NUM, 4}, + {V_NUM, 5}, + {V_NUM, 6}, + {V_LEN, 7, SUBNET_TABLE, "prefix"}, + {V_TYPE, 8, 0, "ace_type", 0, MR_ACE}, + {V_TYPEDATA, 9, 0, 0, 0, MR_ACE}, +}; + +static struct validate asnt_validate = +{ + asnt_valobj, + 10, + "name", + "name = UPPER('%s')", + 1, + "snet_id", + 0, + setup_asnt, + set_uppercase_modtime, +}; + +static char *usnt2_fields[] = { "name", "newname", "description", "address", "mask", "low", "high", "prefix", "ace_type", "ace_name", }; -static struct valobj usnt_valobj[] = { +static struct valobj usnt2_valobj[] = { {V_ID, 0, SUBNET_TABLE, "name", "snet_id", MR_NO_MATCH}, {V_RENAME, 1, SUBNET_TABLE, "name", "snet_id", MR_NOT_UNIQUE}, {V_LEN, 2, SUBNET_TABLE, "description"}, @@ -1119,9 +1247,9 @@ static struct valobj usnt_valobj[] = { {V_TYPEDATA, 9, 0, 0, 0, MR_ACE}, }; -static struct validate usnt_validate = +static struct validate usnt2_validate = { - usnt_valobj, + usnt2_valobj, 10, "name", "snet_id = %d", @@ -1132,6 +1260,39 @@ static struct validate usnt_validate = set_modtime_by_id, }; +static char *usnt_fields[] = { + "name", + "newname", "description", "status", "address", "mask", "low", "high", + "prefix", "ace_type", "ace_name", +}; + +static struct valobj usnt_valobj[] = { + {V_ID, 0, SUBNET_TABLE, "name", "snet_id", MR_NO_MATCH}, + {V_RENAME, 1, SUBNET_TABLE, "name", "snet_id", MR_NOT_UNIQUE}, + {V_LEN, 2, SUBNET_TABLE, "description"}, + {V_NUM, 3}, + {V_NUM, 4}, + {V_NUM, 5}, + {V_NUM, 6}, + {V_NUM, 7}, + {V_LEN, 8, SUBNET_TABLE, "prefix"}, + {V_TYPE, 9, 0, "ace_type", 0, MR_ACE}, + {V_TYPEDATA, 10, 0, 0, 0, MR_ACE}, +}; + +static struct validate usnt_validate = +{ + usnt_valobj, + 11, + "name", + "snet_id = %d", + 1, + "snet_id", + 0, + setup_asnt, + set_modtime_by_id, +}; + static char *dsnt_fields[] = { "name", }; @@ -4255,7 +4416,7 @@ struct query Queries[] = { "m", MACHINE_TABLE, "m.name, m.vendor, m.model, m.os, m.location, m.contact, m.billing_contact, m.use, m.status, TO_CHAR(m.statuschange, 'DD-mon-YYYY HH24:MI:SS'), s.name, m.address, m.owner_type, m.owner_id, m.acomment, m.ocomment, TO_CHAR(m.created, 'DD-mon-YYYY HH24:MI:SS'), m.creator, TO_CHAR(m.inuse, 'DD-mon-YYYY HH24:MI:SS'), TO_CHAR(m.modtime, 'DD-mon-YYYY HH24:MI:SS'), m.modby, m.modwith FROM machine m, subnet s", - ghst_fields, + ghst6_fields, 22, "m.name LIKE UPPER('%s') AND m.address LIKE '%s' AND m.location LIKE UPPER('%s') AND s.name LIKE UPPER('%s') AND m.mach_id != 0 AND s.snet_id = m.snet_id", 4, @@ -4263,6 +4424,23 @@ struct query Queries[] = { &ghst_validate, }, + { + /* Q_GHST - GET_HOST, v8 */ + "get_host", + "ghst", + 8, + RETRIEVE, + "m", + MACHINE_TABLE, + "m.name, m.vendor, m.model, m.os, m.location, m.contact, m.billing_contact, m.account_number, m.use, m.status, TO_CHAR(m.statuschange, 'DD-mon-YYYY HH24:MI:SS'), s.name, m.address, m.owner_type, m.owner_id, m.acomment, m.ocomment, TO_CHAR(m.created, 'DD-mon-YYYY HH24:MI:SS'), m.creator, TO_CHAR(m.inuse, 'DD-mon-YYYY HH24:MI:SS'), TO_CHAR(m.modtime, 'DD-mon-YYYY HH24:MI:SS'), m.modby, m.modwith FROM machine m, subnet s", + ghst_fields, + 23, + "m.name LIKE UPPER('%s') AND m.address LIKE '%s' AND m.location LIKE UPPER('%s') AND s.name LIKE UPPER('%s') AND m.mach_id != 0 AND s.snet_id = m.snet_id", + 4, + "m.name", + &ghst_validate, + }, + { /* Q_GHBH - GET_HOST_BY_HWADDR, v2 */ "get_host_by_hwaddr", @@ -4289,7 +4467,7 @@ struct query Queries[] = { "m", MACHINE_TABLE, "m.name, m.vendor, m.model, m.os, m.location, m.contact, m.billing_contact, m.use, m.status, TO_CHAR(m.statuschange, 'DD-mon-YYYY HH24:MI:SS'), s.name, m.address, m.owner_type, m.owner_id, m.acomment, m.ocomment, TO_CHAR(m.created, 'DD-mon-YYYY HH24:MI:SS'), m.creator, TO_CHAR(m.inuse, 'DD-mon-YYYY HH24:MI:SS'), TO_CHAR(m.modtime, 'DD-mon-YYYY HH24:MI:SS'), m.modby, m.modwith FROM machine m, subnet s", - ghbh_fields, + ghbh6_fields, 22, "m.hwaddr LIKE LOWER('%s') AND m.mach_id != 0 AND s.snet_id = m.snet_id", 1, @@ -4297,6 +4475,23 @@ struct query Queries[] = { &ghst_validate, }, + { + /* Q_GHBH - GET_HOST_BY_HWADDR, v8 */ + "get_host_by_hwaddr", + "ghbh", + 8, + RETRIEVE, + "m", + MACHINE_TABLE, + "m.name, m.vendor, m.model, m.os, m.location, m.contact, m.billing_contact, m.account_number, m.use, m.status, TO_CHAR(m.statuschange, 'DD-mon-YYYY HH24:MI:SS'), s.name, m.address, m.owner_type, m.owner_id, m.acomment, m.ocomment, TO_CHAR(m.created, 'DD-mon-YYYY HH24:MI:SS'), m.creator, TO_CHAR(m.inuse, 'DD-mon-YYYY HH24:MI:SS'), TO_CHAR(m.modtime, 'DD-mon-YYYY HH24:MI:SS'), m.modby, m.modwith FROM machine m, subnet s", + ghbh_fields, + 23, + "m.hwaddr LIKE LOWER('%s') AND m.mach_id != 0 AND s.snet_id = m.snet_id", + 1, + "m.name", + &ghst_validate, + }, + { /* Q_GHHA - GET_HOST_HWADDR */ "get_host_hwaddr", @@ -4340,11 +4535,28 @@ struct query Queries[] = { "m", MACHINE_TABLE, "INTO machine (name, vendor, model, os, location, contact, billing_contact, use, status, statuschange, snet_id, address, owner_type, owner_id, acomment, ocomment, created, inuse, mach_id, creator) VALUES (UPPER('%s'), NVL(UPPER('%s'), CHR(0)), NVL(UPPER('%s'), CHR(0)), NVL(UPPER('%s'), CHR(0)), NVL(UPPER('%s'), CHR(0)), NVL('%s', CHR(0)), NVL('%s', CHR(0)), %s, %s, SYSDATE, %d, '%s', '%s', %d, %d, %d, SYSDATE, SYSDATE, %s, %s)", - ahst_fields, + ahst6_fields, 15, 0, 0, NULL, + &ahst6_validate, + }, + + { + /* Q_AHST - ADD_HOST, v8 */ /* Uses prefetch_value() for mach_id */ + "add_host", + "ahst", + 8, + APPEND, + "m", + MACHINE_TABLE, + "INTO machine (name, vendor, model, os, location, contact, billing_contact, account_number, use, status, statuschange, snet_id, address, owner_type, owner_id, acomment, ocomment, created, inuse, mach_id, creator) VALUES (UPPER('%s'), NVL(UPPER('%s'), CHR(0)), NVL(UPPER('%s'), CHR(0)), NVL(UPPER('%s'), CHR(0)), NVL(UPPER('%s'), CHR(0)), NVL('%s', CHR(0)), NVL('%s', CHR(0)), NVL('%s', CHR(0)), %s, %s, SYSDATE, %d, '%s', '%s', %d, %d, %d, SYSDATE, SYSDATE, %s, %s)", + ahst_fields, + 16, + 0, + 0, + NULL, &ahst_validate, }, @@ -4374,11 +4586,28 @@ struct query Queries[] = { "m", MACHINE_TABLE, "machine SET name = NVL(UPPER('%s'), CHR(0)), vendor = NVL(UPPER('%s'), CHR(0)), model = NVL(UPPER('%s'), CHR(0)), os = NVL(UPPER('%s'), CHR(0)), location = NVL(UPPER('%s'), CHR(0)), contact = NVL('%s', CHR(0)), billing_contact = NVL('%s', CHR(0)), use = %s, status = %s, snet_id = %d, address = '%s', owner_type = '%s', owner_id = %d, acomment = %d, ocomment = %d", - uhst_fields, + uhst6_fields, 15, "mach_id = %d", 1, NULL, + &uhst6_validate, + }, + + { + /* Q_UHST - UPDATE_HOST, v8 */ + "update_host", + "uhst", + 8, + UPDATE, + "m", + MACHINE_TABLE, + "machine SET name = NVL(UPPER('%s'), CHR(0)), vendor = NVL(UPPER('%s'), CHR(0)), model = NVL(UPPER('%s'), CHR(0)), os = NVL(UPPER('%s'), CHR(0)), location = NVL(UPPER('%s'), CHR(0)), contact = NVL('%s', CHR(0)), billing_contact = NVL('%s', CHR(0)), account_number = NVL('%s', CHR(0)), use = %s, status = %s, snet_id = %d, address = '%s', owner_type = '%s', owner_id = %d, acomment = %d, ocomment = %d", + uhst_fields, + 16, + "mach_id = %d", + 1, + NULL, &uhst_validate, }, @@ -4485,7 +4714,7 @@ struct query Queries[] = { }, { - /* Q_GSNT - GET_SUBNET */ + /* Q_GSNT - GET_SUBNET, v2 */ "get_subnet", "gsnt", 2, @@ -4493,7 +4722,7 @@ struct query Queries[] = { "s", SUBNET_TABLE, "name, description, saddr, mask, low, high, prefix, owner_type, owner_id, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS'), modby, modwith FROM subnet", - gsnt_fields, + gsnt2_fields, 12, "name LIKE UPPER('%s')", 1, @@ -4502,7 +4731,24 @@ struct query Queries[] = { }, { - /* Q_ASNT - ADD_SUBNET */ + /* Q_GSNT - GET_SUBNET, v8 */ + "get_subnet", + "gsnt", + 8, + RETRIEVE, + "s", + SUBNET_TABLE, + "name, description, status, saddr, mask, low, high, prefix, owner_type, owner_id, TO_CHAR(modtime, 'DD-mon-YYYY HH24:MI:SS'), modby, modwith FROM subnet", + gsnt_fields, + 13, + "name LIKE UPPER('%s')", + 1, + "name", + &gsnt_validate, + }, + + { + /* Q_ASNT - ADD_SUBNET, v2 */ "add_subnet", "asnt", 2, @@ -4510,16 +4756,33 @@ struct query Queries[] = { "s", SUBNET_TABLE, "INTO subnet (name, description, saddr, mask, low, high, prefix, owner_type, owner_id, snet_id) VALUES (UPPER('%s'), NVL('%s', CHR(0)), %s, %s, %s, %s, NVL('%s', CHR(0)), '%s', %d, %s)", - asnt_fields, + asnt2_fields, 9, 0, 0, NULL, + &asnt2_validate, + }, + + { + /* Q_ASNT - ADD_SUBNET, v8 */ + "add_subnet", + "asnt", + 8, + APPEND, + "s", + SUBNET_TABLE, + "INTO subnet (name, description, status, saddr, mask, low, high, prefix, owner_type, owner_id, snet_id) VALUES (UPPER('%s'), NVL('%s', CHR(0)), %s, %d, %s, %s, %s, NVL('%s', CHR(0)), '%s', %d, %s)", + asnt_fields, + 10, + 0, + 0, + NULL, &asnt_validate, }, { - /* Q_USNT - UPDATE_SUBNET */ + /* Q_USNT - UPDATE_SUBNET, v2 */ "update_subnet", "usnt", 2, @@ -4527,11 +4790,28 @@ struct query Queries[] = { "s", SUBNET_TABLE, "subnet SET name = UPPER('%s'), description = NVL('%s', CHR(0)), saddr = %s, mask = %s, low = %s, high = %s, prefix = NVL('%s', CHR(0)), owner_type = '%s', owner_id = %d", - usnt_fields, + usnt2_fields, 9, "snet_id = %d", 1, NULL, + &usnt2_validate, + }, + + { + /* Q_USNT - UPDATE_SUBNET, v8 */ + "update_subnet", + "usnt", + 8, + UPDATE, + "s", + SUBNET_TABLE, + "subnet SET name = UPPER('%s'), description = NVL('%s', CHR(0)), status = %d, saddr = %s, mask = %s, low = %s, high = %s, prefix = NVL('%s', CHR(0)), owner_type = '%s', owner_id = %d", + usnt_fields, + 10, + "snet_id = %d", + 1, + NULL, &usnt_validate, }, @@ -6763,10 +7043,10 @@ struct query Queries[] = { }, { - /* Q_GTLC - GET_TOPLEVEL_CONTAINERS, v7 */ + /* Q_GTLC - GET_TOPLEVEL_CONTAINERS, v8 */ "get_toplevel_containers", "gtlc", - 7, + 8, RETRIEVE, "c", CONTAINERS_TABLE,