dect
/
libdect
Archived
13
0
Fork 0

example: add PP info request example

Signed-off-by: Patrick McHardy <kaber@trash.net>
This commit is contained in:
Patrick McHardy 2010-07-30 14:52:19 +02:00
parent 57b42f1f73
commit 5e43fe632b
3 changed files with 79 additions and 1 deletions

2
example/.gitignore vendored
View File

@ -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

View File

@ -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

72
example/pp-info-request.c Normal file
View File

@ -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, &param);
}
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;
}