summaryrefslogtreecommitdiffstats
path: root/example/pp-info-request.c
blob: 71d232f383dead2fb96cd0a93eeba3b8fd18a39f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * 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);
	dect_mm_endpoint_destroy(dh, mme);
	return 0;
}