diff options
author | Patrick McHardy <kaber@trash.net> | 2010-08-13 00:03:56 +0200 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2010-08-13 15:07:36 +0200 |
commit | 77f31308d8b2471d5022a2a04772b2ab77c06684 (patch) | |
tree | ae9c9d83fa13aae7a53de3754007aa4f53f090ee /example | |
parent | f04852105cf8dc08065a8a98af927c5d2dd19852 (diff) |
libdect: add ConnetionLess Message Service (CLMS) support
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'example')
-rw-r--r-- | example/.gitignore | 1 | ||||
-rw-r--r-- | example/Makefile.in | 6 | ||||
-rw-r--r-- | example/clms.c | 81 | ||||
-rw-r--r-- | example/debug.c | 1 | ||||
-rw-r--r-- | example/dummy_ops.c | 21 |
5 files changed, 109 insertions, 1 deletions
diff --git a/example/.gitignore b/example/.gitignore index 7cfb7f8..8576339 100644 --- a/example/.gitignore +++ b/example/.gitignore @@ -1,5 +1,6 @@ cc ss +clms mm-fp mm-pp discover diff --git a/example/Makefile.in b/example/Makefile.in index 4d03153..219519c 100644 --- a/example/Makefile.in +++ b/example/Makefile.in @@ -1,6 +1,6 @@ CFLAGS += $(EVENT_CFLAGS) LDFLAGS += -Wl,-rpath $(PWD)/src -Lsrc -ldect $(EVENT_LDFLAGS) -PROGRAMS += cc ss mm-fp discover hijack +PROGRAMS += cc ss clms mm-fp discover hijack PROGRAMS += pp-access-rights pp-access-rights-terminate pp-location-update PROGRAMS += pp-detach pp-info-request pp-list-access pp-wait-page @@ -19,6 +19,10 @@ ss-destdir := $(destdir) ss-obj += $(common-obj) ss-obj += ss.o +clms-destdir := $(destdir) +clms-obj += $(common-obj) +clms-obj += clms.o + mm-fp-destdir := $(destdir) mm-fp-obj += $(common-obj) mm-fp-obj += mm-fp.o diff --git a/example/clms.c b/example/clms.c new file mode 100644 index 0000000..7a59294 --- /dev/null +++ b/example/clms.c @@ -0,0 +1,81 @@ +/* + * DECT FP CLMS 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 <stdio.h> + +#include <dect/libdect.h> +#include "common.h" + +static const char *name = "- FP 1 -"; + +#define debug(fmt, args...) printf("IWU: " fmt, ## args); + +static void dect_invoke_clms(struct dect_handle *dh) +{ + DECT_DEFINE_MSG_BUF_ONSTACK(_mb), *mb = &_mb; + struct dect_ie_network_parameter network_parameter; + + network_parameter.discriminator = DECT_NETWORK_PARAMETER_DEVICE_NAME; + network_parameter.len = strlen(name); + memcpy(network_parameter.data, name, network_parameter.len); + + debug("build CLMS message\n"); + if (dect_build_sfmt_ie(dh, DECT_IE_NETWORK_PARAMETER, mb, + &network_parameter.common) < 0) + return; + + dect_mncl_unitdata_req(dh, DECT_CLMS_FIXED, NULL, mb); +} + +static void dect_mncl_unitdata_ind(struct dect_handle *dh, + enum dect_clms_message_types type, + struct dect_mncl_unitdata_param *param, + struct dect_msg_buf *mb) +{ + struct dect_ie_network_parameter *network_parameter; + struct dect_ie_common *dst; + struct dect_sfmt_ie ie; + + debug("parse CLMS message\n"); + if (dect_parse_sfmt_ie_header(&ie, mb) < 0) + return; + if (ie.id != DECT_IE_NETWORK_PARAMETER) + return; + if (dect_parse_sfmt_ie(dh, 0, &dst, &ie) < 0) + return; + + network_parameter = dect_ie_container(network_parameter, dst); + debug("FP-Name: '%.*s'\n", + network_parameter->len, network_parameter->data); + + dect_ie_put(dh, network_parameter); + dect_event_loop_stop(); +} + +static struct dect_clms_ops clms_ops = { + .mncl_unitdata_ind = dect_mncl_unitdata_ind, +}; + +static struct dect_ops ops = { + .clms_ops = &clms_ops, +}; + +int main(int argc, char **argv) +{ + dect_common_init(&ops, argv[1]); + + if (dh->mode == DECT_MODE_FP) + dect_invoke_clms(dh); + else + dect_event_loop(); + + dect_common_cleanup(dh); + return 0; +} diff --git a/example/debug.c b/example/debug.c index 4bc6e05..abd1d65 100644 --- a/example/debug.c +++ b/example/debug.c @@ -27,6 +27,7 @@ static const char * const debug_colors[] = { [DECT_DEBUG_LCE] = LIGHT_BLUE, [DECT_DEBUG_CC] = YELLOW, [DECT_DEBUG_SS] = LIGHT_CYAN, + [DECT_DEBUG_CLMS] = LIGHT_RED, [DECT_DEBUG_MM] = YELLOW, [DECT_DEBUG_SFMT] = LIGHT_GREEN, [DECT_DEBUG_NL] = LIGHT_PURPLE, diff --git a/example/dummy_ops.c b/example/dummy_ops.c index 6ed89fa..6913cce 100644 --- a/example/dummy_ops.c +++ b/example/dummy_ops.c @@ -296,6 +296,19 @@ static void mnss_release_ind(struct dect_handle *dh, struct dect_ss_endpoint *ss static struct dect_ss_ops dummy_ss_ops; +/* + * CLMS Ops + */ + +static void mncl_unitdata_ind(struct dect_handle *dh, + enum dect_clms_message_types type, + struct dect_mncl_unitdata_param *param, + struct dect_msg_buf *mb) +{ +} + +static struct dect_clms_ops dummy_clms_ops; + void dect_dummy_ops_init(struct dect_ops *ops) { struct dect_llme_ops_ *llme_ops; @@ -303,6 +316,7 @@ void dect_dummy_ops_init(struct dect_ops *ops) struct dect_cc_ops *cc_ops; struct dect_mm_ops *mm_ops; struct dect_ss_ops *ss_ops; + struct dect_clms_ops *clms_ops; if (!ops->llme_ops) ops->llme_ops = &dummy_llme_ops; @@ -416,4 +430,11 @@ void dect_dummy_ops_init(struct dect_ops *ops) ss_ops->mnss_facility_ind = mnss_facility_ind; if (!ss_ops->mnss_release_ind) ss_ops->mnss_release_ind = mnss_release_ind; + + if (!ops->clms_ops) + ops->clms_ops = &dummy_clms_ops; + clms_ops = (void *)ops->clms_ops; + + if (!clms_ops->mncl_unitdata_ind) + clms_ops->mncl_unitdata_ind = mncl_unitdata_ind; } |