xref: /freebsd/contrib/libfido2/src/netlink.h (revision 2ccfa855)
10afa8e06SEd Maste /*
20afa8e06SEd Maste  * Copyright (c) 2020 Yubico AB. All rights reserved.
30afa8e06SEd Maste  * Use of this source code is governed by a BSD-style
40afa8e06SEd Maste  * license that can be found in the LICENSE file.
5*2ccfa855SEd Maste  * SPDX-License-Identifier: BSD-2-Clause
60afa8e06SEd Maste  */
70afa8e06SEd Maste 
80afa8e06SEd Maste #ifndef _FIDO_NETLINK_H
90afa8e06SEd Maste #define _FIDO_NETLINK_H
100afa8e06SEd Maste 
110afa8e06SEd Maste #include <sys/socket.h>
120afa8e06SEd Maste 
130afa8e06SEd Maste #include <linux/genetlink.h>
140afa8e06SEd Maste #include <linux/netlink.h>
150afa8e06SEd Maste #include <linux/nfc.h>
160afa8e06SEd Maste 
170afa8e06SEd Maste #include <stdlib.h>
180afa8e06SEd Maste #include <stdint.h>
190afa8e06SEd Maste 
200afa8e06SEd Maste #ifdef __cplusplus
210afa8e06SEd Maste extern "C" {
220afa8e06SEd Maste #endif /* __cplusplus */
230afa8e06SEd Maste 
240afa8e06SEd Maste typedef struct fido_nl {
250afa8e06SEd Maste 	int                fd;
260afa8e06SEd Maste 	uint16_t           nfc_type;
270afa8e06SEd Maste 	uint32_t           nfc_mcastgrp;
280afa8e06SEd Maste 	struct sockaddr_nl saddr;
290afa8e06SEd Maste } fido_nl_t;
300afa8e06SEd Maste 
310afa8e06SEd Maste fido_nl_t *fido_nl_new(void);
320afa8e06SEd Maste void fido_nl_free(struct fido_nl **);
330afa8e06SEd Maste int fido_nl_power_nfc(struct fido_nl *, uint32_t);
340afa8e06SEd Maste int fido_nl_get_nfc_target(struct fido_nl *, uint32_t , uint32_t *);
350afa8e06SEd Maste 
360afa8e06SEd Maste #ifdef FIDO_FUZZ
370afa8e06SEd Maste void set_netlink_io_functions(ssize_t (*)(int, void *, size_t),
380afa8e06SEd Maste     ssize_t (*)(int, const void *, size_t));
390afa8e06SEd Maste #endif
400afa8e06SEd Maste 
410afa8e06SEd Maste #ifdef __cplusplus
420afa8e06SEd Maste } /* extern "C" */
430afa8e06SEd Maste #endif /* __cplusplus */
440afa8e06SEd Maste 
450afa8e06SEd Maste #endif /* !_FIDO_NETLINK_H */
46