lce: maintain TPUI assignment in location table
Maintain TPUIs and use for paging PTs. Signed-off-by: Patrick McHardy <kaber@trash.net>
This commit is contained in:
parent
ff3028a515
commit
ce7df5b796
|
@ -139,14 +139,18 @@ extern void dect_lce_register_protocol(const struct dect_nwk_protocol *protocol)
|
|||
/**
|
||||
* struct dect_lte - Location Table Entry
|
||||
*
|
||||
* @list: Location table list node
|
||||
* @ipui: International Portable User ID
|
||||
* @tpui: Temporary Portable User ID
|
||||
* @list: Location table list node
|
||||
* @ipui: International Portable User ID
|
||||
* @tpui: Assigned Temporary Portable User ID
|
||||
* @tpui_valid: TPUI is valid
|
||||
* @setup_capability: PT's setup capabilities
|
||||
* @terminal_capability: PT's terminal capabilities
|
||||
*/
|
||||
struct dect_lte {
|
||||
struct list_head list;
|
||||
struct dect_ipui ipui;
|
||||
struct dect_tpui tpui;
|
||||
bool tpui_valid;
|
||||
struct dect_ie_setup_capability *setup_capability;
|
||||
struct dect_ie_terminal_capability *terminal_capability;
|
||||
};
|
||||
|
@ -155,6 +159,10 @@ extern void dect_lte_update(struct dect_handle *dh, const struct dect_ipui *ipui
|
|||
struct dect_ie_setup_capability *setup_capability,
|
||||
struct dect_ie_terminal_capability *terminal_capability);
|
||||
|
||||
extern void dect_lte_update_tpui(const struct dect_handle *dh,
|
||||
const struct dect_ipui *ipui,
|
||||
const struct dect_tpui *tpui);
|
||||
|
||||
enum dect_data_link_states {
|
||||
DECT_DATA_LINK_RELEASED,
|
||||
DECT_DATA_LINK_ESTABLISHED,
|
||||
|
|
|
@ -356,6 +356,7 @@ struct dect_mm_procedure {
|
|||
uint8_t retransmissions;
|
||||
struct dect_transaction transaction;
|
||||
struct dect_ie_collection *iec;
|
||||
struct dect_tpui tpui;
|
||||
struct dect_timer *timer;
|
||||
};
|
||||
|
||||
|
|
47
src/lce.c
47
src/lce.c
|
@ -248,6 +248,7 @@ static struct dect_lte *dect_lte_alloc(struct dect_handle *dh,
|
|||
lte = dect_malloc(dh, sizeof(*lte));
|
||||
if (lte == NULL)
|
||||
return NULL;
|
||||
memset(lte, 0, sizeof(*lte));
|
||||
lte->ipui = *ipui;
|
||||
|
||||
list_add_tail(<e->list, &dh->ldb);
|
||||
|
@ -279,6 +280,30 @@ void dect_lte_update(struct dect_handle *dh, const struct dect_ipui *ipui,
|
|||
dect_ie_update(lte->terminal_capability, terminal_capability);
|
||||
}
|
||||
|
||||
void dect_lte_update_tpui(const struct dect_handle *dh,
|
||||
const struct dect_ipui *ipui,
|
||||
const struct dect_tpui *tpui)
|
||||
{
|
||||
struct dect_lte *lte;
|
||||
|
||||
lte = dect_lte_get_by_ipui(dh, ipui);
|
||||
if (lte == NULL)
|
||||
return;
|
||||
lte->tpui = *tpui;
|
||||
lte->tpui_valid = true;
|
||||
}
|
||||
|
||||
static const struct dect_tpui *dect_tpui(const struct dect_handle *dh,
|
||||
const struct dect_ipui *ipui)
|
||||
{
|
||||
const struct dect_lte *lte;
|
||||
|
||||
lte = dect_lte_get_by_ipui(dh, ipui);
|
||||
if (lte == NULL || !lte->tpui_valid)
|
||||
return NULL;
|
||||
return <e->tpui;
|
||||
}
|
||||
|
||||
static enum dect_setup_capabilities
|
||||
dect_setup_capability(const struct dect_handle *dh,
|
||||
const struct dect_ipui *ipui)
|
||||
|
@ -1093,15 +1118,21 @@ static int dect_lce_send_short_page(const struct dect_handle *dh,
|
|||
{
|
||||
DECT_DEFINE_MSG_BUF_ONSTACK(_mb), *mb = &_mb;
|
||||
struct dect_short_page_msg *msg;
|
||||
struct dect_tpui tpui;
|
||||
const struct dect_tpui *tpui;
|
||||
struct dect_tpui _tpui;
|
||||
bool fast_page = false;
|
||||
uint16_t page;
|
||||
|
||||
msg = dect_mbuf_put(mb, sizeof(*msg));
|
||||
msg->hdr = DECT_LCE_PAGE_GENERAL_VOICE;
|
||||
|
||||
page = dect_build_tpui(dect_ipui_to_tpui(&tpui, ipui)) &
|
||||
DECT_LCE_SHORT_PAGE_TPUI_MASK;
|
||||
tpui = dect_tpui(dh, ipui);
|
||||
if (tpui == NULL)
|
||||
tpui = dect_ipui_to_tpui(&_tpui, ipui);
|
||||
else
|
||||
msg->hdr |= DECT_LCE_PAGE_W_FLAG;
|
||||
|
||||
page = dect_build_tpui(tpui) & DECT_LCE_SHORT_PAGE_TPUI_MASK;
|
||||
msg->information = __cpu_to_be16(page);
|
||||
|
||||
if (dect_page_capability(dh, ipui) ==
|
||||
|
@ -1116,7 +1147,8 @@ static int dect_lce_send_full_page(const struct dect_handle *dh,
|
|||
{
|
||||
DECT_DEFINE_MSG_BUF_ONSTACK(_mb), *mb = &_mb;
|
||||
struct dect_full_page_msg *msg;
|
||||
struct dect_tpui tpui;
|
||||
const struct dect_tpui *tpui;
|
||||
struct dect_tpui _tpui;
|
||||
uint8_t ipui_buf[8];
|
||||
bool fast_page = false;
|
||||
uint32_t page;
|
||||
|
@ -1127,8 +1159,11 @@ static int dect_lce_send_full_page(const struct dect_handle *dh,
|
|||
if (1) {
|
||||
msg->hdr |= DECT_LCE_PAGE_W_FLAG;
|
||||
|
||||
page = dect_build_tpui(dect_ipui_to_tpui(&tpui, ipui)) <<
|
||||
DECT_LCE_FULL_PAGE_TPUI_SHIFT;
|
||||
tpui = dect_tpui(dh, ipui);
|
||||
if (tpui == NULL)
|
||||
tpui = dect_ipui_to_tpui(&_tpui, ipui);
|
||||
|
||||
page = dect_build_tpui(tpui) << DECT_LCE_FULL_PAGE_TPUI_SHIFT;
|
||||
page |= DECT_LCE_PAGE_FULL_SLOT <<
|
||||
DECT_LCE_FULL_PAGE_SLOT_TYPE_SHIFT;
|
||||
page |= DECT_LCE_PAGE_BASIC_CONN_ATTR_OPTIONAL <<
|
||||
|
|
13
src/mm.c
13
src/mm.c
|
@ -1448,7 +1448,7 @@ int dect_mm_access_rights_res(struct dect_handle *dh,
|
|||
const struct dect_mm_access_rights_param *param)
|
||||
{
|
||||
struct dect_mm_procedure *mp = &mme->procedure[DECT_TRANSACTION_RESPONDER];
|
||||
struct dect_mm_access_rights_param *req;
|
||||
const struct dect_mm_access_rights_param *req;
|
||||
int err;
|
||||
|
||||
mm_debug_entry(mme, "MM_ACCESS_RIGHTS-res: accept: %u", accept);
|
||||
|
@ -1456,7 +1456,7 @@ int dect_mm_access_rights_res(struct dect_handle *dh,
|
|||
return -1;
|
||||
|
||||
if (accept) {
|
||||
req = (struct dect_mm_access_rights_param *)mp->iec;
|
||||
req = (const struct dect_mm_access_rights_param *)mp->iec;
|
||||
dect_lte_update(dh, &req->portable_identity->ipui,
|
||||
req->setup_capability,
|
||||
req->terminal_capability);
|
||||
|
@ -1991,7 +1991,7 @@ int dect_mm_locate_res(struct dect_handle *dh, struct dect_mm_endpoint *mme,
|
|||
bool accept, const struct dect_mm_locate_param *param)
|
||||
{
|
||||
struct dect_mm_procedure *mp = &mme->procedure[DECT_TRANSACTION_RESPONDER];
|
||||
struct dect_mm_locate_param *req;
|
||||
const struct dect_mm_locate_param *req;
|
||||
int err;
|
||||
|
||||
mm_debug_entry(mme, "MM_LOCATE-res: accept: %u", accept);
|
||||
|
@ -1999,7 +1999,7 @@ int dect_mm_locate_res(struct dect_handle *dh, struct dect_mm_endpoint *mme,
|
|||
return -1;
|
||||
|
||||
if (accept) {
|
||||
req = (struct dect_mm_locate_param *)mp->iec;
|
||||
req = (const struct dect_mm_locate_param *)mp->iec;
|
||||
dect_lte_update(dh, &req->portable_identity->ipui,
|
||||
req->setup_capability,
|
||||
req->terminal_capability);
|
||||
|
@ -2018,6 +2018,7 @@ int dect_mm_locate_res(struct dect_handle *dh, struct dect_mm_endpoint *mme,
|
|||
if (accept && param->portable_identity &&
|
||||
(param->portable_identity->type == DECT_PORTABLE_ID_TYPE_TPUI ||
|
||||
param->nwk_assigned_identity)) {
|
||||
mp->tpui = param->portable_identity->tpui;
|
||||
mp->type = DECT_MMP_TEMPORARY_IDENTITY_ASSIGNMENT;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2624,6 +2625,7 @@ static void dect_mm_rcv_temporary_identity_assign_ack(struct dect_handle *dh,
|
|||
struct dect_mm_procedure *mp = &mme->procedure[DECT_TRANSACTION_RESPONDER];
|
||||
struct dect_mm_temporary_identity_assign_ack_msg msg;
|
||||
struct dect_mm_identity_assign_param *param;
|
||||
const struct dect_mm_locate_param *req;
|
||||
|
||||
mm_debug(mme, "TEMPORARY-IDENTITY-ASSIGN-ACK");
|
||||
if (mp->type != DECT_MMP_TEMPORARY_IDENTITY_ASSIGNMENT)
|
||||
|
@ -2640,6 +2642,9 @@ static void dect_mm_rcv_temporary_identity_assign_ack(struct dect_handle *dh,
|
|||
param->iwu_to_iwu = dect_ie_hold(msg.iwu_to_iwu);
|
||||
param->escape_to_proprietary = dect_ie_hold(msg.escape_to_proprietary);
|
||||
|
||||
req = (const struct dect_mm_locate_param *)mp->iec;
|
||||
dect_lte_update_tpui(dh, &req->portable_identity->ipui, &mp->tpui);
|
||||
|
||||
dect_mm_procedure_complete(dh, mme);
|
||||
|
||||
mm_debug(mme, "MM_IDENTITY_ASSIGN-cfm: accept: 1");
|
||||
|
|
Reference in New Issue