2010-07-08 19:40:16 +00:00
|
|
|
/*
|
2010-07-08 20:31:51 +00:00
|
|
|
* libdect IO handling
|
2010-07-08 19:40:16 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 2009-2010 Patrick McHardy <kaber@trash.net>
|
|
|
|
*/
|
|
|
|
|
2010-07-08 20:31:51 +00:00
|
|
|
#ifndef _LIBDECT_IO_H
|
|
|
|
#define _LIBDECT_IO_H
|
2010-07-03 07:30:09 +00:00
|
|
|
|
|
|
|
#include <sys/socket.h>
|
2010-07-28 00:03:08 +00:00
|
|
|
#include <utils.h>
|
2010-07-03 07:30:09 +00:00
|
|
|
|
2010-07-27 22:31:26 +00:00
|
|
|
enum dect_fd_state {
|
|
|
|
DECT_FD_UNREGISTERED,
|
|
|
|
DECT_FD_REGISTERED,
|
|
|
|
};
|
|
|
|
|
2010-07-03 07:30:09 +00:00
|
|
|
/**
|
|
|
|
* struct dect_fd - libdect file descriptor
|
|
|
|
*
|
|
|
|
* @callback: callback to invoke for events
|
|
|
|
* @fd: file descriptor numer
|
2010-07-27 22:31:26 +00:00
|
|
|
* @state: file descriptor registration state (debugging)
|
2010-07-03 07:30:09 +00:00
|
|
|
* @data: libdect internal data
|
|
|
|
* @priv: libdect user private file-descriptor storage
|
|
|
|
*/
|
|
|
|
struct dect_fd {
|
2010-07-27 22:31:26 +00:00
|
|
|
void (*callback)(struct dect_handle *,
|
|
|
|
struct dect_fd *, uint32_t);
|
|
|
|
int fd;
|
|
|
|
enum dect_fd_state state;
|
|
|
|
void *data;
|
|
|
|
uint8_t priv[] __aligned(__alignof__(uint64_t));
|
2010-07-03 07:30:09 +00:00
|
|
|
};
|
|
|
|
|
2010-08-02 03:25:03 +00:00
|
|
|
extern struct dect_fd *dect_fd_alloc(const struct dect_handle *dh);
|
|
|
|
extern void dect_fd_setup(struct dect_fd *fd,
|
2010-07-03 07:30:09 +00:00
|
|
|
void (*cb)(struct dect_handle *, struct dect_fd *,
|
|
|
|
uint32_t),
|
|
|
|
void *data);
|
|
|
|
extern void dect_close(const struct dect_handle *dh, struct dect_fd *dfd);
|
|
|
|
|
|
|
|
extern struct dect_fd *dect_socket(const struct dect_handle *dh,
|
|
|
|
int type, int protocol);
|
|
|
|
extern struct dect_fd *dect_accept(const struct dect_handle *dh,
|
|
|
|
const struct dect_fd *dfd,
|
|
|
|
struct sockaddr *addr, socklen_t len);
|
|
|
|
|
2010-08-02 03:25:03 +00:00
|
|
|
extern int dect_fd_register(const struct dect_handle *dh, struct dect_fd *dfd,
|
2010-07-03 07:30:09 +00:00
|
|
|
uint32_t events);
|
2010-08-02 03:25:03 +00:00
|
|
|
extern void dect_fd_unregister(const struct dect_handle *dh, struct dect_fd *dfd);
|
2010-07-03 07:30:09 +00:00
|
|
|
|
2010-07-08 20:31:51 +00:00
|
|
|
#endif /* _LIBDECT_IO_H */
|