sgsn: Restructure the 'update-subscriber' command

This patch drops the following commands:

 - update-subscriber imsi IMSI insert authorized <0-1>
 - update-subscriber imsi IMSI commit

since they are already covered by the 'update-location-result'
sub-command, except that this command doesn't create an new entry if
none is found with the given IMSI.

It adds the following command:

 - update-subscriber imsi IMSI create

which can be used to create a new entry.

Sponsored-by: On-Waves ehf
This commit is contained in:
Jacob Erlbeck 2015-01-19 14:11:46 +01:00 committed by Holger Hans Peter Freyther
parent 15cc8c8125
commit d91934357f
2 changed files with 12 additions and 39 deletions

View File

@ -503,32 +503,6 @@ DEFUN(show_subscr_cache,
#define UPDATE_SUBSCR_INSERT_HELP "Insert data into the subscriber record\n" #define UPDATE_SUBSCR_INSERT_HELP "Insert data into the subscriber record\n"
DEFUN(update_subscr_insert, update_subscr_insert_cmd,
UPDATE_SUBSCR_STR "insert authorized <0-1>)",
UPDATE_SUBSCR_HELP
UPDATE_SUBSCR_INSERT_HELP
"Authorize the subscriber to attach\n"
"New option value\n")
{
const char *imsi = argv[0];
const char *value = argv[1];
struct gsm_subscriber *subscr;
subscr = gprs_subscr_get_or_create(imsi);
if (!subscr) {
vty_out(vty, "%% unable get subscriber record for %s%s",
imsi, VTY_NEWLINE);
return CMD_WARNING;
}
subscr->authorized = atoi(value);
subscr_put(subscr);
return CMD_SUCCESS;
}
DEFUN(update_subscr_insert_auth_triplet, update_subscr_insert_auth_triplet_cmd, DEFUN(update_subscr_insert_auth_triplet, update_subscr_insert_auth_triplet_cmd,
UPDATE_SUBSCR_STR "insert auth-triplet <1-5> sres SRES rand RAND kc KC", UPDATE_SUBSCR_STR "insert auth-triplet <1-5> sres SRES rand RAND kc KC",
UPDATE_SUBSCR_HELP UPDATE_SUBSCR_HELP
@ -548,7 +522,7 @@ DEFUN(update_subscr_insert_auth_triplet, update_subscr_insert_auth_triplet_cmd,
struct gsm_subscriber *subscr; struct gsm_subscriber *subscr;
subscr = gprs_subscr_get_or_create(imsi); subscr = gprs_subscr_get_by_imsi(imsi);
if (!subscr) { if (!subscr) {
vty_out(vty, "%% unable get subscriber record for %s%s", vty_out(vty, "%% unable get subscriber record for %s%s",
imsi, VTY_NEWLINE); imsi, VTY_NEWLINE);
@ -607,10 +581,10 @@ DEFUN(update_subscr_cancel, update_subscr_cancel_cmd,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
DEFUN(update_subscr_commit, update_subscr_commit_cmd, DEFUN(update_subscr_create, update_subscr_create_cmd,
UPDATE_SUBSCR_STR "commit", UPDATE_SUBSCR_STR "create",
UPDATE_SUBSCR_HELP UPDATE_SUBSCR_HELP
"Apply the changes made by the insert commands\n") "Create a subscriber entry\n")
{ {
const char *imsi = argv[0]; const char *imsi = argv[0];
@ -623,8 +597,8 @@ DEFUN(update_subscr_commit, update_subscr_commit_cmd,
return CMD_WARNING; return CMD_WARNING;
} }
gprs_subscr_update(subscr); subscr = gprs_subscr_get_or_create(imsi);
subscr->keep_in_ram = 1;
subscr_put(subscr); subscr_put(subscr);
return CMD_SUCCESS; return CMD_SUCCESS;
@ -757,10 +731,9 @@ int sgsn_vty_init(void)
install_element_ve(&show_pdpctx_all_cmd); install_element_ve(&show_pdpctx_all_cmd);
install_element_ve(&show_subscr_cache_cmd); install_element_ve(&show_subscr_cache_cmd);
install_element(ENABLE_NODE, &update_subscr_insert_cmd);
install_element(ENABLE_NODE, &update_subscr_insert_auth_triplet_cmd); install_element(ENABLE_NODE, &update_subscr_insert_auth_triplet_cmd);
install_element(ENABLE_NODE, &update_subscr_create_cmd);
install_element(ENABLE_NODE, &update_subscr_cancel_cmd); install_element(ENABLE_NODE, &update_subscr_cancel_cmd);
install_element(ENABLE_NODE, &update_subscr_commit_cmd);
install_element(ENABLE_NODE, &update_subscr_update_location_result_cmd); install_element(ENABLE_NODE, &update_subscr_update_location_result_cmd);
install_element(ENABLE_NODE, &update_subscr_update_auth_info_cmd); install_element(ENABLE_NODE, &update_subscr_update_auth_info_cmd);

View File

@ -760,14 +760,14 @@ class TestVTYSGSN(TestVTYGenericBSC):
self.vty.enable() self.vty.enable()
res = self.vty.command('show subscriber cache') res = self.vty.command('show subscriber cache')
self.assert_(res.find('1234567890') < 0) self.assert_(res.find('1234567890') < 0)
self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 insert authorized 1', [''])) self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 create', ['']))
res = self.vty.command('show subscriber cache')
self.assert_(res.find('1234567890') >= 0)
self.assert_(res.find('Authorized: 0') >= 0)
self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 update-location-result ok', ['']))
res = self.vty.command('show subscriber cache') res = self.vty.command('show subscriber cache')
self.assert_(res.find('1234567890') >= 0) self.assert_(res.find('1234567890') >= 0)
self.assert_(res.find('Authorized: 1') >= 0) self.assert_(res.find('Authorized: 1') >= 0)
self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 insert authorized 0', ['']))
res = self.vty.command('show subscriber cache')
self.assert_(res.find('Authorized: 0') >= 0)
self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 commit', ['']))
self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 cancel', [''])) self.assertTrue(self.vty.verify('update-subscriber imsi 1234567890 cancel', ['']))
res = self.vty.command('show subscriber cache') res = self.vty.command('show subscriber cache')
self.assert_(res.find('1234567890') < 0) self.assert_(res.find('1234567890') < 0)