File tree Expand file tree Collapse file tree 5 files changed +388
-2
lines changed Expand file tree Collapse file tree 5 files changed +388
-2
lines changed Original file line number Diff line number Diff line change 2424#ifndef __LINUX_NFC_H
2525#define __LINUX_NFC_H
2626
27+ #include <linux/types.h>
28+ #include <linux/socket.h>
29+
2730#define NFC_GENL_NAME "nfc"
2831#define NFC_GENL_VERSION 1
2932
@@ -109,7 +112,15 @@ enum nfc_attrs {
109112#define NFC_PROTO_ISO14443_MASK (1 << NFC_PROTO_ISO14443)
110113#define NFC_PROTO_NFC_DEP_MASK (1 << NFC_PROTO_NFC_DEP)
111114
115+ struct sockaddr_nfc {
116+ sa_family_t sa_family ;
117+ __u32 dev_idx ;
118+ __u32 target_idx ;
119+ __u32 nfc_protocol ;
120+ };
121+
112122/* NFC socket protocols */
113- #define NFC_SOCKPROTO_MAX 0
123+ #define NFC_SOCKPROTO_RAW 0
124+ #define NFC_SOCKPROTO_MAX 1
114125
115126#endif /*__LINUX_NFC_H */
Original file line number Diff line number Diff line change 44
55obj-$(CONFIG_NFC) += nfc.o
66
7- nfc-objs := core.o netlink.o af_nfc.o
7+ nfc-objs := core.o netlink.o af_nfc.o rawsock.o
Original file line number Diff line number Diff line change @@ -432,13 +432,19 @@ static int __init nfc_init(void)
432432 /* the first generation must not be 0 */
433433 nfc_devlist_generation = 1 ;
434434
435+ rc = rawsock_init ();
436+ if (rc )
437+ goto err_rawsock ;
438+
435439 rc = af_nfc_init ();
436440 if (rc )
437441 goto err_af_nfc ;
438442
439443 return 0 ;
440444
441445err_af_nfc :
446+ rawsock_exit ();
447+ err_rawsock :
442448 nfc_genl_exit ();
443449err_genl :
444450 class_unregister (& nfc_class );
@@ -448,6 +454,7 @@ static int __init nfc_init(void)
448454static void __exit nfc_exit (void )
449455{
450456 af_nfc_exit ();
457+ rawsock_exit ();
451458 nfc_genl_exit ();
452459 class_unregister (& nfc_class );
453460}
Original file line number Diff line number Diff line change @@ -42,6 +42,20 @@ struct nfc_protocol {
4242 const struct nfc_protocol * nfc_proto );
4343};
4444
45+ struct nfc_rawsock {
46+ struct sock sk ;
47+ struct nfc_dev * dev ;
48+ u32 target_idx ;
49+ struct work_struct tx_work ;
50+ bool tx_work_scheduled ;
51+ };
52+ #define nfc_rawsock (sk ) ((struct nfc_rawsock *) sk)
53+ #define to_rawsock_sk (_tx_work ) \
54+ ((struct sock *) container_of(_tx_work, struct nfc_rawsock, tx_work))
55+
56+ int __init rawsock_init (void );
57+ void rawsock_exit (void );
58+
4559int __init af_nfc_init (void );
4660void af_nfc_exit (void );
4761int nfc_proto_register (const struct nfc_protocol * nfc_proto );
You can’t perform that action at this time.
0 commit comments