example: add PP info request example
Signed-off-by: Patrick McHardy <kaber@trash.net>
This commit is contained in:
parent
57b42f1f73
commit
5e43fe632b
|
@ -5,7 +5,9 @@ mm-pp
|
|||
discover
|
||||
hijack
|
||||
pp-access-rights
|
||||
pp-access-rights-terminate
|
||||
pp-location-update
|
||||
pp-detach
|
||||
pp-info-request
|
||||
pp-list-access
|
||||
pp-wait-page
|
||||
|
|
|
@ -2,7 +2,7 @@ CFLAGS += $(EVENT_CFLAGS)
|
|||
LDFLAGS += -Wl,-rpath $(PWD)/src -Lsrc -ldect $(EVENT_LDFLAGS)
|
||||
PROGRAMS += cc ss mm-fp mm-pp discover hijack
|
||||
PROGRAMS += pp-access-rights pp-access-rights-terminate pp-location-update
|
||||
PROGRAMS += pp-detach pp-list-access pp-wait-page
|
||||
PROGRAMS += pp-detach pp-info-request pp-list-access pp-wait-page
|
||||
|
||||
destdir := usr/share/dect/examples
|
||||
|
||||
|
@ -39,6 +39,10 @@ pp-detach-destdir := $(destdir)
|
|||
pp-detach-obj += $(pp-common-obj)
|
||||
pp-detach-obj += pp-detach.o
|
||||
|
||||
pp-info-request-destdir := $(destdir)
|
||||
pp-info-request-obj += $(pp-common-obj)
|
||||
pp-info-request-obj += pp-info-request.o
|
||||
|
||||
pp-list-access-destdir := $(destdir)
|
||||
pp-list-access-obj += $(pp-common-obj)
|
||||
pp-list-access-obj += pp-list-access.o
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* DECT PP information request example
|
||||
*
|
||||
* Copyright (c) 2010 Patrick McHardy <kaber@trash.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include <dect/libdect.h>
|
||||
#include <dect/auth.h>
|
||||
#include "common.h"
|
||||
|
||||
static const struct dect_ipui ipui = {
|
||||
.put = DECT_IPUI_N,
|
||||
.pun.n.ipei = {
|
||||
.emc = 0x0ba8,
|
||||
.psn = 0xa782a,
|
||||
}
|
||||
};
|
||||
|
||||
static void mm_info_cfm(struct dect_handle *dh,
|
||||
struct dect_mm_endpoint *mme, bool accept,
|
||||
struct dect_mm_info_param *param)
|
||||
{
|
||||
dect_event_loop_stop();
|
||||
}
|
||||
|
||||
static int mm_info_req(struct dect_handle *dh, struct dect_mm_endpoint *mme)
|
||||
{
|
||||
struct dect_ie_portable_identity portable_identity;
|
||||
struct dect_ie_info_type info_type;
|
||||
struct dect_mm_info_param param = {
|
||||
.portable_identity = &portable_identity,
|
||||
.info_type = &info_type,
|
||||
};
|
||||
|
||||
portable_identity.type = DECT_PORTABLE_ID_TYPE_IPUI;
|
||||
portable_identity.ipui = ipui;
|
||||
|
||||
info_type.num = 1;
|
||||
info_type.type[0] = DECT_INFO_LOCATION_AREA;
|
||||
|
||||
return dect_mm_info_req(dh, mme, ¶m);
|
||||
}
|
||||
|
||||
static struct dect_mm_ops mm_ops = {
|
||||
.mm_info_cfm = mm_info_cfm,
|
||||
};
|
||||
|
||||
static struct dect_ops ops = {
|
||||
.mm_ops = &mm_ops,
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
struct dect_mm_endpoint *mme;
|
||||
|
||||
dect_pp_auth_init(&ops, &ipui);
|
||||
dect_common_init(&ops, argv[1]);
|
||||
|
||||
mme = dect_mm_endpoint_alloc(dh, &ipui);
|
||||
if (mme == NULL)
|
||||
pexit("dect_mm_endpoint_alloc");
|
||||
|
||||
mm_info_req(dh, mme);
|
||||
dect_event_loop();
|
||||
|
||||
dect_common_cleanup(dh);
|
||||
return 0;
|
||||
}
|
Reference in New Issue