dect
/
libdect
Archived
13
0
Fork 0

mm: destroy endpoint when link is shut down

Also rebind the endpoint from the requesting link when an indirect link
establishment is complete.

Signed-off-by: Patrick McHardy <kaber@trash.net>
This commit is contained in:
Patrick McHardy 2010-10-10 19:57:04 +02:00
parent 08ffd40ba7
commit ce4da27071
3 changed files with 33 additions and 0 deletions

View File

@ -125,6 +125,9 @@ struct dect_nwk_protocol {
void (*encrypt_ind)(struct dect_handle *dh,
struct dect_transaction *ta,
enum dect_cipher_states state);
void (*rebind)(struct dect_handle *dh,
struct dect_data_link *from,
struct dect_data_link *to);
};
extern void dect_lce_register_protocol(const struct dect_nwk_protocol *protocol);

View File

@ -258,10 +258,16 @@ err1:
static void dect_ddl_destroy(struct dect_handle *dh, struct dect_data_link *ddl)
{
struct dect_msg_buf *mb, *next;
unsigned int i;
ddl_debug(ddl, "destroy");
dect_assert(list_empty(&ddl->transactions));
for (i = 0; i < array_size(protocols); i++) {
if (protocols[i] && protocols[i]->rebind != NULL)
protocols[i]->rebind(dh, ddl, NULL);
}
list_del(&ddl->list);
list_for_each_entry_safe(mb, next, &ddl->msg_queue, list)
dect_mbuf_free(dh, mb);
@ -638,6 +644,7 @@ static void dect_ddl_complete_indirect_establish(struct dect_handle *dh,
{
struct dect_transaction *ta, *ta_next;
struct dect_msg_buf *mb, *mb_next;
unsigned int i;
/* Stop page timer */
dect_timer_stop(dh, req->page_timer);
@ -646,6 +653,11 @@ static void dect_ddl_complete_indirect_establish(struct dect_handle *dh,
ddl_debug(ddl, "complete indirect link establishment req %p", req);
dect_ddl_set_ipui(dh, ddl, &req->ipui);
for (i = 0; i < array_size(protocols); i++) {
if (protocols[i] && protocols[i]->rebind != NULL)
protocols[i]->rebind(dh, req, ddl);
}
/* Transfer transactions to the new link */
list_for_each_entry_safe(ta, ta_next, &req->transactions, list) {
ddl_debug(ta->link, "transfer transaction to link %p", ddl);

View File

@ -558,6 +558,7 @@ EXPORT_SYMBOL(dect_mm_endpoint_alloc);
void dect_mm_endpoint_destroy(struct dect_handle *dh,
struct dect_mm_endpoint *mme)
{
list_del(&mme->list);
dect_timer_free(dh, mme->procedure[DECT_TRANSACTION_RESPONDER].timer);
dect_timer_free(dh, mme->procedure[DECT_TRANSACTION_INITIATOR].timer);
dect_free(dh, mme);
@ -3300,6 +3301,22 @@ static void dect_mm_shutdown(struct dect_handle *dh,
proc->abort(dh, mme, mp);
}
static void dect_mm_link_rebind(struct dect_handle *dh,
struct dect_data_link *from,
struct dect_data_link *to)
{
struct dect_mm_endpoint *mme;
mme = dect_mm_endpoint_get_by_link(dh, from);
if (mme == NULL)
return;
if (to != NULL)
mme->link = to;
else
dect_mm_endpoint_destroy(dh, mme);
}
const struct dect_nwk_protocol dect_mm_protocol = {
.name = "Mobility Management",
.pd = DECT_PD_MM,
@ -3308,6 +3325,7 @@ const struct dect_nwk_protocol dect_mm_protocol = {
.shutdown = dect_mm_shutdown,
.rcv = dect_mm_rcv,
.encrypt_ind = dect_mm_encrypt_ind,
.rebind = dect_mm_link_rebind,
};
/** @} */