dect
/
libdect
Archived
13
0
Fork 0

lce: add page response callback

Add a page response callback that is invoked for unknown page responses.
This can be used to initiate procedures with unknown PPs after a broadcast
page.

Signed-off-by: Patrick McHardy <kaber@trash.net>
This commit is contained in:
Patrick McHardy 2009-12-22 01:10:09 +01:00
parent 5abe119633
commit a9373d66ce
4 changed files with 87 additions and 2 deletions

View File

@ -20,6 +20,39 @@ static void pexit(const char *str)
exit(1);
}
static void mm_locate_ind(struct dect_handle *dh,
struct dect_mm_endpoint *mme,
struct dect_mm_locate_param *param)
{
struct dect_mm_locate_param reply = {};
dect_mm_locate_res(dh, mme, false, &reply);
}
static struct dect_mm_ops mm_ops = {
.mm_locate_ind = mm_locate_ind,
};
static bool lce_page_response(struct dect_handle *dh, struct dect_lce_page_param *param)
{
struct dect_ie_info_type info_type;
struct dect_mm_info_param req = { .info_type = &info_type };
struct dect_mm_endpoint *mme;
mme = dect_mm_endpoint_alloc(dh, &param->portable_identity->ipui);
if (mme == NULL)
return false;
info_type.num = 1;
info_type.type[0] = DECT_INFO_LOCATE_SUGGEST;
dect_mm_info_req(dh, mme, &req);
return true;
}
static struct dect_lce_ops lce_ops = {
.lce_page_response = lce_page_response,
};
static void raw_sock_event(struct dect_handle *dh, struct dect_fd *dfd,
uint32_t events)
{
@ -61,7 +94,10 @@ static void page_timer(struct dect_handle *dh, struct dect_timer *timer)
dect_start_timer(dh, timer, 1);
}
static struct dect_ops ops;
static struct dect_ops ops = {
.lce_ops = &lce_ops,
.mm_ops = &mm_ops,
};
int main(int argc, char **argv)
{

26
include/dect/lce.h Normal file
View File

@ -0,0 +1,26 @@
/*
* DECT Link Control Entity (LCE) NWK <-> IWU interface
*
* Copyright (c) 2009 Patrick McHardy <kaber@trash.net>
*/
#ifndef _LIBDECT_DECT_LCE_H
#define _LIBDECT_DECT_LCE_H
#include <dect/ie.h>
struct dect_lce_page_param {
struct dect_ie_collection common;
struct dect_ie_portable_identity *portable_identity;
struct dect_ie_fixed_identity *fixed_identity;
struct dect_ie_nwk_assigned_identity *nwk_assigned_identity;
struct dect_ie_cipher_info *cipher_info;
struct dect_ie_escape_to_proprietary *escape_to_proprietary;
};
struct dect_lce_ops {
bool (*lce_page_response)(struct dect_handle *dh,
struct dect_lce_page_param *param);
};
#endif /* _LIBDECT_DECT_LCE_H */

View File

@ -14,6 +14,7 @@
#include <dect/identities.h>
#include <dect/auth.h>
#include <dect/lce.h>
#include <dect/cc.h>
#include <dect/mm.h>
#include <dect/ss.h>
@ -126,6 +127,7 @@ struct dect_ops {
void (*free)(void *ptr);
const struct dect_event_ops *event_ops;
const struct dect_lce_ops *lce_ops;
const struct dect_cc_ops *cc_ops;
const struct dect_mm_ops *mm_ops;
const struct dect_ss_ops *ss_ops;

View File

@ -652,6 +652,7 @@ static void dect_lce_rcv_page_response(struct dect_handle *dh,
struct dect_lce_page_response msg;
struct dect_data_link *i, *req = NULL;
enum dect_sfmt_error err;
bool reject = true;
ddl_debug(ta->link, "LCE-PAGE-RESPONSE");
err = dect_parse_sfmt_msg(dh, &lce_page_response_msg_desc,
@ -670,9 +671,29 @@ static void dect_lce_rcv_page_response(struct dect_handle *dh,
break;
}
ta->link->ipui = msg.portable_identity->ipui;
if (req == NULL && dh->ops->lce_ops &&
dh->ops->lce_ops->lce_page_response) {
struct dect_lce_page_param *param;
param = dect_ie_collection_alloc(dh, sizeof(*param));
if (param == NULL)
goto err;
param->portable_identity = dect_ie_hold(msg.portable_identity);
param->fixed_identity = dect_ie_hold(msg.fixed_identity);
param->nwk_assigned_identity = dect_ie_hold(msg.nwk_assigned_identity);
param->cipher_info = dect_ie_hold(msg.cipher_info);
param->escape_to_proprietary = dect_ie_hold(msg.escape_to_proprietary);
reject = !dh->ops->lce_ops->lce_page_response(dh, param);
dect_ie_collection_put(dh, param);
}
err:
if (req != NULL)
dect_ddl_complete_indirect_establish(dh, ta->link, req);
else {
else if (reject) {
dect_send_reject(dh, ta, DECT_REJECT_IPUI_UNKNOWN);
dect_ddl_release(dh, ta->link);
}