xref: /freebsd/contrib/libfido2/src/netlink.h (revision a64729f5077d77e13b9497cb33ecb3c82e606ee8)
1 /*
2  * Copyright (c) 2020 Yubico AB. All rights reserved.
3  * Use of this source code is governed by a BSD-style
4  * license that can be found in the LICENSE file.
5  * SPDX-License-Identifier: BSD-2-Clause
6  */
7 
8 #ifndef _FIDO_NETLINK_H
9 #define _FIDO_NETLINK_H
10 
11 #include <sys/socket.h>
12 
13 #include <linux/genetlink.h>
14 #include <linux/netlink.h>
15 #include <linux/nfc.h>
16 
17 #include <stdlib.h>
18 #include <stdint.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif /* __cplusplus */
23 
24 typedef struct fido_nl {
25 	int                fd;
26 	uint16_t           nfc_type;
27 	uint32_t           nfc_mcastgrp;
28 	struct sockaddr_nl saddr;
29 } fido_nl_t;
30 
31 fido_nl_t *fido_nl_new(void);
32 void fido_nl_free(struct fido_nl **);
33 int fido_nl_power_nfc(struct fido_nl *, uint32_t);
34 int fido_nl_get_nfc_target(struct fido_nl *, uint32_t , uint32_t *);
35 
36 #ifdef FIDO_FUZZ
37 void set_netlink_io_functions(ssize_t (*)(int, void *, size_t),
38     ssize_t (*)(int, const void *, size_t));
39 #endif
40 
41 #ifdef __cplusplus
42 } /* extern "C" */
43 #endif /* __cplusplus */
44 
45 #endif /* !_FIDO_NETLINK_H */
46