UID#
Functions
-
struct uid_store *uid_store_create(const struct uid_store_config *config)#
Creates and initializes a UID store instance.
This initializes both in-memory cache and backing storage under the specified namespace.
- Parameters:
config – [in] Store configuration including fs, namespace, and cache size.
- Returns:
Pointer to initialized store instance, or NULL on failure.
-
void uid_store_destroy(struct uid_store *store)#
Destroys a previously created UID store instance.
Frees all associated memory and internal structures.
- Parameters:
store – [in] The UID store instance to destroy.
-
int uid_update(struct uid_store *store, const uid_id_t id, const uid_id_t pid, uid_status_t status, time_t expiry)#
Updates or inserts a UID entry into the store (cache + persistent storage).
This function is typically called when a response is received from the server, or when a local decision is made to override the cached status.
- Parameters:
store – [in] The UID store instance.
id – [in] The UID to update.
pid – [in] Provisioning or parent ID to associate (optional).
status – [in] The new status to associate with the UID.
expiry – [in] The expiration time for the UID status.
- Returns:
0 on success, negative value on failure.
-
int uid_delete(struct uid_store *store, const uid_id_t id)#
Removes a UID entry from the store (RAM only).
This function explicitly purges the UID from the in-memory cache. It does not affect any persistent storage or remote server state.
- Parameters:
store – [in] The UID store instance.
id – [in] The UID to remove from the cache.
- Returns:
0 on success, negative value if the UID was not found.
-
uid_status_t uid_status(struct uid_store *store, const uid_id_t id, uid_id_t pid, time_t *expiry)#
Retrieves the status and expiry time of a UID.
This function first checks the cache; if not found, it searches the persistent storage. If the UID is found, its current status and expiry time are returned.
- Parameters:
store – [in] The UID store instance.
id – [in] The UID to query.
expiry – [out] Pointer to store the UID’s expiry time (can be NULL).
- Returns:
The status of the UID.
-
int uid_clear(struct uid_store *store)#
Clears all entries in the UID store.
This function removes all user identification (UID) entries from the specified UID store, effectively resetting it to an empty state.
- Parameters:
store – [in] Pointer to the UID store structure to be cleared.
- Returns:
0 on success, or a negative error code on failure.
-
int uid_register_update_cb(struct uid_store *store, uid_update_cb_t cb, void *ctx)#
Registers a callback to be invoked when a UID is updated.
The callback is called when a UID entry is updated or inserted via
uid_update()
, even if the new value is the same as the existing one. Only one callback can be registered per store. Subsequent calls overwrite the previous registration.- Parameters:
store – [in] The UID store instance.
cb – [in] The callback function to register.
ctx – [in] A user-defined context pointer passed to the callback.
- Returns:
0 on success, negative value on failure.
Typedefs
-
typedef uint8_t uid_id_t[UID_ID_MAXLEN]#
-
typedef void (*uid_update_cb_t)(const uid_id_t id, uid_status_t status, time_t expiry, void *ctx)#
-
struct uid_store_config#
- #include <uid.h>
Enums
-
enum uid_status_t#
Values:
-
enumerator UID_STATUS_UNKNOWN#
ID has not been processed yet.
-
enumerator UID_STATUS_ACCEPTED#
ID is valid and recognized, access allowed.
-
enumerator UID_STATUS_BLOCKED#
ID is explicitly blocked from access.
-
enumerator UID_STATUS_EXPIRED#
ID was valid but has expired.
-
enumerator UID_STATUS_INVALID#
ID is invalid, blacklisted, or corrupted.
-
enumerator UID_STATUS_NO_ENTRY#
ID is not found in the local cache or store.
-
enumerator UID_STATUS_UNKNOWN#
Defines
-
UID_ID_MAXLEN 21#