summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Ortiz <sameo@linux.intel.com>2011-04-22 20:53:13 +0200
committerMarcel Holtmann <marcel@holtmann.org>2011-10-20 23:54:01 -0700
commitc8445d1720c4ca75c4c560e904bf96c41475d49c (patch)
tree5d683c2ad0793c6d87273708f612d1e2044251d2
parent170b18a6fff13213f6ca14f946df55e517b585a0 (diff)
downloadneard-c8445d1720c4ca75c4c560e904bf96c41475d49c.tar.gz
neard-c8445d1720c4ca75c4c560e904bf96c41475d49c.tar.bz2
neard-c8445d1720c4ca75c4c560e904bf96c41475d49c.zip
netlink: Implement polling start and stop hooks
-rw-r--r--src/near.h2
-rw-r--r--src/netlink.c64
2 files changed, 66 insertions, 0 deletions
diff --git a/src/near.h b/src/near.h
index 62a0aee..f41f47d 100644
--- a/src/near.h
+++ b/src/near.h
@@ -73,5 +73,7 @@ int __near_adapter_init(void);
void __near_adapter_cleanup(void);
int __near_netlink_get_adapters(void);
+int __near_netlink_start_poll(int idx, guint32 protocols);
+int __near_netlink_stop_poll(int idx);
int __near_netlink_init(void);
void __near_netlink_cleanup(void);
diff --git a/src/netlink.c b/src/netlink.c
index 1d43f94..97cd01e 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -175,6 +175,70 @@ out:
return err;
}
+int __near_netlink_start_poll(int idx, guint32 protocols)
+{
+ struct nl_msg *msg;
+ void *hdr;
+ int family, err = 0;
+
+ DBG("");
+
+ msg = nlmsg_alloc();
+ if (msg == NULL)
+ return -ENOMEM;
+
+ family = genl_family_get_id(nfc_state->nlnfc);
+
+ hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family, 0,
+ NLM_F_REQUEST, NFC_CMD_START_POLL, NFC_GENL_VERSION);
+ if (hdr == NULL) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+
+ NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, idx);
+ NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, protocols);
+
+ err = nl_send_msg(nfc_state->nl_sock, msg, NULL, NULL);
+
+nla_put_failure:
+ nlmsg_free(msg);
+
+ return err;
+}
+
+
+int __near_netlink_stop_poll(int idx)
+{
+ struct nl_msg *msg;
+ void *hdr;
+ int family, err = 0;
+
+ DBG("");
+
+ msg = nlmsg_alloc();
+ if (msg == NULL)
+ return -ENOMEM;
+
+ family = genl_family_get_id(nfc_state->nlnfc);
+
+ hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family, 0,
+ NLM_F_REQUEST, NFC_CMD_STOP_POLL, NFC_GENL_VERSION);
+ if (hdr == NULL) {
+ err = -EINVAL;
+ goto nla_put_failure;
+ }
+
+ NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, idx);
+
+ err = nl_send_msg(nfc_state->nl_sock, msg, NULL, NULL);
+
+nla_put_failure:
+ nlmsg_free(msg);
+
+ return err;
+}
+
static int no_seq_check(struct nl_msg *n, void *arg)
{
DBG("");