forked from colognechip/libcapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
capilib.h
120 lines (97 loc) · 4.14 KB
/
capilib.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*-
* Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*---------------------------------------------------------------------------
*
* capilib.h
* ---------
*
* $FreeBSD: $
*
*---------------------------------------------------------------------------*/
#ifndef __CAPILIB_H__
#define __CAPILIB_H__
/*
* This structure is used to cache incoming B-channel data!
*/
struct data_buffer {
struct data_buffer * next; /* pointer to next data buffer on free list */
uint8_t state;
# define ST_FREE 0 /* default */
# define ST_USED 1
uint8_t unused; /* for sake of alignment */
uint16_t wHandle; /* copy of wHandle from data-b3-indication */
struct capi_message_encoded msg;
uint8_t data[0]; /* B-channel data follows */
} __packed;
/*
* This structure stores information about a registered application
*/
struct app_softc {
uint32_t sc_app_id; /* applet number (internal) */
uint16_t sc_app_id_real; /* applet number (external) */
int sc_fd; /* CAPI device filenumber */
void * sc_msg_start_ptr; /* pointer to start of
* messages (inclusive)
*/
void * sc_msg_end_ptr; /* pointer to end of
* messages (exclusive)
*/
uint32_t sc_msg_size; /* size of a message in bytes */
uint32_t sc_msg_data_size; /* size of data part
* of a message in bytes
*/
struct data_buffer * sc_msg_free_list; /* pointer to first free message */
uint32_t sc_max_connections;
uint8_t sc_backend;
uint8_t sc_temp[64+16];
struct app_softc * sc_next;
};
struct debug {
uint8_t what;
uint16_t size;
uint16_t offset;
const char *field;
} __packed;
struct capi20_backend {
uint8_t bBackendType;
#define CAPI_BACKEND_TYPE_I4B 0
#define CAPI_BACKEND_TYPE_BINTEC 1
#define CAPI_BACKEND_TYPE_CLIENT 2
char sHostName[64];
char sServName[16];
char sUserName[64];
char sPassWord[64];
};
extern int capilib_get_message_sub(struct app_softc *sc, void *buf, uint16_t msg_len);
extern int capilib_client_do_ioctl(struct app_softc *sc, uint32_t cmd, void *data);
extern int capilib_bintec_do_ioctl(struct app_softc *sc, uint32_t cmd, void *data);
extern int capilib_read(int fd, char *buf, int len, int first);
extern struct app_softc * capilib_alloc_app_client(struct capi20_backend *be);
extern struct app_softc * capilib_alloc_app_bintec(struct capi20_backend *be);
extern struct app_softc * capilib_alloc_app_sub(struct capi20_backend *be);
extern struct app_softc * capilib_alloc_app(struct capi20_backend *be);
extern void capilib_free_app(struct app_softc *sc);
#endif /* __CAPILIB_H__ */