osmo-hlr/tests/test_subscriber.sql

18 lines
1.0 KiB
MySQL
Raw Normal View History

-- 2G only subscriber
ctrl: completely replace all CTRL commands The previous commands are not conforming to how the CTRL interface is intended to work: SET enable-ps <IMSI> SET disable-ps <IMSI> SET status-ps <IMSI> 'status-ps' is a write-only command even though it returns the status. 'enable-ps' / 'disable-ps' indicate the value instead of a variable name of an entity. The entity <IMSI> takes the place of the variable value. See also https://lists.osmocom.org/pipermail/openbsc/2017-September/011236.html Instead, replace with SET subscriber.by-imsi-123456.ps-enabled {0,1} GET subscriber.by-imsi-123456.ps-enabled and also provide further CTRL functions while at it: {SET,GET} subscriber.by-{imsi,msisdn,id}-123456.{cs,ps}-enabled {0,1} GET subscriber.by-{imsi,msisdn,id}-123456.{info,info-aud,info-all} Provide CTRL tests in the form of transcripts. Adjust tests/test_subscriber.sql to feature nonzero SQN, to see some values for SQN in the CTRL transcript tests. (This does not affect the VTY tests, because that creates its own subscribers, and there's no VTY command to set the SQN.) This is the first time an application uses CTRL_NODE ids that are defined outside of libosmocore, see 'Depends' below. Implementation choice: the first idea was to have a '.' between the 'by-xxx' and the value, like: subscriber.by-xxx.123456.function but the difficulty with subscribers is that they are not in RAM, and I can't just point node_data at a struct instance that is always there (like, say, a global bts[0] struct in osmo-bsc). Instead, I want to store the selector and later decide whether to read from the DB or whatever. With a '.' separating things, the only way in a ctrl function to obtain both 'by-xxx' and '123456' for picking a subscriber record would be to parse the entire variable path string elements, including 'subscriber' and 'function', which would then also clumsily fix at which node level we hook these commands; there could have been separate CTRL_NODE_SUBSCR_BY_{IMSI,MSISDN,ID} parent nodes, but we cannot introspect the current parent node dynamically within a ctrl function handler (plus I'm not sure whether it's possible and a good idea to have the same command under multiple parent nodes). Rather than that, I store the 'by-foo-123' token in the node_data pointer to have both bits of information pointed at by a single pointer; I use the incoming command parsing to get this token pre-separated from surrounding node names, and no need to re-allocate it, since the vector of tokens lives until after command execution is complete. Each leaf command obtains this token from cmd->node (aka node_data), and feeds this token to a common static function to parse selector and value from it and to retrieve a subscriber record as needed. (BTW, I have mentioned on the mailing list that this way might be necessary to avoid numeric-only CTRL node names, but we don't need to, and that is not at all related to this choice of structure.) Depends: libosmocore I1bd62ae0d4eefde7e1517db15a2155640a1bab58 libosmocore Ic9dba0e4a1eb5a7dc3cee2f181b9024ed4fc7005 Change-Id: I98ee6a06b3aa6a67adb868e0b63b0e04eb42eb50
2017-10-16 23:58:24 +00:00
INSERT INTO subscriber (id, imsi, msisdn) VALUES (1, '901990000000001', '1');
INSERT INTO auc_2g (subscriber_id, algo_id_2g, ki) VALUES (1, 1, '000102030405060708090a0b0c0d0e0f');
-- 3G only subscriber
INSERT INTO subscriber (id, imsi) VALUES (2, '901990000000002');
ctrl: completely replace all CTRL commands The previous commands are not conforming to how the CTRL interface is intended to work: SET enable-ps <IMSI> SET disable-ps <IMSI> SET status-ps <IMSI> 'status-ps' is a write-only command even though it returns the status. 'enable-ps' / 'disable-ps' indicate the value instead of a variable name of an entity. The entity <IMSI> takes the place of the variable value. See also https://lists.osmocom.org/pipermail/openbsc/2017-September/011236.html Instead, replace with SET subscriber.by-imsi-123456.ps-enabled {0,1} GET subscriber.by-imsi-123456.ps-enabled and also provide further CTRL functions while at it: {SET,GET} subscriber.by-{imsi,msisdn,id}-123456.{cs,ps}-enabled {0,1} GET subscriber.by-{imsi,msisdn,id}-123456.{info,info-aud,info-all} Provide CTRL tests in the form of transcripts. Adjust tests/test_subscriber.sql to feature nonzero SQN, to see some values for SQN in the CTRL transcript tests. (This does not affect the VTY tests, because that creates its own subscribers, and there's no VTY command to set the SQN.) This is the first time an application uses CTRL_NODE ids that are defined outside of libosmocore, see 'Depends' below. Implementation choice: the first idea was to have a '.' between the 'by-xxx' and the value, like: subscriber.by-xxx.123456.function but the difficulty with subscribers is that they are not in RAM, and I can't just point node_data at a struct instance that is always there (like, say, a global bts[0] struct in osmo-bsc). Instead, I want to store the selector and later decide whether to read from the DB or whatever. With a '.' separating things, the only way in a ctrl function to obtain both 'by-xxx' and '123456' for picking a subscriber record would be to parse the entire variable path string elements, including 'subscriber' and 'function', which would then also clumsily fix at which node level we hook these commands; there could have been separate CTRL_NODE_SUBSCR_BY_{IMSI,MSISDN,ID} parent nodes, but we cannot introspect the current parent node dynamically within a ctrl function handler (plus I'm not sure whether it's possible and a good idea to have the same command under multiple parent nodes). Rather than that, I store the 'by-foo-123' token in the node_data pointer to have both bits of information pointed at by a single pointer; I use the incoming command parsing to get this token pre-separated from surrounding node names, and no need to re-allocate it, since the vector of tokens lives until after command execution is complete. Each leaf command obtains this token from cmd->node (aka node_data), and feeds this token to a common static function to parse selector and value from it and to retrieve a subscriber record as needed. (BTW, I have mentioned on the mailing list that this way might be necessary to avoid numeric-only CTRL node names, but we don't need to, and that is not at all related to this choice of structure.) Depends: libosmocore I1bd62ae0d4eefde7e1517db15a2155640a1bab58 libosmocore Ic9dba0e4a1eb5a7dc3cee2f181b9024ed4fc7005 Change-Id: I98ee6a06b3aa6a67adb868e0b63b0e04eb42eb50
2017-10-16 23:58:24 +00:00
INSERT INTO auc_3g (subscriber_id, algo_id_3g, k, opc, sqn) VALUES (2, 5, '000102030405060708090a0b0c0d0e0f', '101112131415161718191a1b1c1d1e1f', 4223);
-- 2G + 3G subscriber
ctrl: completely replace all CTRL commands The previous commands are not conforming to how the CTRL interface is intended to work: SET enable-ps <IMSI> SET disable-ps <IMSI> SET status-ps <IMSI> 'status-ps' is a write-only command even though it returns the status. 'enable-ps' / 'disable-ps' indicate the value instead of a variable name of an entity. The entity <IMSI> takes the place of the variable value. See also https://lists.osmocom.org/pipermail/openbsc/2017-September/011236.html Instead, replace with SET subscriber.by-imsi-123456.ps-enabled {0,1} GET subscriber.by-imsi-123456.ps-enabled and also provide further CTRL functions while at it: {SET,GET} subscriber.by-{imsi,msisdn,id}-123456.{cs,ps}-enabled {0,1} GET subscriber.by-{imsi,msisdn,id}-123456.{info,info-aud,info-all} Provide CTRL tests in the form of transcripts. Adjust tests/test_subscriber.sql to feature nonzero SQN, to see some values for SQN in the CTRL transcript tests. (This does not affect the VTY tests, because that creates its own subscribers, and there's no VTY command to set the SQN.) This is the first time an application uses CTRL_NODE ids that are defined outside of libosmocore, see 'Depends' below. Implementation choice: the first idea was to have a '.' between the 'by-xxx' and the value, like: subscriber.by-xxx.123456.function but the difficulty with subscribers is that they are not in RAM, and I can't just point node_data at a struct instance that is always there (like, say, a global bts[0] struct in osmo-bsc). Instead, I want to store the selector and later decide whether to read from the DB or whatever. With a '.' separating things, the only way in a ctrl function to obtain both 'by-xxx' and '123456' for picking a subscriber record would be to parse the entire variable path string elements, including 'subscriber' and 'function', which would then also clumsily fix at which node level we hook these commands; there could have been separate CTRL_NODE_SUBSCR_BY_{IMSI,MSISDN,ID} parent nodes, but we cannot introspect the current parent node dynamically within a ctrl function handler (plus I'm not sure whether it's possible and a good idea to have the same command under multiple parent nodes). Rather than that, I store the 'by-foo-123' token in the node_data pointer to have both bits of information pointed at by a single pointer; I use the incoming command parsing to get this token pre-separated from surrounding node names, and no need to re-allocate it, since the vector of tokens lives until after command execution is complete. Each leaf command obtains this token from cmd->node (aka node_data), and feeds this token to a common static function to parse selector and value from it and to retrieve a subscriber record as needed. (BTW, I have mentioned on the mailing list that this way might be necessary to avoid numeric-only CTRL node names, but we don't need to, and that is not at all related to this choice of structure.) Depends: libosmocore I1bd62ae0d4eefde7e1517db15a2155640a1bab58 libosmocore Ic9dba0e4a1eb5a7dc3cee2f181b9024ed4fc7005 Change-Id: I98ee6a06b3aa6a67adb868e0b63b0e04eb42eb50
2017-10-16 23:58:24 +00:00
INSERT INTO subscriber (id, imsi, msisdn) VALUES (3, '901990000000003', '103');
INSERT INTO auc_2g (subscriber_id, algo_id_2g, ki) VALUES (3, 1, '000102030405060708090a0b0c0d0e0f');
ctrl: completely replace all CTRL commands The previous commands are not conforming to how the CTRL interface is intended to work: SET enable-ps <IMSI> SET disable-ps <IMSI> SET status-ps <IMSI> 'status-ps' is a write-only command even though it returns the status. 'enable-ps' / 'disable-ps' indicate the value instead of a variable name of an entity. The entity <IMSI> takes the place of the variable value. See also https://lists.osmocom.org/pipermail/openbsc/2017-September/011236.html Instead, replace with SET subscriber.by-imsi-123456.ps-enabled {0,1} GET subscriber.by-imsi-123456.ps-enabled and also provide further CTRL functions while at it: {SET,GET} subscriber.by-{imsi,msisdn,id}-123456.{cs,ps}-enabled {0,1} GET subscriber.by-{imsi,msisdn,id}-123456.{info,info-aud,info-all} Provide CTRL tests in the form of transcripts. Adjust tests/test_subscriber.sql to feature nonzero SQN, to see some values for SQN in the CTRL transcript tests. (This does not affect the VTY tests, because that creates its own subscribers, and there's no VTY command to set the SQN.) This is the first time an application uses CTRL_NODE ids that are defined outside of libosmocore, see 'Depends' below. Implementation choice: the first idea was to have a '.' between the 'by-xxx' and the value, like: subscriber.by-xxx.123456.function but the difficulty with subscribers is that they are not in RAM, and I can't just point node_data at a struct instance that is always there (like, say, a global bts[0] struct in osmo-bsc). Instead, I want to store the selector and later decide whether to read from the DB or whatever. With a '.' separating things, the only way in a ctrl function to obtain both 'by-xxx' and '123456' for picking a subscriber record would be to parse the entire variable path string elements, including 'subscriber' and 'function', which would then also clumsily fix at which node level we hook these commands; there could have been separate CTRL_NODE_SUBSCR_BY_{IMSI,MSISDN,ID} parent nodes, but we cannot introspect the current parent node dynamically within a ctrl function handler (plus I'm not sure whether it's possible and a good idea to have the same command under multiple parent nodes). Rather than that, I store the 'by-foo-123' token in the node_data pointer to have both bits of information pointed at by a single pointer; I use the incoming command parsing to get this token pre-separated from surrounding node names, and no need to re-allocate it, since the vector of tokens lives until after command execution is complete. Each leaf command obtains this token from cmd->node (aka node_data), and feeds this token to a common static function to parse selector and value from it and to retrieve a subscriber record as needed. (BTW, I have mentioned on the mailing list that this way might be necessary to avoid numeric-only CTRL node names, but we don't need to, and that is not at all related to this choice of structure.) Depends: libosmocore I1bd62ae0d4eefde7e1517db15a2155640a1bab58 libosmocore Ic9dba0e4a1eb5a7dc3cee2f181b9024ed4fc7005 Change-Id: I98ee6a06b3aa6a67adb868e0b63b0e04eb42eb50
2017-10-16 23:58:24 +00:00
INSERT INTO auc_3g (subscriber_id, algo_id_3g, k, opc, sqn) VALUES (3, 5, '000102030405060708090a0b0c0d0e0f', '101112131415161718191a1b1c1d1e1f', 2342);
-- A subscriber id > 7 and > 15 to check against octal and hex notations
INSERT INTO subscriber (id, imsi, msisdn) VALUES (123, '123123', '123');
INSERT INTO auc_2g (subscriber_id, algo_id_2g, ki) VALUES (123, 3, 'BeefedCafeFaceAcedAddedDecadeFee');