diff options
author | Patrick McHardy <kaber@trash.net> | 2010-07-28 05:51:41 +0200 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2010-07-28 09:08:31 +0200 |
commit | ed397371ed55fed8633174c0b4d236da01cde700 (patch) | |
tree | b245fd8e7bf9046e0a179b5b223067a5c7d75a79 | |
parent | f63b59f4274348fd8ff44fd2397f18a05de9d628 (diff) |
example: add PP detach example
Signed-off-by: Patrick McHardy <kaber@trash.net>
-rw-r--r-- | example/.gitignore | 1 | ||||
-rw-r--r-- | example/Makefile.in | 6 | ||||
-rw-r--r-- | example/pp-detach.c | 54 |
3 files changed, 60 insertions, 1 deletions
diff --git a/example/.gitignore b/example/.gitignore index 302be83..b3dba19 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -6,3 +6,4 @@ discover hijack pp-access-rights pp-location-update +pp-detach diff --git a/example/Makefile.in b/example/Makefile.in index 4b3c688..f29508f 100644 --- a/example/Makefile.in +++ b/example/Makefile.in @@ -1,7 +1,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-location-update +PROGRAMS += pp-access-rights pp-location-update pp-detach destdir := usr/share/dect/examples @@ -30,6 +30,10 @@ pp-location-update-destdir := $(destdir) pp-location-update-obj += $(pp-common-obj) pp-location-update-obj += pp-location-update.o +pp-detach-destdir := $(destdir) +pp-detach-obj += $(pp-common-obj) +pp-detach-obj += pp-detach.o + mm-pp-destdir := $(destdir) mm-pp-obj += $(common-obj) mm-pp-obj += mm-pp.o diff --git a/example/pp-detach.c b/example/pp-detach.c new file mode 100644 index 0000000..ad6f956 --- /dev/null +++ b/example/pp-detach.c @@ -0,0 +1,54 @@ +/* + * DECT PP detach 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 int mm_detach_req(struct dect_handle *dh, struct dect_mm_endpoint *mme) +{ + struct dect_ie_portable_identity portable_identity; + struct dect_mm_detach_param param = { + .portable_identity = &portable_identity, + }; + + portable_identity.type = DECT_PORTABLE_ID_TYPE_IPUI; + portable_identity.ipui = ipui; + + return dect_mm_detach_req(dh, mme, ¶m); +} + +static struct dect_ops 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_detach_req(dh, mme); + dect_event_loop(); + + dect_common_cleanup(dh); + return 0; +} |