summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2010-07-30 14:36:43 +0200
committerPatrick McHardy <kaber@trash.net>2010-07-30 14:36:43 +0200
commit57b42f1f734a648e5338ac7e05fe112eeee6c53d (patch)
tree810478e859be72fba366d2e94a27984079b676a4
parentb6222491a48886ca5515707122e262284d80347e (diff)
example: add PP access rights termination example
Signed-off-by: Patrick McHardy <kaber@trash.net>
-rw-r--r--example/Makefile.in7
-rw-r--r--example/pp-access-rights-terminate.c68
2 files changed, 74 insertions, 1 deletions
diff --git a/example/Makefile.in b/example/Makefile.in
index 5a7cc0f..b855c31 100644
--- a/example/Makefile.in
+++ b/example/Makefile.in
@@ -1,7 +1,8 @@
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-location-update pp-detach pp-list-access pp-wait-page
+PROGRAMS += pp-access-rights pp-access-rights-terminate pp-location-update
+PROGRAMS += pp-detach pp-list-access pp-wait-page
destdir := usr/share/dect/examples
@@ -26,6 +27,10 @@ pp-access-rights-destdir := $(destdir)
pp-access-rights-obj += $(common-obj)
pp-access-rights-obj += pp-access-rights.o
+pp-access-rights-terminate-destdir := $(destdir)
+pp-access-rights-terminate-obj += $(pp-common-obj)
+pp-access-rights-terminate-obj += pp-access-rights-terminate.o
+
pp-location-update-destdir := $(destdir)
pp-location-update-obj += $(pp-common-obj)
pp-location-update-obj += pp-location-update.o
diff --git a/example/pp-access-rights-terminate.c b/example/pp-access-rights-terminate.c
new file mode 100644
index 0000000..87cc7c0
--- /dev/null
+++ b/example/pp-access-rights-terminate.c
@@ -0,0 +1,68 @@
+/*
+ * DECT PP access rights termination 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_access_rights_terminate_cfm(struct dect_handle *dh,
+ struct dect_mm_endpoint *mme, bool accept,
+ struct dect_mm_access_rights_terminate_param *param)
+{
+ dect_event_loop_stop();
+}
+
+static int mm_access_rights_terminate_req(struct dect_handle *dh,
+ struct dect_mm_endpoint *mme)
+{
+ struct dect_ie_portable_identity portable_identity;
+ struct dect_mm_access_rights_terminate_param param = {
+ .portable_identity = &portable_identity,
+ };
+
+ portable_identity.type = DECT_PORTABLE_ID_TYPE_IPUI;
+ portable_identity.ipui = ipui;
+
+ return dect_mm_access_rights_terminate_req(dh, mme, &param);
+}
+
+static struct dect_mm_ops mm_ops = {
+ .mm_access_rights_terminate_cfm = mm_access_rights_terminate_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_access_rights_terminate_req(dh, mme);
+ dect_event_loop();
+
+ dect_common_cleanup(dh);
+ return 0;
+}