diff options
author | Patrick McHardy <kaber@trash.net> | 2010-08-03 00:35:27 +0200 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2010-08-03 00:38:10 +0200 |
commit | 23838258a0552cff25ad7d1b7aadd81da4c4af1b (patch) | |
tree | 8afccb239a6e3bb3ea4feb8dafe1fb363af3800d /example | |
parent | e31ee2ae7fcb4f21ca0524add23331a022af7aef (diff) |
example: check FP capabilities before invoking optional features
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'example')
-rw-r--r-- | example/pp-access-rights.c | 19 | ||||
-rw-r--r-- | example/pp-list-access.c | 12 | ||||
-rw-r--r-- | example/pp-location-update.c | 13 |
3 files changed, 39 insertions, 5 deletions
diff --git a/example/pp-access-rights.c b/example/pp-access-rights.c index e5bbcfe..d5d0630 100644 --- a/example/pp-access-rights.c +++ b/example/pp-access-rights.c @@ -19,7 +19,7 @@ #include <dect/auth.h> #include "common.h" -#define debug(fmt, args...) printf("IWU: PP-MM: " fmt, ## args) +#define debug(fmt, args...) printf("P-IWU: " fmt, ## args) static const char *pin = "0000"; static int rand_fd; @@ -177,6 +177,17 @@ static int mm_access_rights_req(struct dect_handle *dh, struct dect_mm_endpoint return dect_mm_access_rights_req(dh, mme, ¶m); } +static void llme_mac_me_info_ind(struct dect_handle *dh, + const struct dect_fp_capabilities *fpc) +{ + if (fpc->hlc & DECT_HLC_ACCESS_RIGHT_REQUESTS) + dect_event_loop_stop(); +} + +static struct dect_llme_ops_ llme_ops = { + .mac_me_info_ind = llme_mac_me_info_ind, +}; + static struct dect_mm_ops mm_ops = { .priv_size = sizeof(struct mm_priv), .mm_key_allocate_ind = mm_key_allocate_ind, @@ -186,7 +197,8 @@ static struct dect_mm_ops mm_ops = { }; static struct dect_ops ops = { - .mm_ops = &mm_ops, + .llme_ops = &llme_ops, + .mm_ops = &mm_ops, }; int main(int argc, char **argv) @@ -199,6 +211,9 @@ int main(int argc, char **argv) dect_common_init(&ops, argv[1]); + debug("waiting for ACCESS_RIGHTS_REQUESTS capability ...\n"); + dect_event_loop(); + mme = dect_mm_endpoint_alloc(dh, &ipui); if (mme == NULL) pexit("dect_mm_endpoint_alloc"); diff --git a/example/pp-list-access.c b/example/pp-list-access.c index 55c7bfa..9d24469 100644 --- a/example/pp-list-access.c +++ b/example/pp-list-access.c @@ -8,6 +8,8 @@ * published by the Free Software Foundation. */ +#include <stdio.h> + #include <dect/libdect.h> #include <dect/auth.h> #include <dect/lia.h> @@ -75,12 +77,20 @@ static struct dect_ops ops = { int main(int argc, char **argv) { + const struct dect_fp_capabilities *fpc; + dect_pp_auth_init(&ops, &ipui); dect_common_init(&ops, argv[1]); + fpc = dect_llme_fp_capabilities(dh); + if (!(fpc->ehlc2 & DECT_EHLC2_LIST_ACCESS_FEATURES)) { + fprintf(stderr, "FP does not support List Access (LiA)\n"); + goto out; + } + dect_open_call(dh, &ipui); dect_event_loop(); - +out: dect_common_cleanup(dh); return 0; } diff --git a/example/pp-location-update.c b/example/pp-location-update.c index 9585d92..41db3a6 100644 --- a/example/pp-location-update.c +++ b/example/pp-location-update.c @@ -8,6 +8,8 @@ * published by the Free Software Foundation. */ +#include <stdio.h> + #include <dect/libdect.h> #include <dect/auth.h> #include "common.h" @@ -76,18 +78,25 @@ static struct dect_ops ops = { int main(int argc, char **argv) { - struct dect_mm_endpoint *mme; + const struct dect_fp_capabilities *fpc; + struct dect_mm_endpoint *mme; dect_pp_auth_init(&ops, &ipui); dect_common_init(&ops, argv[1]); + fpc = dect_llme_fp_capabilities(dh); + if (!(fpc->hlc & DECT_HLC_LOCATION_REGISTRATION)) { + fprintf(stderr, "FP does not support location registration\n"); + goto out; + } + mme = dect_mm_endpoint_alloc(dh, &ipui); if (mme == NULL) pexit("dect_mm_endpoint_alloc"); mm_locate_req(dh, mme); dect_event_loop(); - +out: dect_common_cleanup(dh); return 0; } |