2009-05-06 16:41:57 +00:00
|
|
|
/*
|
|
|
|
* libdect main header file
|
|
|
|
*
|
2010-07-08 19:40:16 +00:00
|
|
|
* Copyright (c) 2009-2010 Patrick McHardy <kaber@trash.net>
|
2009-05-06 16:41:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _LIBDECT_DECT_LIBDECT_H
|
|
|
|
#define _LIBDECT_DECT_LIBDECT_H
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
2009-12-05 14:43:51 +00:00
|
|
|
#include <stdarg.h>
|
2009-05-06 16:41:57 +00:00
|
|
|
|
|
|
|
#include <dect/identities.h>
|
2009-12-15 20:12:36 +00:00
|
|
|
#include <dect/auth.h>
|
2009-12-22 00:10:09 +00:00
|
|
|
#include <dect/lce.h>
|
2009-05-06 16:41:57 +00:00
|
|
|
#include <dect/cc.h>
|
|
|
|
#include <dect/mm.h>
|
2010-01-10 19:45:55 +00:00
|
|
|
#include <dect/ss.h>
|
2010-05-27 17:18:59 +00:00
|
|
|
#include <dect/debug.h>
|
2009-05-23 05:59:23 +00:00
|
|
|
#include <list.h>
|
2009-05-06 16:41:57 +00:00
|
|
|
|
2010-07-08 22:18:04 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2009-05-06 16:41:57 +00:00
|
|
|
struct dect_handle;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct dect_msg_buf - DECT message buffer
|
|
|
|
*
|
2010-07-08 19:17:12 +00:00
|
|
|
* @arg list Data link TX queue node
|
2010-07-31 10:41:25 +00:00
|
|
|
* @arg refcnt Reference count
|
2010-07-08 19:17:12 +00:00
|
|
|
* @arg type Message type
|
|
|
|
* @arg len Data length
|
|
|
|
* @arg data Data pointer
|
|
|
|
* @arg head Storage area for on-stack buffers
|
2009-05-06 16:41:57 +00:00
|
|
|
*/
|
|
|
|
struct dect_msg_buf {
|
|
|
|
struct list_head list;
|
2010-07-31 10:41:25 +00:00
|
|
|
uint8_t refcnt;
|
2009-05-06 16:41:57 +00:00
|
|
|
uint8_t type;
|
|
|
|
uint8_t len;
|
|
|
|
uint8_t *data;
|
|
|
|
uint8_t head[128];
|
|
|
|
};
|
|
|
|
|
|
|
|
extern struct dect_msg_buf *dect_mbuf_alloc(const struct dect_handle *dh);
|
2010-07-31 10:41:25 +00:00
|
|
|
extern void dect_mbuf_free(const struct dect_handle *dh, struct dect_msg_buf *mb);
|
2009-05-06 16:41:57 +00:00
|
|
|
|
|
|
|
static inline void dect_mbuf_pull(struct dect_msg_buf *mb, unsigned int len)
|
|
|
|
{
|
|
|
|
assert(len <= mb->len);
|
|
|
|
mb->data += len;
|
|
|
|
mb->len -= len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void dect_mbuf_push(struct dect_msg_buf *mb, unsigned int len)
|
|
|
|
{
|
|
|
|
mb->data -= len;
|
|
|
|
mb->len += len;
|
|
|
|
assert(mb->data >= mb->head);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void dect_mbuf_reserve(struct dect_msg_buf *mb, unsigned int len)
|
|
|
|
{
|
|
|
|
mb->data += len;
|
|
|
|
assert(mb->data < mb->head + sizeof(mb->head));
|
|
|
|
}
|
|
|
|
|
2010-07-08 20:11:02 +00:00
|
|
|
/**
|
|
|
|
* @addtogroup io
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2009-05-06 16:41:57 +00:00
|
|
|
/**
|
2010-07-28 02:16:57 +00:00
|
|
|
* libdect file descriptor events
|
2009-05-06 16:41:57 +00:00
|
|
|
*/
|
|
|
|
enum dect_fd_events {
|
2010-07-28 02:16:57 +00:00
|
|
|
DECT_FD_READ = 0x1, /**< file descriptor is readable */
|
|
|
|
DECT_FD_WRITE = 0x2 /**< file descriptor is writable */
|
2009-05-06 16:41:57 +00:00
|
|
|
};
|
|
|
|
|
2010-07-03 07:30:09 +00:00
|
|
|
struct dect_fd;
|
|
|
|
extern void *dect_fd_priv(struct dect_fd *dfd);
|
2010-07-08 20:41:54 +00:00
|
|
|
extern int dect_fd_num(const struct dect_fd *dfd);
|
2010-08-02 03:25:03 +00:00
|
|
|
extern void dect_fd_process(struct dect_handle *dh, struct dect_fd *dfd,
|
|
|
|
uint32_t events);
|
2010-07-08 20:11:02 +00:00
|
|
|
/** @} */
|
2009-05-06 16:41:57 +00:00
|
|
|
|
2010-07-08 20:49:09 +00:00
|
|
|
/**
|
|
|
|
* @addtogroup timer
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2010-03-31 01:14:08 +00:00
|
|
|
struct dect_timer;
|
|
|
|
extern void *dect_timer_priv(struct dect_timer *timer);
|
2010-08-02 03:21:45 +00:00
|
|
|
extern void dect_timer_run(struct dect_handle *dh, struct dect_timer *timer);
|
2009-05-06 16:41:57 +00:00
|
|
|
|
2010-07-08 20:49:09 +00:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @addtogroup events
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2009-05-06 16:41:57 +00:00
|
|
|
struct timeval;
|
|
|
|
struct dect_event_ops {
|
|
|
|
size_t fd_priv_size;
|
|
|
|
size_t timer_priv_size;
|
|
|
|
|
|
|
|
int (*register_fd)(const struct dect_handle *dh,
|
|
|
|
struct dect_fd *dfd,
|
|
|
|
uint32_t events);
|
|
|
|
void (*unregister_fd)(const struct dect_handle *dh,
|
|
|
|
struct dect_fd *dfd);
|
|
|
|
|
|
|
|
void (*start_timer)(const struct dect_handle *dh,
|
|
|
|
struct dect_timer *timer,
|
|
|
|
const struct timeval *tv);
|
|
|
|
void (*stop_timer)(const struct dect_handle *dh,
|
|
|
|
struct dect_timer *timer);
|
|
|
|
};
|
|
|
|
|
2010-07-08 20:49:09 +00:00
|
|
|
/** @} */
|
|
|
|
|
2009-05-06 16:41:57 +00:00
|
|
|
struct dect_ops {
|
|
|
|
void *(*malloc)(size_t size);
|
|
|
|
void (*free)(void *ptr);
|
|
|
|
|
|
|
|
const struct dect_event_ops *event_ops;
|
2009-12-22 00:10:09 +00:00
|
|
|
const struct dect_lce_ops *lce_ops;
|
2009-05-06 16:41:57 +00:00
|
|
|
const struct dect_cc_ops *cc_ops;
|
|
|
|
const struct dect_mm_ops *mm_ops;
|
2010-01-10 19:45:55 +00:00
|
|
|
const struct dect_ss_ops *ss_ops;
|
2010-07-27 22:21:03 +00:00
|
|
|
const struct dect_raw_ops *raw_ops;
|
2009-05-06 16:41:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct dect_handle *dect_alloc_handle(struct dect_ops *ops);
|
|
|
|
extern void dect_close_handle(struct dect_handle *dh);
|
|
|
|
|
2010-03-03 13:03:41 +00:00
|
|
|
extern int dect_init(struct dect_handle *dh, const char *cluster);
|
2009-05-06 16:41:57 +00:00
|
|
|
|
2010-07-29 14:00:09 +00:00
|
|
|
extern void dect_pp_set_ipui(struct dect_handle *dh,
|
|
|
|
const struct dect_ipui *ipui);
|
2010-07-30 02:23:55 +00:00
|
|
|
extern void dect_pp_set_tpui(struct dect_handle *dh,
|
|
|
|
const struct dect_tpui *tpui);
|
2010-07-29 14:00:09 +00:00
|
|
|
|
2010-07-08 22:18:04 +00:00
|
|
|
#ifdef __cplusplus
|
2010-07-09 12:56:47 +00:00
|
|
|
}
|
2010-07-08 22:18:04 +00:00
|
|
|
#endif
|
2009-05-06 16:41:57 +00:00
|
|
|
#endif /* _LIBDECT_DECT_LIBDECT_H */
|