mirror of
				https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
				synced 2025-11-04 05:53:26 +00:00 
			
		
		
		
	db: Rename AuthTuples to AuthLastTuples
Ultimately, we'll need to store both the last used tuple by a subscriber and a list of known tuples (for unknown Ki). What's currently implemented for AuthTuples is the former behavior, so reflect that. The second use case will be added as a separate table with separate accessors later on. Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
This commit is contained in:
		
				
					committed by
					
						
						Harald Welte
					
				
			
			
				
	
			
			
			
						parent
						
							b48216f9d1
						
					
				
				
					commit
					c614a6a199
				
			@@ -48,10 +48,10 @@ int get_authinfo_by_subscr(struct gsm_auth_info *ainfo,
 | 
				
			|||||||
                           struct gsm_subscriber *subscr);
 | 
					                           struct gsm_subscriber *subscr);
 | 
				
			||||||
int set_authinfo_for_subscr(struct gsm_auth_info *ainfo,
 | 
					int set_authinfo_for_subscr(struct gsm_auth_info *ainfo,
 | 
				
			||||||
                            struct gsm_subscriber *subscr);
 | 
					                            struct gsm_subscriber *subscr);
 | 
				
			||||||
int get_authtuple_by_subscr(struct gsm_auth_tuple *atuple,
 | 
					int get_lastauthtuple_by_subscr(struct gsm_auth_tuple *atuple,
 | 
				
			||||||
                            struct gsm_subscriber *subscr);
 | 
					                                struct gsm_subscriber *subscr);
 | 
				
			||||||
int set_authtuple_for_subscr(struct gsm_auth_tuple *atuple,
 | 
					int set_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple,
 | 
				
			||||||
                             struct gsm_subscriber *subscr);
 | 
					                                 struct gsm_subscriber *subscr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* SMS store-and-forward */
 | 
					/* SMS store-and-forward */
 | 
				
			||||||
int db_sms_store(struct gsm_sms *sms);
 | 
					int db_sms_store(struct gsm_sms *sms);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -140,7 +140,7 @@ static char *create_stmts[] = {
 | 
				
			|||||||
		"algorithm_id INTEGER NOT NULL, "
 | 
							"algorithm_id INTEGER NOT NULL, "
 | 
				
			||||||
		"a3a8_ki BLOB "
 | 
							"a3a8_ki BLOB "
 | 
				
			||||||
		")",
 | 
							")",
 | 
				
			||||||
	"CREATE TABLE IF NOT EXISTS AuthTuples ("
 | 
						"CREATE TABLE IF NOT EXISTS AuthLastTuples ("
 | 
				
			||||||
		"id INTEGER PRIMARY KEY AUTOINCREMENT, "
 | 
							"id INTEGER PRIMARY KEY AUTOINCREMENT, "
 | 
				
			||||||
		"subscriber_id NUMERIC UNIQUE NOT NULL, "
 | 
							"subscriber_id NUMERIC UNIQUE NOT NULL, "
 | 
				
			||||||
		"issued TIMESTAMP NOT NULL, "
 | 
							"issued TIMESTAMP NOT NULL, "
 | 
				
			||||||
@@ -435,15 +435,15 @@ int set_authinfo_for_subscr(struct gsm_auth_info *ainfo,
 | 
				
			|||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int get_authtuple_by_subscr(struct gsm_auth_tuple *atuple,
 | 
					int get_lastauthtuple_by_subscr(struct gsm_auth_tuple *atuple,
 | 
				
			||||||
			    struct gsm_subscriber *subscr)
 | 
					                                struct gsm_subscriber *subscr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	dbi_result result;
 | 
						dbi_result result;
 | 
				
			||||||
	int len;
 | 
						int len;
 | 
				
			||||||
	const unsigned char *blob;
 | 
						const unsigned char *blob;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	result = dbi_conn_queryf(conn,
 | 
						result = dbi_conn_queryf(conn,
 | 
				
			||||||
			"SELECT * FROM AuthTuples WHERE subscriber_id=%u",
 | 
								"SELECT * FROM AuthLastTuples WHERE subscriber_id=%u",
 | 
				
			||||||
			subscr->id);
 | 
								subscr->id);
 | 
				
			||||||
	if (!result)
 | 
						if (!result)
 | 
				
			||||||
		return -EIO;
 | 
							return -EIO;
 | 
				
			||||||
@@ -488,8 +488,8 @@ err_size:
 | 
				
			|||||||
	return -EIO;
 | 
						return -EIO;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int set_authtuple_for_subscr(struct gsm_auth_tuple *atuple,
 | 
					int set_lastauthtuple_for_subscr(struct gsm_auth_tuple *atuple,
 | 
				
			||||||
			     struct gsm_subscriber *subscr)
 | 
					                                 struct gsm_subscriber *subscr)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	dbi_result result;
 | 
						dbi_result result;
 | 
				
			||||||
	int rc, upd;
 | 
						int rc, upd;
 | 
				
			||||||
@@ -499,7 +499,7 @@ int set_authtuple_for_subscr(struct gsm_auth_tuple *atuple,
 | 
				
			|||||||
	/* Deletion ? */
 | 
						/* Deletion ? */
 | 
				
			||||||
	if (atuple == NULL) {
 | 
						if (atuple == NULL) {
 | 
				
			||||||
		result = dbi_conn_queryf(conn,
 | 
							result = dbi_conn_queryf(conn,
 | 
				
			||||||
			"DELETE FROM AuthTuples WHERE subscriber_id=%u",
 | 
								"DELETE FROM AuthLastTuples WHERE subscriber_id=%u",
 | 
				
			||||||
			subscr->id);
 | 
								subscr->id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (!result)
 | 
							if (!result)
 | 
				
			||||||
@@ -511,7 +511,7 @@ int set_authtuple_for_subscr(struct gsm_auth_tuple *atuple,
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Check if already existing */
 | 
						/* Check if already existing */
 | 
				
			||||||
	rc = get_authtuple_by_subscr(&atuple_old, subscr);
 | 
						rc = get_lastauthtuple_by_subscr(&atuple_old, subscr);
 | 
				
			||||||
	if (rc && rc != -ENOENT)
 | 
						if (rc && rc != -ENOENT)
 | 
				
			||||||
		return rc;
 | 
							return rc;
 | 
				
			||||||
	upd = rc ? 0 : 1;
 | 
						upd = rc ? 0 : 1;
 | 
				
			||||||
@@ -526,7 +526,7 @@ int set_authtuple_for_subscr(struct gsm_auth_tuple *atuple,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if (!upd) {
 | 
						if (!upd) {
 | 
				
			||||||
		result = dbi_conn_queryf(conn,
 | 
							result = dbi_conn_queryf(conn,
 | 
				
			||||||
				"INSERT INTO AuthTuples "
 | 
									"INSERT INTO AuthLastTuples "
 | 
				
			||||||
				"(subscriber_id, issued, use_count, "
 | 
									"(subscriber_id, issued, use_count, "
 | 
				
			||||||
				 "key_seq, rand, sres, kc) "
 | 
									 "key_seq, rand, sres, kc) "
 | 
				
			||||||
				"VALUES (%u, datetime('now'), %u, "
 | 
									"VALUES (%u, datetime('now'), %u, "
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -100,7 +100,7 @@ static void subscr_dump_full_vty(struct vty *vty, struct gsm_subscriber *subscr)
 | 
				
			|||||||
			VTY_NEWLINE);
 | 
								VTY_NEWLINE);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rc = get_authtuple_by_subscr(&atuple, subscr);
 | 
						rc = get_lastauthtuple_by_subscr(&atuple, subscr);
 | 
				
			||||||
	if (!rc) {
 | 
						if (!rc) {
 | 
				
			||||||
		vty_out(vty, "    A3A8 last tuple (used %d times):%s",
 | 
							vty_out(vty, "    A3A8 last tuple (used %d times):%s",
 | 
				
			||||||
			atuple.use_count, VTY_NEWLINE);
 | 
								atuple.use_count, VTY_NEWLINE);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user