diff options
-rw-r--r-- | src/netlink.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/netlink.c b/src/netlink.c index 68777bd..d9c9ed4 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -562,6 +562,27 @@ static int nfc_netlink_event_dep_up(struct genlmsghdr *gnlh) } } +static int nfc_netlink_event_dep_down(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]); + + near_adapter_disconnect(idx); + + return 0; +} + static int nfc_netlink_event(struct nl_msg *n, void *arg) { struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(n)); @@ -583,12 +604,16 @@ static int nfc_netlink_event(struct nl_msg *n, void *arg) nfc_netlink_event_adapter(gnlh, FALSE); break; - case NFC_CMD_DEP_LINK_UP: DBG("DEP link is up"); nfc_netlink_event_dep_up(gnlh); break; + case NFC_CMD_DEP_LINK_DOWN: + DBG("DEP link is down"); + nfc_netlink_event_dep_down(gnlh); + + break; } return NL_SKIP; |