blob: 55033dd872c0258b4902e3056e3563d273770793 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* $Id: isdn_divert.h,v 1.5.6.1 2001/09/23 22:24:36 kai Exp $
2 *
3 * Header for the diversion supplementary ioctl interface.
4 *
5 * Copyright 1998 by Werner Cornelius (werner@ikt.de)
Joe Perches475be4d2012-02-19 19:52:38 -08006 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference.
9 *
10 */
11
12#include <linux/ioctl.h>
13#include <linux/types.h>
14
15/******************************************/
16/* IOCTL codes for interface to user prog */
17/******************************************/
18#define DIVERT_IIOC_VERSION 0x01 /* actual version */
19#define IIOCGETVER _IO('I', 1) /* get version of interface */
20#define IIOCGETDRV _IO('I', 2) /* get driver number */
21#define IIOCGETNAM _IO('I', 3) /* get driver name */
22#define IIOCGETRULE _IO('I', 4) /* read one rule */
Joe Perches475be4d2012-02-19 19:52:38 -080023#define IIOCMODRULE _IO('I', 5) /* modify/replace a rule */
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#define IIOCINSRULE _IO('I', 6) /* insert/append one rule */
25#define IIOCDELRULE _IO('I', 7) /* delete a rule */
26#define IIOCDODFACT _IO('I', 8) /* hangup/reject/alert/immediately deflect a call */
27#define IIOCDOCFACT _IO('I', 9) /* activate control forwarding in PBX */
Joe Perches475be4d2012-02-19 19:52:38 -080028#define IIOCDOCFDIS _IO('I', 10) /* deactivate control forwarding in PBX */
29#define IIOCDOCFINT _IO('I', 11) /* interrogate control forwarding in PBX */
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31/*************************************/
32/* states reported through interface */
33/*************************************/
34#define DEFLECT_IGNORE 0 /* ignore incoming call */
35#define DEFLECT_REPORT 1 /* only report */
36#define DEFLECT_PROCEED 2 /* deflect when externally triggered */
Joe Perches475be4d2012-02-19 19:52:38 -080037#define DEFLECT_ALERT 3 /* alert and deflect after delay */
Linus Torvalds1da177e2005-04-16 15:20:36 -070038#define DEFLECT_REJECT 4 /* reject immediately */
39#define DIVERT_ACTIVATE 5 /* diversion activate */
40#define DIVERT_DEACTIVATE 6 /* diversion deactivate */
Joe Perches475be4d2012-02-19 19:52:38 -080041#define DIVERT_REPORT 7 /* interrogation result */
42#define DEFLECT_AUTODEL 255 /* only for internal use */
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
44#define DEFLECT_ALL_IDS 0xFFFFFFFF /* all drivers selected */
45
Tilman Schmidt03f18282013-01-21 11:57:20 +000046typedef struct {
47 ulong drvid; /* driver ids, bit mapped */
Joe Perches475be4d2012-02-19 19:52:38 -080048 char my_msn[35]; /* desired msn, subaddr allowed */
49 char caller[35]; /* caller id, partial string with * + subaddr allowed */
50 char to_nr[35]; /* deflected to number incl. subaddress */
51 u_char si1, si2; /* service indicators, si1=bitmask, si1+2 0 = all */
52 u_char screen; /* screening: 0 = no info, 1 = info, 2 = nfo with nr */
53 u_char callopt; /* option for call handling:
54 0 = all calls
55 1 = only non waiting calls
56 2 = only waiting calls */
57 u_char action; /* desired action:
58 0 = don't report call -> ignore
59 1 = report call, do not allow/proceed for deflection
60 2 = report call, send proceed, wait max waittime secs
61 3 = report call, alert and deflect after waittime
62 4 = report call, reject immediately
63 actions 1-2 only take place if interface is opened
64 */
65 u_char waittime; /* maximum wait time for proceeding */
66} divert_rule;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
Tilman Schmidt03f18282013-01-21 11:57:20 +000068typedef union {
69 int drv_version; /* return of driver version */
70 struct {
71 int drvid; /* id of driver */
Joe Perches475be4d2012-02-19 19:52:38 -080072 char drvnam[30]; /* name of driver */
73 } getid;
Tilman Schmidt03f18282013-01-21 11:57:20 +000074 struct {
75 int ruleidx; /* index of rule */
Joe Perches475be4d2012-02-19 19:52:38 -080076 divert_rule rule; /* rule parms */
77 } getsetrule;
Tilman Schmidt03f18282013-01-21 11:57:20 +000078 struct {
79 u_char subcmd; /* 0 = hangup/reject,
Joe Perches475be4d2012-02-19 19:52:38 -080080 1 = alert,
81 2 = deflect */
82 ulong callid; /* id of call delivered by ascii output */
83 char to_nr[35]; /* destination when deflect,
84 else uus1 string (maxlen 31),
85 data from rule used if empty */
86 } fwd_ctrl;
Tilman Schmidt03f18282013-01-21 11:57:20 +000087 struct {
88 int drvid; /* id of driver */
Joe Perches475be4d2012-02-19 19:52:38 -080089 u_char cfproc; /* cfu = 0, cfb = 1, cfnr = 2 */
90 ulong procid; /* process id returned when no error */
91 u_char service; /* basically coded service, 0 = all */
92 char msn[25]; /* desired msn, empty = all */
93 char fwd_nr[35];/* forwarded to number + subaddress */
94 } cf_ctrl;
95} divert_ioctl;
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
97#ifdef __KERNEL__
98
99#include <linux/isdnif.h>
100#include <linux/isdn_divertif.h>
101
102#define AUTODEL_TIME 30 /* timeout in s to delete internal entries */
103
104/**************************************************/
105/* structure keeping ascii info for device output */
106/**************************************************/
Tilman Schmidt03f18282013-01-21 11:57:20 +0000107struct divert_info {
108 struct divert_info *next;
Joe Perches475be4d2012-02-19 19:52:38 -0800109 ulong usage_cnt; /* number of files still to work */
110 char info_start[2]; /* info string start */
111};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
113
114/**************/
115/* Prototypes */
116/**************/
117extern spinlock_t divert_lock;
118
119extern ulong if_used; /* number of interface users */
120extern int divert_dev_deinit(void);
121extern int divert_dev_init(void);
122extern void put_info_buffer(char *);
123extern int ll_callback(isdn_ctrl *);
124extern isdn_divert_if divert_if;
125extern divert_rule *getruleptr(int);
126extern int insertrule(int, divert_rule *);
127extern int deleterule(int);
128extern void deleteprocs(void);
129extern int deflect_extern_action(u_char, ulong, char *);
130extern int cf_command(int, int, u_char, char *, u_char, char *, ulong *);
131
132#endif /* __KERNEL__ */