summaryrefslogtreecommitdiff
path: root/src/netlink.c
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2012-05-17 01:19:41 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2012-05-26 16:23:17 +0200
commit6acbdfb04d364658c091619d3e2e6faaa3a36a4b (patch)
treef7e494a531b329a32e9372cc498e7d8585f7ee55 /src/netlink.c
parent7028b54578f13e978c97127c1fe80c7cf272e469 (diff)
downloadneard-6acbdfb04d364658c091619d3e2e6faaa3a36a4b.tar.gz
neard-6acbdfb04d364658c091619d3e2e6faaa3a36a4b.tar.bz2
neard-6acbdfb04d364658c091619d3e2e6faaa3a36a4b.zip
netlink: Support target mode netlink events
Target mode activation and deactivation events are sent by the kernel through netlink.
Diffstat (limited to 'src/netlink.c')
-rw-r--r--src/netlink.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/netlink.c b/src/netlink.c
index b2822e0..b7e918d 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -611,6 +611,48 @@ static int nfc_netlink_event_dep_down(struct genlmsghdr *gnlh)
return 0;
}
+static int nfc_netlink_event_tm_activated(struct genlmsghdr *gnlh)
+{
+ struct nlattr *attrs[NFC_ATTR_MAX + 1];
+ uint32_t idx;
+
+ DBG("");
+
+ nla_parse(attrs, NFC_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+ genlmsg_attrlen(gnlh, 0), NULL);
+ if (attrs[NFC_ATTR_DEVICE_INDEX] == NULL) {
+ near_error("Missing device index");
+ return -ENODEV;
+ }
+
+ idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]);
+
+ DBG("%d", idx);
+
+ return __near_adapter_add_device(idx, NULL, 0);
+}
+
+static int nfc_netlink_event_tm_deactivated(struct genlmsghdr *gnlh)
+{
+ struct nlattr *attrs[NFC_ATTR_MAX + 1];
+ uint32_t idx;
+
+ DBG("");
+
+ nla_parse(attrs, NFC_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
+ genlmsg_attrlen(gnlh, 0), NULL);
+ if (attrs[NFC_ATTR_DEVICE_INDEX] == NULL) {
+ near_error("Missing device index");
+ return -ENODEV;
+ }
+
+ idx = nla_get_u32(attrs[NFC_ATTR_DEVICE_INDEX]);
+
+ DBG("%d", idx);
+
+ return __near_adapter_remove_device(idx);
+}
+
static int nfc_netlink_event(struct nl_msg *n, void *arg)
{
struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(n));
@@ -646,6 +688,16 @@ static int nfc_netlink_event(struct nl_msg *n, void *arg)
nfc_netlink_event_dep_down(gnlh);
break;
+ case NFC_EVENT_TM_ACTIVATED:
+ DBG("Target mode activated");
+ nfc_netlink_event_tm_activated(gnlh);
+
+ break;
+ case NFC_EVENT_TM_DEACTIVATED:
+ DBG("Target mode deactivated");
+ nfc_netlink_event_tm_deactivated(gnlh);
+
+ break;
}
return NL_SKIP;