• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* $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)
6  *
7  * 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 */
23 #define IIOCMODRULE  _IO('I', 5)  /* modify/replace a rule */
24 #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 */
28 #define IIOCDOCFDIS  _IO('I', 10)  /* deactivate control forwarding in PBX */
29 #define IIOCDOCFINT  _IO('I', 11)  /* interrogate control forwarding in PBX */
30 
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 */
37 #define DEFLECT_ALERT     3  /* alert and deflect after delay */
38 #define DEFLECT_REJECT    4  /* reject immediately */
39 #define DIVERT_ACTIVATE   5  /* diversion activate */
40 #define DIVERT_DEACTIVATE 6  /* diversion deactivate */
41 #define DIVERT_REPORT     7  /* interrogation result */
42 #define DEFLECT_AUTODEL 255  /* only for internal use */
43 
44 #define DEFLECT_ALL_IDS   0xFFFFFFFF /* all drivers selected */
45 
46 typedef struct
47 { ulong drvid;     /* driver ids, bit mapped */
48 	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;
67 
68 typedef union
69 { int drv_version; /* return of driver version */
70 	struct
71 	{ int drvid;		/* id of driver */
72 		char drvnam[30];	/* name of driver */
73 	} getid;
74 	struct
75 	{ int ruleidx;	/* index of rule */
76 		divert_rule rule;	/* rule parms */
77 	} getsetrule;
78 	struct
79 	{ u_char subcmd;  /* 0 = hangup/reject,
80 			     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;
87 	struct
88 	{ int drvid;      /* id of driver */
89 		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;
96 
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 /**************************************************/
107 struct divert_info
108 { struct divert_info *next;
109 	ulong usage_cnt; /* number of files still to work */
110 	char info_start[2]; /* info string start */
111 };
112 
113 
114 /**************/
115 /* Prototypes */
116 /**************/
117 extern spinlock_t divert_lock;
118 
119 extern ulong if_used; /* number of interface users */
120 extern int divert_dev_deinit(void);
121 extern int divert_dev_init(void);
122 extern void put_info_buffer(char *);
123 extern int ll_callback(isdn_ctrl *);
124 extern isdn_divert_if divert_if;
125 extern divert_rule *getruleptr(int);
126 extern int insertrule(int, divert_rule *);
127 extern int deleterule(int);
128 extern void deleteprocs(void);
129 extern int deflect_extern_action(u_char, ulong, char *);
130 extern int cf_command(int, int, u_char, char *, u_char, char *, ulong *);
131 
132 #endif /* __KERNEL__ */
133