1 /*
2 * Copyright (c) 2009|Konrad Hammel <konrad@sangoma.com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms|with or without
6 * modification|are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice|this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice|this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of the original author; nor the names of any contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES|INCLUDING|BUT NOT
23 * LIMITED TO|THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
25 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT|INDIRECT|INCIDENTAL|SPECIAL,
26 * EXEMPLARY|OR CONSEQUENTIAL DAMAGES (INCLUDING|BUT NOT LIMITED TO,
27 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE|DATA|OR
28 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY|WHETHER IN CONTRACT|STRICT LIABILITY|OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE|EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34
35 /* INCLUDE ********************************************************************/
36 #include "ftmod_sangoma_ss7_main.h"
37 /******************************************************************************/
38
39 /* DEFINES ********************************************************************/
40 /******************************************************************************/
41
42 /* GLOBALS ********************************************************************/
43 /******************************************************************************/
44
45 /* PROTOTYPES *****************************************************************/
46 void handle_sng_log(uint8_t level, char *fmt,...);
47 void handle_sng_mtp1_alarm(Pst *pst, L1Mngmt *sta);
48 void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta);
49 void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta);
50 void handle_sng_isup_alarm(Pst *pst, SiMngmt *sta);
51 void handle_sng_cc_alarm(Pst *pst, CcMngmt *sta);
52 void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta);
53
54 /******************************************************************************/
55
56 /* FUNCTIONS ******************************************************************/
handle_sng_log(uint8_t level,char * fmt,...)57 void handle_sng_log(uint8_t level, char *fmt,...)
58 {
59 char *data;
60 int ret;
61 va_list ap;
62
63 va_start(ap, fmt);
64 ret = vasprintf(&data, fmt, ap);
65 if (ret == -1) {
66 return;
67 }
68
69 switch (level) {
70 /**************************************************************************/
71 case SNG_LOGLEVEL_DEBUG:
72 ftdm_log(FTDM_LOG_DEBUG, "sng_ss7->%s", data);
73 break;
74 /**************************************************************************/
75 case SNG_LOGLEVEL_WARN:
76 ftdm_log(FTDM_LOG_WARNING, "sng_ss7->%s", data);
77 break;
78 /**************************************************************************/
79 case SNG_LOGLEVEL_INFO:
80 ftdm_log(FTDM_LOG_INFO, "sng_ss7->%s", data);
81 break;
82 /**************************************************************************/
83 case SNG_LOGLEVEL_NOTICE:
84 ftdm_log(FTDM_LOG_NOTICE, "sng_ss7->%s", data);
85 break;
86 /**************************************************************************/
87 case SNG_LOGLEVEL_ERROR:
88 ftdm_log(FTDM_LOG_ERROR, "sng_ss7->%s", data);
89 break;
90 /**************************************************************************/
91 case SNG_LOGLEVEL_CRIT:
92 /*printf("%s",data);*/
93 ftdm_log(FTDM_LOG_CRIT, "sng_ss7->%s", data);
94 break;
95 /**************************************************************************/
96 default:
97 ftdm_log(FTDM_LOG_INFO, "sng_ss7->%s", data);
98 break;
99 /**************************************************************************/
100 }
101
102 return;
103 }
104
105 /******************************************************************************/
handle_sng_mtp1_alarm(Pst * pst,L1Mngmt * sta)106 void handle_sng_mtp1_alarm(Pst *pst, L1Mngmt *sta)
107 {
108
109
110 } /* handle_mtp1_alarm */
111
112 /******************************************************************************/
handle_sng_mtp2_alarm(Pst * pst,SdMngmt * sta)113 void handle_sng_mtp2_alarm(Pst *pst, SdMngmt *sta)
114 {
115 char buf[50];
116 int x = 1;
117 int log_level = FTDM_LOG_LEVEL_DEBUG;
118
119 memset(buf, '\0', sizeof(buf));
120
121 switch (sta->t.usta.alarm.category) {
122 /**************************************************************************/
123 case (LCM_CATEGORY_PROTOCOL):
124 case (LCM_CATEGORY_INTERFACE):
125
126 switch (sta->t.usta.alarm.event) {
127 /**********************************************************************/
128 case (LSD_EVENT_ENTR_CONG):
129 case (LSD_EVENT_EXIT_CONG):
130 case (LSD_EVENT_PROT_ST_UP):
131 case (LSD_EVENT_PROT_ST_DN):
132 case (LSD_EVENT_LINK_ALIGNED):
133 case (LSD_EVENT_REMOTE_CONG_START):
134 case (LSD_EVENT_REMOTE_CONG_END):
135 case (LSD_EVENT_RX_REMOTE_SIPO):
136
137 /* find the name for the sap in question */
138 x = 1;
139 while (x < (MAX_MTP_LINKS+1)) {
140 if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
141 break;
142 }
143 x++;
144 }
145
146 if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
147 sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
148 } else {
149 sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
150 }
151
152
153 switch (sta->t.usta.alarm.cause) {
154 case (LCM_CAUSE_MGMT_INITIATED):
155 ftdm_log(FTDM_LOG_DEBUG,"[MTP2]%s[MGMT] cause:%s event:%s\n",
156 buf,
157 DECODE_LCM_CAUSE(sta->t.usta.alarm.cause),
158 DECODE_LSD_EVENT(sta->t.usta.alarm.event));
159 break;
160 case (LCM_CAUSE_UNKNOWN):
161 default:
162 {
163 if ((LSD_EVENT_ALIGN_LOST == sta->t.usta.alarm.event) ||
164 (LSD_EVENT_PROT_ST_DN == sta->t.usta.alarm.event)) {
165 log_level = FTDM_LOG_LEVEL_WARNING;
166 } else if ((LSD_EVENT_LINK_ALIGNED == sta->t.usta.alarm.event) ||
167 (LSD_EVENT_PROT_ST_UP == sta->t.usta.alarm.event)){
168 log_level = FTDM_LOG_LEVEL_INFO;
169 } else {
170 log_level = FTDM_LOG_LEVEL_WARNING;
171 }
172 ftdm_log(FTDM_PRE, log_level,"[MTP2]%s cause:%s event:%s\n",
173 buf,
174 DECODE_LCM_CAUSE(sta->t.usta.alarm.cause),
175 DECODE_LSD_EVENT(sta->t.usta.alarm.event));
176 break;
177 }
178 /******************************************************************/
179 } /* switch (sta->t.usta.alarm.cause) */
180 break;
181 /**********************************************************************/
182 case (LSD_EVENT_PROT_ERR):
183
184 /* find the name for the sap in question */
185 x = 1;
186 while (x < (MAX_MTP_LINKS+1)) {
187 if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
188 break;
189 }
190 x++;
191 }
192
193 if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
194 sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
195 } else {
196 sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
197 }
198
199 ftdm_log(FTDM_LOG_WARNING,"[MTP2]%s %s : %s\n",
200 buf,
201 DECODE_LSD_EVENT(sta->t.usta.alarm.event),
202 DECODE_LSD_CAUSE(sta->t.usta.alarm.cause));
203 break;
204 /**********************************************************************/
205 case (LSD_EVENT_ALIGN_LOST):
206
207 /* find the name for the sap in question */
208 x = 1;
209 while (x < (MAX_MTP_LINKS+1)) {
210 if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
211 break;
212 }
213 x++;
214 }
215
216 if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
217 sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
218 } else {
219 sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
220 }
221
222 ftdm_log(FTDM_LOG_WARNING,"[MTP2]%s %s : %s\n",
223 buf,
224 DECODE_LSD_EVENT(sta->t.usta.alarm.event),
225 DECODE_DISC_REASON(sta->t.usta.evntParm[1]));
226 break;
227 /**********************************************************************/
228 case (LSD_EVENT_RTB_FULL):
229 case (LSD_EVENT_RTB_FULL_OVER):
230
231 /* find the name for the sap in question */
232 x = 1;
233 while (x < (MAX_MTP_LINKS+1)) {
234 if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
235 break;
236 }
237 x++;
238 }
239
240 if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
241 sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
242 } else {
243 sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
244 }
245
246 ftdm_log(FTDM_LOG_WARNING,"[MTP2]%s %s : RTB Queue Len(%d)|Oldest BSN(%d)|Tx Queue Len(%d)|Outstanding Frames(%d)\n",
247 buf,
248 DECODE_LSD_EVENT(sta->t.usta.alarm.event),
249 sta->t.usta.evntParm[1],
250 sta->t.usta.evntParm[2],
251 sta->t.usta.evntParm[3],
252 sta->t.usta.evntParm[4]);
253 break;
254 /**********************************************************************/
255 case (LSD_EVENT_NEG_ACK):
256
257 /* find the name for the sap in question */
258 x = 1;
259 while (x < (MAX_MTP_LINKS+1)) {
260 if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
261 break;
262 }
263 x++;
264 }
265
266 if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
267 sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
268 } else {
269 sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
270 }
271
272 ftdm_log(FTDM_LOG_WARNING,"[MTP2]%s %s : RTB Queue Len(%d)\n",
273 buf,
274 DECODE_LSD_EVENT(sta->t.usta.alarm.event),
275 sta->t.usta.evntParm[1]);
276 break;
277 /**********************************************************************/
278 case (LSD_EVENT_DAT_CFM_SDT):
279
280 /* find the name for the sap in question */
281 x = 1;
282 while (x < (MAX_MTP_LINKS+1)) {
283 if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == sta->t.usta.evntParm[0]) {
284 break;
285 }
286 x++;
287 }
288
289 if (g_ftdm_sngss7_data.cfg.mtp2Link[x].id == 0) {
290 sprintf(buf, "[SAPID:%d]", sta->t.usta.evntParm[0]);
291 } else {
292 sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp2Link[x].name);
293 }
294
295 ftdm_log(FTDM_LOG_WARNING,"[MTP2]%s %s : %s\n",
296 buf,
297 DECODE_LSD_EVENT(sta->t.usta.alarm.event),
298 DECODE_DISC_REASON(sta->t.usta.evntParm[1]));
299 break;
300 /**********************************************************************/
301 case (LCM_EVENT_UI_INV_EVT):
302 case (LCM_EVENT_LI_INV_EVT):
303 ftdm_log(FTDM_LOG_WARNING,"[MTP2] %s(%d) : %s(%d) : Primitive (%d)\n",
304 DECODE_LSD_EVENT(sta->t.usta.alarm.event),
305 sta->t.usta.alarm.event,
306 DECODE_LCM_CAUSE(sta->t.usta.alarm.cause),
307 sta->t.usta.alarm.cause,
308 sta->t.usta.evntParm[0]);
309 break;
310 /**********************************************************************/
311 case (LCM_EVENT_INV_EVT):
312
313 switch (sta->t.usta.alarm.cause) {
314 /******************************************************************/
315 case (LCM_CAUSE_UNKNOWN):
316 case (LCM_CAUSE_SWVER_NAVAIL):
317 ftdm_log(FTDM_LOG_WARNING,"[MTP2] %s : %s : Event (%d)\n",
318 DECODE_LSD_EVENT(sta->t.usta.alarm.event),
319 DECODE_LCM_CAUSE(sta->t.usta.alarm.cause),
320 sta->t.usta.evntParm[0]);
321 break;
322 /******************************************************************/
323 case (LCM_CAUSE_DECODE_ERR):
324 ftdm_log(FTDM_LOG_WARNING,"[MTP2] %s : %s : Primitive (%d)|Version (%d)\n",
325 DECODE_LSD_EVENT(sta->t.usta.alarm.event),
326 DECODE_LCM_CAUSE(sta->t.usta.alarm.cause),
327 sta->t.usta.evntParm[0],
328 sta->t.usta.evntParm[1]);
329 break;
330 /******************************************************************/
331 default:
332 ftdm_log(FTDM_LOG_WARNING,"[MTP2] %s(%d) : %s(%d)\n",
333 DECODE_LSD_EVENT(sta->t.usta.alarm.event),
334 sta->t.usta.alarm.event,
335 DECODE_LSD_CAUSE(sta->t.usta.alarm.cause),
336 sta->t.usta.alarm.cause);
337 break;
338 /******************************************************************/
339 } /* switch (sta->t.usta.alarm.cause) */
340 break;
341 /**********************************************************************/
342 default:
343 ftdm_log(FTDM_LOG_WARNING,"[MTP2] %s(%d) : %s(%d)\n",
344 DECODE_LSD_EVENT(sta->t.usta.alarm.event),
345 sta->t.usta.alarm.event,
346 DECODE_LSD_CAUSE(sta->t.usta.alarm.cause),
347 sta->t.usta.alarm.cause);
348 break;
349 /**********************************************************************/
350 } /* switch (sta->t.usta.alarm.event) */
351 break;
352 /**************************************************************************/
353 default:
354 ftdm_log(FTDM_LOG_ERROR,"[MTP2] Unknown alarm category %d\n",
355 sta->t.usta.alarm.category);
356 break;
357 /**************************************************************************/
358 } /* switch(sta->t.usta.alarm.category) */
359
360 return;
361 } /* handle_mtp2_alarm */
362
363 /******************************************************************************/
handle_sng_mtp3_alarm(Pst * pst,SnMngmt * sta)364 void handle_sng_mtp3_alarm(Pst *pst, SnMngmt *sta)
365 {
366 char buf[50];
367 int x = 1;
368
369 SS7_RELAY_DBG_FUN(handle_sng_mtp3_alarm);
370
371 memset(buf, '\0', sizeof(buf));
372
373 switch (sta->hdr.elmId.elmnt) {
374 /**************************************************************************/
375 case (STDLSAP):
376
377 /* find the name for the sap in question */
378 x = 1;
379 while (x < (MAX_MTP_LINKS+1)) {
380 if (g_ftdm_sngss7_data.cfg.mtp3Link[x].id == sta->hdr.elmId.elmntInst1) {
381 break;
382 }
383 x++;
384 }
385
386 if (g_ftdm_sngss7_data.cfg.mtp3Link[x].id == 0) {
387 sprintf(buf, "[SAPID:%d]", sta->hdr.elmId.elmntInst1);
388 } else {
389 sprintf(buf, "[%s]", g_ftdm_sngss7_data.cfg.mtp3Link[x].name);
390 }
391
392 switch (sta->t.usta.alarm.event) {
393 /**********************************************************************/
394 case (LSN_EVENT_INV_OPC_OTHER_END):
395
396 ftdm_log(FTDM_LOG_WARNING,"[MTP3]%s %s : %s : OPC(0x%X%X%X%X)\n",
397 buf,
398 DECODE_LSN_EVENT(sta->t.usta.alarm.event),
399 DECODE_LSN_CAUSE(sta->t.usta.alarm.cause),
400 sta->t.usta.evntParm[3],
401 sta->t.usta.evntParm[2],
402 sta->t.usta.evntParm[1],
403 sta->t.usta.evntParm[0]);
404 break;
405 /**********************************************************************/
406 case (LSN_EVENT_INV_SLC_OTHER_END):
407 ftdm_log(FTDM_LOG_WARNING,"[MTP3]%s %s : %s : SLC(%d)\n",
408 buf,
409 DECODE_LSN_EVENT(sta->t.usta.alarm.event),
410 DECODE_LSN_CAUSE(sta->t.usta.alarm.cause),
411 sta->t.usta.evntParm[0]);
412 break;
413 /**********************************************************************/
414 default:
415 ftdm_log(FTDM_LOG_WARNING,"[MTP3]%s %s(%d) : %s(%d)\n",
416 buf,
417 DECODE_LSN_EVENT(sta->t.usta.alarm.event),
418 sta->t.usta.alarm.event,
419 DECODE_LSN_CAUSE(sta->t.usta.alarm.cause),
420 sta->t.usta.alarm.cause);
421 break;
422 /**********************************************************************/
423 } /* sta->t.usta.alarm.event */
424 break;
425 /**************************************************************************/
426 case (STNSAP):
427 ftdm_log(FTDM_LOG_WARNING,"[MTP3][SAPID:%d] %s : %s\n",
428 sta->hdr.elmId.elmntInst1,
429 DECODE_LSN_EVENT(sta->t.usta.alarm.event),
430 DECODE_LSN_CAUSE(sta->t.usta.alarm.cause));
431 break;
432 /**************************************************************************/
433 case (STLNKSET):
434 ftdm_log(FTDM_LOG_DEBUG,"[MTP3][LNKSET:%d] %s : %s\n",
435 sta->hdr.elmId.elmntInst1,
436 DECODE_LSN_EVENT(sta->t.usta.alarm.event),
437 DECODE_LSN_CAUSE(sta->t.usta.alarm.cause));
438 break;
439 /**************************************************************************/
440 case (STROUT):
441 switch (sta->t.usta.alarm.event) {
442 /**********************************************************************/
443 case (LSN_EVENT_RX_TRANSFER_MSG):
444 switch (sta->t.usta.evntParm[5]) {
445 /******************************************************************/
446 case (0x23):
447 ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFC\n");
448 break;
449 /******************************************************************/
450 case (0x34):
451 ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFR\n");
452 break;
453 /******************************************************************/
454 case (0x54):
455 ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFA\n");
456 break;
457 /******************************************************************/
458 case (0x14):
459 ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFP\n");
460 break;
461 /******************************************************************/
462 case (0x24):
463 ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFP (cluster)\n");
464 break;
465 /******************************************************************/
466 case (0x64):
467 ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFA (cluster)\n");
468 break;
469 /******************************************************************/
470 case (0x44):
471 ftdm_log(FTDM_LOG_INFO,"[MTP3] Rx SNM TFR (cluster)\n");
472 break;
473 /******************************************************************/
474 } /* switch (sta->t.usta.evntParm[5]) */
475 break;
476 /**********************************************************************/
477 default:
478 ftdm_log(FTDM_LOG_WARNING,"[MTP3][DPC:0x%X%X%X%X] %s : %s\n",
479 sta->t.usta.evntParm[0],
480 sta->t.usta.evntParm[1],
481 sta->t.usta.evntParm[2],
482 sta->t.usta.evntParm[3],
483 DECODE_LSN_EVENT(sta->t.usta.alarm.event),
484 DECODE_LSN_CAUSE(sta->t.usta.alarm.cause));
485 break;
486 /**********************************************************************/
487 } /* switch (sta->t.usta.alarm.event) */
488 break;
489 /**************************************************************************/
490 default:
491 ftdm_log(FTDM_LOG_ERROR,"[MTP3] %s(%d) : %s(%d)\n",
492 DECODE_LSN_EVENT(sta->t.usta.alarm.event),
493 sta->t.usta.alarm.event,
494 DECODE_LSN_CAUSE(sta->t.usta.alarm.cause),
495 sta->t.usta.alarm.cause);
496 break;
497 /**************************************************************************/
498 } /* switch (sta->hdr.elmId.elmnt) */
499
500 return;
501 } /* handle_mtp3_alarm */
502
503 /******************************************************************************/
handle_sng_isup_alarm(Pst * pst,SiMngmt * sta)504 void handle_sng_isup_alarm(Pst *pst, SiMngmt *sta)
505 {
506 char msg[250];
507 char tmp[25];
508 char *p = NULL;
509 int x = 0;
510
511 SS7_RELAY_DBG_FUN(handle_sng_isup_alarm);
512
513 /* initalize the msg variable to NULLs */
514 memset(&msg[0], '\0', sizeof(&msg));
515
516 /* if the event is REMOTE/LOCAL we don't need to print these */
517 if ((sta->t.usta.alarm.event == LSI_EVENT_REMOTE) ||
518 (sta->t.usta.alarm.event == LSI_EVENT_LOCAL)) {
519 return;
520 }
521
522 /* point p to the first spot in msg */
523 p = &msg[0];
524
525 p = strcat(p, "[ISUP]");
526
527 /* go through the dgnVals */
528 for (x = 0; x < 5; x++) {
529 switch (sta->t.usta.dgn.dgnVal[x].type) {
530 /**********************************************************************/
531 case (LSI_USTA_DGNVAL_NONE):
532 break;
533 /**********************************************************************/
534 case (LSI_USTA_DGNVAL_EVENT):
535 /* init tmp with NULLs */
536 memset(&tmp[0], '\0', sizeof(&tmp));
537
538 /* fill in the dgn val to tmp */
539 sprintf(&tmp[0], "[EVENT:%d]",sta->t.usta.dgn.dgnVal[x].t.event);
540
541 /* concat tmp to msg */
542 p = strcat(p, &tmp[0]);
543 break;
544 /**********************************************************************/
545 case (LSI_USTA_DGNVAL_SPID):
546 /* init tmp with NULLs */
547 memset(&tmp[0], '\0', sizeof(&tmp));
548
549 /* fill in the dgn val to tmp */
550 sprintf(&tmp[0], "[SPID:%d]",sta->t.usta.dgn.dgnVal[x].t.spId);
551
552 /* concat tmp to msg */
553 p = strcat(p, &tmp[0]);
554 break;
555 /**********************************************************************/
556 case (LSI_USTA_DGNVAL_SUID):
557 /* init tmp with NULLs */
558 memset(&tmp[0], '\0', sizeof(&tmp));
559
560 /* fill in the dgn val to tmp */
561 sprintf(&tmp[0], "[SUID:%d]",sta->t.usta.dgn.dgnVal[x].t.suId);
562
563 /* concat tmp to msg */
564 p = strcat(p, &tmp[0]);
565 break;
566 /**********************************************************************/
567 case (LSI_USTA_DGNVAL_SPINSTID):
568 /* init tmp with NULLs */
569 memset(&tmp[0], '\0', sizeof(&tmp));
570
571 /* fill in the dgn val to tmp */
572 sprintf(&tmp[0], "[SPINSTID:%d]", (int)sta->t.usta.dgn.dgnVal[x].t.spInstId);
573
574 /* concat tmp to msg */
575 p = strcat(p, &tmp[0]);
576 break;
577 /**********************************************************************/
578 case (LSI_USTA_DGNVAL_SUINSTID):
579 /* init tmp with NULLs */
580 memset(&tmp[0], '\0', sizeof(&tmp));
581
582 /* fill in the dgn val to tmp */
583 sprintf(&tmp[0], "[SUINSTID:%d]", (int)sta->t.usta.dgn.dgnVal[x].t.suInstId);
584
585 /* concat tmp to msg */
586 p = strcat(p, &tmp[0]);
587 break;
588 /**********************************************************************/
589 case (LSI_USTA_DGNVAL_CIRCUIT):
590 /* init tmp with NULLs */
591 memset(&tmp[0], '\0', sizeof(&tmp));
592
593 /* fill in the dgn val to tmp */
594 sprintf(&tmp[0], "[CKT:%d]", (int)sta->t.usta.dgn.dgnVal[x].t.cirId);
595
596 /* concat tmp to msg */
597 p = strcat(p, &tmp[0]);
598 break;
599 /**********************************************************************/
600 case (LSI_USTA_DGNVAL_CIC):
601 /* init tmp with NULLs */
602 memset(&tmp[0], '\0', sizeof(&tmp));
603
604 /* fill in the dgn val to tmp */
605 sprintf(&tmp[0], "[CIC:%d]", (int)sta->t.usta.dgn.dgnVal[x].t.cic);
606
607 /* concat tmp to msg */
608 p = strcat(p, &tmp[0]);
609 break;
610 /**********************************************************************/
611 case (LSI_USTA_DGNVAL_INTF):
612 /* init tmp with NULLs */
613 memset(&tmp[0], '\0', sizeof(&tmp));
614
615 /* fill in the dgn val to tmp */
616 sprintf(&tmp[0], "[INTF:%d]", (int)sta->t.usta.dgn.dgnVal[x].t.intfId);
617
618 /* concat tmp to msg */
619 p = strcat(p, &tmp[0]);
620 break;
621 /**********************************************************************/
622 case (LSI_USTA_DGNVAL_DPC):
623 /* init tmp with NULLs */
624 memset(&tmp[0], '\0', sizeof(&tmp));
625
626 /* fill in the dgn val to tmp */
627 sprintf(&tmp[0], "[DPC:%d]", (int)sta->t.usta.dgn.dgnVal[x].t.dpc);
628
629 /* concat tmp to msg */
630 p = strcat(p, &tmp[0]);
631 break;
632 /**********************************************************************/
633 case (LSI_USTA_DGNVAL_ADDRS):
634 #if 0
635 /*
636 *typedef struct addrs
637 *{
638 *U8 length;
639 *U8 strg[ADRLEN];
640 *} Addrs;
641 */
642 /* init tmp with NULLs */
643 memset(&tmp[0], '\0', sizeof(&tmp));
644
645 /* fill in the dgn val to tmp */
646 sprintf(&tmp[0], "[ADDRS:%d]",sta->t.usta.dgn.dgnVal[x].t.);
647
648 /* concat tmp to msg */
649 p = strcat(p, &tmp[0]);
650 #endif
651 break;
652 /**********************************************************************/
653 case (LSI_USTA_DGNVAL_SWTCH):
654 /* init tmp with NULLs */
655 memset(&tmp[0], '\0', sizeof(&tmp));
656
657 /* fill in the dgn val to tmp */
658 sprintf(&tmp[0], "[SWTCH:%d]",sta->t.usta.dgn.dgnVal[x].t.swtch);
659
660 /* concat tmp to msg */
661 p = strcat(p, &tmp[0]);
662 break;
663 /**********************************************************************/
664 case (LSI_USTA_DGNVAL_RANGE):
665 /* init tmp with NULLs */
666 memset(&tmp[0], '\0', sizeof(&tmp));
667
668 /* fill in the dgn val to tmp */
669 sprintf(&tmp[0], "[RANGE:0x%X]",sta->t.usta.dgn.dgnVal[x].t.range);
670
671 /* concat tmp to msg */
672 p = strcat(p, &tmp[0]);
673 break;
674 /**********************************************************************/
675 case (LSI_USTA_DGNVAL_STATUS_OCTS):
676 #if 0
677 /*
678 *typedef struct addrs
679 *{
680 *U8 length;
681 *U8 strg[ADRLEN];
682 *} Addrs;
683 */
684 /* init tmp with NULLs */
685 /* init tmp with NULLs */
686 memset(&tmp[0], '\0', sizeof(&tmp));
687
688 /* fill in the dgn val to tmp */
689 sprintf(&tmp[0], "[STATUS_OCT:0x%X]",sta->t.usta.dgn.dgnVal[x].t.);
690
691 /* concat tmp to msg */
692 p = strcat(p, &tmp[0]);
693 #endif
694 break;
695 /**********************************************************************/
696 case (LSI_USTA_DGNVAL_VER):
697 #ifdef SI_RUG
698 /* init tmp with NULLs */
699 memset(&tmp[0], '\0', sizeof(&tmp));
700
701 /* fill in the dgn val to tmp */
702 sprintf(&tmp[0], "[VER:%d]",sta->t.usta.dgn.dgnVal[x].t.intfVer);
703
704 /* concat tmp to msg */
705 p = strcat(p, &tmp[0]);
706 #endif
707 break;
708 /**********************************************************************/
709 case (LSI_USTA_DGNVAL_TIMER):
710 /* init tmp with NULLs */
711 memset(&tmp[0], '\0', sizeof(&tmp));
712
713 /* fill in the dgn val to tmp */
714 sprintf(&tmp[0], "[TIMER:0x%X]",sta->t.usta.dgn.dgnVal[x].t.tmrInfo);
715
716 /* concat tmp to msg */
717 p = strcat(p, &tmp[0]);
718 break;
719 /**********************************************************************/
720 case (LSI_USTA_DGNVAL_MSGTYPE):
721 /* init tmp with NULLs */
722 memset(&tmp[0], '\0', sizeof(&tmp));
723
724 /* fill in the dgn val to tmp */
725 sprintf(&tmp[0], "[MSGTYPE:%d]",sta->t.usta.dgn.dgnVal[x].t.msgType);
726
727 /* concat tmp to msg */
728 p = strcat(p, &tmp[0]);
729 break;
730 /**********************************************************************/
731 case (LSI_USTA_DGNVAL_STATE):
732 /* init tmp with NULLs */
733 memset(&tmp[0], '\0', sizeof(&tmp));
734
735 /* fill in the dgn val to tmp */
736 sprintf(&tmp[0], "[STATE:%d]",sta->t.usta.dgn.dgnVal[x].t.state);
737
738 /* concat tmp to msg */
739 p = strcat(p, &tmp[0]);
740 break;
741 /**********************************************************************/
742 default:
743 break;
744 /**********************************************************************/
745 } /* switch (sta->t.usta.dgn.dgnVal[x].t.type) */
746 } /* for (x = 0; x < 5; x++) */
747
748 ftdm_log(FTDM_LOG_WARNING,"%s %s : %s\n",
749 msg,
750 DECODE_LSI_EVENT(sta->t.usta.alarm.event),
751 DECODE_LSI_CAUSE(sta->t.usta.alarm.cause));
752
753 return;
754
755 } /* handle_isup_alarm */
756
757 /******************************************************************************/
handle_sng_cc_alarm(Pst * pst,CcMngmt * sta)758 void handle_sng_cc_alarm(Pst *pst, CcMngmt *sta)
759 {
760
761 SS7_RELAY_DBG_FUN(handle_sng_cc_alarm);
762 return;
763 } /* handle_cc_alarm */
764
765 /******************************************************************************/
handle_sng_relay_alarm(Pst * pst,RyMngmt * sta)766 void handle_sng_relay_alarm(Pst *pst, RyMngmt *sta)
767 {
768
769 SS7_RELAY_DBG_FUN(handle_sng_relay_alarm);
770
771 switch (sta->hdr.elmId.elmnt) {
772 /**************************************************************************/
773 case (LRY_USTA_ERR): /* ERROR */
774 ftdm_log(FTDM_LOG_WARNING,"[RELAY] Error: tx procId %d: err procId %d: channel %d: seq %s: reason %s\n",
775 sta->t.usta.s.ryErrUsta.sendPid,
776 sta->t.usta.s.ryErrUsta.errPid,
777 sta->t.usta.s.ryErrUsta.id,
778 DECODE_LRY_SEQ(sta->t.usta.s.ryErrUsta.sequence),
779 DECODE_LRY_REASON(sta->t.usta.s.ryErrUsta.reason));
780
781 /* process the event */
782 switch (sta->t.usta.s.ryErrUsta.reason) {
783 /**********************************************************************/
784 case (LRYRSNMGMTREQ):
785 /* do nothing since this is a shutdown */
786 break;
787 /**********************************************************************/
788 default:
789 /* handle the error */
790 handle_relay_disconnect_on_error(sta);
791 break;
792 /**********************************************************************/
793 } /* switch (sta->t.usta.s.ryErrUsta.reason) */
794
795 break;
796 /**************************************************************************/
797 case (LRY_USTA_CNG): /* Congestion */
798 ftdm_log(FTDM_LOG_WARNING,"[RELAY] Congestion: tx procId %d: rem procId %d: channel %d: %s\n",
799 sta->t.usta.s.ryCongUsta.sendPid,
800 sta->t.usta.s.ryCongUsta.remPid,
801 sta->t.usta.s.ryCongUsta.id,
802 DECODE_LRY_CONG_FLAGS(sta->t.usta.s.ryCongUsta.flags));
803 break;
804 /**************************************************************************/
805 case (LRY_USTA_UP): /* channel up */
806 ftdm_log(FTDM_LOG_INFO,"[RELAY] Channel UP: tx procId %d: channel %d\n",
807 sta->t.usta.s.ryUpUsta.sendPid,
808 sta->t.usta.s.ryUpUsta.id);
809
810 /* process the event */
811 handle_relay_connect(sta);
812
813 break;
814 /**************************************************************************/
815 case (LRY_USTA_DN): /* channel down */
816 ftdm_log(FTDM_LOG_WARNING,"[RELAY] Channel DOWN: tx procId %d: channel %d\n",
817 sta->t.usta.s.ryUpUsta.sendPid,
818 sta->t.usta.s.ryUpUsta.id);
819
820 /* process the event */
821 handle_relay_disconnect_on_down(sta);
822
823 break;
824 /**************************************************************************/
825 case (LRY_USTA_TCP_CONN_FAILED):
826 ftdm_log(FTDM_LOG_WARNING,"[RELAY] TCP connection failed \n" );
827
828 break;
829 /**************************************************************************/
830 default:
831 ftdm_log(FTDM_LOG_ERROR,"Unknown Relay Alram\n");
832 break;
833 /**************************************************************************/
834 } /* switch (sta->hdr.elmId.elmnt) */
835
836 return;
837 }
838
839 /******************************************************************************/
handle_sng_m2ua_alarm(Pst * pst,MwMgmt * sta)840 void handle_sng_m2ua_alarm(Pst *pst, MwMgmt *sta)
841 {
842 /* To print the general information */
843 ftdm_log(FTDM_LOG_INFO, "Recieved a status indication from M2UA layer \n\n");
844 ftdm_log(FTDM_LOG_INFO," Category = %d , event = %d , cause = %d\n",
845 sta->t.usta.alarm.category, sta->t.usta.alarm.event, sta->t.usta.alarm.cause);
846
847
848 /* To print the affected element value */
849 switch(sta->hdr.elmId.elmnt)
850 {
851 case STMWDLSAP:
852 {
853 ftdm_log(FTDM_LOG_INFO," STMWDLSAP: with lnkNmb (%d) \n\n",
854 sta->t.usta.s.lnkNmb);
855 break;
856 }
857 case STMWSCTSAP:
858 {
859 ftdm_log(FTDM_LOG_INFO," STMWSCTSAP: suId (%d) \n\n",
860 sta->t.usta.s.suId);
861 break;
862 }
863 case STMWPEER:
864 {
865 ftdm_log(FTDM_LOG_INFO," STMWPEER: peerId (%d) \n\n",
866 sta->t.usta.s.peerId);
867 break;
868 }
869 case STMWCLUSTER:
870 {
871 ftdm_log(FTDM_LOG_INFO," STMWCLUSTER: clusterId (%d) \n\n",
872 sta->t.usta.s.peerId);
873 break;
874 }
875 default:
876 {
877 ftdm_log(FTDM_LOG_ERROR, "[MW_USTA]: Invalid element \n\n");
878 break;
879 }
880 }
881
882 /* To print the event specific information */
883 switch(sta->t.usta.alarm.event)
884 {
885 case LMW_EVENT_TERM_OK:
886 {
887 ftdm_log(FTDM_LOG_INFO," M2UA : LMW_EVENT_TERM_OK: Association Terminated with PeerId[%d] \n",sta->t.usta.s.peerId);
888 break;
889 }
890 case LMW_EVENT_ENDPOPEN_OK:
891 {
892 ftdm_log(FTDM_LOG_INFO," M2UA : LMW_EVENT_ENDPOPEN_OK: \n");
893 break;
894 }
895 case LMW_EVENT_ESTABLISH_OK:
896 {
897 ftdm_log(FTDM_LOG_INFO," M2UA : LMW_EVENT_ESTABLISH_OK Event raised on peerId[%d]\n",sta->t.usta.s.peerId);
898 break;
899 }
900 case LMW_EVENT_ESTABLISH_FAIL:
901 {
902 ftdm_log(FTDM_LOG_INFO," M2UA : LMW_EVENT_ESTABLISH_FAIL Event raised on peerId[%d]\n",sta->t.usta.s.peerId);
903 break;
904 }
905 case LMW_EVENT_ASPM:
906 {
907 ftdm_log(FTDM_LOG_INFO," M2UA : LMW_EVENT_ASPM Event raised with peerId (%d),"
908 " msgType (%d)\n\n",sta->t.usta.s.peerId,
909 sta->t.usta.t.aspm.msgType);
910 break;
911 }
912 case LMW_EVENT_CLUSTER:
913 {
914 ftdm_log(FTDM_LOG_INFO," M2UA : LMW_EVENT_CLUSTER Event raised on clusterId (%d), state (%d)\n\n",
915 sta->t.usta.s.clusterId, sta->t.usta.t.cluster.state);
916
917 break;
918 }
919 case LMW_EVENT_NOTIFY:
920 {
921 ftdm_log(FTDM_LOG_INFO," M2UA : LMW_EVENT_NOTIFY: peerId (%d), aspId (%u), ntfy status type (%d),"
922 " ntfy status id (%d)\n\n", sta->t.usta.s.peerId,
923 (uint32_t) sta->t.usta.t.ntfy.aspId, sta->t.usta.t.ntfy.stType,
924 sta->t.usta.t.ntfy.stId);
925
926 break;
927 }
928
929
930 case LMW_EVENT_M2UA_PROTO_ERROR:
931 {
932 ftdm_log(FTDM_LOG_ERROR, " M2UA : LMW_EVENT_M2UA_PROTO_ERROR with errorCode (%u)\n\n",
933 (uint32_t) sta->t.usta.t.error.errCode);
934 break;
935 }
936 default:
937 break;
938 }
939
940 } /* handle_sng_m2ua_alarm */
941
942 /******************************************************************************/
handle_sng_nif_alarm(Pst * pst,NwMgmt * sta)943 void handle_sng_nif_alarm(Pst *pst, NwMgmt *sta)
944 {
945 /* To print the general information */
946 ftdm_log(FTDM_LOG_INFO," Recieved a status indication from NIF layer\n");
947 ftdm_log(FTDM_LOG_INFO," Category = %d , event = %d , cause = %d\n", sta->t.usta.alarm.category,
948 sta->t.usta.alarm.event, sta->t.usta.alarm.cause);
949
950 switch(sta->hdr.elmId.elmnt)
951 {
952 case STNWDLSAP:
953 {
954 ftdm_log(FTDM_LOG_INFO," Recieved STNWDLSAP status indication for suId (%d) \n", sta->t.usta.suId);
955 switch(sta->t.usta.alarm.event)
956 {
957 case LCM_EVENT_LI_INV_EVT:
958 {
959 switch(sta->t.usta.alarm.cause)
960 {
961 case LCM_CAUSE_INV_SAP:
962 {
963 ftdm_log(FTDM_LOG_ERROR, " LCM_CAUSE_INV_SAP Alarm \n");
964 break;
965 }
966 case LCM_CAUSE_INV_STATE:
967 {
968 ftdm_log(FTDM_LOG_ERROR, " LCM_CAUSE_INV_STATE Alarm \n");
969 break;
970 }
971 default:
972 break;
973 }
974 break;
975 }
976 case LCM_EVENT_BND_OK:
977 {
978 ftdm_log(FTDM_LOG_INFO," NIF: LCM_EVENT_BND_OK Alarm \n");
979 break;
980 }
981 case LCM_EVENT_BND_FAIL:
982 {
983 ftdm_log(FTDM_LOG_INFO," NIF: LCM_EVENT_BND_FAIL Alarm \n");
984 break;
985 }
986 default:
987 break;
988 }
989 break;
990 }
991 default:
992 break;
993 }
994 } /* handle_sng_nif_alarm */
995
996 /******************************************************************************/
handle_sng_tucl_alarm(Pst * pst,HiMngmt * sta)997 void handle_sng_tucl_alarm(Pst *pst, HiMngmt *sta)
998 {
999 /* To print the general information */
1000 ftdm_log(FTDM_LOG_INFO, "Recieved a status indication from TUCL layer \n\n");
1001 ftdm_log(FTDM_LOG_INFO, " Category = %d , event = %d , cause = %d\n",
1002 sta->t.usta.alarm.category,
1003 sta->t.usta.alarm.event, sta->t.usta.alarm.cause);
1004
1005 switch(sta->t.usta.alarm.event)
1006 {
1007 case LCM_EVENT_INV_EVT:
1008 {
1009 ftdm_log(FTDM_LOG_INFO," [HI_USTA]: LCM_EVENT_INV_EVT with type (%d)\n\n",
1010 sta->t.usta.info.type);
1011 break;
1012 }
1013 case LHI_EVENT_BNDREQ:
1014 {
1015 ftdm_log(FTDM_LOG_INFO," [HI_USTA]: LHI_EVENT_BNDREQ with type (%d) spId (%d)\n\n",
1016 sta->t.usta.info.type, sta->t.usta.info.spId);
1017 break;
1018 }
1019 case LHI_EVENT_SERVOPENREQ:
1020 case LHI_EVENT_DATREQ:
1021 case LHI_EVENT_UDATREQ:
1022 case LHI_EVENT_CONREQ:
1023 case LHI_EVENT_DISCREQ:
1024 #if(defined(HI_TLS) && defined(HI_TCP_TLS))
1025 case LHI_EVENT_TLS_ESTREQ:
1026 #endif
1027 {
1028 ftdm_log(FTDM_LOG_INFO," [HI_USTA]: partype (%d) type(%d)\n\n",
1029 sta->t.usta.info.inf.parType, sta->t.usta.info.type);
1030 break;
1031 }
1032 case LCM_EVENT_DMEM_ALLOC_FAIL:
1033 case LCM_EVENT_SMEM_ALLOC_FAIL:
1034 {
1035 ftdm_log(FTDM_LOG_ERROR," [HI_USTA]: MEM_ALLOC_FAIL with region(%d) pool (%d) type(%d)\n\n",
1036 sta->t.usta.info.inf.mem.region, sta->t.usta.info.inf.mem.pool,
1037 sta->t.usta.info.type);
1038 break;
1039 }
1040 default:
1041 break;
1042 }
1043
1044 } /* handle_sng_tucl_alarm */
1045
1046 /******************************************************************************/
handle_sng_sctp_alarm(Pst * pst,SbMgmt * sta)1047 void handle_sng_sctp_alarm(Pst *pst, SbMgmt *sta)
1048 {
1049 ftdm_log(FTDM_LOG_INFO, "Recieved a status indication from SCTP layer \n\n");
1050 ftdm_log(FTDM_LOG_INFO," Category = %d , event = %d , cause = %d "
1051 " [SB_USTA]: sapId (%d) and swtch (%d)\n",
1052 sta->t.usta.alarm.category,
1053 sta->t.usta.alarm.event, sta->t.usta.alarm.cause,
1054 sta->t.usta.sapId, sta->t.usta.swtch);
1055
1056 switch(sta->t.usta.alarm.category)
1057 {
1058 case LCM_CATEGORY_INTERFACE:
1059 {
1060 switch(sta->t.usta.alarm.cause)
1061 {
1062 case LCM_CAUSE_INV_SPID:
1063 {
1064 ftdm_log(FTDM_LOG_ERROR, "SCTP : LCM_CAUSE_INV_SPID Alarm \n");
1065 break;
1066 }
1067 case LCM_CAUSE_SWVER_NAVAIL:
1068 {
1069 ftdm_log(FTDM_LOG_ERROR, "SCTP : LCM_CAUSE_SWVER_NAVAIL Alarm\n");
1070 break;
1071 }
1072 case LCM_CAUSE_INV_PAR_VAL:
1073 {
1074 ftdm_log(FTDM_LOG_ERROR, "SCTP : LCM_CAUSE_INV_PAR_VAL Alarm\n");
1075 break;
1076 }
1077 case LCM_CAUSE_INV_SUID:
1078 {
1079 ftdm_log(FTDM_LOG_ERROR, "SCTP : LCM_CAUSE_INV_SUID Alarm\n");
1080 break;
1081 }
1082 case LCM_CAUSE_INV_SAP:
1083 {
1084 ftdm_log(FTDM_LOG_ERROR, "SCTP : LCM_CAUSE_INV_SAP Alarm\n");
1085 break;
1086 }
1087 default:
1088 break;
1089 }
1090
1091 break;
1092 }
1093 case LCM_CATEGORY_RESOURCE:
1094 {
1095 switch(sta->t.usta.alarm.cause)
1096 {
1097 case LCM_CAUSE_MEM_ALLOC_FAIL:
1098 {
1099 ftdm_log(FTDM_LOG_ERROR, "SCTP : LCM_CAUSE_MEM_ALLOC_FAIL Alarm \n");
1100 break;
1101 }
1102 case LSB_CAUSE_NUM_ADDR_EXCEED:
1103 {
1104 ftdm_log(FTDM_LOG_ERROR, "SCTP : LSB_CAUSE_NUM_ADDR_EXCEED Alarm\n");
1105 break;
1106 }
1107 default:
1108 break;
1109 }
1110 break;
1111 }
1112 case LCM_CATEGORY_PROTOCOL:
1113 {
1114 switch(sta->t.usta.alarm.cause)
1115 {
1116 case LSB_CAUSE_PATH_FAILURE:
1117 {
1118 ftdm_log(FTDM_LOG_ERROR, "SCTP : LSB_CAUSE_PATH_FAILURE Alarm \n");
1119 break;
1120 }
1121 case LSB_CAUSE_PATH_ACTIVE:
1122 {
1123 ftdm_log(FTDM_LOG_ERROR, "SCTP : LSB_CAUSE_PATH_ACTIVE Alarm \n");
1124 break;
1125 }
1126 case LSB_CAUSE_UNRSLVD_ADDR:
1127 {
1128 ftdm_log(FTDM_LOG_ERROR, "SCTP : LSB_CAUSE_UNRSLVD_ADDR Alarm \n");
1129 break;
1130 }
1131 default:
1132 break;
1133 }
1134 break;
1135 }
1136 default:
1137 break;
1138 }
1139
1140 } /* handle_sng_sctp_alarm */
1141 /******************************************************************************/
1142
1143
1144 /******************************************************************************/
1145 /* For Emacs:
1146 * Local Variables:
1147 * mode:c
1148 * indent-tabs-mode:t
1149 * tab-width:4
1150 * c-basic-offset:4
1151 * End:
1152 * For VIM:
1153 * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
1154 */
1155 /******************************************************************************/
1156