1 /*****************************************************************************\
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
8 ** mISDN-port header file **
10 \*****************************************************************************/
13 #define B_STATE_IDLE 0
14 #define B_STATE_ACTIVATING 1
15 #define B_STATE_ACTIVE 2
16 #define B_STATE_DEACTIVATING 3
20 extern int mISDNdevice;
22 /* mISDN port structure list */
24 net_stack_t nst; /* MUST be the first entry, so &nst equals &mISDNlist */
26 struct mISDNport *next;
27 struct interface_port *ifport; /* link to interface_port */
28 // int iftype; /* IF_* */
29 // int multilink; /* if set, this port will not support callwaiting */
30 int portnum; /* port number */
31 int ptp; /* if ptp is set, we keep track of l2link */
32 int l1link; /* if l1 is available (only works with nt-mode) */
33 int l2link; /* if l2 is available (at PTP we take this serious) */
34 // time_t l1timeout; /* timout when establishing link */
35 time_t l2establish; /* time until establishing after link failure */
36 int use; /* counts the number of port that uses this port */
37 int ntmode; /* is TRUE if port is nt mode */
38 int pri; /* is TRUE if port is a primary rate interface */
39 int upper_id; /* id to transfer data down */
40 int lower_id; /* id to transfer data up */
42 int b_num; /* number of bchannels */
43 int b_reserved; /* number of bchannels reserved or in use */
44 class PmISDN *b_port[128]; /* maximum number of ports shall be 128 due to S0 / E1 / special E1 */
47 int b_state[128]; /* state 0 = IDLE */
48 int procids[128]; /* keep track of free ids */
49 msg_queue_t downqueue; /* l4->l3 */
51 extern mISDNport *mISDNport_first;
57 if a b-channel is in use, the b_port[channel] is linked to the port using it.
58 also each used b-channel counts b_inuse.
59 to assign a bchannel, that is not jet defined due to remote channel assignment,
60 the b_inuse is also increased to reserve channel
62 'use' is the number of port instances using this mISDNport. this counts also
63 calls with no bchannel (call waiting, call on hold).
68 /* mISDN none-object functions */
69 void mISDN_port_info(void);
70 struct mISDNport *mISDNport_open(int port, int ptp);
71 void mISDNport_close_all(void);
72 void mISDNport_close(struct mISDNport *mISDNport);
73 void mISDN_port_reorder(void);
74 int mISDN_handler(void);
75 void enc_ie_cause_standalone(unsigned char **ntmode, msg_t *msg, int location, int cause);
76 void ph_control(unsigned long b_addr, int c1, int c2);
77 void ph_control_block(unsigned long b_addr, int c1, void *c2, int c2_len);
78 msg_t *create_l2msg(int prim, int dinfo, int size);
79 void setup_queue(struct mISDNport *mISDNport, int link);
80 int stack2manager_nt(void *dat, void *arg);
81 int stack2manager_te(struct mISDNport *mISDNport, msg_t *msg);
84 /* mISDN port classes */
85 class PmISDN : public Port
88 PmISDN(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, int channel);
90 void bchannel_receive(iframe_t *frm);
92 int message_epoint(unsigned long epoint_id, int message, union parameter *param);
93 void message_mISDNsignal(unsigned long epoint_id, int message_id, union parameter *param);
94 void message_crypt(unsigned long epoint_id, int message_id, union parameter *param);
95 struct mISDNport *p_m_mISDNport; /* pointer to port */
96 int p_m_delay; /* use delay instead of dejitter */
97 int p_m_txvol, p_m_rxvol; /* volume shift (0 = no change) */
98 int p_m_echo, p_m_conf; /* remote echo, conference number */
99 int p_m_tone; /* current kernel space tone */
100 int p_m_rxoff; /* rx from driver is disabled */
101 int p_m_nodata; /* all parties within a conf are isdn ports, so pure bridging is possible */
102 int p_m_txmix; /* mix tx with conference */
103 int p_m_txmix_on; /* delay for turning back on after sending a binary message, must be signed */
104 int p_m_dtmf; /* dtmf decoding is enabled */
106 int p_m_crypt; /* encryption is enabled */
107 int p_m_crypt_msg_loops; /* sending a message */
108 int p_m_crypt_msg_len;
109 unsigned char p_m_crypt_msg[1100];
110 int p_m_crypt_msg_current;
111 unsigned char p_m_crypt_key[128];
112 int p_m_crypt_key_len;
113 int p_m_crypt_listen;
114 int p_m_crypt_listen_state;
115 int p_m_crypt_listen_len;
116 unsigned char p_m_crypt_listen_msg[1100];
117 unsigned long p_m_crypt_listen_crc;
118 void cryptman_listen_bch(unsigned char *p, int l);
120 void set_tone(char *dir, char *name);
121 void set_echotest(int echotest);
123 int p_m_portnum; /* used port number (1...n) */
124 int p_m_b_index; /* index 0,1 0..29 */
125 int p_m_b_channel; /* number 1,2 1..15,17... */
126 int p_m_b_exclusive; /* if bchannel is exclusive */
127 // int p_m_b_reserved; /* set if channel is reserved */
128 int p_m_b_stid; /* current stack id */
129 int p_m_b_addr; /* current layer address */
130 long long p_m_jittercheck; /* time of audio data */
131 long long p_m_jitterdropped; /* number of bytes dropped */
132 int p_m_delete; /* true if obj. must del. */
133 int p_m_hold; /* if port is on hold */
134 unsigned long p_m_timeout; /* timeout of timers */
135 time_t p_m_timer; /* start of timer */
137 int alloc_bchannel(int channel, int exclusive);
138 void free_bchannel(void);
141 extern unsigned char mISDN_rand[256]; /* noisy randomizer */