aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/isdn/divert/isdn_divert.c
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-02-19 22:52:38 -0500
committerJoe Perches <joe@perches.com>2012-02-21 12:04:01 -0500
commit475be4d85a274d0961593db41cf85689db1d583c (patch)
treeb2b8931eb747794730522c3cf1898e46948527b9 /drivers/isdn/divert/isdn_divert.c
parent0b0a635f79f91f3755b6518627ea06dd0dbfd523 (diff)
isdn: whitespace coding style cleanup
isdn source code uses a not-current coding style. Update the coding style used on a per-line basis so that git diff -w shows only elided blank lines at EOF. Done with emacs and some scripts and some typing. Built x86 allyesconfig. No detected change in objdump -d or size. Signed-off-by: Joe Perches <joe@perches.com>
Diffstat (limited to 'drivers/isdn/divert/isdn_divert.c')
-rw-r--r--drivers/isdn/divert/isdn_divert.c1475
1 files changed, 737 insertions, 738 deletions
diff --git a/drivers/isdn/divert/isdn_divert.c b/drivers/isdn/divert/isdn_divert.c
index 48e6d220f62c..e61e55f1f193 100644
--- a/drivers/isdn/divert/isdn_divert.c
+++ b/drivers/isdn/divert/isdn_divert.c
@@ -3,7 +3,7 @@
3 * DSS1 main diversion supplementary handling for i4l. 3 * DSS1 main diversion supplementary handling for i4l.
4 * 4 *
5 * Copyright 1999 by Werner Cornelius (werner@isdn4linux.de) 5 * Copyright 1999 by Werner Cornelius (werner@isdn4linux.de)
6 * 6 *
7 * This software may be used and distributed according to the terms 7 * This software may be used and distributed according to the terms
8 * of the GNU General Public License, incorporated herein by reference. 8 * of the GNU General Public License, incorporated herein by reference.
9 * 9 *
@@ -20,24 +20,24 @@
20/* structure keeping calling info */ 20/* structure keeping calling info */
21/**********************************/ 21/**********************************/
22struct call_struc 22struct call_struc
23 { isdn_ctrl ics; /* delivered setup + driver parameters */ 23{ isdn_ctrl ics; /* delivered setup + driver parameters */
24 ulong divert_id; /* Id delivered to user */ 24 ulong divert_id; /* Id delivered to user */
25 unsigned char akt_state; /* actual state */ 25 unsigned char akt_state; /* actual state */
26 char deflect_dest[35]; /* deflection destination */ 26 char deflect_dest[35]; /* deflection destination */
27 struct timer_list timer; /* timer control structure */ 27 struct timer_list timer; /* timer control structure */
28 char info[90]; /* device info output */ 28 char info[90]; /* device info output */
29 struct call_struc *next; /* pointer to next entry */ 29 struct call_struc *next; /* pointer to next entry */
30 struct call_struc *prev; 30 struct call_struc *prev;
31 }; 31};
32 32
33 33
34/********************************************/ 34/********************************************/
35/* structure keeping deflection table entry */ 35/* structure keeping deflection table entry */
36/********************************************/ 36/********************************************/
37struct deflect_struc 37struct deflect_struc
38 { struct deflect_struc *next,*prev; 38{ struct deflect_struc *next, *prev;
39 divert_rule rule; /* used rule */ 39 divert_rule rule; /* used rule */
40 }; 40};
41 41
42 42
43/*****************************************/ 43/*****************************************/
@@ -45,10 +45,10 @@ struct deflect_struc
45/*****************************************/ 45/*****************************************/
46/* diversion/deflection processes */ 46/* diversion/deflection processes */
47static struct call_struc *divert_head = NULL; /* head of remembered entrys */ 47static struct call_struc *divert_head = NULL; /* head of remembered entrys */
48static ulong next_id = 1; /* next info id */ 48static ulong next_id = 1; /* next info id */
49static struct deflect_struc *table_head = NULL; 49static struct deflect_struc *table_head = NULL;
50static struct deflect_struc *table_tail = NULL; 50static struct deflect_struc *table_tail = NULL;
51static unsigned char extern_wait_max = 4; /* maximum wait in s for external process */ 51static unsigned char extern_wait_max = 4; /* maximum wait in s for external process */
52 52
53DEFINE_SPINLOCK(divert_lock); 53DEFINE_SPINLOCK(divert_lock);
54 54
@@ -57,50 +57,50 @@ DEFINE_SPINLOCK(divert_lock);
57/***************************/ 57/***************************/
58static void deflect_timer_expire(ulong arg) 58static void deflect_timer_expire(ulong arg)
59{ 59{
60 unsigned long flags; 60 unsigned long flags;
61 struct call_struc *cs = (struct call_struc *) arg; 61 struct call_struc *cs = (struct call_struc *) arg;
62 62
63 spin_lock_irqsave(&divert_lock, flags); 63 spin_lock_irqsave(&divert_lock, flags);
64 del_timer(&cs->timer); /* delete active timer */ 64 del_timer(&cs->timer); /* delete active timer */
65 spin_unlock_irqrestore(&divert_lock, flags); 65 spin_unlock_irqrestore(&divert_lock, flags);
66 66
67 switch(cs->akt_state) 67 switch (cs->akt_state)
68 { case DEFLECT_PROCEED: 68 { case DEFLECT_PROCEED:
69 cs->ics.command = ISDN_CMD_HANGUP; /* cancel action */ 69 cs->ics.command = ISDN_CMD_HANGUP; /* cancel action */
70 divert_if.ll_cmd(&cs->ics); 70 divert_if.ll_cmd(&cs->ics);
71 spin_lock_irqsave(&divert_lock, flags); 71 spin_lock_irqsave(&divert_lock, flags);
72 cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ 72 cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
73 cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); 73 cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
74 add_timer(&cs->timer); 74 add_timer(&cs->timer);
75 spin_unlock_irqrestore(&divert_lock, flags); 75 spin_unlock_irqrestore(&divert_lock, flags);
76 break; 76 break;
77 77
78 case DEFLECT_ALERT: 78 case DEFLECT_ALERT:
79 cs->ics.command = ISDN_CMD_REDIR; /* protocol */ 79 cs->ics.command = ISDN_CMD_REDIR; /* protocol */
80 strlcpy(cs->ics.parm.setup.phone, cs->deflect_dest, sizeof(cs->ics.parm.setup.phone)); 80 strlcpy(cs->ics.parm.setup.phone, cs->deflect_dest, sizeof(cs->ics.parm.setup.phone));
81 strcpy(cs->ics.parm.setup.eazmsn,"Testtext delayed"); 81 strcpy(cs->ics.parm.setup.eazmsn, "Testtext delayed");
82 divert_if.ll_cmd(&cs->ics); 82 divert_if.ll_cmd(&cs->ics);
83 spin_lock_irqsave(&divert_lock, flags); 83 spin_lock_irqsave(&divert_lock, flags);
84 cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ 84 cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
85 cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); 85 cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
86 add_timer(&cs->timer); 86 add_timer(&cs->timer);
87 spin_unlock_irqrestore(&divert_lock, flags); 87 spin_unlock_irqrestore(&divert_lock, flags);
88 break; 88 break;
89 89
90 case DEFLECT_AUTODEL: 90 case DEFLECT_AUTODEL:
91 default: 91 default:
92 spin_lock_irqsave(&divert_lock, flags); 92 spin_lock_irqsave(&divert_lock, flags);
93 if (cs->prev) 93 if (cs->prev)
94 cs->prev->next = cs->next; /* forward link */ 94 cs->prev->next = cs->next; /* forward link */
95 else 95 else
96 divert_head = cs->next; 96 divert_head = cs->next;
97 if (cs->next) 97 if (cs->next)
98 cs->next->prev = cs->prev; /* back link */ 98 cs->next->prev = cs->prev; /* back link */
99 spin_unlock_irqrestore(&divert_lock, flags); 99 spin_unlock_irqrestore(&divert_lock, flags);
100 kfree(cs); 100 kfree(cs);
101 return; 101 return;
102 102
103 } /* switch */ 103 } /* switch */
104} /* deflect_timer_func */ 104} /* deflect_timer_func */
105 105
106 106
@@ -108,94 +108,94 @@ static void deflect_timer_expire(ulong arg)
108/* handle call forwarding de/activations */ 108/* handle call forwarding de/activations */
109/* 0 = deact, 1 = act, 2 = interrogate */ 109/* 0 = deact, 1 = act, 2 = interrogate */
110/*****************************************/ 110/*****************************************/
111int cf_command(int drvid, int mode, 111int cf_command(int drvid, int mode,
112 u_char proc, char *msn, 112 u_char proc, char *msn,
113 u_char service, char *fwd_nr, ulong *procid) 113 u_char service, char *fwd_nr, ulong *procid)
114{ unsigned long flags; 114{ unsigned long flags;
115 int retval,msnlen; 115 int retval, msnlen;
116 int fwd_len; 116 int fwd_len;
117 char *p,*ielenp,tmp[60]; 117 char *p, *ielenp, tmp[60];
118 struct call_struc *cs; 118 struct call_struc *cs;
119 119
120 if (strchr(msn,'.')) return(-EINVAL); /* subaddress not allowed in msn */ 120 if (strchr(msn, '.')) return (-EINVAL); /* subaddress not allowed in msn */
121 if ((proc & 0x7F) > 2) return(-EINVAL); 121 if ((proc & 0x7F) > 2) return (-EINVAL);
122 proc &= 3; 122 proc &= 3;
123 p = tmp; 123 p = tmp;
124 *p++ = 0x30; /* enumeration */ 124 *p++ = 0x30; /* enumeration */
125 ielenp = p++; /* remember total length position */ 125 ielenp = p++; /* remember total length position */
126 *p++ = 0xa; /* proc tag */ 126 *p++ = 0xa; /* proc tag */
127 *p++ = 1; /* length */ 127 *p++ = 1; /* length */
128 *p++ = proc & 0x7F; /* procedure to de/activate/interrogate */ 128 *p++ = proc & 0x7F; /* procedure to de/activate/interrogate */
129 *p++ = 0xa; /* service tag */ 129 *p++ = 0xa; /* service tag */
130 *p++ = 1; /* length */ 130 *p++ = 1; /* length */
131 *p++ = service; /* service to handle */ 131 *p++ = service; /* service to handle */
132 132
133 if (mode == 1) 133 if (mode == 1)
134 { if (!*fwd_nr) return(-EINVAL); /* destination missing */ 134 { if (!*fwd_nr) return (-EINVAL); /* destination missing */
135 if (strchr(fwd_nr,'.')) return(-EINVAL); /* subaddress not allowed */ 135 if (strchr(fwd_nr, '.')) return (-EINVAL); /* subaddress not allowed */
136 fwd_len = strlen(fwd_nr); 136 fwd_len = strlen(fwd_nr);
137 *p++ = 0x30; /* number enumeration */ 137 *p++ = 0x30; /* number enumeration */
138 *p++ = fwd_len + 2; /* complete forward to len */ 138 *p++ = fwd_len + 2; /* complete forward to len */
139 *p++ = 0x80; /* fwd to nr */ 139 *p++ = 0x80; /* fwd to nr */
140 *p++ = fwd_len; /* length of number */ 140 *p++ = fwd_len; /* length of number */
141 strcpy(p,fwd_nr); /* copy number */ 141 strcpy(p, fwd_nr); /* copy number */
142 p += fwd_len; /* pointer beyond fwd */ 142 p += fwd_len; /* pointer beyond fwd */
143 } /* activate */ 143 } /* activate */
144 144
145 msnlen = strlen(msn); 145 msnlen = strlen(msn);
146 *p++ = 0x80; /* msn number */ 146 *p++ = 0x80; /* msn number */
147 if (msnlen > 1) 147 if (msnlen > 1)
148 { *p++ = msnlen; /* length */ 148 { *p++ = msnlen; /* length */
149 strcpy(p,msn); 149 strcpy(p, msn);
150 p += msnlen; 150 p += msnlen;
151 } 151 }
152 else *p++ = 0; 152 else *p++ = 0;
153 153
154 *ielenp = p - ielenp - 1; /* set total IE length */ 154 *ielenp = p - ielenp - 1; /* set total IE length */
155 155
156 /* allocate mem for information struct */ 156 /* allocate mem for information struct */
157 if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC))) 157 if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC)))
158 return(-ENOMEM); /* no memory */ 158 return (-ENOMEM); /* no memory */
159 init_timer(&cs->timer); 159 init_timer(&cs->timer);
160 cs->info[0] = '\0'; 160 cs->info[0] = '\0';
161 cs->timer.function = deflect_timer_expire; 161 cs->timer.function = deflect_timer_expire;
162 cs->timer.data = (ulong) cs; /* pointer to own structure */ 162 cs->timer.data = (ulong) cs; /* pointer to own structure */
163 cs->ics.driver = drvid; 163 cs->ics.driver = drvid;
164 cs->ics.command = ISDN_CMD_PROT_IO; /* protocol specific io */ 164 cs->ics.command = ISDN_CMD_PROT_IO; /* protocol specific io */
165 cs->ics.arg = DSS1_CMD_INVOKE; /* invoke supplementary service */ 165 cs->ics.arg = DSS1_CMD_INVOKE; /* invoke supplementary service */
166 cs->ics.parm.dss1_io.proc = (mode == 1) ? 7: (mode == 2) ? 11:8; /* operation */ 166 cs->ics.parm.dss1_io.proc = (mode == 1) ? 7 : (mode == 2) ? 11 : 8; /* operation */
167 cs->ics.parm.dss1_io.timeout = 4000; /* from ETS 300 207-1 */ 167 cs->ics.parm.dss1_io.timeout = 4000; /* from ETS 300 207-1 */
168 cs->ics.parm.dss1_io.datalen = p - tmp; /* total len */ 168 cs->ics.parm.dss1_io.datalen = p - tmp; /* total len */
169 cs->ics.parm.dss1_io.data = tmp; /* start of buffer */ 169 cs->ics.parm.dss1_io.data = tmp; /* start of buffer */
170 170
171 spin_lock_irqsave(&divert_lock, flags); 171 spin_lock_irqsave(&divert_lock, flags);
172 cs->ics.parm.dss1_io.ll_id = next_id++; /* id for callback */ 172 cs->ics.parm.dss1_io.ll_id = next_id++; /* id for callback */
173 spin_unlock_irqrestore(&divert_lock, flags); 173 spin_unlock_irqrestore(&divert_lock, flags);
174 *procid = cs->ics.parm.dss1_io.ll_id; 174 *procid = cs->ics.parm.dss1_io.ll_id;
175 175
176 sprintf(cs->info,"%d 0x%lx %s%s 0 %s %02x %d%s%s\n", 176 sprintf(cs->info, "%d 0x%lx %s%s 0 %s %02x %d%s%s\n",
177 (!mode ) ? DIVERT_DEACTIVATE : (mode == 1) ? DIVERT_ACTIVATE : DIVERT_REPORT, 177 (!mode) ? DIVERT_DEACTIVATE : (mode == 1) ? DIVERT_ACTIVATE : DIVERT_REPORT,
178 cs->ics.parm.dss1_io.ll_id, 178 cs->ics.parm.dss1_io.ll_id,
179 (mode != 2) ? "" : "0 ", 179 (mode != 2) ? "" : "0 ",
180 divert_if.drv_to_name(cs->ics.driver), 180 divert_if.drv_to_name(cs->ics.driver),
181 msn, 181 msn,
182 service & 0xFF, 182 service & 0xFF,
183 proc, 183 proc,
184 (mode != 1) ? "" : " 0 ", 184 (mode != 1) ? "" : " 0 ",
185 (mode != 1) ? "" : fwd_nr); 185 (mode != 1) ? "" : fwd_nr);
186 186
187 retval = divert_if.ll_cmd(&cs->ics); /* execute command */ 187 retval = divert_if.ll_cmd(&cs->ics); /* execute command */
188 188
189 if (!retval) 189 if (!retval)
190 { cs->prev = NULL; 190 { cs->prev = NULL;
191 spin_lock_irqsave(&divert_lock, flags); 191 spin_lock_irqsave(&divert_lock, flags);
192 cs->next = divert_head; 192 cs->next = divert_head;
193 divert_head = cs; 193 divert_head = cs;
194 spin_unlock_irqrestore(&divert_lock, flags); 194 spin_unlock_irqrestore(&divert_lock, flags);
195 } 195 }
196 else 196 else
197 kfree(cs); 197 kfree(cs);
198 return(retval); 198 return (retval);
199} /* cf_command */ 199} /* cf_command */
200 200
201 201
@@ -204,165 +204,165 @@ int cf_command(int drvid, int mode,
204/****************************************/ 204/****************************************/
205int deflect_extern_action(u_char cmd, ulong callid, char *to_nr) 205int deflect_extern_action(u_char cmd, ulong callid, char *to_nr)
206{ struct call_struc *cs; 206{ struct call_struc *cs;
207 isdn_ctrl ic; 207 isdn_ctrl ic;
208 unsigned long flags; 208 unsigned long flags;
209 int i; 209 int i;
210 210
211 if ((cmd & 0x7F) > 2) return(-EINVAL); /* invalid command */ 211 if ((cmd & 0x7F) > 2) return (-EINVAL); /* invalid command */
212 cs = divert_head; /* start of parameter list */ 212 cs = divert_head; /* start of parameter list */
213 while (cs) 213 while (cs)
214 { if (cs->divert_id == callid) break; /* found */ 214 { if (cs->divert_id == callid) break; /* found */
215 cs = cs->next; 215 cs = cs->next;
216 } /* search entry */ 216 } /* search entry */
217 if (!cs) return(-EINVAL); /* invalid callid */ 217 if (!cs) return (-EINVAL); /* invalid callid */
218 218
219 ic.driver = cs->ics.driver; 219 ic.driver = cs->ics.driver;
220 ic.arg = cs->ics.arg; 220 ic.arg = cs->ics.arg;
221 i = -EINVAL; 221 i = -EINVAL;
222 if (cs->akt_state == DEFLECT_AUTODEL) return(i); /* no valid call */ 222 if (cs->akt_state == DEFLECT_AUTODEL) return (i); /* no valid call */
223 switch (cmd & 0x7F) 223 switch (cmd & 0x7F)
224 { case 0: /* hangup */ 224 { case 0: /* hangup */
225 del_timer(&cs->timer); 225 del_timer(&cs->timer);
226 ic.command = ISDN_CMD_HANGUP; 226 ic.command = ISDN_CMD_HANGUP;
227 i = divert_if.ll_cmd(&ic); 227 i = divert_if.ll_cmd(&ic);
228 spin_lock_irqsave(&divert_lock, flags); 228 spin_lock_irqsave(&divert_lock, flags);
229 cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ 229 cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
230 cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); 230 cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
231 add_timer(&cs->timer); 231 add_timer(&cs->timer);
232 spin_unlock_irqrestore(&divert_lock, flags); 232 spin_unlock_irqrestore(&divert_lock, flags);
233 break; 233 break;
234 234
235 case 1: /* alert */ 235 case 1: /* alert */
236 if (cs->akt_state == DEFLECT_ALERT) return(0); 236 if (cs->akt_state == DEFLECT_ALERT) return (0);
237 cmd &= 0x7F; /* never wait */ 237 cmd &= 0x7F; /* never wait */
238 del_timer(&cs->timer); 238 del_timer(&cs->timer);
239 ic.command = ISDN_CMD_ALERT; 239 ic.command = ISDN_CMD_ALERT;
240 if ((i = divert_if.ll_cmd(&ic))) 240 if ((i = divert_if.ll_cmd(&ic)))
241 { 241 {
242 spin_lock_irqsave(&divert_lock, flags); 242 spin_lock_irqsave(&divert_lock, flags);
243 cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ 243 cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
244 cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); 244 cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
245 add_timer(&cs->timer); 245 add_timer(&cs->timer);
246 spin_unlock_irqrestore(&divert_lock, flags); 246 spin_unlock_irqrestore(&divert_lock, flags);
247 } 247 }
248 else 248 else
249 cs->akt_state = DEFLECT_ALERT; 249 cs->akt_state = DEFLECT_ALERT;
250 break; 250 break;
251 251
252 case 2: /* redir */ 252 case 2: /* redir */
253 del_timer(&cs->timer); 253 del_timer(&cs->timer);
254 strlcpy(cs->ics.parm.setup.phone, to_nr, sizeof(cs->ics.parm.setup.phone)); 254 strlcpy(cs->ics.parm.setup.phone, to_nr, sizeof(cs->ics.parm.setup.phone));
255 strcpy(cs->ics.parm.setup.eazmsn, "Testtext manual"); 255 strcpy(cs->ics.parm.setup.eazmsn, "Testtext manual");
256 ic.command = ISDN_CMD_REDIR; 256 ic.command = ISDN_CMD_REDIR;
257 if ((i = divert_if.ll_cmd(&ic))) 257 if ((i = divert_if.ll_cmd(&ic)))
258 { 258 {
259 spin_lock_irqsave(&divert_lock, flags); 259 spin_lock_irqsave(&divert_lock, flags);
260 cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ 260 cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
261 cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); 261 cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
262 add_timer(&cs->timer); 262 add_timer(&cs->timer);
263 spin_unlock_irqrestore(&divert_lock, flags); 263 spin_unlock_irqrestore(&divert_lock, flags);
264 } 264 }
265 else 265 else
266 cs->akt_state = DEFLECT_ALERT; 266 cs->akt_state = DEFLECT_ALERT;
267 break; 267 break;
268 268
269 } /* switch */ 269 } /* switch */
270 return(i); 270 return (i);
271} /* deflect_extern_action */ 271} /* deflect_extern_action */
272 272
273/********************************/ 273/********************************/
274/* insert a new rule before idx */ 274/* insert a new rule before idx */
275/********************************/ 275/********************************/
276int insertrule(int idx, divert_rule *newrule) 276int insertrule(int idx, divert_rule *newrule)
277{ struct deflect_struc *ds,*ds1=NULL; 277{ struct deflect_struc *ds, *ds1 = NULL;
278 unsigned long flags; 278 unsigned long flags;
279 279
280 if (!(ds = kmalloc(sizeof(struct deflect_struc), 280 if (!(ds = kmalloc(sizeof(struct deflect_struc),
281 GFP_KERNEL))) 281 GFP_KERNEL)))
282 return(-ENOMEM); /* no memory */ 282 return (-ENOMEM); /* no memory */
283 283
284 ds->rule = *newrule; /* set rule */ 284 ds->rule = *newrule; /* set rule */
285 285
286 spin_lock_irqsave(&divert_lock, flags); 286 spin_lock_irqsave(&divert_lock, flags);
287 287
288 if (idx >= 0) 288 if (idx >= 0)
289 { ds1 = table_head; 289 { ds1 = table_head;
290 while ((ds1) && (idx > 0)) 290 while ((ds1) && (idx > 0))
291 { idx--; 291 { idx--;
292 ds1 = ds1->next; 292 ds1 = ds1->next;
293 } 293 }
294 if (!ds1) idx = -1; 294 if (!ds1) idx = -1;
295 } 295 }
296 296
297 if (idx < 0) 297 if (idx < 0)
298 { ds->prev = table_tail; /* previous entry */ 298 { ds->prev = table_tail; /* previous entry */
299 ds->next = NULL; /* end of chain */ 299 ds->next = NULL; /* end of chain */
300 if (ds->prev) 300 if (ds->prev)
301 ds->prev->next = ds; /* last forward */ 301 ds->prev->next = ds; /* last forward */
302 else 302 else
303 table_head = ds; /* is first entry */ 303 table_head = ds; /* is first entry */
304 table_tail = ds; /* end of queue */ 304 table_tail = ds; /* end of queue */
305 } 305 }
306 else 306 else
307 { ds->next = ds1; /* next entry */ 307 { ds->next = ds1; /* next entry */
308 ds->prev = ds1->prev; /* prev entry */ 308 ds->prev = ds1->prev; /* prev entry */
309 ds1->prev = ds; /* backward chain old element */ 309 ds1->prev = ds; /* backward chain old element */
310 if (!ds->prev) 310 if (!ds->prev)
311 table_head = ds; /* first element */ 311 table_head = ds; /* first element */
312 } 312 }
313 313
314 spin_unlock_irqrestore(&divert_lock, flags); 314 spin_unlock_irqrestore(&divert_lock, flags);
315 return(0); 315 return (0);
316} /* insertrule */ 316} /* insertrule */
317 317
318/***********************************/ 318/***********************************/
319/* delete the rule at position idx */ 319/* delete the rule at position idx */
320/***********************************/ 320/***********************************/
321int deleterule(int idx) 321int deleterule(int idx)
322{ struct deflect_struc *ds,*ds1; 322{ struct deflect_struc *ds, *ds1;
323 unsigned long flags; 323 unsigned long flags;
324 324
325 if (idx < 0) 325 if (idx < 0)
326 { spin_lock_irqsave(&divert_lock, flags); 326 { spin_lock_irqsave(&divert_lock, flags);
327 ds = table_head; 327 ds = table_head;
328 table_head = NULL; 328 table_head = NULL;
329 table_tail = NULL; 329 table_tail = NULL;
330 spin_unlock_irqrestore(&divert_lock, flags); 330 spin_unlock_irqrestore(&divert_lock, flags);
331 while (ds) 331 while (ds)
332 { ds1 = ds; 332 { ds1 = ds;
333 ds = ds->next; 333 ds = ds->next;
334 kfree(ds1); 334 kfree(ds1);
335 } 335 }
336 return(0); 336 return (0);
337 } 337 }
338 338
339 spin_lock_irqsave(&divert_lock, flags); 339 spin_lock_irqsave(&divert_lock, flags);
340 ds = table_head; 340 ds = table_head;
341 341
342 while ((ds) && (idx > 0)) 342 while ((ds) && (idx > 0))
343 { idx--; 343 { idx--;
344 ds = ds->next; 344 ds = ds->next;
345 } 345 }
346 346
347 if (!ds) 347 if (!ds)
348 { 348 {
349 spin_unlock_irqrestore(&divert_lock, flags); 349 spin_unlock_irqrestore(&divert_lock, flags);
350 return(-EINVAL); 350 return (-EINVAL);
351 } 351 }
352 352
353 if (ds->next) 353 if (ds->next)
354 ds->next->prev = ds->prev; /* backward chain */ 354 ds->next->prev = ds->prev; /* backward chain */
355 else 355 else
356 table_tail = ds->prev; /* end of chain */ 356 table_tail = ds->prev; /* end of chain */
357 357
358 if (ds->prev) 358 if (ds->prev)
359 ds->prev->next = ds->next; /* forward chain */ 359 ds->prev->next = ds->next; /* forward chain */
360 else 360 else
361 table_head = ds->next; /* start of chain */ 361 table_head = ds->next; /* start of chain */
362 362
363 spin_unlock_irqrestore(&divert_lock, flags); 363 spin_unlock_irqrestore(&divert_lock, flags);
364 kfree(ds); 364 kfree(ds);
365 return(0); 365 return (0);
366} /* deleterule */ 366} /* deleterule */
367 367
368/*******************************************/ 368/*******************************************/
@@ -370,16 +370,16 @@ int deleterule(int idx)
370/*******************************************/ 370/*******************************************/
371divert_rule *getruleptr(int idx) 371divert_rule *getruleptr(int idx)
372{ struct deflect_struc *ds = table_head; 372{ struct deflect_struc *ds = table_head;
373 373
374 if (idx < 0) return(NULL); 374 if (idx < 0) return (NULL);
375 while ((ds) && (idx >= 0)) 375 while ((ds) && (idx >= 0))
376 { if (!(idx--)) 376 { if (!(idx--))
377 { return(&ds->rule); 377 { return (&ds->rule);
378 break; 378 break;
379 } 379 }
380 ds = ds->next; 380 ds = ds->next;
381 } 381 }
382 return(NULL); 382 return (NULL);
383} /* getruleptr */ 383} /* getruleptr */
384 384
385/*************************************************/ 385/*************************************************/
@@ -387,168 +387,168 @@ divert_rule *getruleptr(int idx)
387/*************************************************/ 387/*************************************************/
388static int isdn_divert_icall(isdn_ctrl *ic) 388static int isdn_divert_icall(isdn_ctrl *ic)
389{ int retval = 0; 389{ int retval = 0;
390 unsigned long flags; 390 unsigned long flags;
391 struct call_struc *cs = NULL; 391 struct call_struc *cs = NULL;
392 struct deflect_struc *dv; 392 struct deflect_struc *dv;
393 char *p,*p1; 393 char *p, *p1;
394 u_char accept; 394 u_char accept;
395 395
396 /* first check the internal deflection table */ 396 /* first check the internal deflection table */
397 for (dv = table_head; dv ; dv = dv->next ) 397 for (dv = table_head; dv; dv = dv->next)
398 { /* scan table */ 398 { /* scan table */
399 if (((dv->rule.callopt == 1) && (ic->command == ISDN_STAT_ICALLW)) || 399 if (((dv->rule.callopt == 1) && (ic->command == ISDN_STAT_ICALLW)) ||
400 ((dv->rule.callopt == 2) && (ic->command == ISDN_STAT_ICALL))) 400 ((dv->rule.callopt == 2) && (ic->command == ISDN_STAT_ICALL)))
401 continue; /* call option check */ 401 continue; /* call option check */
402 if (!(dv->rule.drvid & (1L << ic->driver))) 402 if (!(dv->rule.drvid & (1L << ic->driver)))
403 continue; /* driver not matching */ 403 continue; /* driver not matching */
404 if ((dv->rule.si1) && (dv->rule.si1 != ic->parm.setup.si1)) 404 if ((dv->rule.si1) && (dv->rule.si1 != ic->parm.setup.si1))
405 continue; /* si1 not matching */ 405 continue; /* si1 not matching */
406 if ((dv->rule.si2) && (dv->rule.si2 != ic->parm.setup.si2)) 406 if ((dv->rule.si2) && (dv->rule.si2 != ic->parm.setup.si2))
407 continue; /* si2 not matching */ 407 continue; /* si2 not matching */
408 408
409 p = dv->rule.my_msn; 409 p = dv->rule.my_msn;
410 p1 = ic->parm.setup.eazmsn; 410 p1 = ic->parm.setup.eazmsn;
411 accept = 0; 411 accept = 0;
412 while (*p) 412 while (*p)
413 { /* complete compare */ 413 { /* complete compare */
414 if (*p == '-') 414 if (*p == '-')
415 { accept = 1; /* call accepted */ 415 { accept = 1; /* call accepted */
416 break; 416 break;
417 } 417 }
418 if (*p++ != *p1++) 418 if (*p++ != *p1++)
419 break; /* not accepted */ 419 break; /* not accepted */
420 if ((!*p) && (!*p1)) 420 if ((!*p) && (!*p1))
421 accept = 1; 421 accept = 1;
422 } /* complete compare */ 422 } /* complete compare */
423 if (!accept) continue; /* not accepted */ 423 if (!accept) continue; /* not accepted */
424 424
425 if ((strcmp(dv->rule.caller,"0")) || (ic->parm.setup.phone[0])) 425 if ((strcmp(dv->rule.caller, "0")) || (ic->parm.setup.phone[0]))
426 { p = dv->rule.caller; 426 { p = dv->rule.caller;
427 p1 = ic->parm.setup.phone; 427 p1 = ic->parm.setup.phone;
428 accept = 0; 428 accept = 0;
429 while (*p) 429 while (*p)
430 { /* complete compare */ 430 { /* complete compare */
431 if (*p == '-') 431 if (*p == '-')
432 { accept = 1; /* call accepted */ 432 { accept = 1; /* call accepted */
433 break; 433 break;
434 } 434 }
435 if (*p++ != *p1++) 435 if (*p++ != *p1++)
436 break; /* not accepted */ 436 break; /* not accepted */
437 if ((!*p) && (!*p1)) 437 if ((!*p) && (!*p1))
438 accept = 1; 438 accept = 1;
439 } /* complete compare */ 439 } /* complete compare */
440 if (!accept) continue; /* not accepted */ 440 if (!accept) continue; /* not accepted */
441 } 441 }
442 442
443 switch (dv->rule.action) 443 switch (dv->rule.action)
444 { case DEFLECT_IGNORE: 444 { case DEFLECT_IGNORE:
445 return(0); 445 return (0);
446 break; 446 break;
447 447
448 case DEFLECT_ALERT: 448 case DEFLECT_ALERT:
449 case DEFLECT_PROCEED: 449 case DEFLECT_PROCEED:
450 case DEFLECT_REPORT: 450 case DEFLECT_REPORT:
451 case DEFLECT_REJECT: 451 case DEFLECT_REJECT:
452 if (dv->rule.action == DEFLECT_PROCEED) 452 if (dv->rule.action == DEFLECT_PROCEED)
453 if ((!if_used) || ((!extern_wait_max) && (!dv->rule.waittime))) 453 if ((!if_used) || ((!extern_wait_max) && (!dv->rule.waittime)))
454 return(0); /* no external deflection needed */ 454 return (0); /* no external deflection needed */
455 if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC))) 455 if (!(cs = kmalloc(sizeof(struct call_struc), GFP_ATOMIC)))
456 return(0); /* no memory */ 456 return (0); /* no memory */
457 init_timer(&cs->timer); 457 init_timer(&cs->timer);
458 cs->info[0] = '\0'; 458 cs->info[0] = '\0';
459 cs->timer.function = deflect_timer_expire; 459 cs->timer.function = deflect_timer_expire;
460 cs->timer.data = (ulong) cs; /* pointer to own structure */ 460 cs->timer.data = (ulong) cs; /* pointer to own structure */
461 461
462 cs->ics = *ic; /* copy incoming data */ 462 cs->ics = *ic; /* copy incoming data */
463 if (!cs->ics.parm.setup.phone[0]) strcpy(cs->ics.parm.setup.phone,"0"); 463 if (!cs->ics.parm.setup.phone[0]) strcpy(cs->ics.parm.setup.phone, "0");
464 if (!cs->ics.parm.setup.eazmsn[0]) strcpy(cs->ics.parm.setup.eazmsn,"0"); 464 if (!cs->ics.parm.setup.eazmsn[0]) strcpy(cs->ics.parm.setup.eazmsn, "0");
465 cs->ics.parm.setup.screen = dv->rule.screen; 465 cs->ics.parm.setup.screen = dv->rule.screen;
466 if (dv->rule.waittime) 466 if (dv->rule.waittime)
467 cs->timer.expires = jiffies + (HZ * dv->rule.waittime); 467 cs->timer.expires = jiffies + (HZ * dv->rule.waittime);
468 else 468 else
469 if (dv->rule.action == DEFLECT_PROCEED) 469 if (dv->rule.action == DEFLECT_PROCEED)
470 cs->timer.expires = jiffies + (HZ * extern_wait_max); 470 cs->timer.expires = jiffies + (HZ * extern_wait_max);
471 else 471 else
472 cs->timer.expires = 0; 472 cs->timer.expires = 0;
473 cs->akt_state = dv->rule.action; 473 cs->akt_state = dv->rule.action;
474 spin_lock_irqsave(&divert_lock, flags); 474 spin_lock_irqsave(&divert_lock, flags);
475 cs->divert_id = next_id++; /* new sequence number */ 475 cs->divert_id = next_id++; /* new sequence number */
476 spin_unlock_irqrestore(&divert_lock, flags); 476 spin_unlock_irqrestore(&divert_lock, flags);
477 cs->prev = NULL; 477 cs->prev = NULL;
478 if (cs->akt_state == DEFLECT_ALERT) 478 if (cs->akt_state == DEFLECT_ALERT)
479 { strcpy(cs->deflect_dest,dv->rule.to_nr); 479 { strcpy(cs->deflect_dest, dv->rule.to_nr);
480 if (!cs->timer.expires) 480 if (!cs->timer.expires)
481 { strcpy(ic->parm.setup.eazmsn,"Testtext direct"); 481 { strcpy(ic->parm.setup.eazmsn, "Testtext direct");
482 ic->parm.setup.screen = dv->rule.screen; 482 ic->parm.setup.screen = dv->rule.screen;
483 strlcpy(ic->parm.setup.phone, dv->rule.to_nr, sizeof(ic->parm.setup.phone)); 483 strlcpy(ic->parm.setup.phone, dv->rule.to_nr, sizeof(ic->parm.setup.phone));
484 cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */ 484 cs->akt_state = DEFLECT_AUTODEL; /* delete after timeout */
485 cs->timer.expires = jiffies + (HZ * AUTODEL_TIME); 485 cs->timer.expires = jiffies + (HZ * AUTODEL_TIME);
486 retval = 5; 486 retval = 5;
487 } 487 }
488 else 488 else
489 retval = 1; /* alerting */ 489 retval = 1; /* alerting */
490 } 490 }
491 else 491 else
492 { cs->deflect_dest[0] = '\0'; 492 { cs->deflect_dest[0] = '\0';
493 retval = 4; /* only proceed */ 493 retval = 4; /* only proceed */
494 } 494 }
495 sprintf(cs->info,"%d 0x%lx %s %s %s %s 0x%x 0x%x %d %d %s\n", 495 sprintf(cs->info, "%d 0x%lx %s %s %s %s 0x%x 0x%x %d %d %s\n",
496 cs->akt_state, 496 cs->akt_state,
497 cs->divert_id, 497 cs->divert_id,
498 divert_if.drv_to_name(cs->ics.driver), 498 divert_if.drv_to_name(cs->ics.driver),
499 (ic->command == ISDN_STAT_ICALLW) ? "1":"0", 499 (ic->command == ISDN_STAT_ICALLW) ? "1" : "0",
500 cs->ics.parm.setup.phone, 500 cs->ics.parm.setup.phone,
501 cs->ics.parm.setup.eazmsn, 501 cs->ics.parm.setup.eazmsn,
502 cs->ics.parm.setup.si1, 502 cs->ics.parm.setup.si1,
503 cs->ics.parm.setup.si2, 503 cs->ics.parm.setup.si2,
504 cs->ics.parm.setup.screen, 504 cs->ics.parm.setup.screen,
505 dv->rule.waittime, 505 dv->rule.waittime,
506 cs->deflect_dest); 506 cs->deflect_dest);
507 if ((dv->rule.action == DEFLECT_REPORT) || 507 if ((dv->rule.action == DEFLECT_REPORT) ||
508 (dv->rule.action == DEFLECT_REJECT)) 508 (dv->rule.action == DEFLECT_REJECT))
509 { put_info_buffer(cs->info); 509 { put_info_buffer(cs->info);
510 kfree(cs); /* remove */ 510 kfree(cs); /* remove */
511 return((dv->rule.action == DEFLECT_REPORT) ? 0:2); /* nothing to do */ 511 return ((dv->rule.action == DEFLECT_REPORT) ? 0 : 2); /* nothing to do */
512 } 512 }
513 break; 513 break;
514 514
515 default: 515 default:
516 return(0); /* ignore call */ 516 return (0); /* ignore call */
517 break; 517 break;
518 } /* switch action */ 518 } /* switch action */
519 break; 519 break;
520 } /* scan_table */ 520 } /* scan_table */
521 521
522 if (cs) 522 if (cs)
523 { cs->prev = NULL; 523 { cs->prev = NULL;
524 spin_lock_irqsave(&divert_lock, flags); 524 spin_lock_irqsave(&divert_lock, flags);
525 cs->next = divert_head; 525 cs->next = divert_head;
526 divert_head = cs; 526 divert_head = cs;
527 if (cs->timer.expires) add_timer(&cs->timer); 527 if (cs->timer.expires) add_timer(&cs->timer);
528 spin_unlock_irqrestore(&divert_lock, flags); 528 spin_unlock_irqrestore(&divert_lock, flags);
529 529
530 put_info_buffer(cs->info); 530 put_info_buffer(cs->info);
531 return(retval); 531 return (retval);
532 } 532 }
533 else 533 else
534 return(0); 534 return (0);
535} /* isdn_divert_icall */ 535} /* isdn_divert_icall */
536 536
537 537
538void deleteprocs(void) 538void deleteprocs(void)
539{ struct call_struc *cs, *cs1; 539{ struct call_struc *cs, *cs1;
540 unsigned long flags; 540 unsigned long flags;
541 541
542 spin_lock_irqsave(&divert_lock, flags); 542 spin_lock_irqsave(&divert_lock, flags);
543 cs = divert_head; 543 cs = divert_head;
544 divert_head = NULL; 544 divert_head = NULL;
545 while (cs) 545 while (cs)
546 { del_timer(&cs->timer); 546 { del_timer(&cs->timer);
547 cs1 = cs; 547 cs1 = cs;
548 cs = cs->next; 548 cs = cs->next;
549 kfree(cs1); 549 kfree(cs1);
550 } 550 }
551 spin_unlock_irqrestore(&divert_lock, flags); 551 spin_unlock_irqrestore(&divert_lock, flags);
552} /* deleteprocs */ 552} /* deleteprocs */
553 553
554/****************************************************/ 554/****************************************************/
@@ -556,42 +556,42 @@ void deleteprocs(void)
556/****************************************************/ 556/****************************************************/
557static int put_address(char *st, u_char *p, int len) 557static int put_address(char *st, u_char *p, int len)
558{ u_char retval = 0; 558{ u_char retval = 0;
559 u_char adr_typ = 0; /* network standard */ 559 u_char adr_typ = 0; /* network standard */
560 560
561 if (len < 2) return(retval); 561 if (len < 2) return (retval);
562 if (*p == 0xA1) 562 if (*p == 0xA1)
563 { retval = *(++p) + 2; /* total length */ 563 { retval = *(++p) + 2; /* total length */
564 if (retval > len) return(0); /* too short */ 564 if (retval > len) return (0); /* too short */
565 len = retval - 2; /* remaining length */ 565 len = retval - 2; /* remaining length */
566 if (len < 3) return(0); 566 if (len < 3) return (0);
567 if ((*(++p) != 0x0A) || (*(++p) != 1)) return(0); 567 if ((*(++p) != 0x0A) || (*(++p) != 1)) return (0);
568 adr_typ = *(++p); 568 adr_typ = *(++p);
569 len -= 3; 569 len -= 3;
570 p++; 570 p++;
571 if (len < 2) return(0); 571 if (len < 2) return (0);
572 if (*p++ != 0x12) return(0); 572 if (*p++ != 0x12) return (0);
573 if (*p > len) return(0); /* check number length */ 573 if (*p > len) return (0); /* check number length */
574 len = *p++; 574 len = *p++;
575 } 575 }
576 else 576 else
577 if (*p == 0x80) 577 if (*p == 0x80)
578 { retval = *(++p) + 2; /* total length */ 578 { retval = *(++p) + 2; /* total length */
579 if (retval > len) return(0); 579 if (retval > len) return (0);
580 len = retval - 2; 580 len = retval - 2;
581 p++; 581 p++;
582 } 582 }
583 else 583 else
584 return(0); /* invalid address information */ 584 return (0); /* invalid address information */
585 585
586 sprintf(st,"%d ",adr_typ); 586 sprintf(st, "%d ", adr_typ);
587 st += strlen(st); 587 st += strlen(st);
588 if (!len) 588 if (!len)
589 *st++ = '-'; 589 *st++ = '-';
590 else 590 else
591 while (len--) 591 while (len--)
592 *st++ = *p++; 592 *st++ = *p++;
593 *st = '\0'; 593 *st = '\0';
594 return(retval); 594 return (retval);
595} /* put_address */ 595} /* put_address */
596 596
597/*************************************/ 597/*************************************/
@@ -599,93 +599,93 @@ static int put_address(char *st, u_char *p, int len)
599/*************************************/ 599/*************************************/
600static int interrogate_success(isdn_ctrl *ic, struct call_struc *cs) 600static int interrogate_success(isdn_ctrl *ic, struct call_struc *cs)
601{ char *src = ic->parm.dss1_io.data; 601{ char *src = ic->parm.dss1_io.data;
602 int restlen = ic->parm.dss1_io.datalen; 602 int restlen = ic->parm.dss1_io.datalen;
603 int cnt = 1; 603 int cnt = 1;
604 u_char n,n1; 604 u_char n, n1;
605 char st[90], *p, *stp; 605 char st[90], *p, *stp;
606 606
607 if (restlen < 2) return(-100); /* frame too short */ 607 if (restlen < 2) return (-100); /* frame too short */
608 if (*src++ != 0x30) return(-101); 608 if (*src++ != 0x30) return (-101);
609 if ((n = *src++) > 0x81) return(-102); /* invalid length field */ 609 if ((n = *src++) > 0x81) return (-102); /* invalid length field */
610 restlen -= 2; /* remaining bytes */ 610 restlen -= 2; /* remaining bytes */
611 if (n == 0x80) 611 if (n == 0x80)
612 { if (restlen < 2) return(-103); 612 { if (restlen < 2) return (-103);
613 if ((*(src+restlen-1)) || (*(src+restlen-2))) return(-104); 613 if ((*(src + restlen - 1)) || (*(src + restlen - 2))) return (-104);
614 restlen -= 2; 614 restlen -= 2;
615 } 615 }
616 else 616 else
617 if ( n == 0x81) 617 if (n == 0x81)
618 { n = *src++; 618 { n = *src++;
619 restlen--; 619 restlen--;
620 if (n > restlen) return(-105); 620 if (n > restlen) return (-105);
621 restlen = n; 621 restlen = n;
622 } 622 }
623 else 623 else
624 if (n > restlen) return(-106); 624 if (n > restlen) return (-106);
625 else 625 else
626 restlen = n; /* standard format */ 626 restlen = n; /* standard format */
627 if (restlen < 3) return(-107); /* no procedure */ 627 if (restlen < 3) return (-107); /* no procedure */
628 if ((*src++ != 2) || (*src++ != 1) || (*src++ != 0x0B)) return(-108); 628 if ((*src++ != 2) || (*src++ != 1) || (*src++ != 0x0B)) return (-108);
629 restlen -= 3; 629 restlen -= 3;
630 if (restlen < 2) return(-109); /* list missing */ 630 if (restlen < 2) return (-109); /* list missing */
631 if (*src == 0x31) 631 if (*src == 0x31)
632 { src++; 632 { src++;
633 if ((n = *src++) > 0x81) return(-110); /* invalid length field */ 633 if ((n = *src++) > 0x81) return (-110); /* invalid length field */
634 restlen -= 2; /* remaining bytes */ 634 restlen -= 2; /* remaining bytes */
635 if (n == 0x80) 635 if (n == 0x80)
636 { if (restlen < 2) return(-111); 636 { if (restlen < 2) return (-111);
637 if ((*(src+restlen-1)) || (*(src+restlen-2))) return(-112); 637 if ((*(src + restlen - 1)) || (*(src + restlen - 2))) return (-112);
638 restlen -= 2; 638 restlen -= 2;
639 } 639 }
640 else 640 else
641 if ( n == 0x81) 641 if (n == 0x81)
642 { n = *src++; 642 { n = *src++;
643 restlen--; 643 restlen--;
644 if (n > restlen) return(-113); 644 if (n > restlen) return (-113);
645 restlen = n; 645 restlen = n;
646 } 646 }
647 else 647 else
648 if (n > restlen) return(-114); 648 if (n > restlen) return (-114);
649 else 649 else
650 restlen = n; /* standard format */ 650 restlen = n; /* standard format */
651 } /* result list header */ 651 } /* result list header */
652 652
653 while (restlen >= 2) 653 while (restlen >= 2)
654 { stp = st; 654 { stp = st;
655 sprintf(stp,"%d 0x%lx %d %s ",DIVERT_REPORT, ic->parm.dss1_io.ll_id, 655 sprintf(stp, "%d 0x%lx %d %s ", DIVERT_REPORT, ic->parm.dss1_io.ll_id,
656 cnt++,divert_if.drv_to_name(ic->driver)); 656 cnt++, divert_if.drv_to_name(ic->driver));
657 stp += strlen(stp); 657 stp += strlen(stp);
658 if (*src++ != 0x30) return(-115); /* invalid enum */ 658 if (*src++ != 0x30) return (-115); /* invalid enum */
659 n = *src++; 659 n = *src++;
660 restlen -= 2; 660 restlen -= 2;
661 if (n > restlen) return(-116); /* enum length wrong */ 661 if (n > restlen) return (-116); /* enum length wrong */
662 restlen -= n; 662 restlen -= n;
663 p = src; /* one entry */ 663 p = src; /* one entry */
664 src += n; 664 src += n;
665 if (!(n1 = put_address(stp,p,n & 0xFF))) continue; 665 if (!(n1 = put_address(stp, p, n & 0xFF))) continue;
666 stp += strlen(stp); 666 stp += strlen(stp);
667 p += n1; 667 p += n1;
668 n -= n1; 668 n -= n1;
669 if (n < 6) continue; /* no service and proc */ 669 if (n < 6) continue; /* no service and proc */
670 if ((*p++ != 0x0A) || (*p++ != 1)) continue; 670 if ((*p++ != 0x0A) || (*p++ != 1)) continue;
671 sprintf(stp," 0x%02x ",(*p++) & 0xFF); 671 sprintf(stp, " 0x%02x ", (*p++) & 0xFF);
672 stp += strlen(stp); 672 stp += strlen(stp);
673 if ((*p++ != 0x0A) || (*p++ != 1)) continue; 673 if ((*p++ != 0x0A) || (*p++ != 1)) continue;
674 sprintf(stp,"%d ",(*p++) & 0xFF); 674 sprintf(stp, "%d ", (*p++) & 0xFF);
675 stp += strlen(stp); 675 stp += strlen(stp);
676 n -= 6; 676 n -= 6;
677 if (n > 2) 677 if (n > 2)
678 { if (*p++ != 0x30) continue; 678 { if (*p++ != 0x30) continue;
679 if (*p > (n-2)) continue; 679 if (*p > (n - 2)) continue;
680 n = *p++; 680 n = *p++;
681 if (!(n1 = put_address(stp,p,n & 0xFF))) continue; 681 if (!(n1 = put_address(stp, p, n & 0xFF))) continue;
682 stp += strlen(stp); 682 stp += strlen(stp);
683 } 683 }
684 sprintf(stp,"\n"); 684 sprintf(stp, "\n");
685 put_info_buffer(st); 685 put_info_buffer(st);
686 } /* while restlen */ 686 } /* while restlen */
687 if (restlen) return(-117); 687 if (restlen) return (-117);
688 return(0); 688 return (0);
689} /* interrogate_success */ 689} /* interrogate_success */
690 690
691/*********************************************/ 691/*********************************************/
@@ -693,90 +693,90 @@ static int interrogate_success(isdn_ctrl *ic, struct call_struc *cs)
693/*********************************************/ 693/*********************************************/
694static int prot_stat_callback(isdn_ctrl *ic) 694static int prot_stat_callback(isdn_ctrl *ic)
695{ struct call_struc *cs, *cs1; 695{ struct call_struc *cs, *cs1;
696 int i; 696 int i;
697 unsigned long flags; 697 unsigned long flags;
698 698
699 cs = divert_head; /* start of list */ 699 cs = divert_head; /* start of list */
700 cs1 = NULL; 700 cs1 = NULL;
701 while (cs) 701 while (cs)
702 { if (ic->driver == cs->ics.driver) 702 { if (ic->driver == cs->ics.driver)
703 { switch (cs->ics.arg) 703 { switch (cs->ics.arg)
704 { case DSS1_CMD_INVOKE: 704 { case DSS1_CMD_INVOKE:
705 if ((cs->ics.parm.dss1_io.ll_id == ic->parm.dss1_io.ll_id) && 705 if ((cs->ics.parm.dss1_io.ll_id == ic->parm.dss1_io.ll_id) &&
706 (cs->ics.parm.dss1_io.hl_id == ic->parm.dss1_io.hl_id)) 706 (cs->ics.parm.dss1_io.hl_id == ic->parm.dss1_io.hl_id))
707 { switch (ic->arg) 707 { switch (ic->arg)
708 { case DSS1_STAT_INVOKE_ERR: 708 { case DSS1_STAT_INVOKE_ERR:
709 sprintf(cs->info,"128 0x%lx 0x%x\n", 709 sprintf(cs->info, "128 0x%lx 0x%x\n",
710 ic->parm.dss1_io.ll_id, 710 ic->parm.dss1_io.ll_id,
711 ic->parm.dss1_io.timeout); 711 ic->parm.dss1_io.timeout);
712 put_info_buffer(cs->info); 712 put_info_buffer(cs->info);
713 break; 713 break;
714 714
715 case DSS1_STAT_INVOKE_RES: 715 case DSS1_STAT_INVOKE_RES:
716 switch (cs->ics.parm.dss1_io.proc) 716 switch (cs->ics.parm.dss1_io.proc)
717 { case 7: 717 { case 7:
718 case 8: 718 case 8:
719 put_info_buffer(cs->info); 719 put_info_buffer(cs->info);
720 break; 720 break;
721 721
722 case 11: 722 case 11:
723 i = interrogate_success(ic,cs); 723 i = interrogate_success(ic, cs);
724 if (i) 724 if (i)
725 sprintf(cs->info,"%d 0x%lx %d\n",DIVERT_REPORT, 725 sprintf(cs->info, "%d 0x%lx %d\n", DIVERT_REPORT,
726 ic->parm.dss1_io.ll_id,i); 726 ic->parm.dss1_io.ll_id, i);
727 put_info_buffer(cs->info); 727 put_info_buffer(cs->info);
728 break; 728 break;
729 729
730 default: 730 default:
731 printk(KERN_WARNING "dss1_divert: unknown proc %d\n",cs->ics.parm.dss1_io.proc); 731 printk(KERN_WARNING "dss1_divert: unknown proc %d\n", cs->ics.parm.dss1_io.proc);
732 break; 732 break;
733 } 733 }
734 734
735 735
736 break; 736 break;
737 737
738 default: 738 default:
739 printk(KERN_WARNING "dss1_divert unknown invoke answer %lx\n",ic->arg); 739 printk(KERN_WARNING "dss1_divert unknown invoke answer %lx\n", ic->arg);
740 break; 740 break;
741 } 741 }
742 cs1 = cs; /* remember structure */ 742 cs1 = cs; /* remember structure */
743 cs = NULL; 743 cs = NULL;
744 continue; /* abort search */ 744 continue; /* abort search */
745 } /* id found */ 745 } /* id found */
746 break; 746 break;
747 747
748 case DSS1_CMD_INVOKE_ABORT: 748 case DSS1_CMD_INVOKE_ABORT:
749 printk(KERN_WARNING "dss1_divert unhandled invoke abort\n"); 749 printk(KERN_WARNING "dss1_divert unhandled invoke abort\n");
750 break; 750 break;
751 751
752 default: 752 default:
753 printk(KERN_WARNING "dss1_divert unknown cmd 0x%lx\n",cs->ics.arg); 753 printk(KERN_WARNING "dss1_divert unknown cmd 0x%lx\n", cs->ics.arg);
754 break; 754 break;
755 } /* switch ics.arg */ 755 } /* switch ics.arg */
756 cs = cs->next; 756 cs = cs->next;
757 } /* driver ok */ 757 } /* driver ok */
758 } 758 }
759 759
760 if (!cs1) 760 if (!cs1)
761 { printk(KERN_WARNING "dss1_divert unhandled process\n"); 761 { printk(KERN_WARNING "dss1_divert unhandled process\n");
762 return(0); 762 return (0);
763 } 763 }
764 764
765 if (cs1->ics.driver == -1) 765 if (cs1->ics.driver == -1)
766 { 766 {
767 spin_lock_irqsave(&divert_lock, flags); 767 spin_lock_irqsave(&divert_lock, flags);
768 del_timer(&cs1->timer); 768 del_timer(&cs1->timer);
769 if (cs1->prev) 769 if (cs1->prev)
770 cs1->prev->next = cs1->next; /* forward link */ 770 cs1->prev->next = cs1->next; /* forward link */
771 else 771 else
772 divert_head = cs1->next; 772 divert_head = cs1->next;
773 if (cs1->next) 773 if (cs1->next)
774 cs1->next->prev = cs1->prev; /* back link */ 774 cs1->next->prev = cs1->prev; /* back link */
775 spin_unlock_irqrestore(&divert_lock, flags); 775 spin_unlock_irqrestore(&divert_lock, flags);
776 kfree(cs1); 776 kfree(cs1);
777 } 777 }
778 778
779 return(0); 779 return (0);
780} /* prot_stat_callback */ 780} /* prot_stat_callback */
781 781
782 782
@@ -785,79 +785,78 @@ static int prot_stat_callback(isdn_ctrl *ic)
785/***************************/ 785/***************************/
786static int isdn_divert_stat_callback(isdn_ctrl *ic) 786static int isdn_divert_stat_callback(isdn_ctrl *ic)
787{ struct call_struc *cs, *cs1; 787{ struct call_struc *cs, *cs1;
788 unsigned long flags; 788 unsigned long flags;
789 int retval; 789 int retval;
790 790
791 retval = -1; 791 retval = -1;
792 cs = divert_head; /* start of list */ 792 cs = divert_head; /* start of list */
793 while (cs) 793 while (cs)
794 { if ((ic->driver == cs->ics.driver) && (ic->arg == cs->ics.arg)) 794 { if ((ic->driver == cs->ics.driver) && (ic->arg == cs->ics.arg))
795 { switch (ic->command) 795 { switch (ic->command)
796 { case ISDN_STAT_DHUP: 796 { case ISDN_STAT_DHUP:
797 sprintf(cs->info,"129 0x%lx\n",cs->divert_id); 797 sprintf(cs->info, "129 0x%lx\n", cs->divert_id);
798 del_timer(&cs->timer); 798 del_timer(&cs->timer);
799 cs->ics.driver = -1; 799 cs->ics.driver = -1;
800 break; 800 break;
801 801
802 case ISDN_STAT_CAUSE: 802 case ISDN_STAT_CAUSE:
803 sprintf(cs->info,"130 0x%lx %s\n",cs->divert_id,ic->parm.num); 803 sprintf(cs->info, "130 0x%lx %s\n", cs->divert_id, ic->parm.num);
804 break; 804 break;
805 805
806 case ISDN_STAT_REDIR: 806 case ISDN_STAT_REDIR:
807 sprintf(cs->info,"131 0x%lx\n",cs->divert_id); 807 sprintf(cs->info, "131 0x%lx\n", cs->divert_id);
808 del_timer(&cs->timer); 808 del_timer(&cs->timer);
809 cs->ics.driver = -1; 809 cs->ics.driver = -1;
810 break; 810 break;
811 811
812 default: 812 default:
813 sprintf(cs->info,"999 0x%lx 0x%x\n",cs->divert_id,(int)(ic->command)); 813 sprintf(cs->info, "999 0x%lx 0x%x\n", cs->divert_id, (int)(ic->command));
814 break; 814 break;
815 } 815 }
816 put_info_buffer(cs->info); 816 put_info_buffer(cs->info);
817 retval = 0; 817 retval = 0;
818 } 818 }
819 cs1 = cs; 819 cs1 = cs;
820 cs = cs->next; 820 cs = cs->next;
821 if (cs1->ics.driver == -1) 821 if (cs1->ics.driver == -1)
822 { 822 {
823 spin_lock_irqsave(&divert_lock, flags); 823 spin_lock_irqsave(&divert_lock, flags);
824 if (cs1->prev) 824 if (cs1->prev)
825 cs1->prev->next = cs1->next; /* forward link */ 825 cs1->prev->next = cs1->next; /* forward link */
826 else 826 else
827 divert_head = cs1->next; 827 divert_head = cs1->next;
828 if (cs1->next) 828 if (cs1->next)
829 cs1->next->prev = cs1->prev; /* back link */ 829 cs1->next->prev = cs1->prev; /* back link */
830 spin_unlock_irqrestore(&divert_lock, flags); 830 spin_unlock_irqrestore(&divert_lock, flags);
831 kfree(cs1); 831 kfree(cs1);
832 } 832 }
833 } 833 }
834 return(retval); /* not found */ 834 return (retval); /* not found */
835} /* isdn_divert_stat_callback */ 835} /* isdn_divert_stat_callback */
836 836
837 837
838/********************/ 838/********************/
839/* callback from ll */ 839/* callback from ll */
840/********************/ 840/********************/
841int ll_callback(isdn_ctrl *ic) 841int ll_callback(isdn_ctrl *ic)
842{ 842{
843 switch (ic->command) 843 switch (ic->command)
844 { case ISDN_STAT_ICALL: 844 { case ISDN_STAT_ICALL:
845 case ISDN_STAT_ICALLW: 845 case ISDN_STAT_ICALLW:
846 return(isdn_divert_icall(ic)); 846 return (isdn_divert_icall(ic));
847 break; 847 break;
848 848
849 case ISDN_STAT_PROT: 849 case ISDN_STAT_PROT:
850 if ((ic->arg & 0xFF) == ISDN_PTYPE_EURO) 850 if ((ic->arg & 0xFF) == ISDN_PTYPE_EURO)
851 { if (ic->arg != DSS1_STAT_INVOKE_BRD) 851 { if (ic->arg != DSS1_STAT_INVOKE_BRD)
852 return(prot_stat_callback(ic)); 852 return (prot_stat_callback(ic));
853 else 853 else
854 return(0); /* DSS1 invoke broadcast */ 854 return (0); /* DSS1 invoke broadcast */
855 } 855 }
856 else 856 else
857 return(-1); /* protocol not euro */ 857 return (-1); /* protocol not euro */
858 858
859 default: 859 default:
860 return(isdn_divert_stat_callback(ic)); 860 return (isdn_divert_stat_callback(ic));
861 } 861 }
862} /* ll_callback */ 862} /* ll_callback */
863